main
HuangHai 4 months ago
parent a6a51d6121
commit bb210eedd0

@ -81,6 +81,7 @@ async def reply(session_id: str = Form(...), prompt: str = Form(...)):
:return: 大模型的回复
"""
try:
print(f"收到用户输入: {prompt}")
# 从连接池中获取一个连接
connection = milvus_pool.get_connection()
@ -131,13 +132,14 @@ async def reply(session_id: str = Form(...), prompt: str = Form(...)):
# 提取生成的回复
if response.choices and response.choices[0].message.content:
result = response.choices[0].message.content.strip()
print(f"大模型回复: {result}")
# 记录用户输入和大模型反馈到向量数据库
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
entities = [
[session_id], # session_id
[prompt], # user_input
[result], # model_response
[prompt[:500]], # user_input,截断到 500 字符
[result[:500]], # model_response,截断到 500 字符
[timestamp], # timestamp
[current_embedding] # embedding
]

Loading…
Cancel
Save