fix remove index from tool calls cohere error

This commit is contained in:
Ishaan Jaff 2024-07-16 21:49:17 -07:00
parent 5e1e413de0
commit ee33a80486
3 changed files with 22 additions and 0 deletions

View file

@ -39,3 +39,18 @@ def map_finish_reason(
elif finish_reason == "content_filtered":
return "content_filter"
return finish_reason
def remove_index_from_tool_calls(messages, tool_calls):
for tool_call in tool_calls:
if "index" in tool_call:
tool_call.pop("index")
for message in messages:
if "tool_calls" in message:
tool_calls = message["tool_calls"]
for tool_call in tool_calls:
if "index" in tool_call:
tool_call.pop("index")
return