Document
@Deprecated(forRemoval = true, since = "2.0.0") public class Document
io/agentscope/core/rag/model/Document.java:37–238文档,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.rag.model 包。核心成员包括 getId、getMetadata、getEmbedding、setEmbedding、getScore、setScore。
Document class representing a document chunk in the RAG system.
This is the core data structure for RAG operations. Each document contains metadata, an optional embedding vector, and an optional similarity score.
The document ID is automatically generated as a deterministic UUID based on the document metadata (doc_id, chunk_id, and content), ensuring consistent IDs for the same content across different runs.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public Document(DocumentMetadata metadata) | 创建新的文档实例。 Creates a new Document instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getId() | 获取文档标识。 Gets the document ID. |
public DocumentMetadata getMetadata() | 获取文档元数据。 Gets the document metadata. |
public double[] getEmbedding() | 获取向量化向量。 Gets the embedding vector. |
public void setEmbedding(double[] embedding) | 设置向量化向量。 Sets the embedding vector. |
public Double getScore() | 获取分数。 Gets the similarity score. |
public void setScore(Double score) | 设置分数。 Sets the similarity score. |
public Map<String, Object> getPayload() | 获取自定义负载来自文档元数据。 Gets the custom payload from document metadata. |
public Object getPayloadValue(String key) | 获取特定负载值通过密钥。 Gets a specific payload value by key. |
public T T getPayloadValueAs(String key, Class<T> targetClass) | 获取负载值 As。 Gets a specific payload value by key and converts it to the specified type. |
public boolean hasPayloadKey(String key) | 判断是否具有负载键。 Checks if the document payload contains a specific key. |
public String getVectorName() | 获取文档向量名称。 Gets the document vector name. |
public void setVectorName(String vectorName) | 设置文档向量名称。 Sets the document vector name. |
public String toString() | 返回 `toString` 结果。 Returns the to string. |
构造器详情Constructor Detail
Document
public Document(DocumentMetadata metadata)
创建新的文档实例。
Creates a new Document instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
metadata | DocumentMetadata | 文档元数据。the document metadata |
io/agentscope/core/rag/model/Document.java:54–60方法详情Method Detail
getId
public String getId()
获取文档标识。
Gets the document ID.
Stringio/agentscope/core/rag/model/Document.java:67–69getMetadata
public DocumentMetadata getMetadata()
获取文档元数据。
Gets the document metadata.
DocumentMetadataio/agentscope/core/rag/model/Document.java:76–78getEmbedding
public double[] getEmbedding()
获取向量化向量。
Gets the embedding vector.
double[]io/agentscope/core/rag/model/Document.java:85–87setEmbedding
public void setEmbedding(double[] embedding)
设置向量化向量。
Sets the embedding vector.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
embedding | double[] | 向量化向量。the embedding vector |
io/agentscope/core/rag/model/Document.java:94–96getScore
public Double getScore()
获取分数。
Gets the similarity score.
Doubleio/agentscope/core/rag/model/Document.java:103–105setScore
public void setScore(Double score)
设置分数。
Sets the similarity score.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
score | Double | 分数(类型 `Double`)。the similarity score |
io/agentscope/core/rag/model/Document.java:112–114getPayload
public Map<String, Object> getPayload()
获取自定义负载来自文档元数据。
Gets the custom payload from document metadata.
Map<String, Object>io/agentscope/core/rag/model/Document.java:125–127getPayloadValue
public Object getPayloadValue(String key)
获取特定负载值通过密钥。
Gets a specific payload value by key.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 负载密钥。the payload key |
ObjectNullPointerException可能抛出 `NullPointerException`。if key is null
io/agentscope/core/rag/model/Document.java:139–141getPayloadValueAs
public T T getPayloadValueAs(String key, Class<T> targetClass)
获取负载值 As。
Gets a specific payload value by key and converts it to the specified type.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 负载密钥。the payload key |
targetClass | Class<T> | 目标类到转换到。the target class to convert to |
TIllegalArgumentException可能抛出 `IllegalArgumentException`。if the value cannot be converted to the target typeNullPointerException可能抛出 `NullPointerException`。if key or clazz is null
io/agentscope/core/rag/model/Document.java:157–171hasPayloadKey
public boolean hasPayloadKey(String key)
判断是否具有负载键。
Checks if the document payload contains a specific key.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 负载密钥到检查。the payload key to check |
booleanNullPointerException可能抛出 `NullPointerException`。if key is null
io/agentscope/core/rag/model/Document.java:183–185getVectorName
public String getVectorName()
获取文档向量名称。
Gets the document vector name.
Stringio/agentscope/core/rag/model/Document.java:192–194setVectorName
public void setVectorName(String vectorName)
设置文档向量名称。
Sets the document vector name.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
vectorName | String | 文档名称。the document name |
io/agentscope/core/rag/model/Document.java:201–203toString
public String toString()
返回 toString 结果。
Returns the to string.
Stringio/agentscope/core/rag/model/Document.java:229–237