
Human-in-the-Loop RAG Agent
https://github.com/coleam00/human-in-the-loop-rag-agent- Category
- AI Agents
- Rank
- No. 1584Tools index
- Pricing
- Open Source
- Type
- AGENT
- Builder
- coleam00
- GitHub
- 66 stars
- Date
About
RAG AI agent with realtime source validation (human in the loop), built with CopilotKit and Pydantic AI.
What it does
A user asks a question, inspects retrieved document chunks, selects acceptable sources, and then authorizes answer generation. The browser and Python agent share search settings, results, approval state, and progress through server-sent events.
Why it's ranked here
The project makes source control concrete instead of merely showing citations after generation. Users can reject weak context before synthesis, while semantic and hybrid retrieval remain configurable. That transparency comes with meaningful setup and an intentionally interrupted conversation flow.
What's good
The approval boundary is explicit: retrieval stops before answer synthesis, and the final response uses only selected chunks. Search controls include result limits, similarity thresholds, and semantic or hybrid matching. State snapshots also expose loading, errors, query history, and knowledge-base status.
Tradeoffs
Running it requires Python, Node.js, PostgreSQL with pgvector, and an OpenAI-compatible model and embedding endpoint. Each substantive question pauses for manual source selection. Frontend and backend state definitions must match exactly, creating a maintenance point when the shared contract changes.
How to use it well
Use it for internal knowledge workflows where a person should inspect evidence before an answer reaches others. It suits teams evaluating agent state synchronization and controlled retrieval. It does not serve workflows needing fully automatic answers without an approval pause.
Technical notes+
agent/main.py wraps the AG-UI application in FastAPI, adds localhost CORS, and exposes /health. agent/state.py defines RAGState, including retrieved chunks, approvals, search configuration, status flags, and errors. agent/agent.py builds a Pydantic AI agent whose search tools return StateSnapshotEvent metadata; the supplied copy is truncated during synthesize_with_sources. agent/tools.py queries PostgreSQL functions for semantic and hybrid retrieval, while agent/dependencies.py manages asyncpg pools and an OpenAI-compatible embedding client. agent/ingestion/ingest.py ingests Markdown documents, chunks them, generates embeddings, and inserts documents and chunks.
Observed
- Application shape
- Full-stack browser application with a React frontend and Python backend.
- Backend interface
- FastAPI service carrying AG-UI traffic through Server-Sent Events, plus a health endpoint.
- Install surface
- Backend dependencies install with uv; frontend dependencies install with npm.
- Runtime requirements
- Python 3.12+, Node.js 18+, PostgreSQL with pgvector, and an OpenAI-compatible API endpoint.
- Retrieval modes
- Supports semantic vector search and hybrid vector plus text search.
- Ingestion surface
- Includes a command-line Python script that ingests Markdown documents into PostgreSQL.
Read from README.md, agent/main.py, agent/agent.py, agent/state.py, agent/tools.py, agent/prompts.py, agent/__init__.py, agent/settings.py, agent/providers.py, agent/dependencies.py, frontend/next.config.ts, frontend/postcss.config.mjs, agent/utils/__init__.py, agent/utils/db_utils.py, agent/ingestion/ingest.py.
What it can do
Retrieve relevant information from knowledge base
User query or question → Contextually relevant documents or data
Validate source reliability in real-time
Retrieved sources and documents → Human-verified source validation status
Generate AI responses with human oversight
User query and validated sources → AI-generated answer with human approval
Flag questionable sources for human review
Retrieved documents and metadata → Flagged sources requiring human validation
Structure data validation using schemas
Raw data and Pydantic models → Validated, structured data objects
Enable human intervention in AI workflows
AI processing steps and decisions → Human-modified or approved AI actions
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.