From 6f9f74dae0f7c289334e3225bb890fb274ecd1d2 Mon Sep 17 00:00:00 2001 From: ThomasTaroni Date: Sat, 21 Jun 2025 21:35:54 +0200 Subject: [PATCH] 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. --- src/phoenix_technologies/smd/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/phoenix_technologies/smd/server.py b/src/phoenix_technologies/smd/server.py index eeae925..b35ddfb 100644 --- a/src/phoenix_technologies/smd/server.py +++ b/src/phoenix_technologies/smd/server.py @@ -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 {