Skip to content

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

Added ollama example in ollama.py

Jacob Byerlinedaa5e47ce3c4
diff --git a/examples/ollama.py b/examples/ollama.py
new file mode 100644
index 000000000..ded387e5b
--- /dev/null
+++ b/examples/ollama.py
@@ -0,0 +1,33 @@
+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())
\ No newline at end of file