Browser use integration issues
2025-03-232 turns1,542 charsgpt-4o
Summary
User was testing browser-use integration with LangChain and Ollama to automate web browsing tasks.
Messages
# Test browser-use functionality
from langchain_ollama import ChatOllama
from browser_use import Agent
from pydantic import SecretStr
import asyncio
# Initialize the model
llm=ChatOllama(model="mistral", num_ctx=32000)
async def main():
task = 'go to danielkliewer.com and tell me what it is about'
model = llm
agent = Agent(task=task, llm=model)
history = await agent.run()
print(history)
if __name__ == '__main__':
asyncio.run(main())
Your code is structured well, but I noticed a few potential issues:
1. **Missing `browser_use` package**: Ensure that `browser_use.Agent` is a valid class from an installed package. If this is a custom module, verify that it is correctly implemented.
2. **`Agent` Instantiation**: Does `Agent` support `task` and `llm` as parameters? Double-check the expected arguments.
3. **Long Context Size**: `num_ctx=32000` might not be supported by `mistral`. Most versions of `Mistral` max out at `8K` or `16K`. Check if your model supports this.
4. **Potential Async Issues**: Some libraries (like LangChain) may have compatibility issues when running inside an event loop with `asyncio.run()`.
### **Debugging Steps**
1. Install dependencies if you haven't:
```bash
pip install langchain_ollama browser_use
```
2. Verify that `browser_use.Agent` works correctly. Try a simple test:
```python
agent = Agent(task="test task", llm=llm)
print(agent)
```
3. Reduce `num_ctx` to a safe value like `4096` or `8192` to avoid model issues.
Would you like help troubleshooting further?
gpt-4o