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
prompt guide
Magnus Müller4a0e9fe5908e
diff --git a/docs/customize/examples/prompting-guide.mdx b/docs/customize/examples/prompting-guide.mdxnew file mode 100644index 000000000..60ad8ca70--- /dev/null+++ b/docs/customize/examples/prompting-guide.mdx@@ -0,0 +1,92 @@+---+title: "Prompting Guide"+description: "Tips and tricks "+icon: "lightbulb"+---++Prompting can trasticly improve performance and solve existing limitations of the library.++### 1. Be Specific vs Open-Ended++**✅ Specific (Recommended)**+```python+task = """+1. Go to https://quotes.toscrape.com/+2. Use extract_structured_data action with the query "first 3 quotes with their authors"+3. Save results to quotes.csv using write_file action+4. Do a google search for the first quote and find when it was written+"""+```++**❌ Open-Ended**+```python+task = "Go to web and make money"+```++### 2. Name Actions Directly++When you know exactly what the agent should do, reference actions by name:++```python+task = """+1. Use search_google action to find "Python tutorials"+2. Use click_element_by_index to open first result in a new tab+3. Use scroll action to scroll down 2 pages+4. Use extract_structured_data to extract the names of the first 5 items+5. Wait for 2 seconds if the page is not loaded, refresh it and wait 10 sec+6. Use send_keys action with "Tab", "Tab", "ArrowDown", send "Hello World" and press "Enter"+"""+```++See [Available Tools](/customize/tools/available) for the complete list of actions.+++### 3. Handle interaction problems via keyboard navigation++Sometimes buttons can't be clicked (you found a bug in the library - open an issue).+Good news - often you can work around it with keyboard navigation!++```python+task = """+If the submit button cannot be clicked:+1. Use send_keys action with "Tab Tab Enter" to navigate and activate+2. Or use send_keys with "ArrowDown ArrowDown Enter" for form submission+"""+```+++++### 4. Custom Actions Integration++```python+# When you have custom actions[email protected]("Get 2FA code from authenticator app")+async def get_2fa_code():+ # Your implementation+ pass++task = """+Login with 2FA:+1. Enter username/password+2. When prompted for 2FA, use get_2fa_code action+3. NEVER try to extract 2FA codes from the page manually+4. ALWAYS use the get_2fa_code action for authentication codes+"""+```++### 5. Error Recovery++```python+task = """+Robust data extraction:+1. Go to openai.com to find their CEO+2. If navigation fails due to anti-bot protection:+ - Use google search to find the CEO+3. If page times out, use go_back and try alternative approach+"""+```++++The key to effective prompting is being specific about actions.diff --git a/docs/docs.json b/docs/docs.jsonindex 412a8c426..b29973810 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -9,7 +9,10 @@},"favicon": "/favicon.ico","contextual": {- "options": ["copy", "view"]+ "options": [+ "copy",+ "view"+ ]},"fonts": {"family": "Geist"@@ -72,7 +75,11 @@"groups": [{"group": "Get Started",- "pages": ["introduction", "quickstart", "quickstart_llm"]+ "pages": [+ "introduction",+ "quickstart",+ "quickstart_llm"+ ]},{"group": "Customize",@@ -115,6 +122,7 @@"group": "Examples","icon": "folder-open","pages": [+ "customize/examples/prompting-guide","customize/examples/fast-agent","customize/examples/chain-agents","customize/examples/parallel-browser",@@ -196,7 +204,11 @@"display": "interactive"},"examples": {- "languages": ["javascript", "curl", "python"],+ "languages": [+ "javascript",+ "curl",+ "python"+ ],"required": true}},@@ -224,4 +236,4 @@"linkedin": "https://linkedin.com/company/browser-use"}}-}+}\ No newline at end of file