AS AgentScopeAPI 手册 / API Reference

OpenAIContentPart

@JsonInclude(JsonInclude.Include.NON_NULL) public class OpenAIContentPart
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:46–250

用于多模态消息的OpenAI 内容片段 DTO。位于 io.agentscope.extensions.model.openai.dto 包。核心成员包括 getType、setType、getText、setText、getImageUrl、setImageUrl。

OpenAI content part DTO for multimodal messages.

Each content part has a type and corresponding data: - "text" type with text field - "image_url" type with image_url field - "video_url" type with video_url field - "input_audio" type with input_audio field

Example text part:

`{"type": "text", "text": "What's in this image?"}
`

Example image part:

`{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
`

Example video part:

`{"type": "video_url", "videoUrl": {"url": "https://example.com/video.mp4"}}
`

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
构建器,用于构建并配置目标实例。
A class in io.agentscope.extensions.model.openai.dto that talks to model services and returns generated or embedded output.

构造器摘要Constructor Summary

构造器Constructor说明Description
public OpenAIContentPart()
初始化 `OpenAIContentPart` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String getType()
获取类型。
Returns the type.
public void setType(String type)
设置类型。
Sets the type.
public String getText()
获取文本。
Returns the text.
public void setText(String text)
设置文本。
Sets the text.
public OpenAIImageUrl getImageUrl()
获取图像 URL。
Returns the image url.
public void setImageUrl(OpenAIImageUrl imageUrl)
设置图像 URL。
Sets the image url.
public OpenAIInputAudio getInputAudio()
获取输入音频。
Returns the input audio.
public void setInputAudio(OpenAIInputAudio inputAudio)
设置输入音频。
Sets the input audio.
public OpenAIVideoUrl getVideoUrl()
获取视频 URL。
Returns the video url.
public void setVideoUrl(OpenAIVideoUrl videoUrl)
设置视频 URL。
Sets the video url.
public Map<String, String> getCacheControl()
获取 `getCacheControl`。
Get the cache control configuration.
public void setCacheControl(Map<String, String> cacheControl)
设置 `setCacheControl`。
Set the cache control configuration.
public static OpenAIContentPart text(String text)
static
创建文本内容片段。
Create a text content part.
public static OpenAIContentPart imageUrl(String url)
static
创建图像内容片段。
Create an image content part.
public static OpenAIContentPart imageUrl(String url, String detail)
static
创建图像内容片段使用详情级别。
Create an image content part with detail level.
public static OpenAIContentPart inputAudio(String data, String format)
static
创建音频内容片段。
Create an audio content part.
public static OpenAIContentPart videoUrl(String url)
static
创建视频内容片段。
Create a video content part.
public static Builder builder()
static
返回构建器实例。
Returns the builder.

构造器详情Constructor Detail

OpenAIContentPart

public OpenAIContentPart()

初始化 OpenAIContentPart 实例。

Creates a new instance.

源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:74

方法详情Method Detail

getType

public String getType()

获取类型。

Returns the type.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:76–78

setType

public void setType(String type)

设置类型。

Sets the type.

参数Parameters
名称Name类型Type说明Description
typeString类型(类型 `String`)。The type.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:80–82

getText

public String getText()

获取文本。

Returns the text.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:84–86

setText

public void setText(String text)

设置文本。

Sets the text.

参数Parameters
名称Name类型Type说明Description
textString文本(类型 `String`)。The text.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:88–90

getImageUrl

public OpenAIImageUrl getImageUrl()

获取图像 URL。

Returns the image url.

返回Returns OpenAIImageUrl
返回OpenAIImageUrl。Returns OpenAI image url.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:92–94

setImageUrl

public void setImageUrl(OpenAIImageUrl imageUrl)

设置图像 URL。

Sets the image url.

参数Parameters
名称Name类型Type说明Description
imageUrlOpenAIImageUrl图像 URL(类型 `OpenAIImageUrl`)。The image url.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:96–98

getInputAudio

public OpenAIInputAudio getInputAudio()

获取输入音频。

Returns the input audio.

返回Returns OpenAIInputAudio
返回OpenAIInputAudio。Returns OpenAI input audio.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:100–102

setInputAudio

public void setInputAudio(OpenAIInputAudio inputAudio)

设置输入音频。

Sets the input audio.

参数Parameters
名称Name类型Type说明Description
inputAudioOpenAIInputAudio输入音频(类型 `OpenAIInputAudio`)。The input audio.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:104–106

getVideoUrl

public OpenAIVideoUrl getVideoUrl()

获取视频 URL。

Returns the video url.

返回Returns OpenAIVideoUrl
返回OpenAIVideoUrl。Returns OpenAI video url.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:108–110

setVideoUrl

public void setVideoUrl(OpenAIVideoUrl videoUrl)

设置视频 URL。

Sets the video url.

参数Parameters
名称Name类型Type说明Description
videoUrlOpenAIVideoUrl视频 URL(类型 `OpenAIVideoUrl`)。The video url.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:112–114

getCacheControl

public Map<String, String> getCacheControl()

获取 getCacheControl。

Get the cache control configuration.

返回Returns Map<String, String>
返回映射。the cache control configuration, or null when not configured
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:121–123

setCacheControl

public void setCacheControl(Map<String, String> cacheControl)

设置 setCacheControl。

Set the cache control configuration.

参数Parameters
名称Name类型Type说明Description
cacheControlMap<String, String>缓存 Control(类型 `Map`)。the cache control configuration
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:130–132

text

public static OpenAIContentPart text(String text)
static

创建文本内容片段。

Create a text content part.

参数Parameters
名称Name类型Type说明Description
textString文本内容。the text content
返回Returns OpenAIContentPart
一种新的OpenAIContentPart。a new OpenAIContentPart
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:140–145

imageUrl

public static OpenAIContentPart imageUrl(String url)
static

创建图像内容片段。

Create an image content part.

参数Parameters
名称Name类型Type说明Description
urlString图像 URL 或 base64 数据 URI。the image URL or base64 data URI
返回Returns OpenAIContentPart
一种新的OpenAIContentPart。a new OpenAIContentPart
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:153–158

imageUrl

public static OpenAIContentPart imageUrl(String url, String detail)
static

创建图像内容片段使用详情级别。

Create an image content part with detail level.

参数Parameters
名称Name类型Type说明Description
urlString图像 URL 或 base64 数据 URI。the image URL or base64 data URI
detailString详情(类型 `String`)。the detail level ("low", "high", or "auto")
返回Returns OpenAIContentPart
一种新的OpenAIContentPart。a new OpenAIContentPart
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:167–172

inputAudio

public static OpenAIContentPart inputAudio(String data, String format)
static

创建音频内容片段。

Create an audio content part.

参数Parameters
名称Name类型Type说明Description
dataStringBase64 编码的音频数据。the base64-encoded audio data
formatString格式(类型 `String`)。the audio format (e.g., "wav", "mp3")
返回Returns OpenAIContentPart
一种新的OpenAIContentPart。a new OpenAIContentPart
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:181–186

videoUrl

public static OpenAIContentPart videoUrl(String url)
static

创建视频内容片段。

Create a video content part.

参数Parameters
名称Name类型Type说明Description
urlString视频 URL 或 base64 数据 URI。the video URL or base64 data URI
返回Returns OpenAIContentPart
一种新的OpenAIContentPart。a new OpenAIContentPart
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:194–199

builder

public static Builder builder()
static

返回构建器实例。

Returns the builder.

返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/extensions/model/openai/dto/OpenAIContentPart.java:201–203

嵌套类详情Nested Class Detail

Builder

public static class Builder

构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.model.openai.dto 包。核心成员包括 type、text、imageUrl、inputAudio、videoUrl、cacheControl。

A class in io.agentscope.extensions.model.openai.dto that talks to model services and returns generated or embedded output. Declared in io.agentscope.extensions.model.openai.dto.

基于官方固定版本源码静态生成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.