Fix linting

This commit is contained in:
yangdx
2025-02-05 12:36:52 +08:00
parent 4663dcfbab
commit f77faf8023

View File

@@ -1793,9 +1793,9 @@ def create_app(args):
error_msg = "Stream was cancelled by server" error_msg = "Stream was cancelled by server"
else: else:
error_msg = f"Provider error: {error_msg}" error_msg = f"Provider error: {error_msg}"
logging.error(f"Stream error: {error_msg}") logging.error(f"Stream error: {error_msg}")
# Send error message to client # Send error message to client
error_data = { error_data = {
"model": ollama_server_infos.LIGHTRAG_MODEL, "model": ollama_server_infos.LIGHTRAG_MODEL,
@@ -1803,12 +1803,12 @@ def create_app(args):
"message": { "message": {
"role": "assistant", "role": "assistant",
"content": f"\n\nError: {error_msg}", "content": f"\n\nError: {error_msg}",
"images": None "images": None,
}, },
"done": False "done": False,
} }
yield f"{json.dumps(error_data, ensure_ascii=False)}\n" yield f"{json.dumps(error_data, ensure_ascii=False)}\n"
# Send final message to close the stream # Send final message to close the stream
final_data = { final_data = {
"model": ollama_server_infos.LIGHTRAG_MODEL, "model": ollama_server_infos.LIGHTRAG_MODEL,
@@ -1845,10 +1845,7 @@ def create_app(args):
error_data = { error_data = {
"model": ollama_server_infos.LIGHTRAG_MODEL, "model": ollama_server_infos.LIGHTRAG_MODEL,
"created_at": ollama_server_infos.LIGHTRAG_CREATED_AT, "created_at": ollama_server_infos.LIGHTRAG_CREATED_AT,
"error": { "error": {"code": "STREAM_ERROR", "message": error_msg},
"code": "STREAM_ERROR",
"message": error_msg
},
} }
yield f"{json.dumps(error_data, ensure_ascii=False)}\n" yield f"{json.dumps(error_data, ensure_ascii=False)}\n"