feat: add function tools to openai responses

This commit is contained in:
Ashwin Bharambe 2025-04-30 13:06:33 -07:00 committed by Ben Browning
parent b90bb66f28
commit 1990df2c50
5 changed files with 220 additions and 3 deletions

View file

@ -235,6 +235,7 @@ class OpenAIResponsesImpl:
status="completed",
output=output_messages,
)
logger.debug(f"OpenAI Responses response: {response}")
if store:
# Store in kvstore
@ -290,7 +291,9 @@ class OpenAIResponsesImpl:
chat_tools: list[ChatCompletionToolParam] = []
for input_tool in tools:
# TODO: Handle other tool types
if input_tool.type == "web_search":
if input_tool.type == "function":
chat_tools.append(ChatCompletionToolParam(type="function", function=input_tool.model_dump()))
elif input_tool.type == "web_search":
tool_name = "web_search"
tool = await self.tool_groups_api.get_tool(tool_name)
tool_def = ToolDefinition(