Use OpenAI SDK types for tool params in adapters and tests

These are TypedDicts (plain dicts at runtime), so no behavioral change
— just more descriptive type hints for readers. Use ToolParam instead
of FunctionToolParam for the Responses adapter to reflect that custom
non-function tools are supported. Use ChatCompletionToolParam instead
of Any for the completions adapter return type. Update tests to use
typed params in expected values.
This commit is contained in:
Paul Kompfner
2026-04-10 10:15:39 -04:00
parent 1443dfb070
commit fc3307bc63
3 changed files with 14 additions and 12 deletions

View File

@@ -7,6 +7,8 @@
import unittest
from openai.types.chat import ChatCompletionToolParam
from openai.types.responses.function_tool_param import FunctionToolParam
from openai.types.responses.tool_search_tool_param import ToolSearchToolParam
from pipecat.adapters.schemas.function_schema import FunctionSchema
from pipecat.adapters.schemas.tools_schema import AdapterType, ToolsSchema
@@ -213,11 +215,11 @@ class TestFunctionAdapters(unittest.TestCase):
"""Test OpenAI Responses adapter appends custom tools."""
tool_search = {"type": "tool_search"}
expected = [
{
"type": "function",
"name": "get_weather",
"description": "Get the weather in a given location",
"parameters": {
FunctionToolParam(
type="function",
name="get_weather",
description="Get the weather in a given location",
parameters={
"type": "object",
"properties": {
"location": {
@@ -232,9 +234,9 @@ class TestFunctionAdapters(unittest.TestCase):
},
"required": ["location", "format"],
},
"strict": None,
},
tool_search,
strict=None,
),
ToolSearchToolParam(type="tool_search"),
]
tools_def = self.tools_def
tools_def.custom_tools = {AdapterType.OPENAI: [tool_search]}