Fix the bug where the Claude API does not return the DONE SSE message.
Browse files- response.py +3 -0
response.py
CHANGED
@@ -90,6 +90,7 @@ async def fetch_gemini_response_stream(client, url, headers, payload, model):
|
|
90 |
function_full_response = json.dumps(function_call["functionCall"]["args"])
|
91 |
sse_string = await generate_sse_response(timestamp, model, content=None, tools_id="chatcmpl-9inWv0yEtgn873CxMBzHeCeiHctTV", function_call_name=None, function_call_content=function_full_response)
|
92 |
yield sse_string
|
|
|
93 |
|
94 |
async def fetch_vertex_claude_response_stream(client, url, headers, payload, model):
|
95 |
timestamp = datetime.timestamp(datetime.now())
|
@@ -136,6 +137,7 @@ async def fetch_vertex_claude_response_stream(client, url, headers, payload, mod
|
|
136 |
function_full_response = json.dumps(function_call["input"])
|
137 |
sse_string = await generate_sse_response(timestamp, model, content=None, tools_id=function_call_id, function_call_name=None, function_call_content=function_full_response)
|
138 |
yield sse_string
|
|
|
139 |
|
140 |
async def fetch_gpt_response_stream(client, url, headers, payload, max_redirects=5):
|
141 |
redirect_count = 0
|
@@ -234,6 +236,7 @@ async def fetch_claude_response_stream(client, url, headers, payload, model):
|
|
234 |
function_call_content = delta["partial_json"]
|
235 |
sse_string = await generate_sse_response(timestamp, model, None, None, None, function_call_content)
|
236 |
yield sse_string
|
|
|
237 |
|
238 |
async def fetch_response(client, url, headers, payload):
|
239 |
response = await client.post(url, headers=headers, json=payload)
|
|
|
90 |
function_full_response = json.dumps(function_call["functionCall"]["args"])
|
91 |
sse_string = await generate_sse_response(timestamp, model, content=None, tools_id="chatcmpl-9inWv0yEtgn873CxMBzHeCeiHctTV", function_call_name=None, function_call_content=function_full_response)
|
92 |
yield sse_string
|
93 |
+
yield "data: [DONE]\n\r"
|
94 |
|
95 |
async def fetch_vertex_claude_response_stream(client, url, headers, payload, model):
|
96 |
timestamp = datetime.timestamp(datetime.now())
|
|
|
137 |
function_full_response = json.dumps(function_call["input"])
|
138 |
sse_string = await generate_sse_response(timestamp, model, content=None, tools_id=function_call_id, function_call_name=None, function_call_content=function_full_response)
|
139 |
yield sse_string
|
140 |
+
yield "data: [DONE]\n\r"
|
141 |
|
142 |
async def fetch_gpt_response_stream(client, url, headers, payload, max_redirects=5):
|
143 |
redirect_count = 0
|
|
|
236 |
function_call_content = delta["partial_json"]
|
237 |
sse_string = await generate_sse_response(timestamp, model, None, None, None, function_call_content)
|
238 |
yield sse_string
|
239 |
+
yield "data: [DONE]\n\r"
|
240 |
|
241 |
async def fetch_response(client, url, headers, payload):
|
242 |
response = await client.post(url, headers=headers, json=payload)
|