mirror of
https://github.com/trycua/computer.git
synced 2026-02-22 22:39:33 -06:00
Added simple ollama agent example
This commit is contained in:
71
notebooks/ollama_nb.ipynb
Normal file
71
notebooks/ollama_nb.ipynb
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user