Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
option to not force structured output
mertunsall61779863bc70
diff --git a/browser_use/llm/openai/chat.py b/browser_use/llm/openai/chat.pyindex db999045a..ecf05b654 100644--- a/browser_use/llm/openai/chat.py+++ b/browser_use/llm/openai/chat.py@@ -41,6 +41,7 @@ class ChatOpenAI(BaseChatModel):service_tier: Literal['auto', 'default', 'flex', 'priority', 'scale'] | None = Nonetop_p: float | None = Noneadd_schema_to_system_prompt: bool = False # Add JSON schema to system prompt instead of using response_format+ dont_force_structured_output: bool = False # If True, the model will not be forced to output a structured output# Client initialization parametersapi_key: str | None = None@@ -218,13 +219,20 @@ class ChatOpenAI(BaseChatModel):ChatCompletionContentPartTextParam(text=schema_text, type='text')]- # Return structured response- response = await self.get_client().chat.completions.create(- model=self.model,- messages=openai_messages,- response_format=ResponseFormatJSONSchema(json_schema=response_format, type='json_schema'),- **model_params,- )+ if self.dont_force_structured_output:+ response = await self.get_client().chat.completions.create(+ model=self.model,+ messages=openai_messages,+ **model_params,+ )+ else:+ # Return structured response+ response = await self.get_client().chat.completions.create(+ model=self.model,+ messages=openai_messages,+ response_format=ResponseFormatJSONSchema(json_schema=response_format, type='json_schema'),+ **model_params,+ )if response.choices[0].message.content is None:raise ModelProviderError(