← back

power_bi_agent

View on GitHub →

🌟 Architectural Vision & System Design

The power_bi_agent is designed as a Modular Agentic Monolith that decouples the LLM reasoning engine from the execution environment. This separation of concerns ensures that changes to the underlying LLM provider or the Power BI API schemas do not disrupt the core business logic.

[ User Query ] ──> [ Agentic Orchestrator (LangGraph) ] ──> [ Semantic Router ]
                                                                   │
                                                                   ▼
[ Power BI API ] <── [ Execution & Validation Engine ] <── [ Schema Cache (Redis) ]

Core Data & System Flow

  • Ingestion / Input: Natural language questions enter the system via a structured API gateway. Inputs are validated using strict Pydantic schemas to prevent prompt injection and ensure type safety.
  • Processing / Logic: The core engine utilizes a Reasoning and Acting (ReAct) loop. When a query is received, the agent:
    1. Retrieves the relevant semantic model schema from the cache.
    2. Prunes the schema to fit within the LLM’s optimal context window.
    3. Generates a candidate DAX (Data Analysis Expressions) query.
    4. Runs the query through a local dry-run parser to validate syntax.
  • Persistence & Caching: To avoid hitting Power BI REST API rate limits, semantic model metadata (tables, columns, measures, and relationships) is cached in Redis with a configurable Time-To-Live (TTL).

💻 Tech Stack & Engineering Decisions

Every technology in this stack was selected to balance developer velocity, runtime