Skip to content

Daniel-mass/bi_assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI-Driven Business Intelligence Assistant (BI-Agent)

Next-Gen Enterprise Analytics with MLOps & Numerical Integrity Enforcement


๐ŸŒŸ Project Overview

This project is an Autonomous BI Ecosystem that goes beyond simple dashboards. It leverages a Multi-Agent system to ingest raw SQL or CSV data, perform automated MLOps validation, generate time-series forecasts, and provide strategic business insights.

The Core Innovation: A strict Numerical Integrity Enforcement layer that acts as a "Straitjacket" for Large Language Models, physically preventing hallucinations by validating every metric against database ground truth before it reaches the user.


๐ŸŒŸ The Vision: "Trustworthy Generative BI"

Most BI tools fail because LLMs hallucinate numbers. We solved this. This project integrates a high-performance Multi-Agent system with a rigid MLOps pipeline to ensure that every strategic insight is backed by mathematically verified ground truth.


๐Ÿง  Core Intelligence: The CrewAI Multi-Agent System

At the center of this project is a specialized "Council of Agents" that collaborate to turn raw data into executive strategy.

๐Ÿ•ต๏ธ The Business Intelligence Clerk (Data Agent)

  • Responsibility: The "Source of Truth."
  • Capabilities: Executes complex SQL queries, interacts with the Qdrant Vector DB for context, and calculates raw financial metrics.
  • Power: It is physically restricted to returning raw data onlyโ€”no opinions.

โš–๏ธ The Senior Business Strategist (Insight Agent)

  • Responsibility: Strategic Interpretation.
  • Capabilities: Analyzes the clerk's data against the 200-day baseline, identifies 33.57% growth spikes, and warns about category monopolies.
  • Power: Uses a specialized prompt to bridge the gap between MLflow metrics (MAPE) and real-world risks.

๐Ÿ›ก๏ธ The "Straitjacket" Validator: enforcement.py

This is the project's most powerful innovation. We implemented a Deterministic Gate between the AI and the User to kill hallucinations:

  • Parity Enforcement: The system extracts the Strategist's JSON and compares every digit against the Clerk's SQL result.
  • Zero-Tolerance Policy: If the AI rounds 33.57% to 33.6%, the gate blocks the response and triggers a NumericalIntegrityError.
  • Hybrid Parsing: We built a custom parser using ast.literal_eval to handle LLM syntax variance (single quotes vs double quotes), ensuring the system never crashes due to "lazy" AI handwriting.

๐Ÿš€ The MLOps Power Stack

We used industry-standard tools to automate the entire data lifecycle:

  • ๐Ÿ”„ Prefect: Orchestrates the pipeline, ensuring Deepchecks runs before the Prophet model training starts.
  • ๐Ÿ“Š MLflow: Logs every "Experiment." We tracked our model reaching a highly precise 2.82% MAPE over a 200-day history.
  • ๐Ÿ” Evidently AI: Automatically generates Data Drift reports. It flags "Concept Drift" if your revenue suddenly shifts categories (e.g., from Kitchen to Electronics).
  • ๐Ÿ›ก๏ธ Deepchecks: Acts as the "Data Policeman," scanning for duplicates in order_id or logical inconsistencies in the 200-day ledger.
  • โšก Qdrant: Stores semantic embeddings of business contexts, allowing the agents to "remember" past trends.

๐Ÿ› ๏ธ Technical Workflow & User Flow

  1. Semantic Mapping (mapper.py): Uses AI to instantly understand your DB schema. Whether your column is named total_amt or Price_Final, the system maps it to amount.
  2. The Pipeline: Prefect triggers:
    • Deepchecks (Integrity Check)
    • Evidently (Drift Report)
    • Prophet (7-Day Forecast via MLflow)
  3. Agent Reasoning: CrewAI kicks off the Clerk and Strategist.
  4. Verification: The enforcement.py gate validates the math.
  5. Delivery: The user receives a verified, 200-day trend analysis in a clean UI.

project structure

โ”œโ”€โ”€ app/ โ”‚ โ”œโ”€โ”€ flows/ โ”‚ โ”‚ โ””โ”€โ”€ bi_pipeline.py # ๐Ÿ”„ Prefect Orchestration โ”‚ โ”œโ”€โ”€ llm/ โ”‚ โ”‚ โ””โ”€โ”€ groq_client.py # ๐Ÿค– LLM Interface โ”‚ โ”œโ”€โ”€ logic/ โ”‚ โ”‚ โ”œโ”€โ”€ enforcement.py # ๐Ÿ›ก๏ธ THE GATEKEEPER (Numerical Integrity) โ”‚ โ”‚ โ”œโ”€โ”€ forecasting.py # ๐Ÿ“ˆ MLflow & Prophet Logic โ”‚ โ”‚ โ”œโ”€โ”€ drift_monitoring.py # ๐Ÿ” Evidently AI Reports โ”‚ โ”‚ โ”œโ”€โ”€ data_health.py # ๐Ÿ‘ฎ Deepchecks Validation โ”‚ โ”‚ โ””โ”€โ”€ mapper.py # ๐Ÿ—บ๏ธ Semantic AI Column Mapper โ”‚ โ”œโ”€โ”€ tools/ โ”‚ โ”‚ โ””โ”€โ”€ revenue_tools.py # ๐Ÿ› ๏ธ CrewAI SQL/Data Tools โ”‚ โ”œโ”€โ”€ crew_agents.py # ๐Ÿง  Agent Personality Definitions โ”‚ โ”œโ”€โ”€ crew_runner.py # โš™๏ธ Execution & Rate-Limit Logic โ”‚ โ”œโ”€โ”€ database.py # ๐Ÿ—„๏ธ SQLAlchemy Connection โ”‚ โ””โ”€โ”€ main.py # ๐Ÿš€ FastAPI Entrypoint โ”œโ”€โ”€ streamlit_app.py # ๐Ÿ–ฅ๏ธ Executive Dashboard UI โ”œโ”€โ”€ mlflow.db # ๐Ÿ“Š Model Registry Database โ”œโ”€โ”€ requirements.txt # ๐Ÿ“ฆ Dependencies โ””โ”€โ”€ .env # ๐Ÿ”‘ Environment Secrets

๐Ÿ“‚ System Architecture (Key Files)

  • app/crew_runner.py: The heart of the AIโ€”manages Rate Limits, API cooling, and the Numerical Gate.
  • app/logic/enforcement.py: The "Hallucination Killer" that validates parity.
  • app/logic/mapper.py: Automated column-to-entity AI mapping.
  • app/logic/forecasting.py: Facebook Prophet integration for time-series modeling.
  • streamlit_app.py: The executive command center.

๐Ÿ† Project Achievements

  • Hallucination Rate: Reduced to 0% via Deterministic Gating.
  • Forecasting Accuracy: Maintained <3% MAPE consistently over 200 days.
  • Adaptability: Full "Universal Mode" support for both SQL Databases and CSV uploads.

live

image image image image

๐Ÿ‘จโ€๐Ÿ’ป Developed By

Daniel Denision Engineering Intelligent Systems that don't just guessโ€”they verify.

About

This Multi-Agent BI Ecosystem uses CrewAI to turn raw SQL/CSV data into strategy. Its Numerical Enforcement Gate kills hallucinations by validating AI insights against database truth. Backed by MLOps (Prefect, MLflow, Evidently), it delivers Prophet forecasts with 2.82% MAPE. A production-ready, hallucination-proof BI tool. ๐Ÿš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages