# ⚖️ Ethiopia Commercial Code AI Agent
**A Self-Reflective RAG Assistant built with LangGraph, Streamlit, and Ollama.**
Welcome to the **Ethiopia Commercial Code Assistant**! This isn't just a simple chatbot; it's an intelligent **agent** that "thinks" before it speaks. By using **Self-Reflection**, it critiques its own answers, checks for hallucinations, and ensures every response is grounded in the official Commercial Code of Ethiopia Proclamation.
---
## 🚀 Key Features
* **🧠 Self-Correction**: If the agent hallucinates or gives a vague answer, it catches itself and retries.
* **🔍 Smart Retrieval**: Uses Vector Search (FAISS) to find exact legal articles.
* **⚡ Hybrid Intelligence**: Uses a powerful cloud model (GPT-4o/Groq) for drafting answers and a fast local model (**Qwen 2.5**) for critiquing them (saving you money!).
* **🔄 Query Transformation**: If your question is unclear, the agent rewrites it to find better legal matches.
* **📊 Interactive UI**: A clean, professional interface built with Streamlit.
---
## 📂 Project Structure
```text
ethiopia-commercial-code-agent/
│
├── assets/
│ └── architecture_final.jpeg
│ └── graph.png
│
├── data/
│ └── commercial_code.pdf # 📜 Place your Proclamation PDF here
│
├── vectorstore/ # 🗄️ Vector Database (Auto-generated)
│ └── faiss_index/
│
├── src/
│ ├── __init__.py
│ ├── config.py # ⚙️ Configuration & Model Selection
│ ├── ingestion.py # 📥 PDF Processing & Embedding
│ ├── graph.py # 🕸️ LangGraph Logic (The "Brain")
│ ├── chains.py # 🔗 Prompts for Generation & Critique
│ └── cache.py # 🚀 Caching Mechanism
│
├── app.py # 🖥️ Streamlit Frontend
├── requirements.txt # 📦 Python Dependencies
├── .gitignore
├── .env # 🔑 API Keys
└── README.md
```
---
## 🛠️ Installation & Setup
Follow these steps to get the agent running on your machine. …