Refactor summarize_to_words
to accept text
and title
.
Updated the `summarize_to_words` function to take `text` and `title` as separate parameters instead of a single `article` dictionary. Adjusted payload and function calls accordingly for better clarity and flexibility.
This commit is contained in:
parent
1d5aeb1644
commit
6f9f74dae0
1 changed files with 3 additions and 3 deletions
|
@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
|
|||
# Initialize FastMCP server
|
||||
mcp = FastMCP("SMD Researcher", host="0.0.0.0", port=8000, timeout_keep_alive=720)
|
||||
|
||||
async def summarize_to_words(article: dict, target_word_count: int = 1000) -> str:
|
||||
async def summarize_to_words(text: str, title: str, target_word_count: int = 1000) -> str:
|
||||
url = f"https://maas.ai-2.kvant.cloud/engines/{os.getenv('SWISSDOX_SUMMARIZING_MODEL', '')}/chat/completions"
|
||||
headers = {
|
||||
"x-litellm-api-key": f"Bearer {os.getenv('SWISSDOX_SUMMARIZING_MODEL_APIKEY', '')}",
|
||||
|
@ -41,7 +41,7 @@ async def summarize_to_words(article: dict, target_word_count: int = 1000) -> st
|
|||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"{str(article)}"
|
||||
"content": f"{title} - {text}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ async def smd_detail_article(article_id):
|
|||
async with session.post(url, headers=headers, json=payload) as response:
|
||||
if response.status == 200:
|
||||
data = await response.json()
|
||||
summarized_content = await summarize_to_words(data, target_word_count=10000)
|
||||
summarized_content = await summarize_to_words(title=data.get("title"), text=data.get("text"), target_word_count=10000)
|
||||
return summarized_content
|
||||
else:
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue