Update response handling and add summarized content return
Modified the response handling to return raw text instead of JSON in one case and updated another to include summarized content with article ID. These changes ensure consistency and enhance the response structure for better client integration.
This commit is contained in:
parent
0d532d147b
commit
5799319ade
1 changed files with 6 additions and 3 deletions
|
@ -49,7 +49,7 @@ async def summarize_to_words(text: str, title: str, target_word_count: int = 100
|
|||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(url, headers=headers, json=payload) as response:
|
||||
if response.status == 200:
|
||||
return await response.json()
|
||||
return await response.text()
|
||||
else:
|
||||
return await response.text()
|
||||
|
||||
|
@ -65,8 +65,11 @@ 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(title=data.get("title"), text=data.get("text"), target_word_count=10000)
|
||||
return data
|
||||
summarized_content = await summarize_to_words(title=data.get("title"), text=data.get("text"), target_word_count=10000)
|
||||
return {
|
||||
"message": summarized_content,
|
||||
"article_id": article_id
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"message": await response.text(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue