AS AgentScopeAPI 手册 / API Reference

OpenAIConverterUtils

public final class OpenAIConverterUtils
源码Source io/agentscope/extensions/model/openai/formatter/OpenAIConverterUtils.java:25–115

OpenAI 转换器 Utils,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.openai.formatter 包。核心成员包括 convertImageSourceToUrl、detectAudioFormat、convertVideoSourceToUrl。

Utility class for OpenAI message and conversation conversion.

方法摘要Method Summary

方法Method说明Description
public static String convertImageSourceToUrl(Source source)
static
转换图像来源到 URL。
Convert an image source to a URL string.
public static String detectAudioFormat(String mediaType)
static
设置该参数。
Detect audio format from media type.
public static String convertVideoSourceToUrl(Source source)
static
转换视频来源到 URL。
Convert a video source to a URL string.

方法详情Method Detail

convertImageSourceToUrl

public static String convertImageSourceToUrl(Source source)
static

转换图像来源到 URL。

Convert an image source to a URL string.

参数Parameters
名称Name类型Type说明Description
sourceSource图像来源(URLSource 或 Base64Source)。The image source (URLSource or Base64Source)
返回Returns String
返回字符串结果。The URL string or data URI
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if source is null or of unknown type
源码Source io/agentscope/extensions/model/openai/formatter/OpenAIConverterUtils.java:38–60

detectAudioFormat

public static String detectAudioFormat(String mediaType)
static

设置该参数。

Detect audio format from media type.

参数Parameters
名称Name类型Type说明Description
mediaTypeStringmedia 类型(类型 `String`)。The media type (e.g., "audio/wav")
返回Returns String
返回字符串结果。The format string (e.g., "wav")
源码Source io/agentscope/extensions/model/openai/formatter/OpenAIConverterUtils.java:68–83

convertVideoSourceToUrl

public static String convertVideoSourceToUrl(Source source)
static

转换视频来源到 URL。

Convert a video source to a URL string.

参数Parameters
名称Name类型Type说明Description
sourceSource视频来源(URLSource 或 Base64Source)。The video source (URLSource or Base64Source)
返回Returns String
返回字符串结果。The URL string or data URI
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if source is null or of unknown type
源码Source io/agentscope/extensions/model/openai/formatter/OpenAIConverterUtils.java:92–114
基于官方固定版本源码静态生成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.