Skip to content
This repository was archived by the owner on Jan 26, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 128 additions & 4 deletions customize/langchain-models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,137 @@ AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
AZURE_OPENAI_KEY=
```

## Coming soon
### Gemini
Get your API key from https://aistudio.google.com/apikey
Make sure to use browser-use>=0.1.18

And add the variable:

```bash .env
GEMINI_API_KEY=
```

Subsequently, you can use the model as following:

```python
import asyncio
import os

from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI
from pydantic import SecretStr

from browser_use import Agent

load_dotenv()
api_key = os.getenv('GEMINI_API_KEY')
if not api_key:
raise ValueError('GEMINI_API_KEY is not set')

llm = ChatGoogleGenerativeAI(model='gemini-2.0-flash-exp', api_key=SecretStr(api_key))


async def run_search():
agent = Agent(
task=(
'Go to url r/LocalLLaMA subreddit and search for "browser use" in the search bar and click on the first post and find the funniest comment'
),
llm=llm,
max_actions_per_step=4,
tool_call_in_content=False,
)

await agent.run(max_steps=25)


if __name__ == '__main__':
asyncio.run(run_search())

```

### Qwen

Check [Qwen example](https://github.com/browser-use/browser-use/blob/main/examples/qwen.py)
```python
import asyncio
import os

from langchain_ollama import ChatOllama

from browser_use import Agent


async def run_search():
agent = Agent(
task=(
'1. Go to https://www.reddit.com/r/LocalLLaMA'
"2. Search for 'browser use' in the search bar"
'3. Click search'
'4. Call done'
),
llm=ChatOllama(
# model='qwen2.5:32b-instruct-q4_K_M',
# model='qwen2.5:14b',
model='qwen2.5:latest',
num_ctx=128000,
),
max_actions_per_step=1,
tool_call_in_content=False,
)

await agent.run()


if __name__ == '__main__':
asyncio.run(run_search())
```

### Ollama

Check [llama example](https://github.com/browser-use/browser-use/blob/main/examples/ollama.py)

```python
import os

# Optional: Disable telemetry
# os.environ["ANONYMIZED_TELEMETRY"] = "false"

# Optional: Set the OLLAMA host to a remote server
# os.environ["OLLAMA_HOST"] = "http://x.x.x.x:11434"

import asyncio
from browser_use import Agent
from langchain_ollama import ChatOllama


async def run_search() -> str:
agent = Agent(
task="Search for a 'browser use' post on the r/LocalLLaMA subreddit and open it.",
llm=ChatOllama(
model="qwen2.5:32b-instruct-q4_K_M",
num_ctx=32000,
),
)

result = await agent.run()
return result


async def main():
result = await run_search()
print("\n\n", result)


if __name__ == "__main__":
asyncio.run(main())
```

### granite3.1

Coming soon

(Sorry, we are working on it)

- Gemini
- Groq
- DeepSeek
- Github
- Ollama
- QWen