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.

add cua adapter support for gemini

Sarina Li05b1e5a98412
diff --git a/libs/python/agent/agent/adapters/cua_adapter.py b/libs/python/agent/agent/adapters/cua_adapter.py
index 76ecb7e49e..1d980be9de 100644
--- a/libs/python/agent/agent/adapters/cua_adapter.py
+++ b/libs/python/agent/agent/adapters/cua_adapter.py
@@ -24,6 +24,10 @@ class CUAAdapter(CustomLLM):
if "anthropic/" in model:
model = f"anthropic/{self._normalize_model(model)}"
api_base = api_base.removesuffix("/v1")
+ elif "gemini/" in model or "google/" in model:
+ # Route to Gemini pass-through endpoint
+ model = f"gemini/{self._normalize_model(model)}"
+ api_base = api_base.removesuffix("/v1") + "/gemini"
else:
model = f"openai/{self._normalize_model(model)}"
@@ -35,6 +39,10 @@ class CUAAdapter(CustomLLM):
"stream": False,
}
+ # Forward tools if provided
+ if "tools" in kwargs:
+ params["tools"] = kwargs["tools"]
+
if "optional_params" in kwargs:
params.update(kwargs["optional_params"])
del kwargs["optional_params"]
@@ -71,6 +79,10 @@ class CUAAdapter(CustomLLM):
if "anthropic/" in model:
model = f"anthropic/{self._normalize_model(model)}"
api_base = api_base.removesuffix("/v1")
+ elif "gemini/" in model or "google/" in model:
+ # Route to Gemini pass-through endpoint
+ model = f"gemini/{self._normalize_model(model)}"
+ api_base = api_base.removesuffix("/v1") + "/gemini"
else:
model = f"openai/{self._normalize_model(model)}"
@@ -82,6 +94,10 @@ class CUAAdapter(CustomLLM):
"stream": False,
}
+ # Forward tools if provided
+ if "tools" in kwargs:
+ params["tools"] = kwargs["tools"]
+
if "optional_params" in kwargs:
params.update(kwargs["optional_params"])
del kwargs["optional_params"]