A production-grade, stateful AI agent pipeline with anti-hallucination guardrails.
Project description
🚀 Stateful AI Evaluation Pipeline
A production-grade, stateful AI agent pipeline built with LangGraph, FastAPI, and a multi-database architecture (Neo4j, ChromaDB, Redis). This project implements a high-fidelity anti-hallucination workflow designed for enterprise-level reliability and observability.
🏗️ System Architecture
The application follows a specialized Production Anti-Hallucination Pipeline:
- 🔍 Query Rewriter: Optimizes user input for precise Vector and Graph retrieval.
- 📚 Hybrid Retriever: Parallelized data fetching from ChromaDB (Semantic) and Neo4j (Relational).
- ⚖️ Context Reranker: Filters out noise to provide the LLM with only high-relevance information.
- 🤖 LLM Generator: Produces answers strictly grounded in the verified context.
- ✅ Verifier Agent: Automatically scores the "grounding" of the response to ensure accuracy.
- 🛡️ Guardrails: Applies confidence checks and safety policies before final delivery.
✨ Key Features
- Stateful Conversational Memory: Powered by LangGraph's
MemorySaverfor persistent context across sessions. - Tool-Augmented Intelligence:
- Calculator: For verified mathematical computations.
- Neo4j Tool: Direct Knowledge Graph queries via Cypher.
- Web Search: Real-time information fetching via Tavily.
- Resilience Layer: Circuit Breaker patterns implemented for Groq LLM, ChromaDB, and Neo4j.
- Real-Time Streaming: ChatGPT-style UI with Server-Sent Events (SSE) showing internal pipeline status.
- Observability: Seamless integration with LangSmith for full execution tracing.
🛠️ Tech Stack
- Backend: Python 3.10+, FastAPI
- Orchestration: LangGraph, LangChain
- LLM: Llama 3.3 70B & Llama 3 8B (via Groq)
- Vector DB: ChromaDB
- Graph DB: Neo4j (Aura DB)
- Memory/Cache: Redis
- Monitoring: LangSmith
- Circuit Breaker: PyBreaker
⚙️ Setup & Installation Guide
1. Clone the Repository
git clone <your-repo-url>
cd llm-evaluation
2. Automated Setup
The project includes a setup.sh script that handles pip upgrades and dependency installation:
chmod +x setup.sh
./setup.sh
3. Environment Configuration
Create a .env file in the root directory. Use the following template as a guide:
# --- LLM Provider (Groq) ---
GROQ_API_KEY="your_groq_api_key_here"
# --- Search Tool (Tavily) ---
TAVILY_API_KEY="your_tavily_api_key_here"
# --- Vector Database (ChromaDB Cloud) ---
CHROMA_API_KEY="your_chroma_api_key"
CHROMA_TENANT="your_tenant_id"
CHROMA_DB_NAME="llm-evaluation"
# --- Graph Database (Neo4j Aura) ---
NEO4J_URI="neo4j+s://your-id.databases.neo4j.io"
NEO4J_USER="neo4j"
NEO4J_PASSWORD="your_neo4j_password"
# --- Cache & Pub/Sub (Redis) ---
REDIS_HOST="localhost"
REDIS_PORT=6379
REDIS_PASSWORD=""
# --- Observability (LangSmith) ---
LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_API_KEY="your_langsmith_api_key"
LANGCHAIN_PROJECT="llm-evaluation-pipeline"
🚀 Running the Application
To launch the entire pipeline (including the FastAPI gateway and internal LangGraph logic), simply run:
chmod +x run.sh
./run.sh
The application will be available at: http://localhost:8000
🔍 Anti-Hallucination & Guardrails
The system is designed to be "Grounded by Default."
- Every response is cross-referenced with retrieved context in the Verifier Agent node.
- A Grounding Score is calculated.
- The Guardrails node enforces a threshold (default: 0.6).
- If the score is low, the system provides a safe refusal message: "I cannot answer this as it may contain hallucinated information."
🛡️ Resilience (Circuit Breakers)
The system monitors the health of external services. If Neo4j, ChromaDB, or Groq becomes unresponsive, the Circuit Breaker will open, preventing system-wide crashes and returning a controlled fallback response.
🤝 Contributing
Feel free to open issues or submit pull requests to improve the pipeline logic or UI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langguard_core-0.1.0.tar.gz.
File metadata
- Download URL: langguard_core-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d478d46ee9f81682e8d771637888d76c6cfaf63458a0780985a4ea01957d531
|
|
| MD5 |
2d1af652ade156738b66ba27e550ab6a
|
|
| BLAKE2b-256 |
b745f0b65beabeb1a67d3de8a3f667baad8251d22c6f7566f667ad57de5435ac
|
Provenance
The following attestation bundles were made for langguard_core-0.1.0.tar.gz:
Publisher:
publish.yml on Mayuradlak123/langguard-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langguard_core-0.1.0.tar.gz -
Subject digest:
6d478d46ee9f81682e8d771637888d76c6cfaf63458a0780985a4ea01957d531 - Sigstore transparency entry: 1553204443
- Sigstore integration time:
-
Permalink:
Mayuradlak123/langguard-core@261eac8acf74cf117e43c0b1b5340f4de40ad567 -
Branch / Tag:
refs/tags/testing - Owner: https://github.com/Mayuradlak123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@261eac8acf74cf117e43c0b1b5340f4de40ad567 -
Trigger Event:
release
-
Statement type:
File details
Details for the file langguard_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langguard_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89dabb8fb5163e7ebad6a2a1a495b42cf01c91a1da02642d0368405220f542fd
|
|
| MD5 |
e3585d63b681cc4b61e149db9ef0f3e4
|
|
| BLAKE2b-256 |
8164f6d752ed1deeeb592fa333822cca7f922a83bd06f9a926e2fbf80c8e54ff
|
Provenance
The following attestation bundles were made for langguard_core-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Mayuradlak123/langguard-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langguard_core-0.1.0-py3-none-any.whl -
Subject digest:
89dabb8fb5163e7ebad6a2a1a495b42cf01c91a1da02642d0368405220f542fd - Sigstore transparency entry: 1553204446
- Sigstore integration time:
-
Permalink:
Mayuradlak123/langguard-core@261eac8acf74cf117e43c0b1b5340f4de40ad567 -
Branch / Tag:
refs/tags/testing - Owner: https://github.com/Mayuradlak123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@261eac8acf74cf117e43c0b1b5340f4de40ad567 -
Trigger Event:
release
-
Statement type: