AS AgentScopeAPI 手册 / API Reference

OpenAIToolConverter

public class OpenAIToolConverter
源码Source io/agentscope/core/chat/completions/converter/OpenAIToolConverter.java:34–129

OpenAI 工具转换器,让智能体以受控方式调用外部能力。位于 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
toolsList<OpenAITool>工具列表(类型 `List`)。The list of OpenAI tools to convert (may be null or empty)
返回Returns 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–113

convertToToolSchema

public ToolSchema convertToToolSchema(OpenAITool tool)

转换到工具模式。

Converts a single OpenAI tool to a ToolSchema.

参数Parameters
名称Name类型Type说明Description
toolOpenAIToolOpenAI 工具到转换。The OpenAI tool to convert
返回Returns ToolSchema
返回ToolSchema。The converted ToolSchema, or null if conversion fails
源码Source io/agentscope/core/chat/completions/converter/OpenAIToolConverter.java:121–128
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.