@@ -546,34 +546,6 @@ def close(self):
546546 return self .env .close ()
547547
548548
549- def format_chat_completion_tools_to_response_api (tools : list [dict ]) -> list [dict ]:
550- """Convert tools from OpenAI Chat Completion format to Responses API format.
551-
552- Args:
553- tools: List of tools in Chat Completion format with nested function object
554-
555- Returns:
556- List of tools in Responses API format with flattened structure
557- """
558- formatted_tools = []
559- for tool in tools :
560- function_def = tool ["function" ]
561- formatted_tool = {
562- "type" : "function" ,
563- "name" : function_def ["name" ],
564- "description" : function_def ["description" ],
565- "parameters" : function_def ["parameters" ],
566- }
567-
568- # Handle the strict field if present
569- if "strict" in function_def :
570- formatted_tool ["strict" ] = function_def ["strict" ]
571-
572- formatted_tools .append (formatted_tool )
573-
574- return formatted_tools
575-
576-
577549@dataclass
578550class OSWorldActionSet (AbstractActionSet , DataClassJsonMixin ):
579551 # TODO: Define and use agentlab AbstractActionSet
@@ -620,12 +592,12 @@ def to_tool_description(self, api="openai"):
620592 "Only 'computer_13' action space is currently supported for tool description."
621593 )
622594 if api == "anthropic" :
623- return format_response_api_tools_to_anthropic (tools )
595+ return format_chat_completion_tools_to_anthropic (tools )
624596 else :
625597 return tools
626598
627599
628- def format_response_api_tools_to_anthropic (tools : list [dict ]) -> list [dict ]:
600+ def format_chat_completion_tools_to_anthropic (tools : list [dict ]) -> list [dict ]:
629601 """Convert OpenAI Response API tool format to Anthropic tool format."""
630602 formatted_tools = []
631603 for tool in tools :
@@ -640,6 +612,34 @@ def format_response_api_tools_to_anthropic(tools: list[dict]) -> list[dict]:
640612 return formatted_tools
641613
642614
615+ def format_chat_completion_tools_to_response_api (tools : list [dict ]) -> list [dict ]:
616+ """Convert tools from OpenAI Chat Completion format to Responses API format.
617+
618+ Args:
619+ tools: List of tools in Chat Completion format with nested function object
620+
621+ Returns:
622+ List of tools in Responses API format with flattened structure
623+ """
624+ formatted_tools = []
625+ for tool in tools :
626+ function_def = tool ["function" ]
627+ formatted_tool = {
628+ "type" : "function" ,
629+ "name" : function_def ["name" ],
630+ "description" : function_def ["description" ],
631+ "parameters" : function_def ["parameters" ],
632+ }
633+
634+ # Handle the strict field if present
635+ if "strict" in function_def :
636+ formatted_tool ["strict" ] = function_def ["strict" ]
637+
638+ formatted_tools .append (formatted_tool )
639+
640+ return formatted_tools
641+
642+
643643# @dataclass
644644# class OSWorldActionSetArgs(DataClassJsonMixin):
645645# action_space: Literal["computer_13", "pyautogui"] = "computer_13"
0 commit comments