renamed ComputerHandler to AsyncComputerHandler

This commit is contained in:
Dillon DuPont
2025-08-08 11:09:44 -04:00
parent feec92a1d6
commit f78d026060
5 changed files with 10 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ from .callbacks import (
TelemetryCallback,
)
from .computers import (
ComputerHandler,
AsyncComputerHandler,
is_agent_computer,
make_computer_handler
)
@@ -398,7 +398,7 @@ class ComputerAgent:
# AGENT OUTPUT PROCESSING
# ============================================================================
async def _handle_item(self, item: Any, computer: Optional[ComputerHandler] = None, ignore_call_ids: Optional[List[str]] = None) -> List[Dict[str, Any]]:
async def _handle_item(self, item: Any, computer: Optional[AsyncComputerHandler] = None, ignore_call_ids: Optional[List[str]] = None) -> List[Dict[str, Any]]:
"""Handle each item; may cause a computer action + screenshot."""
if ignore_call_ids and item.get("call_id") and item.get("call_id") in ignore_call_ids:
return []

View File

@@ -6,14 +6,14 @@ computer interface types, supporting both the ComputerHandler protocol and the
Computer library interface.
"""
from .base import ComputerHandler
from .base import AsyncComputerHandler
from .cua import cuaComputerHandler
from .custom import CustomComputerHandler
from computer import Computer as cuaComputer
def is_agent_computer(computer):
"""Check if the given computer is a ComputerHandler or CUA Computer."""
return isinstance(computer, ComputerHandler) or \
return isinstance(computer, AsyncComputerHandler) or \
isinstance(computer, cuaComputer) or \
(isinstance(computer, dict)) #and "screenshot" in computer)
@@ -30,7 +30,7 @@ async def make_computer_handler(computer):
Raises:
ValueError: If the computer type is not supported
"""
if isinstance(computer, ComputerHandler):
if isinstance(computer, AsyncComputerHandler):
return computer
if isinstance(computer, cuaComputer):
computer_handler = cuaComputerHandler(computer)

View File

@@ -6,7 +6,7 @@ from typing import Protocol, Literal, List, Dict, Any, Union, Optional, runtime_
@runtime_checkable
class ComputerHandler(Protocol):
class AsyncComputerHandler(Protocol):
"""Protocol defining the interface for computer interactions."""
# ==== Computer-Use-Preview Action Space ====

View File

@@ -4,10 +4,10 @@ Computer handler implementation for OpenAI computer-use-preview protocol.
import base64
from typing import Dict, List, Any, Literal, Union, Optional
from .base import ComputerHandler
from .base import AsyncComputerHandler
from computer import Computer
class cuaComputerHandler(ComputerHandler):
class cuaComputerHandler(AsyncComputerHandler):
"""Computer handler that implements the Computer protocol using the computer interface."""
def __init__(self, cua_computer: Computer):

View File

@@ -6,10 +6,10 @@ import base64
from typing import Dict, List, Any, Literal, Union, Optional, Callable
from PIL import Image
import io
from .base import ComputerHandler
from .base import AsyncComputerHandler
class CustomComputerHandler(ComputerHandler):
class CustomComputerHandler(AsyncComputerHandler):
"""Computer handler that implements the Computer protocol using a dictionary of custom functions."""
def __init__(self, functions: Dict[str, Callable]):