Update notebooks

This commit is contained in:
f-trycua
2025-04-06 11:28:28 -07:00
parent 36fccfde87
commit 388f474068
8 changed files with 73 additions and 1127 deletions

View File

@@ -172,8 +172,9 @@
"agent = ComputerAgent(\n",
" computer=computer,\n",
" loop=AgentLoop.OMNI,\n",
" model=LLM(provider=LLMProvider.ANTHROPIC, name=\"claude-3-7-sonnet-20250219\"),\n",
" # model=LLM(provider=LLMProvider.ANTHROPIC, name=\"claude-3-7-sonnet-20250219\"),\n",
" # model=LLM(provider=LLMProvider.OPENAI, name=\"gpt-4.5-preview\"),\n",
" model=LLM(provider=LLMProvider.OLLAMA, name=\"gemma3:12b-it-q4_K_M\"),\n",
" save_trajectory=True,\n",
" trajectory_dir=str(Path(\"trajectories\")),\n",
" only_n_most_recent_images=3,\n",
@@ -197,6 +198,25 @@
"\n",
" print(f\"\\n✅ Task {i+1}/{len(tasks)} completed: {task}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using the Gradio UI\n",
"\n",
"The agent includes a Gradio-based user interface for easy interaction. To use it:\n",
"\n",
"```python\n",
"from agent.ui.gradio.app import create_gradio_ui\n",
"\n",
"app = create_gradio_ui()\n",
"app.launch(share=False)\n",
"```\n",
"\n",
"The Gradio UI provides:\n",
"- Selection of different agent loops (OpenAI, Anthropic, OMNI)"
]
}
],
"metadata": {

View File

@@ -1,136 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Gradio UI for Agent\n",
"\n",
"This notebook demonstrates how to use Cua's Agent using a Gradio frontend.\n",
"\n",
"Credits to AK391 for [github.com/AK391/ai-gradio](https://github.com/AK391/ai-gradio)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Installation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install 'ai-gradio[cua]'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Start the Gradio App"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# Get API keys from environment or prompt user\n",
"openai_key = os.getenv(\"OPENAI_API_KEY\") or input(\"Enter your OpenAI API key: \")\n",
"os.environ[\"OPENAI_API_KEY\"] = openai_key"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"UserWarning: The 'tuples' format for chatbot messages is deprecated and will be removed in a future version of Gradio. Please set type='messages' instead, which uses openai-style 'role' and 'content' keys.\n",
"INFO:httpx:HTTP Request: GET http://127.0.0.1:7862/gradio_api/startup-events \"HTTP/1.1 200 OK\"\n",
"INFO:httpx:HTTP Request: HEAD http://127.0.0.1:7862/ \"HTTP/1.1 200 OK\"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7862\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7862/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import gradio as gr\n",
"import ai_gradio\n",
"\n",
"gr.load(\n",
" name='cua:gpt-4', # currently ignored\n",
" src=ai_gradio.registry,\n",
" title=\"Cua - AI Agent\"\n",
").launch()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Available Agent Loop & LLM Providers\n",
"\n",
"Refer to: https://github.com/trycua/cua/tree/main/libs/agent#agent-loops"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "cua",
"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.11.11"
}
},
"nbformat": 4,
"nbformat_minor": 2
}