Class OpenAIToolConverter

java.lang.Object
io.agentscope.core.chat.completions.converter.OpenAIToolConverter

public class OpenAIToolConverter extends Object
Converter for converting OpenAI tool format to AgentScope ToolSchema.

This converter handles the transformation from OpenAI's tool format (used in Chat Completions API requests) to AgentScope's internal ToolSchema format. Tools converted by this converter are intended to be registered as schema-only tools, which will trigger tool suspension when called.

  • Constructor Details

    • OpenAIToolConverter

      public OpenAIToolConverter()
  • Method Details

    • convertToToolSchemas

      public List<io.agentscope.core.model.ToolSchema> convertToToolSchemas(List<OpenAITool> tools)
      Converts a list of OpenAI tools to AgentScope ToolSchemas.

      Only tools with type "function" are converted. Other tool types are skipped with a warning.

      Parameters:
      tools - The list of OpenAI tools to convert (may be null or empty)
      Returns:
      A list of converted ToolSchema objects; returns an empty list if input is null or empty
    • convertToToolSchema

      public io.agentscope.core.model.ToolSchema convertToToolSchema(OpenAITool tool)
      Converts a single OpenAI tool to a ToolSchema.
      Parameters:
      tool - The OpenAI tool to convert
      Returns:
      The converted ToolSchema, or null if conversion fails