agentscope-extensions-rag-simple is the “DIY end-to-end” RAG implementation: it bundles document readers, chunking strategies, embedding adapters, and five out-of-the-box vector store adapters.
Use it when: you’re happy to run embeddings + vector store yourself and don’t want a third-party RAG platform.
Add the dependency
Quickstart
Built-in document readers
Theio.agentscope.core.rag.reader package contains readers for common formats; each produces List<Document>:
The resulting
Document objects already carry metadata; pair with TextChunker and SplitStrategy for chunking.
Built-in embedding providers
Implement
EmbeddingModel to add your own.
EmbeddingModel.embed(ContentBlock) returns Mono<EmbeddingResponse>; the response carries the
embedding vector and, when the provider reports it, EmbeddingUsage token counts.
Pass a usageListener to SimpleKnowledge.builder() to receive each non-null embedding usage
report. The listener runs on the embedding response thread and should be non-blocking and
thread-safe; providers that omit usage do not invoke it.
OpenAITextEmbedding lazily creates one SDK client and reuses it for all requests, including
concurrent calls and retries. Reuse the model for the lifetime of your RAG service. After all
embedding operations have completed, call close() (for example, from your application shutdown
hook), or use try-with-resources for a scoped model. SimpleKnowledge does not close a shared
embedding model for you. Closing an unused model does not create a client; a closed model cannot
be used again. Subscribing to a closed model fails immediately without retrying, including when
the Mono was created before the model was closed.
Built-in vector stores
Switching stores is a one-line change: pass a different
VDBStoreBase to SimpleKnowledge.builder().embeddingStore(...).
Retrieval parameters
RetrieveConfig controls retrieval: