完善 debug 信息
This commit is contained in:
parent
13872c8979
commit
af827d5437
@ -54,35 +54,41 @@ def chat_post(
|
|||||||
yield make_chunk(message=f"Retriever error: {e}", status="error")
|
yield make_chunk(message=f"Retriever error: {e}", status="error")
|
||||||
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 = ""
|
||||||
for delta in startup.model.predict(messages, stream=True):
|
try:
|
||||||
if not delta.content and hasattr(delta, 'reasoning_content'):
|
for delta in startup.model.predict(messages, stream=True):
|
||||||
reasoning_content += delta.reasoning_content or ""
|
if not delta.content and hasattr(delta, 'reasoning_content'):
|
||||||
chunk = make_chunk(reasoning_content=reasoning_content, status="reasoning")
|
reasoning_content += delta.reasoning_content or ""
|
||||||
|
chunk = make_chunk(reasoning_content=reasoning_content, status="reasoning")
|
||||||
|
yield chunk
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 文心一言
|
||||||
|
if hasattr(delta, 'is_full') and delta.is_full:
|
||||||
|
content = delta.content
|
||||||
|
else:
|
||||||
|
content += delta.content or ""
|
||||||
|
|
||||||
|
chunk = make_chunk(content=content, status="loading")
|
||||||
yield chunk
|
yield chunk
|
||||||
continue
|
|
||||||
|
|
||||||
# 文心一言
|
logger.debug(f"Final response: {content}")
|
||||||
if hasattr(delta, 'is_full') and delta.is_full:
|
logger.debug(f"Final reasoning response: {reasoning_content}")
|
||||||
content = delta.content
|
yield make_chunk(content=content,
|
||||||
else:
|
status="finished",
|
||||||
content += delta.content or ""
|
history=history_manager.update_ai(content),
|
||||||
|
refs=refs)
|
||||||
chunk = make_chunk(content=content, status="loading")
|
except Exception as e:
|
||||||
yield chunk
|
logger.error(f"Model error: {e}")
|
||||||
|
yield make_chunk(message=f"Model error: {e}", status="error")
|
||||||
logger.debug(f"Final response: {content}")
|
return
|
||||||
logger.debug(f"Final reasoning response: {reasoning_content}")
|
|
||||||
yield make_chunk(content=content,
|
|
||||||
status="finished",
|
|
||||||
history=history_manager.update_ai(content),
|
|
||||||
refs=refs)
|
|
||||||
|
|
||||||
return StreamingResponse(generate_response(), media_type='application/json')
|
return StreamingResponse(generate_response(), media_type='application/json')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user