> ## Documentation Index
> Fetch the complete documentation index at: https://java.agentscope.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

`io.agentscope.core.rag.Knowledge` is AgentScope's interface for plugging in an external knowledge base. The Agent uses it during inference to retrieve documents that are then handed to the model. The `agentscope-extensions-*` repository ships several implementations:

| Extension                                   | Type                                    | Best for                                                                             |
| ------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------ |
| [Simple](/v2/en/integration/rag/simple)     | Self-managed: embeddings + vector store | Bring-your-own vector store (PgVector / Milvus / Qdrant / Elasticsearch / in-memory) |
| [Bailian](/v2/en/integration/rag/bailian)   | Alibaba Cloud Bailian Knowledge Base    | Use a Bailian-hosted enterprise KB                                                   |
| [Dify](/v2/en/integration/rag/dify)         | Dify dataset                            | Already maintaining KB content in Dify                                               |
| [HayStack](/v2/en/integration/rag/haystack) | Self-hosted HayStack RAG                | Existing HayStack pipelines                                                          |
| [RAGFlow](/v2/en/integration/rag/ragflow)   | RAGFlow service                         | Complex documents needing OCR / knowledge graphs                                     |

## Same wiring everywhere

```java theme={null}
ReActAgent agent = ReActAgent.builder()
    .name("Assistant")
    .model(model)
    .knowledge(knowledge)        // any Knowledge implementation
    .ragMode(RAGMode.AGENTIC)    // or STATIC, NONE
    .build();
```

You can also expose retrieval as a tool that the Agent calls explicitly:

```java theme={null}
KnowledgeRetrievalTools tools = new KnowledgeRetrievalTools(knowledge);
Toolkit toolkit = new Toolkit();
toolkit.registerObject(tools);
```

## Choosing one

| Need                                            | Recommendation |
| ----------------------------------------------- | -------------- |
| Full control over embeddings + store            | **Simple**     |
| Alibaba Cloud ecosystem, enterprise hosting     | **Bailian**    |
| Team already curates content in Dify            | **Dify**       |
| Complex ETL (PDF tables, OCR, knowledge graphs) | **RAGFlow**    |
| Existing HayStack RAG pipeline                  | **HayStack**   |

> Aside from Simple, the platform-backed implementations are **retrieval only**: document ingestion / updates happen via the platform console or its native API. This keeps `Knowledge` implementations swappable on the Agent side.
