main
HuangHai 4 months ago
parent f6acdf880d
commit 918ad133af

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

@ -17,7 +17,8 @@ def extract_keywords(user_input):
# 使用 jieba 进行分词 # 使用 jieba 进行分词
words = jieba.lcut(user_input) words = jieba.lcut(user_input)
# 过滤掉无意义的词(如标点符号、停用词等) # 过滤掉无意义的词(如标点符号、停用词等)
stop_words = ['', '', '', '', '', '', '', '', '怎么', '怎么样', '今天','今日', '', '', ''] stop_words = ['', '', '', '', '', '', '', '', '怎么', '怎么样', '最近', '今天', '今日', '', '',
'']
keywords = [word for word in words if word not in stop_words] keywords = [word for word in words if word not in stop_words]
return keywords return keywords

Loading…
Cancel
Save