修复空值检查问题
This commit is contained in:
parent
ea1e10ad21
commit
16f80b3100
@ -169,6 +169,15 @@ def stream_ragflow_response(result: Generator, chat_id: str, start_time: float)
|
||||
if isinstance(body, dict) and 'answer' in body:
|
||||
current_answer = body['answer']
|
||||
|
||||
# 安全检查:确保current_answer不为None且为字符串
|
||||
if current_answer is None:
|
||||
logger.warning(f"[RAG_SERVER {chunk_time:.3f}] ⚠️ current_answer为None,跳过处理")
|
||||
continue
|
||||
|
||||
if not isinstance(current_answer, str):
|
||||
logger.warning(f"[RAG_SERVER {chunk_time:.3f}] ⚠️ current_answer不是字符串,类型: {type(current_answer)}")
|
||||
current_answer = str(current_answer)
|
||||
|
||||
# 计算增量内容
|
||||
if current_answer.startswith(last_answer):
|
||||
delta = current_answer[len(last_answer):]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user