Refactor response handling to parse JSON content.
Replace raw response text retrieval with JSON parsing to extract specific content. This ensures more precise data handling and aligns with expected response structure.
This commit is contained in:
parent
4c554b1472
commit
bbec6df3fd
1 changed files with 2 additions and 1 deletions
|
@ -49,7 +49,8 @@ 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.text()
|
||||
data = await response.json()
|
||||
return data.get("choices")[0].get("message").get("content")
|
||||
else:
|
||||
return await response.text()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue