Skip to content

Commit bf302c5

Browse files
authored
Use "{}" instead of empty string for arguments (#422)
1 parent 01f5e86 commit bf302c5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/agents/models/openai_chatcompletions.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -923,12 +923,13 @@ def ensure_assistant_message() -> ChatCompletionAssistantMessageParam:
923923
elif func_call := cls.maybe_function_tool_call(item):
924924
asst = ensure_assistant_message()
925925
tool_calls = list(asst.get("tool_calls", []))
926+
arguments = func_call["arguments"] if func_call["arguments"] else "{}"
926927
new_tool_call = ChatCompletionMessageToolCallParam(
927928
id=func_call["call_id"],
928929
type="function",
929930
function={
930931
"name": func_call["name"],
931-
"arguments": func_call["arguments"],
932+
"arguments": arguments,
932933
},
933934
)
934935
tool_calls.append(new_tool_call)
@@ -971,7 +972,7 @@ def to_openai(cls, tool: Tool) -> ChatCompletionToolParam:
971972
}
972973

973974
raise UserError(
974-
f"Hosted tools are not supported with the ChatCompletions API. FGot tool type: "
975+
f"Hosted tools are not supported with the ChatCompletions API. Got tool type: "
975976
f"{type(tool)}, tool: {tool}"
976977
)
977978

0 commit comments

Comments
 (0)