OpenAIToolConverter
public class OpenAIToolConverter
源码Source
io/agentscope/core/chat/completions/converter/OpenAIToolConverter.java:34–129OpenAI 工具转换器,让智能体以受控方式调用外部能力。位于 io.agentscope.core.chat.completions.converter 包。核心成员包括 convertToToolSchemas、convertToToolSchema。
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.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public List<ToolSchema> convertToToolSchemas(List<OpenAITool> tools) | 转换列出的OpenAI 工具到 AgentScope ToolSchemas。 Converts a list of OpenAI tools to AgentScope ToolSchemas. |
public ToolSchema convertToToolSchema(OpenAITool tool) | 转换到工具模式。 Converts a single OpenAI tool to a ToolSchema. |
方法详情Method Detail
convertToToolSchemas
public List<ToolSchema> convertToToolSchemas(List<OpenAITool> tools)
转换列出的OpenAI 工具到 AgentScope ToolSchemas。
Converts a list of OpenAI tools to AgentScope ToolSchemas.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
tools | List<OpenAITool> | 工具列表(类型 `List`)。The list of OpenAI tools to convert (may be null or empty) |
List<ToolSchema>返回列出。A list of converted ToolSchema objects; returns an empty list if input is null or empty
源码Source
io/agentscope/core/chat/completions/converter/OpenAIToolConverter.java:47–113convertToToolSchema
public ToolSchema convertToToolSchema(OpenAITool tool)
转换到工具模式。
Converts a single OpenAI tool to a ToolSchema.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
tool | OpenAITool | OpenAI 工具到转换。The OpenAI tool to convert |
ToolSchema返回ToolSchema。The converted ToolSchema, or null if conversion fails
源码Source
io/agentscope/core/chat/completions/converter/OpenAIToolConverter.java:121–128