The AI Concept Chatbot goes beyond traditional chatbots. It helps organizations streamline data management while accelerating AI initiatives.
Our platform eliminates data silos by unifying structured (SQL/DBs) and unstructured (PDFs, Docs) data in one place, reducing data prep time by 70%. With Agentic AI built directly into the platform, customers cut AI development time by 80% since there's no need to move data or manage separate AI infrastructure.
| Module | Name | Purpose |
|---|---|---|
| 🏛️ MuniFix | Civic Issue Reporter | Unifies municipal databases and citizen reports seamlessly |
| 🛒 SpazaAI | SME TaxMate | Combines unstructured tax laws with structured user financial data |
| 🗺️ QueueLess | Gov Services Concierge | Consolidates disparate government service data into one unified pipeline |
Every module is powered by a shared AI Orchestrator (core/ai_orchestrator.py) that acts directly on the unified data layer, routing queries without complex ETL pipelines.
┌──────────────────────────────────────────────────────────────────────┐
│ CLIENT (Web / WhatsApp) │
└──────────────────────────┬───────────────────────────────────────────┘
│ HTTPS
┌──────────────────────────▼───────────────────────────────────────────┐
│ FastAPI Application Server │
│ ┌────────────────┐ ┌──────────────────┐ ┌──────────────────────┐ │
│ │ /munifix │ │ /spaza-ai │ │ /queueless │ │
│ │ Civic Reports │ │ Tax Advice │ │ Gov Concierge │ │
│ └───────┬────────┘ └────────┬─────────┘ └─────────┬────────────┘ │
│ └────────────────────▼────────────────────────┘ │
│ ┌──────────────────────┐ │
│ │ AI Orchestrator │ │
│ │ (ai_orchestrator.py)│ │
│ └──────────┬───────────┘ │
└───────────────────────────────┼──────────────────────────────────────┘
│
┌─────────────────────▼─────────────────────┐
│ Agentic Layer │
│ Observability → Evaluation → Reflection │
│ ReAct Planner → HITL → Memory │
│ Web Search → Multi-Agent Coordinator │
└─────────────────────┬─────────────────────┘
│
┌───────────▼───────────┐
│ OpenAI API │
│ (GPT-4o / Embeddings)│
└───────────────────────┘
The apps/api/app/core/agent/ package implements a production-grade 9-pattern Agentic Stack. These are not experimental abstractions — they mirror the agent frameworks used in enterprise AI systems (like the proprietary Kirov Nexus architecture).
Eliminates data silos by pulling from both structured databases and unstructured vector stores simultaneously. Reduces data prep time by 70% by handling all joining, metadata extraction, and semantic context-building dynamically before the LLM even sees the prompt. Built directly into the platform to cut AI development time by 80%.
Every action the agent takes is wrapped in a unique TraceID (UUID-based). This enables you to reconstruct the exact sequence of decisions, tool calls, and LLM responses for a given request — critical for debugging and auditing in production.
trace = AgentObserver.start_trace("complaint_report_generation")
# ... your agent logic here ...
AgentObserver.end_trace(trace, status="success", result_metadata={"chars": 1280})After each LLM response is generated, the AgentEvaluator automatically scores it against quality and safety dimensions. Responses that fail the threshold trigger the self-correction loop rather than being returned to the user.
| Dimension | Check | Deduction |
|---|---|---|
| Quality | Response length < 10 chars | -50 pts |
| Quality | Agent expresses uncertainty | -30 pts |
| Safety | Unsafe keywords detected (hack, exploit) |
-100 pts (instant fail) |
Implements ReAct-style self-correction. When an evaluation fails, the agent does not simply raise an error. It appends a correction instruction to its original prompt and retries up to max_retries times, each time noting the specific failure reason.
result = await AgentReflector.self_correcting_execute(
prompt="Generate a formal municipal report for: pothole on main road",
execute_fn=ai_orchestrator.process,
max_retries=2
)The ReAct (Reasoning + Acting) framework is a hallmark of modern agentic systems. When given a complex goal, the planner calls the LLM to decompose it into a JSON array of sub-steps, then executes each step sequentially, accumulating a full trace of intermediate results.
For high-risk agent actions (e.g., submitting a formal legal complaint, triggering bulk database operations), the system pauses and routes the decision to a human approval gate. In a deployed environment, this sends a notification to an admin dashboard and waits for a webhook callback.
approved = HumanInTheLoop.require_approval({
"action": "submit_formal_complaint",
"target": "City of Tshwane",
"risk_level": "high"
})Implements an in-session memory store (a typed Python list) that the agent can use to remember context across multiple turns without depending on the LLM's context window. Key-value based remember / recall interface.
The Web Search Agent connects to SerpAPI (or your configured search provider) to autonomously retrieve real-time information from the web. Falls back to a mock mode when no API key is configured, making local development seamless.
Orchestrates multiple agent tasks concurrently using asyncio.gather — the Python equivalent of goroutine parallelism. A supervisor agent decomposes a goal and dispatches sub-tasks to specialized executor agents, aggregating results.
AI-CONCEPT-CHATBOT/
│
├── apps/
│ ├── api/ # Python FastAPI Backend
│ │ ├── app/
│ │ │ ├── api/ # Route handlers (munifix, spaza, queueless)
│ │ │ ├── core/
│ │ │ │ ├── agent/ # 🧠 Full Agentic Stack (8 modules)
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── observability.py
│ │ │ │ │ ├── evaluation.py
│ │ │ │ │ ├── reflection.py
│ │ │ │ │ ├── react_planner.py
│ │ │ │ │ ├── hitl.py
│ │ │ │ │ ├── memory.py
│ │ │ │ │ ├── web_search.py
│ │ │ │ │ └── multi_agent.py
│ │ │ │ ├── ai_orchestrator.py # Central AI Brain
│ │ │ │ ├── config.py
│ │ │ │ ├── database.py
│ │ │ │ ├── rbac.py
│ │ │ │ └── security.py
│ │ │ ├── models/ # SQLAlchemy ORM models
│ │ │ ├── repositories/ # DB access layer
│ │ │ ├── schemas.py # Pydantic request/response schemas
│ │ │ └── main.py # Application entry point
│ │ ├── requirements.txt
│ │ └── Dockerfile
│ │
│ └── web/ # Frontend Application
│
├── infra/ # Infrastructure as Code
├── docker-compose.yml # Full stack orchestration
├── .env.example # Environment variable template
└── README.md
Before running this project, ensure you have the following installed and configured:
| Dependency | Version | Purpose |
|---|---|---|
| Docker | 24.x+ | Container orchestration |
| Docker Compose | v2.x+ | Multi-service management |
| Python | 3.11+ | Backend runtime |
| Node.js | 20 LTS | Frontend development |
| OpenAI API Key | — | LLM & Embedding access |
1. Clone the repository:
git clone https://github.com/Raphasha27/AI-CONCEPT-CHATBOT.git
cd AI-CONCEPT-CHATBOT2. Configure environment variables:
cp .env.example .envOpen .env and fill in your credentials. The minimum required configuration is:
OPENAI_API_KEY="sk-..."
DATABASE_URL="postgresql+asyncpg://user:password@db:5432/chatbot_db"
SECRET_KEY="your-secret-key-here"3. Start all services with Docker:
docker-compose up -dThis will spin up:
api— FastAPI backend on port8000db— PostgreSQL database on port5432web— Frontend on port3000
4. Run database migrations:
docker-compose exec api alembic upgrade head5. Verify the API is live:
curl http://localhost:8000/health
# Expected: {"status": "ok", "version": "1.0.0"}POST /api/v1/munifix/report
Content-Type: application/json
{
"category": "infrastructure",
"description": "Large pothole on Jan Smuts Avenue blocking traffic",
"location": "Sandton, Johannesburg",
"urgency": "high"
}Response: A formally structured municipal report citing the South African Constitution, Section 152 (Objects of Local Government), and the Municipal Systems Act.
POST /api/v1/spaza/tax-advice
Content-Type: application/json
{
"annual_turnover": 850000,
"business_type": "spaza_shop",
"province": "Gauteng"
}Response: Structured JSON with tips, warnings, and a plain-language bracket explanation targeting the SARS Turnover Tax regime.
POST /api/v1/queueless/guide
Content-Type: application/json
{
"service": "smart_id_application",
"has_existing_id": false,
"province": "Western Cape"
}Response: A step-by-step checklist specifying required documents (originals vs. copies), office locations, and estimated processing times.
The platform implements multiple layers of security to protect agent interactions:
- JWT Authentication: All API routes are protected by bearer token authentication. Tokens are signed with
HS256and expire after the configuredACCESS_TOKEN_EXPIRE_MINUTES. - Role-Based Access Control (RBAC): Defined in
core/rbac.py. Roles includeuser,agent, andadmin, each with distinct permission sets. - Agent Authorization Gates: The agentic layer's
hitl.pyintercepts high-risk agent actions before execution, requiring explicit approval. - Input Sanitization: All user inputs are validated via Pydantic schemas before reaching the AI orchestrator, preventing prompt injection vectors.
- Structured Audit Logging: The
observability.pymodule logs every agent action with a TraceID tostructlog, enabling full post-mortem analysis of any incident.
# Run the full test suite
docker-compose exec api pytest tests/ -v
# Run a specific test module
docker-compose exec api pytest tests/test_orchestrator.py -v
# Run the stress test to benchmark throughput
docker-compose exec api python sizweos_stress_test.pyCause: The OpenAI API key may be invalid or rate-limited.
Fix: Verify your key in .env and check your OpenAI usage dashboard.
Cause: The db container may not be ready before the api container starts.
Fix:
docker-compose restart api
# Or add a healthcheck dependency in docker-compose.ymlCause: The safety keyword list in evaluation.py may be triggering on legitimate content.
Fix: Review and adjust the unsafe_keywords list in evaluation.py for your specific domain.
- Add WhatsApp Business API integration for direct citizen messaging
- Implement long-term PostgreSQL-backed memory for persistent agent state
- Add a React dashboard for real-time agent trace visualization
- Deploy to Vercel (frontend) + Railway (backend) for zero-cost production hosting
- Integrate Wazuh for real-time SIEM monitoring of agent activity
Contributions, issues, and feature requests are welcome. Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feat/your-feature - Commit your changes:
git commit -m 'feat: add new capability' - Push to the branch:
git push origin feat/your-feature - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
Developed as part of the Future AGI ecosystem by Koketso Raphasha (Raphasha27). Part of the Kirov Dynamics Technology portfolio.