Abhisingh-18's picture
Mirror of github.com/Abhisingh18/Trust-first-AI-Copilot
f35583f verified
|
Raw
History Blame Contribute Delete
4.69 kB
# Trust-First AI Copilot
**Perplexity-Style β€’ System-Driven β€’ No Custom LLM**
Deployed Link: https://trust-first-ai.vercel.app/
A trust-first AI Copilot that delivers **verified, source-grounded, and confidence-scored answers** using strict system rules β€” inspired by Perplexity and designed to fix the core limitations of modern AI copilots.
---
## Problem
Most AI copilots today:
- Produce confident but incorrect (hallucinated) answers
- Lose context in long or multi-file documents
- Hide sources and assumptions
- Provide limited admin visibility and control
- Encourage blind dependency on AI outputs
These issues lead to **wrong decisions, rework, and low trust**.
---
## Solution
This project implements a **system-first AI Copilot** where:
- Retrieval is mandatory (no context β†’ no answer)
- Every answer is backed by sources
- Confidence is explicitly shown
- Low-confidence answers are refused
- Automation is human-approved
- Security, transparency, and auditability are built-in
The focus is **system design over model size**.
---
## Core Principles
- No guessing
- No hidden sources
- No blind automation
- Refusal is a feature, not a failure
---
## Key Features
- Mandatory Retrieval-Augmented Generation (RAG)
- Source-linked answers with citations
- Confidence scoring (High / Medium / Low)
- Automatic refusal on insufficient data
- Workspace / project-level context memory
- Intent detection and auto-clarification
- Human-in-the-loop automation (n8n)
- Zero-trust data access
- Full audit logs (OpenTelemetry)
- Model-agnostic LLM layer (Groq)
---
## System Architecture
User
β†’ Intent Detection
β†’ Search & Retrieval (Tavily + Vector DB)
β†’ Context Ranking & Filtering
β†’ LLM (Groq – language & reasoning only)
β†’ Verification & Confidence Engine
β†’ Answer + Sources + Assumptions
β†’ (Optional) Human-Approved Automation
β†’ Audit Logs & Admin Dashboard
## What This Project Is Not
- Not a chatbot
- Not prompt-dependent
- Not blind AI
- Not a Copilot replacement
This is a **controlled, transparent, enterprise-ready AI system**.
---
## Tech Stack
**Frontend**
- Next.js
- React
- Tailwind CSS
**Backend**
- FastAPI (Python)
**AI & Data**
- LLM: Groq (LLaMA / Mixtral)
- Search: Tavily API
- Embeddings: Hugging Face / Local models
- Vector DB: FAISS / Qdrant
- Automation: n8n
- Logging & Audit: OpenTelemetry
**Deployment**
- Frontend: Vercel
- Backend: Render
---
## Project Structure
project-root/
β”œβ”€β”€ frontend/
β”‚ β”œβ”€β”€ pages/
β”‚ β”œβ”€β”€ components/
β”‚ └── services/
β”œβ”€β”€ backend/
β”‚ β”œβ”€β”€ main.py
β”‚ β”œβ”€β”€ rag/
β”‚ β”œβ”€β”€ verification/
β”‚ β”œβ”€β”€ automation/
β”‚ └── requirements.txt
β”œβ”€β”€ docs/
└── README.md
yaml
Copy code
---
## Required API Keys
| Service | Purpose |
|-------|---------|
| Groq | LLM inference |
| Tavily | Web search |
| Hugging Face | Embeddings |
| n8n | Automation |
> All API keys are stored **only in backend environment variables**.
---
## Local Setup (Backend)
```bash
git clone https://github.com/your-username/your-repo.git
cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Create .env:
env
Copy code
GROQ_API_KEY=xxxx
TAVILY_API_KEY=tvly_xxxx
HF_API_KEY=hf_xxxx
N8N_API_KEY=xxxx
N8N_BASE_URL=http://localhost:5678
Run backend:
bash
Copy code
uvicorn main:app --reload
Local Setup (Frontend)
bash
Copy code
cd frontend
npm install
npm run dev
Deployment
Backend
Push code to GitHub
Connect repository to Render
Build command:
bash
Copy code
pip install -r requirements.txt
Start command:
bash
Copy code
uvicorn main:app --host 0.0.0.0 --port 10000
Frontend
Deploy via Vercel
Set backend API URL in environment variables
Security & Trust Model
API keys never exposed to frontend
Per-user data isolation
Role-based access control
Full audit trail for AI actions
How Hallucinations Are Prevented
Retrieval is mandatory
Claims must map to sources
Confidence is evaluated
Low confidence triggers refusal
No source β†’ No answer
Use Cases
Research and academic assistance
Enterprise internal knowledge copilots
Policy and compliance analysis
Long-document summarization
Decision-support systems
Future Improvements
Offline read-only mode
Multimodal reasoning (charts + text)
Advanced admin dashboards
Domain-specific copilots
Final Note
LLMs don’t fail β€” systems fail.
This project demonstrates how strong system design beats larger models.