Builder
public static class Builder
源码Source
io/agentscope/core/rag/model/DocumentMetadata.java:233–319构建器,用于构建并配置目标实例。位于 io.agentscope.core.rag.model 包。核心成员包括 content、docId、chunkId、payload、addPayload、build。
Builder for constructing DocumentMetadata instances with fluent API.
This builder provides a convenient way to create DocumentMetadata objects,
especially when working with custom payload fields. All fields can be set
independently, and the builder validates required fields when #build()
is called.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Builder content(ContentBlock content) | 设置内容块。 Sets the content block. |
public Builder docId(String docId) | 设置文档标识。 Sets the document ID. |
public Builder chunkId(String chunkId) | 设置分块标识。 Sets the chunk ID. |
public Builder payload(Map<String, Object> payload) | 设置负载。 Sets the entire payload map. |
public Builder addPayload(String key, Object value) | 添加负载。 Adds a single payload field. |
public DocumentMetadata build() | 构建并返回最终实例。 Builds a new DocumentMetadata instance with the configured values. |
方法详情Method Detail
content
public Builder content(ContentBlock content)
设置内容块。
Sets the content block.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
content | ContentBlock | 内容(类型 `ContentBlock`)。the content block (text, image, video, etc.) |
Builder返回当前实例,以支持链式调用。this builder for method chaining
源码Source
io/agentscope/core/rag/model/DocumentMetadata.java:247–250docId
public Builder docId(String docId)
设置文档标识。
Sets the document ID.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
docId | String | 文档标识。the document ID |
Builder返回当前实例,以支持链式调用。this builder for method chaining
源码Source
io/agentscope/core/rag/model/DocumentMetadata.java:258–261chunkId
public Builder chunkId(String chunkId)
设置分块标识。
Sets the chunk ID.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
chunkId | String | 分块标识(类型 `String`)。the chunk ID within the document |
Builder返回当前实例,以支持链式调用。this builder for method chaining
源码Source
io/agentscope/core/rag/model/DocumentMetadata.java:269–272payload
public Builder payload(Map<String, Object> payload)
设置负载。
Sets the entire payload map.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
payload | Map<String, Object> | 负载(类型 `Map`)。the custom metadata fields (can be null) |
Builder返回当前实例,以支持链式调用。this builder for method chaining
源码Source
io/agentscope/core/rag/model/DocumentMetadata.java:283–286addPayload
public Builder addPayload(String key, Object value)
添加负载。
Adds a single payload field.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 负载密钥。the payload key |
value | Object | 负载值。the payload value |
Builder返回当前实例,以支持链式调用。this builder for method chaining
NullPointerException可能抛出 `NullPointerException`。if key is null
源码Source
io/agentscope/core/rag/model/DocumentMetadata.java:299–308build
public DocumentMetadata build()
构建并返回最终实例。
Builds a new DocumentMetadata instance with the configured values.
DocumentMetadata一种新的DocumentMetadata 实例。a new DocumentMetadata instance
IllegalArgumentException可能抛出 `IllegalArgumentException`。if required fields (content, docId, chunkId) are null
源码Source
io/agentscope/core/rag/model/DocumentMetadata.java:316–318