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.

simplified examples file

Dillon DuPonta66c9c89bb01
diff --git a/libs/python/agent/agent/proxy/examples.py b/libs/python/agent/agent/proxy/examples.py
index 2838c5dfd1..790e87dffb 100644
--- a/libs/python/agent/agent/proxy/examples.py
+++ b/libs/python/agent/agent/proxy/examples.py
@@ -17,44 +17,6 @@ async def test_http_endpoint():
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
assert isinstance(anthropic_api_key, str), "ANTHROPIC_API_KEY environment variable must be set"
- # Example 1: Simple text request
- simple_request = {
- "model": "anthropic/claude-3-5-sonnet-20241022",
- "input": "Tell me a three sentence bedtime story about a unicorn.",
- "env": {
- "ANTHROPIC_API_KEY": anthropic_api_key
- }
- }
-
- # Example 2: Multi-modal request with image
- multimodal_request = {
- "model": "anthropic/claude-3-5-sonnet-20241022",
- "input": [
- {
- "role": "user",
- "content": [
- {"type": "input_text", "text": "what is in this image?"},
- {
- "type": "input_image",
- "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
- }
- ]
- }
- ],
- "env": {
- "ANTHROPIC_API_KEY": anthropic_api_key
- }
- }
-
- # Example 3: Request with custom agent and computer kwargs
- custom_request = {
- "model": "anthropic/claude-3-5-sonnet-20241022",
- "input": "Take a screenshot and tell me what you see",
- "env": {
- "ANTHROPIC_API_KEY": anthropic_api_key
- }
- }
-
# Test requests
base_url = "https://m-linux-96lcxd2c2k.containers.cloud.trycua.com:8443"
# base_url = "http://localhost:8000"
@@ -63,9 +25,37 @@ async def test_http_endpoint():
async with aiohttp.ClientSession() as session:
for i, request_data in enumerate([
- simple_request,
- # multimodal_request,
- custom_request
+ # ==== Request Body Examples ====
+
+ # Simple text request
+ {
+ "model": "anthropic/claude-3-5-sonnet-20241022",
+ "input": "Tell me a three sentence bedtime story about a unicorn.",
+ "env": {
+ "ANTHROPIC_API_KEY": anthropic_api_key
+ }
+ },
+
+ # Multimodal request with image
+ # {
+ # "model": "anthropic/claude-3-5-sonnet-20241022",
+ # "input": [
+ # {
+ # "role": "user",
+ # "content": [
+ # {"type": "input_text", "text": "what is in this image?"},
+ # {
+ # "type": "input_image",
+ # "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
+ # }
+ # ]
+ # }
+ # ],
+ # "env": {
+ # "ANTHROPIC_API_KEY": anthropic_api_key
+ # }
+ # }
+
], 1):
print(f"\n--- Test {i} ---")
print(f"Request: {json.dumps(request_data, indent=2)}")
@@ -85,55 +75,6 @@ async def test_http_endpoint():
print(f"Error: {e}")
-def curl_examples():
- """Print curl command examples."""
-
- print("=== CURL Examples ===\n")
-
- print("1. Simple text request:")
- print("""curl http://localhost:8000/responses \\
- -H "Content-Type: application/json" \\
- -d '{
- "model": "anthropic/claude-3-5-sonnet-20241022",
- "input": "Tell me a three sentence bedtime story about a unicorn."
- }'""")
-
- print("\n2. Multi-modal request with image:")
- print("""curl http://localhost:8000/responses \\
- -H "Content-Type: application/json" \\
- -d '{
- "model": "anthropic/claude-3-5-sonnet-20241022",
- "input": [
- {
- "role": "user",
- "content": [
- {"type": "input_text", "text": "what is in this image?"},
- {
- "type": "input_image",
- "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
- }
- ]
- }
- ]
- }'""")
-
- print("\n3. Request with custom configuration:")
- print("""curl http://localhost:8000/responses \\
- -H "Content-Type: application/json" \\
- -d '{
- "model": "anthropic/claude-3-5-sonnet-20241022",
- "input": "Take a screenshot and tell me what you see",
- "agent_kwargs": {
- "save_trajectory": true,
- "verbosity": 20
- },
- "computer_kwargs": {
- "os_type": "linux",
- "provider_type": "cloud"
- }
- }'""")
-
-
async def test_p2p_client():
"""Example P2P client using peerjs-python."""
try:
@@ -184,9 +125,7 @@ async def test_p2p_client():
if __name__ == "__main__":
import sys
- if len(sys.argv) > 1 and sys.argv[1] == "curl":
- curl_examples()
- elif len(sys.argv) > 1 and sys.argv[1] == "p2p":
+ if len(sys.argv) > 1 and sys.argv[1] == "p2p":
asyncio.run(test_p2p_client())
else:
asyncio.run(test_http_endpoint())