RAG — chat with your documents
Load documents and the agent answers grounded in them. Load → chunk → embed → store → retrieve → inject, all built in.
from neuroagent import Agent
agent = Agent(provider="openai", rag=True)
agent.load_document("handbook.pdf") # PDF/DOCX/TXT/CSV/MD/HTML/JSON (PDF/DOCX need [rag])
agent.load_text("Our refund window is 30 days.")
print(agent.ask("Summarize chapter 5 of the handbook.").content)
print(agent.ask("What is our refund window?").content)
# Better diversity in retrieved context with MMR re-ranking:
agent = Agent(provider="openai", rag=True, rag_k=6, rag_rerank=True)
Custom embedder or vector store
Build a KnowledgeBase and pass it in — the chat model and embedder can differ:
from neuroagent import Agent, KnowledgeBase
from neuroagent.providers.openai import OpenAIProvider
from neuroagent.rag import InMemoryVectorStore
kb = KnowledgeBase(embedder=OpenAIProvider(), store=InMemoryVectorStore(), chunk_size=800)
await kb.aadd_path("manual.pdf")
agent = Agent(provider="anthropic", rag=kb)
PDF and DOCX loaders need the
[rag] extra
(pip install "neuroagent-ai[rag]"). TXT/CSV/MD/HTML/JSON work on the base install.
NeuroAgent AI