Added simple ollama agent example

This commit is contained in:
Dillon DuPont
2025-09-12 13:02:23 -04:00
parent ab9cf0636b
commit 492ebe9f0e

71
notebooks/ollama_nb.ipynb Normal file
View File

@@ -0,0 +1,71 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "8e017e51",
"metadata": {},
"source": [
"# Running Ollama ComputerAgents\n",
"\n",
"This notebook guides you through examples on how to use your local Ollama to run computer-using models"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a0f9a75",
"metadata": {},
"outputs": [],
"source": [
"from agent import ComputerAgent\n",
"from computer import Computer, VMProviderType\n",
"import logging\n",
"import os\n",
"\n",
"# First we need to connect to a computer\n",
"computer = Computer(\n",
" provider_type=VMProviderType.CLOUD,\n",
" os_type=\"linux\",\n",
" name=os.environ[\"CUA_CONTAINER_NAME\"],\n",
" api_key=os.environ[\"CUA_API_KEY\"]\n",
")\n",
"await computer.run()\n",
"\n",
"# Then we need to pick a model to use\n",
"agent = ComputerAgent(\n",
" model=\"openai/computer-use-preview+ollama/gemma3:4b\",\n",
" tools=[computer],\n",
" trajectory_dir=\"trajectories\",\n",
" verbosity=logging.DEBUG,\n",
" instructions=(\n",
" \"You are a computer-use agent. \"\n",
" \"Control the computer by using the 'computer' tool and specifying the action type in the 'type' argument.\"\n",
" )\n",
")\n",
"async for _ in agent.run(\"Hello! Open the web browser\"):\n",
" pass"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}