yym68686 commited on
Commit
9874f60
·
1 Parent(s): 237c936

✨ Feature: Adapt to the deprecated function call request body format of OpenAI

Browse files
Files changed (1) hide show
  1. request.py +24 -0
request.py CHANGED
@@ -419,6 +419,18 @@ async def get_vertex_claude_payload(request, engine, provider):
419
  "tool_use_id": tool_id,
420
  "content": content
421
  }]})
 
 
 
 
 
 
 
 
 
 
 
 
422
  elif msg.role != "system":
423
  messages.append({"role": msg.role, "content": content})
424
  elif msg.role == "system":
@@ -694,6 +706,18 @@ async def get_claude_payload(request, engine, provider):
694
  "tool_use_id": tool_id,
695
  "content": content
696
  }]})
 
 
 
 
 
 
 
 
 
 
 
 
697
  elif msg.role != "system":
698
  messages.append({"role": msg.role, "content": content})
699
  elif msg.role == "system":
 
419
  "tool_use_id": tool_id,
420
  "content": content
421
  }]})
422
+ elif msg.role == "function":
423
+ messages.append({"role": "assistant", "content": [{
424
+ "type": "tool_use",
425
+ "id": "toolu_017r5miPMV6PGSNKmhvHPic4",
426
+ "name": msg.name,
427
+ "input": {"prompt": "..."}
428
+ }]})
429
+ messages.append({"role": "user", "content": [{
430
+ "type": "tool_result",
431
+ "tool_use_id": "toolu_017r5miPMV6PGSNKmhvHPic4",
432
+ "content": msg.content
433
+ }]})
434
  elif msg.role != "system":
435
  messages.append({"role": msg.role, "content": content})
436
  elif msg.role == "system":
 
706
  "tool_use_id": tool_id,
707
  "content": content
708
  }]})
709
+ elif msg.role == "function":
710
+ messages.append({"role": "assistant", "content": [{
711
+ "type": "tool_use",
712
+ "id": "toolu_017r5miPMV6PGSNKmhvHPic4",
713
+ "name": msg.name,
714
+ "input": {"prompt": "..."}
715
+ }]})
716
+ messages.append({"role": "user", "content": [{
717
+ "type": "tool_result",
718
+ "tool_use_id": "toolu_017r5miPMV6PGSNKmhvHPic4",
719
+ "content": msg.content
720
+ }]})
721
  elif msg.role != "system":
722
  messages.append({"role": msg.role, "content": content})
723
  elif msg.role == "system":