AS AgentScopeAPI 手册 / API Reference

URLSource

@JsonInclude(JsonInclude.Include.NON_NULL) public class URLSource extends Source
源码Source io/agentscope/core/message/URLSource.java:44–147

URL 来源,在智能体、模型与前端之间传递结构化消息和事件。位于 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.

参数Parameters
名称Name类型Type说明Description
urlString服务地址(类型 `String`)。The URL pointing to the media content
mimeTypeStringMIME 类型(类型 `String`)。Optional MIME type hint (e.g. "image/jpeg"); may be null
抛出Throws
  • NullPointerException 可能抛出 `NullPointerException`。if url is null
源码Source io/agentscope/core/message/URLSource.java:59–63

URLSource

public URLSource(String url)

初始化 URLSource 实例。

Creates a new URL source without a MIME type hint.

参数Parameters
名称Name类型Type说明Description
urlString服务地址(类型 `String`)。The URL pointing to the media content
抛出Throws
  • NullPointerException 可能抛出 `NullPointerException`。if url is null
源码Source io/agentscope/core/message/URLSource.java:71–73

方法详情Method Detail

getUrl

public String getUrl()

获取URL。

Gets the URL that points to the media content.

返回Returns String
返回字符串结果。The URL as a string
源码Source io/agentscope/core/message/URLSource.java:80–82

getMimeType

public String getMimeType()

获取MIME 类型。

Gets the optional MIME type hint for this URL source.

返回Returns String
返回字符串结果。The MIME type (e.g. "image/jpeg"), or null if not set
源码Source io/agentscope/core/message/URLSource.java:93–95

builder

public static Builder builder()
static

返回构建器实例。

Creates a new builder for constructing URLSource instances.

返回Returns Builder
一种新的构建器实例。A new builder instance
源码Source io/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.

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