mirror of
https://github.com/trycua/computer.git
synced 2026-01-01 11:00:31 -06:00
Consolidate constructor items table and list
This commit is contained in:
@@ -31,39 +31,34 @@ async for result in agent.run(prompt):
|
||||
|
||||
For a list of supported models and configurations, see the [Supported Agents](./supported-agents/computer-use-agents) page.
|
||||
|
||||
### ComputerAgent Constructor Options
|
||||
### Parameters
|
||||
|
||||
The `ComputerAgent` constructor provides a wide range of options for customizing agent behavior, tool integration, callbacks, resource management, and more.
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
| --------------------------- | ----------------- | ------------ | ---------------------------------------------------------------------------------------------------- |
|
||||
| `model` | `str` | **required** | Model name (e.g., "claude-3-5-sonnet-20241022", "computer-use-preview", "omni+vertex_ai/gemini-pro") |
|
||||
| `tools` | `List[Any]` | `None` | List of tools (e.g., computer objects, decorated functions) |
|
||||
| `custom_loop` | `Callable` | `None` | Custom agent loop function (overrides auto-selection) |
|
||||
| `only_n_most_recent_images` | `int` | `None` | If set, only keep the N most recent images in message history (adds ImageRetentionCallback) |
|
||||
| `callbacks` | `List[Any]` | `None` | List of AsyncCallbackHandler instances for preprocessing/postprocessing |
|
||||
| `verbosity` | `int` | `None` | Logging level (`logging.DEBUG`, `logging.INFO`, etc.; adds LoggingCallback) |
|
||||
| `trajectory_dir` | `str` | `None` | Directory to save trajectory data (adds TrajectorySaverCallback) |
|
||||
| `max_retries` | `int` | `3` | Maximum number of retries for failed API calls |
|
||||
| `screenshot_delay` | `float` \| `int` | `0.5` | Delay before screenshots (seconds) |
|
||||
| `use_prompt_caching` | `bool` | `False` | Use prompt caching to avoid reprocessing the same prompt (mainly for Anthropic) |
|
||||
| `max_trajectory_budget` | `float` \| `dict` | `None` | If set, adds BudgetManagerCallback to track usage costs and stop when budget is exceeded |
|
||||
| `**kwargs` | _any_ | | Additional arguments passed to the agent loop |
|
||||
|
||||
#### Parameter Details
|
||||
|
||||
- **model**: The LLM or agent model to use. Determines which agent loop is selected unless `custom_loop` is provided.
|
||||
- **tools**: List of tools the agent can use (e.g., `Computer`, sandboxed Python functions, etc.).
|
||||
- **custom_loop**: Optional custom agent loop function. If provided, overrides automatic loop selection.
|
||||
- **only_n_most_recent_images**: If set, only the N most recent images are kept in the message history. Useful for limiting memory usage. Automatically adds `ImageRetentionCallback`.
|
||||
- **callbacks**: List of callback instances for advanced preprocessing, postprocessing, logging, or custom hooks. See [Callbacks & Extensibility](#callbacks--extensibility).
|
||||
- **verbosity**: Logging level (e.g., `logging.INFO`). If set, adds a logging callback.
|
||||
- **trajectory_dir**: Directory path to save full trajectory data, including screenshots and responses. Adds `TrajectorySaverCallback`.
|
||||
- **max_retries**: Maximum number of retries for failed API calls (default: 3).
|
||||
- **screenshot_delay**: Delay (in seconds) before taking screenshots (default: 0.5).
|
||||
- **use_prompt_caching**: Enables prompt caching for repeated prompts (mainly for Anthropic models).
|
||||
- **max_trajectory_budget**: If set (float or dict), adds a budget manager callback that tracks usage costs and stops execution if the budget is exceeded. Dict allows advanced options (e.g., `{ "max_budget": 5.0, "raise_error": True }`).
|
||||
- **\*\*kwargs**: Any additional keyword arguments are passed through to the agent loop or model provider.
|
||||
- `model` (`str`): Default: **required**
|
||||
The LLM or agent model to use. Determines which agent loop is selected unless `custom_loop` is provided. (e.g., "claude-3-5-sonnet-20241022", "computer-use-preview", "omni+vertex_ai/gemini-pro")
|
||||
- `tools` (`List[Any]`):
|
||||
List of tools the agent can use (e.g., `Computer`, sandboxed Python functions, etc.).
|
||||
- `custom_loop` (`Callable`):
|
||||
Optional custom agent loop function. If provided, overrides automatic loop selection.
|
||||
- `only_n_most_recent_images` (`int`):
|
||||
If set, only the N most recent images are kept in the message history. Useful for limiting memory usage. Automatically adds `ImageRetentionCallback`.
|
||||
- `callbacks` (`List[Any]`):
|
||||
List of callback instances for advanced preprocessing, postprocessing, logging, or custom hooks. See [Callbacks & Extensibility](#callbacks--extensibility).
|
||||
- `verbosity` (`int`):
|
||||
Logging level (e.g., `logging.INFO`). If set, adds a logging callback.
|
||||
- `trajectory_dir` (`str`):
|
||||
Directory path to save full trajectory data, including screenshots and responses. Adds `TrajectorySaverCallback`.
|
||||
- `max_retries` (`int`): Default: `3`
|
||||
Maximum number of retries for failed API calls (default: 3).
|
||||
- `screenshot_delay` (`float` | `int`): Default: `0.5`
|
||||
Delay (in seconds) before taking screenshots (default: 0.5).
|
||||
- `use_prompt_caching` (`bool`): Default: `False`
|
||||
Enables prompt caching for repeated prompts (mainly for Anthropic models).
|
||||
- `max_trajectory_budget` (`float` | `dict`):
|
||||
If set (float or dict), adds a budget manager callback that tracks usage costs and stops execution if the budget is exceeded. Dict allows advanced options (e.g., `{ "max_budget": 5.0, "raise_error": True }`).
|
||||
- `**kwargs` (`any`):
|
||||
Any additional keyword arguments are passed through to the agent loop or model provider.
|
||||
|
||||
**Example with advanced options:**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user