Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import random

class Summarization:
def __init__(self, api_key: str, model: str = "mistral-large-latest") -> None:
def __init__(self, api_key: str, model: str = "mistral-medium-latest") -> None:
self.api_key = api_key
self.model = model

Expand Down Expand Up @@ -33,7 +33,7 @@ async def _mistral_request(self, prompt: str, max_retries: int = 5) -> str:
retry_delay *= 2 # Увеличиваем задержку экспоненциально
else:
raise
raise Exception("Max retries exceeded")
raise Exception("Max retries exceeded")

async def summarize_news_items(self, news: List[Dict[str, Union[str, int]]]) -> str:
"""
Expand All @@ -44,6 +44,7 @@ async def summarize_news_items(self, news: List[Dict[str, Union[str, int]]]) ->
'channel': channel name (without the '@')
'message': text of the news
'message_id': unique id of the message
'channel_title': title of the channel
}
:returns: A formatted summary string with links to the original news items.
"""
Expand Down Expand Up @@ -99,7 +100,7 @@ async def cluster_summaries(self, summaries_text: str) -> str:
logging.error("Error during clustering: %s", e)
return "Failed to produce the final digest."

async def determine_channel_topic(self, messages: List[Dict[str, Union[str, int]]]) -> List[str]:
async def determine_channel_topic(self, messages: List[Dict[str, Union[str, int]]]) -> Union[List[str], str]:
"""
Determines channel topics based on recent posts.

Expand Down