feat: add function tools to openai responses

This commit is contained in:
Ashwin Bharambe 2025-04-30 13:06:33 -07:00
parent 5a2bfd6ad5
commit 248a4a3f72
5 changed files with 220 additions and 3 deletions

View file

@ -192,6 +192,7 @@ class OpenAIResponsesImpl:
status="completed",
output=output_messages,
)
logger.debug(f"OpenAI Responses response: {response}")
if store:
# Store in kvstore
@ -218,7 +219,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(