Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Fixed vision input

magmueller6f989c6c8739
diff --git a/src/planning/prompts.py b/src/planning/prompts.py
index ad12c8917..edc4ac5cc 100644
--- a/src/planning/prompts.py
+++ b/src/planning/prompts.py
@@ -70,7 +70,7 @@ Interactive elements:
{'type': 'text', 'text': state_description},
{
'type': 'image_url',
- 'image_url': f'data:image/png;base64,{self.state.screenshot}',
+ 'image_url': {'url': f'data:image/png;base64,{self.state.screenshot}'},
},
]
)
diff --git a/src/planning/service.py b/src/planning/service.py
index ad4b4a73f..d60ed9239 100644
--- a/src/planning/service.py
+++ b/src/planning/service.py
@@ -74,7 +74,11 @@ class PlaningService:
new_message = PlanningMessagePrompt(state).get_user_message()
input_messages = self.messages + [new_message]
- print(f'model input: {input_messages}')
+ if self.use_vision:
+ print(f'model input content with image: {new_message.content[0]}')
+ else:
+ print(f'model input: {new_message}')
+
structured_llm = self.llm.with_structured_output(PlanningAgentAction)
# print(f'state:\n{state}')
diff --git a/src/tests/test_kayak_search.py b/src/tests/test_kayak_search.py
index d1d07e87e..f5c09d912 100644
--- a/src/tests/test_kayak_search.py
+++ b/src/tests/test_kayak_search.py
@@ -31,7 +31,7 @@ async def test_kayak_flight_search():
agent = AgentService()
model = ChatOpenAI(model='gpt-4o')
- planning_service = PlaningService(task, model, agent, use_vision=False)
+ planning_service = PlaningService(task, model, agent, use_vision=True)
print('\n' + '=' * 50)
print('🚀 Starting flight search task')