|
|
|
@ -303,10 +303,10 @@ async def reply(person_id: str = Form(...),
|
|
|
|
|
logger.info(f"历史交互提示词: {history_prompt}")
|
|
|
|
|
|
|
|
|
|
# NBA与CBA
|
|
|
|
|
result = await get_news(client, prompt)
|
|
|
|
|
if result is not None:
|
|
|
|
|
history_prompt = result
|
|
|
|
|
print("新闻返回了下面的内容:" + result)
|
|
|
|
|
# result = await get_news(client, prompt)
|
|
|
|
|
# if result is not None:
|
|
|
|
|
# history_prompt = result
|
|
|
|
|
# print("新闻返回了下面的内容:" + result)
|
|
|
|
|
|
|
|
|
|
# 调用大模型,将历史交互作为提示词
|
|
|
|
|
try:
|
|
|
|
@ -643,7 +643,8 @@ async def web_recognize_content(image_url: str,
|
|
|
|
|
|
|
|
|
|
# 流式传输完成后,记录到数据库
|
|
|
|
|
await save_chat_to_mysql(
|
|
|
|
|
app.state.mysql_pool, person_id, f'{image_url}', summary, "", 0, 2, 2, 2, image_width, image_height
|
|
|
|
|
app.state.mysql_pool, person_id, f'{image_url}', summary, "", 0, 2, 3,
|
|
|
|
|
2, image_width, image_height
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
except asyncio.CancelledError:
|
|
|
|
@ -654,8 +655,8 @@ async def web_recognize_content(image_url: str,
|
|
|
|
|
"success": False,
|
|
|
|
|
"message": f"生成内容失败: {str(e)}"
|
|
|
|
|
})
|
|
|
|
|
print(error_response)
|
|
|
|
|
yield error_response.encode("utf-8")
|
|
|
|
|
#yield error_response
|
|
|
|
|
|
|
|
|
|
# 使用 StreamingResponse 返回流式结果
|
|
|
|
|
return StreamingResponse(
|
|
|
|
@ -715,7 +716,7 @@ async def web_recognize_text(image_url: str,
|
|
|
|
|
summary += char # 拼接字符
|
|
|
|
|
|
|
|
|
|
# 流式传输完成后,记录到数据库
|
|
|
|
|
await save_chat_to_mysql(app.state.mysql_pool, person_id, f'{image_url}', summary, "", 0, 2, 2, 1,
|
|
|
|
|
await save_chat_to_mysql(app.state.mysql_pool, person_id, f'{image_url}', summary, "", 0, 2, 3, 1,
|
|
|
|
|
image_width,
|
|
|
|
|
image_height)
|
|
|
|
|
|
|
|
|
|