AS AgentScopeAPI 手册 / API Reference

HayStackKnowledge

public class HayStackKnowledge implements Knowledge
源码Source io/agentscope/core/rag/integration/haystack/HayStackKnowledge.java:71–238

Hay Stack 知识库,把私有文档转化为可检索的知识。位于 io.agentscope.core.rag.integration.haystack 包,实现 Knowledge。核心成员包括 builder、addDocuments、retrieve。

HayStack RAG Knowledge Base implementation.

This class provides integration with HayStack Knowledge Base service, implementing the Knowledge interface to enable seamless RAG (Retrieval-Augmented Generation) capabilities with HayStack-hosted knowledge bases.

Key features:

  • Built on HayStack RAG with end-to-end retrieval, ranking, and generation pipelines

  • Local or remote HayStack deployment support

  • Compatible with Bailian and Dify RAG plugins (same Knowledge interface)

Functional Scope: This plugin focuses on retrieval capabilities only, similar to Bailian and Dify RAG plugins. Document management (upload/delete/update) should be performed via HayStack RAG server.

Example usage:

`HayStackConfig config = HayStackConfig.builder()
.baseUrl("http://localhost:8080")
.topK(10)
.build();

HayStackKnowledge knowledge = HayStackKnowledge.builder()
.config(config)
.build();

// Retrieve documents
List<Document> docs = knowledge.retrieve("What is AI?", retrieveConfig).block();

// Use with Agent
ReActAgent agent = ReActAgent.builder()
.knowledge(knowledge)
.ragMode(RAGMode.AGENTIC)
.build();
`

Note: Document management is not supported via this plugin. Please use HayStack server to upload, delete, and manage documents. This design ensures compatibility with Bailian and Dify RAG plugins and keeps the plugin focused.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
构建器,用于构建并配置目标实例。
A class in io.agentscope.core.rag.integration.haystack that turns private documents into retrievable knowledge.

方法摘要Method Summary

方法Method说明Description
public static Builder builder()
static
返回构建器实例。
Returns the builder.
public Mono<Void> addDocuments(List<Document> documents)
添加文档。
Adds documents to the Haystack knowledge base.
public Mono<List<Document>> retrieve(String query, RetrieveConfig config)
按查询检索相关文档。
Retrieve documents from the HayStack knowledge base.

方法详情Method Detail

builder

public static Builder builder()
static

返回构建器实例。

Returns the builder.

返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/rag/integration/haystack/HayStackKnowledge.java:84–86

addDocuments

public Mono<Void> addDocuments(List<Document> documents)

添加文档。

Adds documents to the Haystack knowledge base.

参数Parameters
名称Name类型Type说明Description
documentsList<Document>文档到添加的列出。the list of documents to add
返回Returns Mono<Void>
返回Mono。a Mono that completes with an error indicating the operation is not supported
源码Source io/agentscope/core/rag/integration/haystack/HayStackKnowledge.java:108–116

retrieve

public Mono<List<Document>> retrieve(String query, RetrieveConfig config)

按查询检索相关文档。

Retrieve documents from the HayStack knowledge base.

参数Parameters
名称Name类型Type说明Description
queryString查询文本(必填)。the query text (required)
configRetrieveConfig检索配置(限制,分数)。the retrieval configuration (limit, score)
返回Returns Mono<List<Document>>
返回Mono>。a Mono emitting the list of retrieved documents, sorted by relevance
源码Source io/agentscope/core/rag/integration/haystack/HayStackKnowledge.java:144–214

嵌套类详情Nested Class Detail

Builder

public static class Builder

构建器,用于构建并配置目标实例。位于 io.agentscope.core.rag.integration.haystack 包。核心成员包括 config、client、build。

A class in io.agentscope.core.rag.integration.haystack that turns private documents into retrievable knowledge. Declared in io.agentscope.core.rag.integration.haystack.

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