URLSource
@JsonInclude(JsonInclude.Include.NON_NULL) public class URLSource extends Source
io/agentscope/core/message/URLSource.java:44–147URL 来源,在智能体、模型与前端之间传递结构化消息和事件。位于 io.agentscope.core.message 包,继承自 Source。核心成员包括 getUrl、getMimeType、builder、URLSource。
Represents URL-based media content.
This source references media files accessible via URLs, supporting both remote HTTP/HTTPS URLs and local file URLs. This approach is preferred when media files are hosted externally or when file size makes Base64 encoding impractical.
Supported URL formats:
-
Remote URLs: https://example.com/image.jpg
-
Local files: file:///absolute/path/to/file.jpg
Using URL sources is more efficient for large media files and allows the system to stream content rather than loading everything into memory.
When the URL has no file extension (e.g. CDN signed URLs), set mimeType
explicitly so converters can route the content to the correct media slot without
relying on extension-based inference.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 Builder for constructing URLSource instances. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public URLSource(String url, String mimeType) | 初始化 `URLSource` 实例。 Creates a new URL source for JSON deserialization. |
public URLSource(String url) | 初始化 `URLSource` 实例。 Creates a new URL source without a MIME type hint. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getUrl() | 获取URL。 Gets the URL that points to the media content. |
public String getMimeType() | 获取MIME 类型。 Gets the optional MIME type hint for this URL source. |
public static Builder builder()static | 返回构建器实例。 Creates a new builder for constructing URLSource instances. |
构造器详情Constructor Detail
URLSource
public URLSource(String url, String mimeType)
初始化 URLSource 实例。
Creates a new URL source for JSON deserialization.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
url | String | 服务地址(类型 `String`)。The URL pointing to the media content |
mimeType | String | MIME 类型(类型 `String`)。Optional MIME type hint (e.g. "image/jpeg"); may be null |
NullPointerException可能抛出 `NullPointerException`。if url is null
io/agentscope/core/message/URLSource.java:59–63URLSource
public URLSource(String url)
初始化 URLSource 实例。
Creates a new URL source without a MIME type hint.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
url | String | 服务地址(类型 `String`)。The URL pointing to the media content |
NullPointerException可能抛出 `NullPointerException`。if url is null
io/agentscope/core/message/URLSource.java:71–73方法详情Method Detail
getUrl
public String getUrl()
获取URL。
Gets the URL that points to the media content.
Stringio/agentscope/core/message/URLSource.java:80–82getMimeType
public String getMimeType()
获取MIME 类型。
Gets the optional MIME type hint for this URL source.
Stringio/agentscope/core/message/URLSource.java:93–95builder
public static Builder builder()
返回构建器实例。
Creates a new builder for constructing URLSource instances.
Builderio/agentscope/core/message/URLSource.java:102–104嵌套类详情Nested Class Detail
Builder
public static class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.core.message 包。核心成员包括 url、mimeType、build。
Builder for constructing URLSource instances.