diff --git a/AI/WxMini/Start.py b/AI/WxMini/Start.py index bd6d68f5..e08aca42 100644 --- a/AI/WxMini/Start.py +++ b/AI/WxMini/Start.py @@ -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) diff --git a/AI/WxMini/Utils/NewsUtil.py b/AI/WxMini/Utils/NewsUtil.py index 65ded7ad..6cb9cfc3 100644 --- a/AI/WxMini/Utils/NewsUtil.py +++ b/AI/WxMini/Utils/NewsUtil.py @@ -17,7 +17,8 @@ def extract_keywords(user_input): # 使用 jieba 进行分词 words = jieba.lcut(user_input) # 过滤掉无意义的词(如标点符号、停用词等) - stop_words = ['的', '了', '吗', '呢', '是', '在', '啊', '呀', '怎么', '怎么样', '今天','今日', '?', ',', '。'] + stop_words = ['的', '了', '吗', '呢', '是', '在', '啊', '呀', '怎么', '怎么样', '最近', '今天', '今日', '?', ',', + '。'] keywords = [word for word in words if word not in stop_words] return keywords