API v2.0.0 · Operational

AI Agents That Know What They Don't Know

Build domain-specific AI agents from your documents. Every answer is grounded in your data, cited with inline references, and scored for hallucination risk using DeBERTa-v3 NLI.

~1.2s Faithfulness Scoring
0.907 Guardrail F1 Score
781 Indexed Vector Chunks
5+ Groq Model Fallbacks

The MEXAR RAG Pipeline

Every query goes through a 9-stage intelligent pipeline — from multimodal input all the way to a cited, faithfulness-verified response.

01
🎤 Multimodal Input Processing optional
Audio → Groq Whisper v3 STT · Images → Groq Vision · Video → OpenCV frame extraction → Vision
02
🔍 Intent & Prompt Analysis LLM
Parse query intent (factual / analytical / comparative), detect domain topic, optionally rewrite query for retrieval clarity.
03
🛡️ Domain Guardrail Check F1 = 0.9072
TF-IDF cosine similarity vs agent signature + spaCy NER Jaccard overlap. Threshold = 0.25. Out-of-domain queries rejected with explanation — no hallucination.
04
⚡ Hybrid Vector + Keyword Retrieval pgvector + BM25
Dense: FastEmbed bge-small-en-v1.5 (384-dim) cosine search via pgvector. Sparse: PostgreSQL tsvector BM25 full-text search. Fused via Reciprocal Rank Fusion (RRF): score = Σ 1/(rank + 60).
05
🎯 Cross-Encoder Reranking sentence-transformers
Re-scores top-20 retrieved candidates using a cross-encoder for precision. Selects final top-5 context chunks for answer generation.
06
🧠 LLM Answer Generation Groq
System prompt with retrieved context. Multi-model inference: llama-3.3-70b → llama-3.1-8b → mixtral-8x7b → gemma2-9b. Automatic quota fallback.
07
📎 Source Attribution citations
Match answer sentences to source chunks. Assign [1], [2], [3] inline reference markers. Track provenance per claim.
08
✅ DeBERTa-v3 Faithfulness Scoring NLI
Extract claims from answer. For each claim-chunk pair: NLI inference (entailment → faithful, contradiction → hallucinated). Batched via torch.inference_mode() — ~1.2s/query (50× speedup vs baseline).
09
🔬 Explainability Packaging transparent
Reasoning trace · Confidence breakdown · Sources cited · Guardrail decision log — all surfaced to the frontend UI panel.

Everything You Need

A complete RAG platform — from document ingestion to explainable, grounded answers.

🔍
Hybrid Search + RRF Fusion
Vector cosine (pgvector) and BM25 keyword search fused via Reciprocal Rank Fusion for optimal retrieval across all document types.
Faithfulness Verification
DeBERTa-v3-base NLI model scores every answer claim against retrieved context. Quantified hallucination risk, not just vibes.
🛡️
Domain Guardrails
TF-IDF + spaCy NER Jaccard similarity prevents answering out-of-domain questions. Tuned to F1 = 0.9072 at threshold 0.25.
📎
Inline Source Citations
Every sentence references its source chunk with [1], [2] markers. Click any citation to see the exact source text and file name.
🗣️
Multimodal Input
Ask questions via audio (Groq Whisper), upload images for visual Q&A (Groq Vision), or extract info from video frames (OpenCV).
🧠
Explainability Panel
Full reasoning trace exposed in the UI: retrieval scores, reranker scores, confidence breakdown, guardrail decision, and sources cited.
🔊
Text-to-Speech
ElevenLabs API integration with per-sentence TTS playback. Falls back to Web Speech API automatically.
Real-time WebSocket Chat
Streaming responses via WebSocket with compilation progress tracking. No polling required.
📁
5 Document Formats
Upload PDF, DOCX, CSV, JSON, or TXT files. Semantic chunking preserves context boundaries for better retrieval quality.

API Endpoints

Full interactive documentation available at /docs

Method Endpoint Description
POST/api/auth/registerCreate a new user account
POST/api/auth/loginLogin and receive JWT bearer token
GET/api/agents/List all compiled agents for current user
POST/api/agents/Create a new agent
POST/api/compile/Start knowledge compilation from uploaded files
GET/api/compile/{job_id}Poll compilation job status + progress
POST/api/chat/Send a query to an agent (REST)
WS/ws/chat/{agent_id}Real-time streaming chat via WebSocket
GET/api/healthHealth check — returns API + Groq status

Multi-Model Fallback Chain

Automatic failover across Groq models when rate limits are hit — zero downtime.

openai/gpt-oss-120b → quota →
llama-3.3-70b-versatile → quota →
llama-3.1-8b-instant → quota →
mixtral-8x7b-32768 → quota →
gemma2-9b-it

Quick Integration

Start querying your agent in three steps.

# 1. Register and login POST /api/auth/register { "email": "you@example.com", "password": "..." } POST /api/auth/login → { "access_token": "eyJ..." } # 2. Compile an agent from your documents POST /api/compile/ Authorization: Bearer {token} Files: report.pdf, research.docx → { "job_id": 42, "status": "compiling" } # 3. Chat with your agent POST /api/chat/ Authorization: Bearer {token} { "agent_id": 36, "message": "What are the key findings?" }{ "answer": "...[1][2]", "faithfulness": 0.87, "sources": [...] }