From 8535f412152803321a1da2be6f3e1cf65eb555a2 Mon Sep 17 00:00:00 2001 From: minbang930 Date: Thu, 20 Mar 2025 07:49:46 +0900 Subject: [PATCH] fix: Add properties to extracted_content object in browser tool schema The OpenAI API was rejecting function declarations due to empty properties in the extracted_content object type. This fix adds required properties to comply with OpenAI's schema requirements: - Add 'text' property for storing extracted page content - Add 'metadata' object with 'source' property for content attribution - Maintain existing functionality while satisfying API schema validation Error resolved: "GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[extracted_content].properties: should be non-empty for OBJECT type" --- app/tool/browser_use_tool.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/tool/browser_use_tool.py b/app/tool/browser_use_tool.py index 0158e07..d938ff5 100644 --- a/app/tool/browser_use_tool.py +++ b/app/tool/browser_use_tool.py @@ -15,7 +15,6 @@ from app.llm import LLM from app.tool.base import BaseTool, ToolResult from app.tool.web_search import WebSearch - _BROWSER_DESCRIPTION = """ Interact with a web browser to perform various actions such as navigation, element interaction, content extraction, and tab management. This tool provides a comprehensive set of browser automation capabilities: @@ -448,6 +447,22 @@ Page content: "extracted_content": { "type": "object", "description": "The content extracted from the page according to the goal", + "properties": { + "text": { + "type": "string", + "description": "Text content extracted from the page", + }, + "metadata": { + "type": "object", + "description": "Additional metadata about the extracted content", + "properties": { + "source": { + "type": "string", + "description": "Source of the extracted content", + } + }, + }, + }, } }, "required": ["extracted_content"],