Knowledge & RAG
Document intelligence and RAG with AgenticX.
Knowledge & RAG
Near's knowledge panel manages brains: a document brain for knowledge_search, a code brain for code_search. Each brain has its own config, files, and index. Avatars mount zero or more brains.
The Python KnowledgeBase helper below is the library API (agenticx/memory/knowledge_base.py). Studio ingest goes through agenticx/studio/kb/ and LiteParseAdapter. Do not treat them as one object.
Default vector store for Desktop is Chroma. Switching embedding config usually requires a rebuild. Ingest must show a real percent or phase, and failures must include filename, type, and a traceback summary.
Document Ingestion
1from agenticx.knowledge import KnowledgeBase23kb = KnowledgeBase(name="my-docs")45# Add documents6kb.add_file("report.pdf")7kb.add_url("https://example.com/article")8kb.add_text("AgenticX is a multi-agent framework...", source="manual")910# Process (chunk, embed, index)11kb.build()
Retrieval
1# Vector retrieval2results = kb.search("What are the key features?", top_k=5)34# Hybrid retrieval (vector + BM25)5results = kb.search("key features", mode="hybrid", top_k=10)67# With reranking8results = kb.search("key features", mode="hybrid", rerank=True, top_k=5)
GraphRAG
For complex documents with rich relationships, use GraphRAG:
1from agenticx.knowledge import GraphKnowledgeBase23gkb = GraphKnowledgeBase(4 name="research-papers",5 graph_backend="neo4j", # or "nebula"6 neo4j_uri="bolt://localhost:7687"7)89gkb.add_file("research_paper.pdf")10gkb.build() # Extracts entities and relationships1112# Graph-aware retrieval13results = gkb.search("relationship between agent memory and performance")
Giving a Knowledge Base to an Agent
In Near, mount a document brain and let the model call knowledge_search. There is no KnowledgeBaseTool on the Studio path.
1from agenticx import Agent, Task, AgentExecutor2from agenticx.llms import OpenAIProvider34executor = AgentExecutor(llm_provider=OpenAIProvider(model="gpt-4o"))5result = executor.run(agent=agent, task=task)
Supported Document Formats
| Format | Studio path | Library notes |
|---|---|---|
| PDF / DOCX / PPTX / images | LiteParseAdapter (npm i -g @llamaindex/liteparse) | Do not feed PDF bytes as raw text |
.xlsx / .xls | Needs local LibreOffice | Hidden from the UI list if missing |
| Markdown / plain text | LiteParse or native | — |
Embeddings
1from agenticx.embeddings import OpenAIEmbeddings23embeddings = OpenAIEmbeddings(model="text-embedding-3-small")4kb = KnowledgeBase(name="my-docs", embeddings=embeddings)
Supported embedding providers: OpenAI, Bailian, SiliconFlow, LiteLLM.
Vector Stores
| Store | Notes |
|---|---|
| Faiss | Local, fast, no server required |
| Chroma | Local or server mode |
| Qdrant | Production-grade, cloud available |
| Milvus | High-scale enterprise |
| PgVector | PostgreSQL extension |
| Pinecone | Managed cloud |
| Weaviate | Managed cloud with GraphQL |
Desktop knowledge base defaults to Chroma. Extra vector adapters exist in the tree; they are not all wired into the Studio main path.
Multi-brain knowledge
Current tree can isolate and mount a document brain plus a code brain, then optionally search across mounted brains.
- Document brain: ingest, chunk, embed, retrieve
- Code brain: hybrid semantic index over one or more codebases
- Cross-brain search is optional, not a forced merge of every index
See Skills and Long-horizon coding for neighboring v0.5 capabilities.