Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions livekit-agents/livekit/agents/llm/_provider_format/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def to_responses_fnc_ctx(
tool_ctx: llm.ToolContext,
*,
strict: bool = True,
provider_tool_type: type[llm.ProviderTool],
provider_tool_type: type[llm.ProviderTool] | None = None,
) -> list[dict[str, Any]]:
schemas: list[dict[str, Any]] = []
for tool in tool_ctx.flatten():
Expand All @@ -233,7 +233,11 @@ def to_responses_fnc_ctx(
elif isinstance(tool, llm.FunctionTool):
schema = llm.utils.build_legacy_openai_schema(tool, internally_tagged=True)
schemas.append(schema)
elif isinstance(tool, provider_tool_type) and hasattr(tool, "to_dict"):
elif (
provider_tool_type is not None
and isinstance(tool, provider_tool_type)
and hasattr(tool, "to_dict")
):
schemas.append(tool.to_dict())

return schemas
2 changes: 1 addition & 1 deletion livekit-agents/livekit/agents/llm/tool_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def parse_function_tools(
format: Literal["openai.responses"],
*,
strict: bool = True,
provider_tool_type: type[ProviderTool],
provider_tool_type: type[ProviderTool] | None = None,
) -> list[dict[str, Any]]: ...

@overload
Expand Down
Loading