█████╗ ██████╗ ███████╗███╗ ██╗████████╗██╗ ███████╗███╗ ██╗███████╗
██╔══██╗██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝██║ ██╔════╝████╗ ██║██╔════╝
███████║██║ ███╗█████╗ ██╔██╗ ██║ ██║ ██║ █████╗ ██╔██╗ ██║███████╗
██╔══██║██║ ██║██╔══╝ ██║╚██╗██║ ██║ ██║ ██╔══╝ ██║╚██╗██║╚════██║
██║ ██║╚██████╔╝███████╗██║ ╚████║ ██║ ███████╗███████╗██║ ╚████║███████║
╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚══════╝╚═╝ ╚═══╝╚══════╝
Know exactly what your AI agent is doing wrong.
Most developers ship AI agents and have no idea what's happening inside them.
AgentLens fixes that. It logs every conversation, automatically extracts user intent and sentiment using AI, detects failures before users churn, and suggests exactly how to improve your system prompt — all in real time.
User asks → Agent responds → AgentLens logs it
↓
AI extracts intent
Detects failures
Tracks sentiment
↓
Dashboard shows patterns
Prompt Lab fixes them
| Feature | Description |
|---|---|
| 📡 Conversation Logging | One line of Python to capture every chat |
| 🧠 Intent Extraction | AI auto-labels what every user was trying to do |
| 💥 Failure Detection | Catches where your agent failed or frustrated users |
| 😤 Sentiment Analysis | Positive / Neutral / Negative breakdown |
| ⚡ Prompt Lab | AI analyzes failures and rewrites your system prompt |
| 🔄 Auto-Analysis | Runs every hour — no manual clicks needed |
| 👥 Multi-tenant | Each user gets their own project and API key |
| 🔑 Auth System | Signup / login with Supabase |
git clone https://github.com/Shraman123/AgentLens.git
cd AgentLenscd backend
pip install -r requirements.txt
# Set your keys
export GROQ_API_KEY=gsk_...
export SUPABASE_URL=https://your-project.supabase.co
export SUPABASE_SERVICE_KEY=eyJ...
uvicorn app:app --reload --port 8000cd frontend
npm install
REACT_APP_API_URL=http://localhost:8000 npm starthttp://localhost:3000
from agentlens import AgentLens
lens = AgentLens(api_key="ak_your_key", base_url="https://your-backend.hf.space")
# Decorator — auto-logs everything
@lens.watch
def my_agent(user_message: str) -> str:
return call_your_llm(user_message)
# That's it. Every conversation is now logged and analyzed.
my_agent("How do I reset my password?")@lens.watch_async
async def my_agent(user_message: str) -> str:
return await call_your_llm(user_message)curl -X POST https://your-backend.hf.space/log \
-H "x-api-key: ak_your_key" \
-H "Content-Type: application/json" \
-d '{"user_message": "Hello", "agent_response": "Hi there!"}'| Method | Endpoint | Auth | Description |
|---|---|---|---|
GET |
/health |
— | Health check |
POST |
/auth/signup |
— | Create account |
POST |
/auth/login |
— | Sign in |
GET |
/projects |
Bearer | List your projects |
POST |
/projects |
Bearer | Create project |
POST |
/log |
API Key | Log a conversation |
POST |
/analyze |
API Key | Analyze conversations |
GET |
/dashboard |
API Key | Get dashboard stats |
GET |
/conversations |
API Key | List conversations |
POST |
/suggest-prompt |
API Key | Get prompt suggestion |
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Your AI Agent │────▶│ AgentLens API │────▶│ Supabase │
│ │ │ (FastAPI + HF) │ │ (Postgres) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌─────────────────┐
│ Groq / LLM │ │ React Dashboard │
│ (Intent extract) │ │ (Vercel) │
└──────────────────┘ └─────────────────┘
| Service | What | Cost |
|---|---|---|
| Hugging Face Spaces | Backend API | Free |
| Vercel | Frontend dashboard | Free |
| Supabase | Database + Auth | Free |
| Groq | AI analysis | Free |
Total: $0/month for up to ~50k conversations analyzed.
- Fork this repo
- Create a new Space → Docker
- Add secrets:
GROQ_API_KEY,SUPABASE_URL,SUPABASE_SERVICE_KEY - Push
backend/files to the Space
- Import repo to Vercel
- Set root directory:
frontend - Add env vars:
REACT_APP_API_URL,REACT_APP_API_KEY - Deploy
- Conversation logging
- AI intent extraction
- Failure detection
- Sentiment analysis
- Prompt Lab
- Auto-analysis scheduler
- Multi-tenant auth
- Email alerts on failure spikes
- Slack / Discord notifications
- OpenTelemetry ingestion
- Prompt version history
- A/B testing for prompts
- CSV export
| Conversations analyzed | Monthly cost |
|---|---|
| 10,000 | ~$0 (Groq free tier) |
| 100,000 | ~$1-2 |
| 1,000,000 | ~$10-20 |
- Backend — FastAPI, Supabase, APScheduler
- AI — Groq (llama-3.3-70b), free tier
- Frontend — React, Recharts, React Query, TanStack
- Auth — Supabase Auth
- Hosting — Hugging Face Spaces + Vercel
MIT — free to use, modify, and build on.
Built in public · Star ⭐ if this helped you