Skip to content

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

Docs for sensitive data

magmuellerf9e7379bdd61
diff --git a/docs/customize/sensitive_data.mdx b/docs/customize/sensitive_data.mdx
new file mode 100644
index 000000000..7f05a90dc
--- /dev/null
+++ b/docs/customize/sensitive_data.mdx
@@ -0,0 +1,50 @@
+---
+title: "Sensitive Data"
+description: "Handle sensitive information securely by preventing the model from seeing actual passwords."
+icon: "shield-lock"
+---
+
+## Handling Sensitive Data
+
+When working with sensitive information like passwords, you can use the `sensitive_data` parameter to prevent the model from seeing the actual values while still allowing it to reference them in its actions.
+
+Here's an example of how to use sensitive data:
+
+```python
+from dotenv import load_dotenv
+from langchain_openai import ChatOpenAI
+from browser_use import Agent
+
+load_dotenv()
+
+# Initialize the model
+llm = ChatOpenAI(
+ model='gpt-4o',
+ temperature=0.0,
+)
+
+# Define sensitive data
+# The model will only see the keys (x_name, x_password) but never the actual values
+sensitive_data = {'x_name': 'magnus', 'x_password': '12345678'}
+
+# Use the placeholder names in your task description
+task = 'go to x.com and login with x_name and x_password then write a post about the meaning of life'
+
+# Pass the sensitive data to the agent
+agent = Agent(task=task, llm=llm, sensitive_data=sensitive_data)
+
+async def main():
+ await agent.run()
+
+if __name__ == '__main__':
+ asyncio.run(main())
+```
+
+In this example:
+1. The model only sees `x_name` and `x_password` as placeholders.
+2. When the model wants to use your password it outputs x_password - and we replace it with the actual value.
+3. When your password is visable on the current page, we replace it in the LLM input - so that the model never has it in its state.
+
+Warning: Vision models still see the image of the page - where the sensitive data might be visible.
+
+This approach ensures that sensitive information remains secure while still allowing the agent to perform tasks that require authentication.
\ No newline at end of file
diff --git a/docs/mint.json b/docs/mint.json
index 77e7e99d0..0b928ae57 100644
--- a/docs/mint.json
+++ b/docs/mint.json
@@ -45,7 +45,10 @@
"navigation": [
{
"group": "Get Started",
- "pages": ["introduction", "quickstart"]
+ "pages": [
+ "introduction",
+ "quickstart"
+ ]
},
{
"group": "Customize",
@@ -56,6 +59,7 @@
"customize/real-browser",
"customize/output-format",
"customize/system-prompt",
+ "customize/sensitive-data",
"customize/custom-functions"
]
},
@@ -74,4 +78,4 @@
"github": "https://github.com/browser-use/browser-use",
"linkedin": "https://linkedin.com/company/browser-use"
}
-}
+}
\ No newline at end of file
diff --git a/examples/features/sensitive_data.py b/examples/features/sensitive_data.py
index 9d3d8d02b..52a8a5bc4 100644
--- a/examples/features/sensitive_data.py
+++ b/examples/features/sensitive_data.py
@@ -12,9 +12,9 @@ llm = ChatOpenAI(
model='gpt-4o',
temperature=0.0,
)
-# the llm will never see the values of your sensitve data, it will only see the keys. Internally we replace after the llm the keys with the values.
-sensitive_data = {'x_name': 'mamagnus00', 'x_password': '12345678'}
-task = 'go to x and login with x_name and x_password then find interesting posts and like them'
+# the model will see x_name and x_password, but never the actual values.
+sensitive_data = {'x_name': 'my_x_name', 'x_password': 'my_x_password'}
+task = 'go to x.com and login with x_name and x_password then find interesting posts and like them'
agent = Agent(task=task, llm=llm, sensitive_data=sensitive_data)