DifyDocumentConverter
public class DifyDocumentConverter
源码Source
io/agentscope/core/rag/integration/dify/DifyDocumentConverter.java:60–297Dify 文档转换器,把私有文档转化为可检索的知识。位于 io.agentscope.core.rag.integration.dify 包。核心成员包括 fromDifyResponse、fromDifyRecord。
Converter for transforming Dify API responses to AgentScope Document objects.
This class handles the conversion between Dify's retrieve response format and AgentScope's internal Document representation, ensuring seamless integration with the RAG system.
Dify API response format:
`{
"query": { "content": "..." },
"records": [
{
"segment": {
"id": "...",
"document_id": "...",
"content": "...",
"document": { "id": "...", "name": "..." }
},
"score": 0.95
}
]
}
`
Example usage:
`DifyResponse response = difyClient.retrieve(...).block();
List<Document> documents = DifyDocumentConverter.fromDifyResponse(response);
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static List<Document> fromDifyResponse(DifyResponse response)static | 设置该参数。 Converts Dify API response to a list of Documents. |
public static Document fromDifyRecord(DifyResponse.Record record)static | 设置该参数。 Converts a single Dify record to a Document. |
方法详情Method Detail
fromDifyResponse
public static List<Document> fromDifyResponse(DifyResponse response)
static
设置该参数。
Converts Dify API response to a list of Documents.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
response | DifyResponse | 响应(类型 `DifyResponse`)。the Dify API response |
List<Document>返回列出。a list of Document objects (never null)
源码Source
io/agentscope/core/rag/integration/dify/DifyDocumentConverter.java:78–104fromDifyRecord
public static Document fromDifyRecord(DifyResponse.Record record)
static
设置该参数。
Converts a single Dify record to a Document.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
record | DifyResponse.Record | 记录(类型 `DifyResponse.Record`)。the Dify record from API response |
Document返回文档。a Document object, or null if conversion fails
源码Source
io/agentscope/core/rag/integration/dify/DifyDocumentConverter.java:116–183