Skip to content

Commit

Permalink
Fix the bug where the Claude API does not return the DONE SSE message.
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed Sep 4, 2024
1 parent 3fc76ba commit 7b515b4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7b515b4

Please sign in to comment.