3030logger = logging .getLogger (__name__ )
3131
3232# TODO: Extract X_Max and Y_MAX from screen size
33- COMPUTER_13_ACTIONS_OAI_RESPONSE_TOOLS = [
33+ COMPUTER_13_ACTIONS_OAI_CHATCOMPLETION_TOOLS = [
3434 {
3535 "type" : "function" ,
3636 "function" : {
@@ -547,6 +547,33 @@ def close(self):
547547 return self .env .close ()
548548
549549
550+ def format_chat_completion_tools_to_response_api (tools : list [dict ]) -> list [dict ]:
551+ """Convert tools from OpenAI Chat Completion format to Responses API format.
552+
553+ Args:
554+ tools: List of tools in Chat Completion format with nested function object
555+
556+ Returns:
557+ List of tools in Responses API format with flattened structure
558+ """
559+ formatted_tools = []
560+ for tool in tools :
561+ function_def = tool ["function" ]
562+ formatted_tool = {
563+ "type" : "function" ,
564+ "name" : function_def ["name" ],
565+ "description" : function_def ["description" ],
566+ "parameters" : function_def ["parameters" ],
567+ }
568+
569+ # Handle the strict field if present
570+ if "strict" in function_def :
571+ formatted_tool ["strict" ] = function_def ["strict" ]
572+
573+ formatted_tools .append (formatted_tool )
574+
575+ return formatted_tools
576+
550577@dataclass
551578class OSWorldActionSet (AbstractActionSet , DataClassJsonMixin ):
552579 # TODO: Define and use agentlab AbstractActionSet
@@ -570,10 +597,12 @@ def to_python_code(self, action) -> str:
570597 pass
571598
572599 def to_tool_description (self , api = "openai" ):
573- """Convert the action set to a tool description for Tool-Use LLMs."""
600+ """Convert the action set to a tool description for Tool-Use LLMs.
601+ The default for openai is openai Response API tools format.
602+ """
574603 # TODO: Rename bgym AbstractActionSet to_tool_descriptor method as to_tool_description for consistency.
575604 if self .action_space == "computer_13" :
576- tools = COMPUTER_13_ACTIONS_OAI_RESPONSE_TOOLS
605+ tools = format_chat_completion_tools_to_response_api ( COMPUTER_13_ACTIONS_OAI_CHATCOMPLETION_TOOLS )
577606 else :
578607 raise ValueError (
579608 "Only 'computer_13' action space is currently supported for tool description."
@@ -613,8 +642,8 @@ class OsworldEnvArgs(AbstractEnvArgs):
613642 task : dict [str , Any ]
614643 task_seed : int = 0
615644 task_name : str | None = None
616- path_to_vm : str | None = "OSWorld/vmware_vm_data/Ubuntu0/Ubuntu0.vmx" # path to .vmx file
617- provider_name : str = "vmware " # path to .vmx file
645+ path_to_vm : str | None = None # path to .vmx file
646+ provider_name : str = "docker " # path to .vmx file
618647 region : str = "us-east-1" # AWS specific, does not apply to all providers
619648 snapshot_name : str = "init_state" # snapshot name to revert to
620649 action_space : Literal ["computer_13" , "pyautogui" ] = "computer_13"
0 commit comments