Re-save example notebooks in Cursor

This commit is contained in:
James Murdza
2025-10-29 16:13:35 -07:00
parent dabbb41948
commit 27fd864153
5 changed files with 151 additions and 31 deletions

View File

@@ -3,7 +3,11 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "## Agent\n\nThis notebook demonstrates how to use Cua's Agent to run workflows in virtual sandboxes, either using Cua Cloud Sandbox or local VMs on Apple Silicon Macs."
"source": [
"## Agent\n",
"\n",
"This notebook demonstrates how to use Cua's Agent to run workflows in virtual sandboxes, either using Cua Cloud Sandbox or local VMs on Apple Silicon Macs."
]
},
{
"cell_type": "markdown",
@@ -57,7 +61,9 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "Agent allows you to run an agentic workflow in virtual sandbox instances. You can choose between Cloud Sandbox or local VMs."
"source": [
"Agent allows you to run an agentic workflow in virtual sandbox instances. You can choose between Cloud Sandbox or local VMs."
]
},
{
"cell_type": "code",
@@ -90,17 +96,32 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "## Option 1: Agent with Cua Cloud Sandbox\n\nUse Cloud Sandbox for running agents from any system without local setup."
"source": [
"## Option 1: Agent with Cua Cloud Sandbox\n",
"\n",
"Use Cloud Sandbox for running agents from any system without local setup."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Prerequisites for Cloud Sandbox\n\nTo use Cua Cloud Sandbox, you need to:\n1. Sign up at https://trycua.com\n2. Create a Cloud Sandbox\n3. Generate an API Key\n\nOnce you have these, you can connect to your Cloud Sandbox and run agents on it."
"source": [
"### Prerequisites for Cloud Sandbox\n",
"\n",
"To use Cua Cloud Sandbox, you need to:\n",
"1. Sign up at https://trycua.com\n",
"2. Create a Cloud Sandbox\n",
"3. Generate an API Key\n",
"\n",
"Once you have these, you can connect to your Cloud Sandbox and run agents on it."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Get Cua API credentials and sandbox details"
"source": [
"Get Cua API credentials and sandbox details"
]
},
{
"cell_type": "code",
@@ -117,31 +138,60 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "Choose the OS type for your sandbox (linux or macos)"
"source": [
"Choose the OS type for your sandbox (linux or macos)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "os_type = input(\"Enter the OS type of your sandbox (linux/macos) [default: linux]: \").lower() or \"linux\""
"source": [
"os_type = input(\"Enter the OS type of your sandbox (linux/macos) [default: linux]: \").lower() or \"linux\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Create an agent with Cloud Sandbox"
"source": [
"### Create an agent with Cloud Sandbox"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "import logging\nfrom pathlib import Path\n\n# Connect to your existing Cloud Sandbox\ncomputer = Computer(\n os_type=os_type,\n api_key=cua_api_key,\n name=container_name,\n provider_type=VMProviderType.CLOUD,\n verbosity=logging.INFO\n)\n\n# Create agent\nagent = ComputerAgent(\n model=\"openai/computer-use-preview\",\n tools=[computer],\n trajectory_dir=str(Path(\"trajectories\")),\n only_n_most_recent_images=3,\n verbosity=logging.INFO\n)\n"
"source": [
"import logging\n",
"from pathlib import Path\n",
"\n",
"# Connect to your existing Cloud Sandbox\n",
"computer = Computer(\n",
" os_type=os_type,\n",
" api_key=cua_api_key,\n",
" name=container_name,\n",
" provider_type=VMProviderType.CLOUD,\n",
" verbosity=logging.INFO\n",
")\n",
"\n",
"# Create agent\n",
"agent = ComputerAgent(\n",
" model=\"openai/computer-use-preview\",\n",
" tools=[computer],\n",
" trajectory_dir=str(Path(\"trajectories\")),\n",
" only_n_most_recent_images=3,\n",
" verbosity=logging.INFO\n",
")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Run tasks on Cloud Sandbox"
"source": [
"Run tasks on Cloud Sandbox"
]
},
{
"cell_type": "code",
@@ -496,7 +546,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "cua",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
@@ -510,9 +560,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.5"
"version": "3.13.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}

View File

@@ -3,7 +3,11 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "## Computer\n\nThis notebook demonstrates how to use Computer to operate sandbox VMs programmatically, either using Cua Cloud Sandbox or local Lume VMs on Apple Silicon macOS systems."
"source": [
"## Computer\n",
"\n",
"This notebook demonstrates how to use Computer to operate sandbox VMs programmatically, either using Cua Cloud Sandbox or local Lume VMs on Apple Silicon macOS systems."
]
},
{
"cell_type": "markdown",
@@ -509,12 +513,25 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "## Option 1: Cua Cloud Sandbox\n\nCua Cloud Sandbox provides remote VMs that can be accessed from any system without local setup."
"source": [
"## Option 1: Cua Cloud Sandbox\n",
"\n",
"Cua Cloud Sandbox provides remote VMs that can be accessed from any system without local setup."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Prerequisites for Cloud Sandbox\n\nTo use Cua Cloud Sandbox, you need to:\n1. Sign up at https://trycua.com\n2. Create a Cloud Sandbox\n3. Generate an API Key\n\nOnce you have these, you can connect to your Cloud Sandbox using its name."
"source": [
"### Prerequisites for Cloud Sandbox\n",
"\n",
"To use Cua Cloud Sandbox, you need to:\n",
"1. Sign up at https://trycua.com\n",
"2. Create a Cloud Sandbox\n",
"3. Generate an API Key\n",
"\n",
"Once you have these, you can connect to your Cloud Sandbox using its name."
]
},
{
"cell_type": "code",
@@ -534,19 +551,25 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "Choose the OS type for your sandbox (linux or macos)"
"source": [
"Choose the OS type for your sandbox (linux or macos)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "os_type = input(\"Enter the OS type of your sandbox (linux/macos) [default: linux]: \").lower() or \"linux\""
"source": [
"os_type = input(\"Enter the OS type of your sandbox (linux/macos) [default: linux]: \").lower() or \"linux\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Connect to your Cloud Sandbox"
"source": [
"### Connect to your Cloud Sandbox"
]
},
{
"cell_type": "code",
@@ -560,14 +583,23 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "Connect to your existing Cua Cloud Sandbox"
"source": [
"Connect to your existing Cua Cloud Sandbox"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "computer = Computer(\n os_type=os_type, # Must match the OS type of your Cloud Sandbox\n api_key=cua_api_key,\n name=container_name,\n provider_type=VMProviderType.CLOUD,\n)"
"source": [
"computer = Computer(\n",
" os_type=os_type, # Must match the OS type of your Cloud Sandbox\n",
" api_key=cua_api_key,\n",
" name=container_name,\n",
" provider_type=VMProviderType.CLOUD,\n",
")"
]
},
{
"cell_type": "markdown",
@@ -1074,4 +1106,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}

View File

@@ -158,7 +158,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "cua",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
@@ -172,7 +172,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.11"
"version": "3.13.6"
}
},
"nbformat": 4,

View File

@@ -271,8 +271,14 @@
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.13.6"
}
},
"nbformat": 4,

View File

@@ -56,7 +56,12 @@
"cell_type": "markdown",
"id": "47171dc3",
"metadata": {},
"source": "1. Create a Cua account at https://www.trycua.com/\n2. Start a small Cua sandbox at https://www.trycua.com/dashboard/containers (If you need credits, ask us!)\n3. Create a HUD account at https://www.hud.so/\n4. Create a .env file:"
"source": [
"1. Create a Cua account at https://www.trycua.com/\n",
"2. Start a small Cua sandbox at https://www.trycua.com/dashboard/containers (If you need credits, ask us!)\n",
"3. Create a HUD account at https://www.hud.so/\n",
"4. Create a .env file:"
]
},
{
"cell_type": "code",
@@ -146,13 +151,21 @@
"cell_type": "markdown",
"id": "a07b09ee",
"metadata": {},
"source": "## 🖱️ Test your agent\n\nRun your agent on a test scenario in a Cua Cloud Sandbox."
"source": [
"## 🖱️ Test your agent\n",
"\n",
"Run your agent on a test scenario in a Cua Cloud Sandbox."
]
},
{
"cell_type": "markdown",
"id": "12b9c22c",
"metadata": {},
"source": "Connect to an existing Cloud Sandbox through the Cua SDK.\n\nYou can access the computer through VNC on the [Cua Dashboard](https://www.trycua.com/dashboard)."
"source": [
"Connect to an existing Cloud Sandbox through the Cua SDK.\n",
"\n",
"You can access the computer through VNC on the [Cua Dashboard](https://www.trycua.com/dashboard)."
]
},
{
"cell_type": "code",
@@ -160,7 +173,20 @@
"id": "a210e959",
"metadata": {},
"outputs": [],
"source": "from computer import Computer, VMProviderType\n\n# Connect to your existing Cloud Sandbox\ncomputer = Computer(\n os_type=\"linux\",\n provider_type=VMProviderType.CLOUD,\n name=os.getenv(\"CUA_CONTAINER_NAME\") or \"\",\n api_key=os.getenv(\"CUA_API_KEY\"),\n verbosity=logging.INFO\n)\n\nagent_config[\"tools\"] = [ computer ]"
"source": [
"from computer import Computer, VMProviderType\n",
"\n",
"# Connect to your existing Cloud Sandbox\n",
"computer = Computer(\n",
" os_type=\"linux\",\n",
" provider_type=VMProviderType.CLOUD,\n",
" name=os.getenv(\"CUA_CONTAINER_NAME\") or \"\",\n",
" api_key=os.getenv(\"CUA_API_KEY\"),\n",
" verbosity=logging.INFO\n",
")\n",
"\n",
"agent_config[\"tools\"] = [ computer ]"
]
},
{
"cell_type": "markdown",
@@ -251,10 +277,16 @@
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.13.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}