yym68686 commited on
Commit
46ce910
·
1 Parent(s): 58a694d

Fix the bug with the incorrect ending character in OpenAI format responses.

Browse files
Files changed (1) hide show
  1. response.py +2 -2
response.py CHANGED
@@ -32,7 +32,7 @@ async def generate_sse_response(timestamp, model, content=None, tools_id=None, f
32
  json_data = json.dumps(sample_data, ensure_ascii=False)
33
 
34
  # 构建SSE响应
35
- sse_response = f"data: {json_data}\n\n"
36
 
37
  return sse_response
38
 
@@ -173,7 +173,7 @@ async def fetch_gpt_response_stream(client, url, headers, payload, max_redirects
173
  line, buffer = buffer.split("\n", 1)
174
  # logger.info("line: %s", repr(line))
175
  if line and line != "data: " and line != "data:" and not line.startswith(": "):
176
- yield line + "\n"
177
  except httpx.RemoteProtocolError as e:
178
  yield {"error": f"fetch_gpt_response_stream RemoteProtocolError {e.__class__.__name__}", "details": str(e)}
179
  return
 
32
  json_data = json.dumps(sample_data, ensure_ascii=False)
33
 
34
  # 构建SSE响应
35
+ sse_response = f"data: {json_data}\n\r"
36
 
37
  return sse_response
38
 
 
173
  line, buffer = buffer.split("\n", 1)
174
  # logger.info("line: %s", repr(line))
175
  if line and line != "data: " and line != "data:" and not line.startswith(": "):
176
+ yield line + "\n\r"
177
  except httpx.RemoteProtocolError as e:
178
  yield {"error": f"fetch_gpt_response_stream RemoteProtocolError {e.__class__.__name__}", "details": str(e)}
179
  return