Browser Use 是将 AI agent 与浏览器相结合的最简单方法。它为浏览器自动化提供了一个强大而简单的界面,使 AI agent 可以像用户一样访问网站。
本项目最初使用如下过程建立相关文件:
$ uv init browser-use-agent
$ cd browser-use-agent
$ uv add "browser-use[memory]"
$ echo "OPENAI_API_KEY=xxxxxx" > .env
建议使用 Chrome DevTools Protocol (CDP) 来使用浏览器,在 macOS 下使用如下命令:
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' \
--remote-debugging-port=9222 \
--user-data-dir='Debug' &
这样方便用户先登录一些需要账户密码的网站。使用 --user-data-dir
参数的原因如下:
DevTools remote debugging requires a non-default data directory. Specify this using --user-data-dir.
具体使用如下命令来执行任务:
uv run python ollama-agent.py "What is Browser Use?"
uv run python gpt-agent.py "What is Browser Use?"
不同的大模型在能力方面存在明显区别,gpt-4o 比 gpt-4o-mini 表现要好,而 Ollama 上提供的小规模模型表现就更加差劲。