From 7b515b4df1cf64ed1ccd7693c3c6a878590100d7 Mon Sep 17 00:00:00 2001 From: yym68686 Date: Wed, 4 Sep 2024 19:12:37 +0800 Subject: [PATCH] Fix the bug where the Claude API does not return the DONE SSE message. --- response.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/response.py b/response.py index 6a484f7..357869d 100644 --- a/response.py +++ b/response.py @@ -90,6 +90,7 @@ async def fetch_gemini_response_stream(client, url, headers, payload, model): function_full_response = json.dumps(function_call["functionCall"]["args"]) sse_string = await generate_sse_response(timestamp, model, content=None, tools_id="chatcmpl-9inWv0yEtgn873CxMBzHeCeiHctTV", function_call_name=None, function_call_content=function_full_response) yield sse_string + yield "data: [DONE]\n\r" async def fetch_vertex_claude_response_stream(client, url, headers, payload, model): timestamp = datetime.timestamp(datetime.now()) @@ -136,6 +137,7 @@ async def fetch_vertex_claude_response_stream(client, url, headers, payload, mod function_full_response = json.dumps(function_call["input"]) 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) yield sse_string + yield "data: [DONE]\n\r" async def fetch_gpt_response_stream(client, url, headers, payload, max_redirects=5): redirect_count = 0 @@ -234,6 +236,7 @@ async def fetch_claude_response_stream(client, url, headers, payload, model): function_call_content = delta["partial_json"] sse_string = await generate_sse_response(timestamp, model, None, None, None, function_call_content) yield sse_string + yield "data: [DONE]\n\r" async def fetch_response(client, url, headers, payload): response = await client.post(url, headers=headers, json=payload)