AS AgentScopeAPI 手册 / API Reference

DifyDocumentConverter

public class DifyDocumentConverter
源码Source io/agentscope/core/rag/integration/dify/DifyDocumentConverter.java:60–297

Dify 文档转换器,把私有文档转化为可检索的知识。位于 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
responseDifyResponse响应(类型 `DifyResponse`)。the Dify API response
返回Returns List<Document>
返回列出。a list of Document objects (never null)
源码Source io/agentscope/core/rag/integration/dify/DifyDocumentConverter.java:78–104

fromDifyRecord

public static Document fromDifyRecord(DifyResponse.Record record)
static

设置该参数。

Converts a single Dify record to a Document.

参数Parameters
名称Name类型Type说明Description
recordDifyResponse.Record记录(类型 `DifyResponse.Record`)。the Dify record from API response
返回Returns Document
返回文档。a Document object, or null if conversion fails
源码Source io/agentscope/core/rag/integration/dify/DifyDocumentConverter.java:116–183
基于官方固定版本源码静态生成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.