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
Refine prompt clarity in service.py to specify handling of vague queries. Updated the prompt to instruct the model to provide a brief summary when the query does not make sense for the page, enhancing the extraction process.
Magnus Müller9ddfce90c79f
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex 8a43c8394..1dc597671 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -284,7 +284,7 @@ class Controller(Generic[Context]):if len(content) > 60000:content = content[:30000] + '... left out the middle because it was too long ...' + content[-30000:]- prompt = 'You convert websites into structured information. Extract information from this webpage based on the query. Focus only on content relevant to the query. If the query is vague, provide a brief summary of the page. Respond in JSON format.\nQuery: {content_to_extract}\n answer:\n{page}'+ prompt = 'You convert websites into structured information. Extract information from this webpage based on the query. Focus only on content relevant to the query. If the query is vague or does not make sense for the page, provide a brief summary of the page. Respond in JSON format.\nQuery: {content_to_extract}\n answer:\n{page}'template = PromptTemplate(input_variables=['content_to_extract', 'page'], template=prompt)try:output = await page_extraction_llm.ainvoke(template.format(content_to_extract=content_to_extract, page=content))