完善 debug 信息

This commit is contained in:
Wenjie Zhang 2025-02-25 21:26:55 +08:00
parent 13872c8979
commit af827d5437

View File

@ -55,12 +55,14 @@ def chat_post(
return return
yield make_chunk(status="generating") yield make_chunk(status="generating")
messages = history_manager.get_history_with_msg(modified_query, max_rounds=meta.get('history_round')) messages = history_manager.get_history_with_msg(modified_query, max_rounds=meta.get('history_round'))
history_manager.add_user(query) # 注意这里使用原始查询 history_manager.add_user(query) # 注意这里使用原始查询
logger.debug(f"Web history: {history_manager.messages}") logger.debug(f"Web history: {history_manager.messages}")
content = "" content = ""
reasoning_content = "" reasoning_content = ""
try:
for delta in startup.model.predict(messages, stream=True): for delta in startup.model.predict(messages, stream=True):
if not delta.content and hasattr(delta, 'reasoning_content'): if not delta.content and hasattr(delta, 'reasoning_content'):
reasoning_content += delta.reasoning_content or "" reasoning_content += delta.reasoning_content or ""
@ -83,6 +85,10 @@ def chat_post(
status="finished", status="finished",
history=history_manager.update_ai(content), history=history_manager.update_ai(content),
refs=refs) refs=refs)
except Exception as e:
logger.error(f"Model error: {e}")
yield make_chunk(message=f"Model error: {e}", status="error")
return
return StreamingResponse(generate_response(), media_type='application/json') return StreamingResponse(generate_response(), media_type='application/json')