Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Added simple ollama agent example

Dillon DuPont492ebe9f0e05
diff --git a/notebooks/ollama_nb.ipynb b/notebooks/ollama_nb.ipynb
new file mode 100644
index 0000000000..a6b6334b3d
--- /dev/null
+++ b/notebooks/ollama_nb.ipynb
@@ -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
+}