yangdx commited on
Commit
7cce235
·
1 Parent(s): 004b58f

update error response format in streaming API to a normal message. So user can get what's going on.

Browse files
Files changed (1) hide show
  1. lightrag/api/lightrag_server.py +5 -3
lightrag/api/lightrag_server.py CHANGED
@@ -1793,10 +1793,12 @@ def create_app(args):
1793
  error_data = {
1794
  "model": ollama_server_infos.LIGHTRAG_MODEL,
1795
  "created_at": ollama_server_infos.LIGHTRAG_CREATED_AT,
1796
- "error": {
1797
- "code": "STREAM_ERROR",
1798
- "message": error_msg
 
1799
  },
 
1800
  }
1801
  yield f"{json.dumps(error_data, ensure_ascii=False)}\n"
1802
 
 
1793
  error_data = {
1794
  "model": ollama_server_infos.LIGHTRAG_MODEL,
1795
  "created_at": ollama_server_infos.LIGHTRAG_CREATED_AT,
1796
+ "message": {
1797
+ "role": "assistant",
1798
+ "content": f"\n\nError: {error_msg}",
1799
+ "images": None
1800
  },
1801
+ "done": False
1802
  }
1803
  yield f"{json.dumps(error_data, ensure_ascii=False)}\n"
1804