Skip to main content

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:

  1. 🔍 Query Rewriter: Optimizes user input for precise Vector and Graph retrieval.
  2. 📚 Hybrid Retriever: Parallelized data fetching from ChromaDB (Semantic) and Neo4j (Relational).
  3. ⚖️ Context Reranker: Filters out noise to provide the LLM with only high-relevance information.
  4. 🤖 LLM Generator: Produces answers strictly grounded in the verified context.
  5. ✅ Verifier Agent: Automatically scores the "grounding" of the response to ensure accuracy.
  6. 🛡️ Guardrails: Applies confidence checks and safety policies before final delivery.

✨ Key Features

  • Stateful Conversational Memory: Powered by LangGraph's MemorySaver for 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langguard_core-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langguard_core-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

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

Hashes for langguard_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d478d46ee9f81682e8d771637888d76c6cfaf63458a0780985a4ea01957d531
MD5 2d1af652ade156738b66ba27e550ab6a
BLAKE2b-256 b745f0b65beabeb1a67d3de8a3f667baad8251d22c6f7566f667ad57de5435ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for langguard_core-0.1.0.tar.gz:

Publisher: publish.yml on Mayuradlak123/langguard-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for langguard_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89dabb8fb5163e7ebad6a2a1a495b42cf01c91a1da02642d0368405220f542fd
MD5 e3585d63b681cc4b61e149db9ef0f3e4
BLAKE2b-256 8164f6d752ed1deeeb592fa333822cca7f922a83bd06f9a926e2fbf80c8e54ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for langguard_core-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Mayuradlak123/langguard-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page