An AI-powered customer-service crew that ingests policy documents, classifies support tickets, and produces fully-cited, policy-compliant resolutions automatically.
Fast ingest Smart RAG CrewAI Gemini Python313+
- Why This Repo?
- Architecture
- Project Structure
- Project Structure
- Outputs
- Usage
- Python API Usage
- Evaluation Suite
- Extending Agents or Policies
- Contributing
- Troubleshooting
- License
Online stores face thousands of repetitive support requests.
This repo automates first-line responses:
- Understands tickets via LLM triage
- Retrieves only relevant policy chunks
- Writes fully-cited replies or escalates intelligently
- 20 real-world test-cases baked in (≈ 85 % accuracy)
No GPUs needed—everything runs on Google's Gemini embeddings , groq/llama-3.1-8b-instant .
- Triage Agent (
crewai) – classify ticket, detect missing info - Retriever Agent –
Policy Search Tool→ exact Chroma collection (refund,dispute,shipping, …) via Gemini embedding-001 - Writer Agent – strict prompt: every claim must cite doc, else escalate
- Compliance Agent – reject hallucinations (citations < 1, fuzzy language)
All results conform to app.schemas.io.Output.
.
├── app/ # Core source
│ ├── agents/ # CrewAI definitions
│ ├── core/ # Gemini LLM wrapper
│ ├── graph/ # Crew → workflow
│ ├── rag/ # Embedding, ingestion, retrieval
│ ├── evaluation/ # Accuracy scoring
│ └── schemas/ # Pydantic models
├── data/
│ └── policies/ # Plaintext knowledge base
├── tests/
│ ├── test_cases.json # 20 golden examples
│ └── test_e2e.py # Pytest harness
├── ingestion_trigger.py # One-click ingestion
└── pyproject.toml # PEP-621 deps
Python 3.13+
Groq API key
Gemini API key
uv init
uv add -r requirements.txtAll dependencies listed in pyproject.toml.
SET env variables
# (1) Make sure Chroma is populated first
uv run ingestion_trigger.py
# (2) Run an interactive loop
uv run python -m app.main
# default ticket in fileChange the hard-coded ticket string in app/main.py or:
python -c "
from app.main import workflow
print(workflow.run('Received damaged laptop – screen cracked, order #12345'))"Sample output
{'classification':'refund',
'confidence':0.93,
'decision':'approve',
'rationale':'Policy §Damaged Item allows refund/replace – evidence required...',
'response':'We’re sorry... full refund processed.',
'citations':['data/policies/disputes.txt', 'data/policies/returns_refunds.txt'],
'notes':'APPROVED by compliance'}
from app.main import workflow
payload = "Package lost, marked delivered but never arrived."
result = workflow.run(payload)
print(result.decision) # → 'approve'To re-use individual Crew agents (advanced):
factory = AgentFactory(tools)
triage_agent = factory.triage()Evaluate on 20 curated tickets (accuracy, citation-score, escalation-rate):
pytest -qResults summary printed per test-case from tests/test_cases.json.
- Drop new
*.txtfiles intodata/policies/ - Re-ingest:
python ingestion_trigger.py - Add new classification in
RAGPipeline.get_collection()mapping - Re-run tests:
pytest -q - (Opt.) tweak Crew prompts in
app/agents/crew_agents.pyfor stricter leniency
We ❤️ pull requests.
Please:
- Fork & branch (
feature/,fix/,docs/) - Add a unit or integration test (
tests/) - Ensure
pytestgreen - Update this README for user-facing changes
- Submit PR with concise description
Code style = Black ≥ 24, isort, pep-8 naming.
ValueError: GOOGLE_API_KEY not found➜ fill.envchromadb.errorson first run ➜ ensure you've run ingestion- Reply too cautious (many escalations) ➜ lower
Compliance Agentstrictness or enrich policy docs - Embeddings slow ➜ Gemini free tier limits; consider batching
MIT – see LICENSE file. No warranties; commercial use at your own risk.



