|
|
|
@ -246,6 +246,21 @@ async def reply(person_id: str = Form(...),
|
|
|
|
|
"message": "请输入内容",
|
|
|
|
|
"success": False
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if '生成图片' in prompt or '生图' in prompt:
|
|
|
|
|
success, key = generate_image(prompt)
|
|
|
|
|
if success:
|
|
|
|
|
# 记录聊天数据到 MySQL
|
|
|
|
|
await save_chat_to_mysql(app.state.mysql_pool, person_id, prompt,
|
|
|
|
|
key, '', 0)
|
|
|
|
|
# 返回数据
|
|
|
|
|
return {
|
|
|
|
|
"success": True,
|
|
|
|
|
"url": None,
|
|
|
|
|
"duration": 0, # 返回大模型的回复时长
|
|
|
|
|
"response": key, # 返回大模型的回复
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 从连接池中获取一个连接
|
|
|
|
|
connection = milvus_pool.get_connection()
|
|
|
|
|
|
|
|
|
@ -374,8 +389,6 @@ async def reply(person_id: str = Form(...),
|
|
|
|
|
"search_time": end_time - start_time, # 返回查询耗时
|
|
|
|
|
"duration": duration, # 返回大模型的回复时长
|
|
|
|
|
"response": result, # 返回大模型的回复
|
|
|
|
|
"login_name": current_user["login_name"],
|
|
|
|
|
"person_name": current_user["person_name"]
|
|
|
|
|
}
|
|
|
|
|
else:
|
|
|
|
|
raise HTTPException(status_code=500, detail="大模型未返回有效结果")
|
|
|
|
|