Mirabelle AI Assistant¶

Overview¶
Mirabelle is a conversational APS (Advanced Planning & Scheduling) assistant built directly into the ForecastAI/Mirabelle application. It translates natural-language questions into read-only ClickHouse queries, renders the results as charts, tables, or KPI cards, and provides a business-friendly explanation — all within a side panel that stays available while you work.
See Configure the connection for screenshots, example values, and links to create provider keys. How an answer is made explains the ontology and query flow, and the MCP connections — both directions: your AI apps reading (and, with a granted scope, acting on) the review queue, and Mirabelle calling registered MCP servers (see also the MCP server reference).
Opening the panel¶
Click the
sparkle button on the right edge of the screen. The panel slides in from the right.
Tap the
sparkle icon in the top toolbar. The panel opens as a full-width overlay.
Panel layout¶
The panel is organised into three tabs:
| Tab | Purpose |
|---|---|
| Chat | Natural-language Q&A with charts, tables, and explainability |
| Exceptions | Preserved legacy alert list with severity pills and approve/dismiss actions |
| Help | Built-in guide with capabilities, sample prompts, and privacy notes |
Resizing¶
The panel width is adjustable between 280 px and 720 px:
- Drag the left border handle to resize continuously.
- Double-click the handle to reset to the default width (320 px).
- Your preferred width is persisted in
localStorageacross sessions.

Chat Tab¶

Asking a question¶
- Type your question in the input area at the bottom.
- Press Ctrl + Enter (or Cmd + Enter on macOS), or click OK to send.
- Mirabelle prepares and checks the query. The panel shows the answer when that processing is complete.
Chat uses the pipeline selected in the left toolbar and its linked scenarios by default. For
another plan, write pipeline "Exact name" or use its pipeline ID. For a scenario, give the type
and exact name, for example MEIO scenario "Growth Buffers". A comparison applies to that
question only. See which plan Chat uses.
Quick-prompt cards¶
When the chat is empty, Mirabelle shows five canonical APS questions as clickable cards:
| Card | Question sent |
|---|---|
| Expiry next week | "What products are at risk of expiry next week?" |
| Highest inventory risk | "Which items have the highest projected shortages?" |
| Service level Spain | "Why did service level drop in Spain?" |
| Top forecast errors | "Show top 20 items with largest forecast error." |
| Allocation shortages | "Which allocations are causing shortages?" |
Click any card to submit it instantly.
Multi-turn conversation¶
Mirabelle keeps the last 6 conversation turns in memory for the current session. A follow-up uses recent context from the same pipeline and scenario scope:
Follow-up refinement
- You: "Show top 20 items with largest forecast error"
- Mirabelle: (returns bar chart + table)
- You: "Only for Spain"
- Mirabelle: (narrows results to Spain using context from turn 1)
The server keeps recent turns in memory, with a default 60-minute inactivity limit. The panel also keeps displayed messages in the browser tab's session storage. Use Clear conversation to clear the panel and its server-side context.
What Mirabelle Can Answer¶
| Intent | Output type | Example prompt |
|---|---|---|
| Direct lookup | Table / KPI cards | "What is the current safety stock for item X at site Y?" |
| Trend over time | Line chart | "Show forecast accuracy trend over the last 12 weeks" |
| Top-N ranking | Bar chart + table | "Top 20 items with largest forecast error" |
| Distribution by category | Bar chart | "Distribution of stock days by country" |
| Scenario comparison | Table or chart | "Compare safety stock using MEIO scenarios 'Baseline Buffers' and 'Growth Buffers'" |
| Pipeline comparison | Table or chart | "Compare supply projections in pipelines 'Baseline' and 'Growth'" |
| Why-question diagnostics | Table + explanation | "Why did service level drop in Spain?" |
| Forecast accuracy review | Bar chart | "Show forecast accuracy by product category" |
| Expiry risk | Table | "What products are at risk of expiry next week?" |
| Capacity bottleneck | Table or bar chart | "Where are the supply bottlenecks?" |
| Allocation shortage | Table | "Which allocations are causing shortages?" |
| Conversational refinement | Narrowed results | "Only for Spain" (as a follow-up) |
Drill-down navigation
In answers about the currently selected pipeline and its linked scenarios, a row that identifies an item-site pair can show a drill-down arrow. Comparisons do not jump to a different plan. The target page depends on the query topic:
| Query topic | Target detail tab |
|---|---|
| Forecast consumption / netting | Netting tab |
| Service level / fill rate | Pipelines view |
| Outliers / anomaly detection | Outlier Analysis tab |
| Supply / inventory | Supply view |
Explainability¶
Use View SQL above a reply's results to see the query sent to ClickHouse, including the planning filters. A successful query can still return no rows. If execution fails, this shows the last query Chat tried to run. Settings → AI → Assistant behaviour → SQL visibility controls who can view it.
Open How was this answered? for the other details:
| Section | Description |
|---|---|
| Tables | Blue chips listing the tables reported for the answer |
| Business concepts | Purple chips listing the APS concepts that matched (e.g. service level, stock days) |
| Generation stats | Number of generation attempts and total response time in milliseconds |
| Team knowledge | Appears when approved ratings from your team informed the answer, and says how many (see Rating answers) |

In this example with synthetic data, View SQL shows the planning filters and How was this answered? lists the source table and business concept.
Self-correction loop
In std speed mode, the default is up to two SQL generation attempts in total. This counter does not include retries inside a provider call.
Rating answers¶
Under every answer in the Chat tab, the thumbs-up and thumbs-down rate it. A thumbs-down asks what was wrong (wrong numbers, wrong table or measure, wrong filter or scope, did not understand the question, or something else). Press the same thumb again to take the rating back until an administrator has reviewed it. A reply that ended in an error can be flagged but not liked, and an answer can be rated for 60 minutes after it was given.
Ratings go to Settings → AI → Ontology → Chat feedback, where an administrator reviews each one, adds a note or a corrected query, and approves or rejects it. Only approved ratings help later answers, and only in your tenant. The full walkthrough, including what a rating stores and what it cannot do, is in Rate an answer, and teach Mirabelle.
Ask the guide¶
The two buttons at the top of the Chat tab, Ask my data and Ask the guide, choose what the question is about. Ask the guide is for how does Mirabelle work questions (what a setting does, how a screen is used, how a plan is computed). It never reads your plan: it compares the question with every section of the published user guide and shows the three that match best, the first open, each with its place in the guide and an Open in the guide link. A … at the start or the end of a passage means the section continues there. When nothing is close enough the panel says The guide does not cover this closely enough and shows no sections: rephrase, or switch to Ask my data.
The first start after the API restarts takes about a minute while the guide is prepared; the line under the buttons says so, and you can type your question meanwhile. By default no language model is used; an administrator can add a short model-written summary under Settings → AI → Ask the guide - answers. The full walkthrough is in Ask the guide: how Mirabelle works.
Exceptions Tab¶
The Exceptions tab preserves the legacy Alerts panel functionality.

Features¶
- Severity summary pills — click a pill (critical, high, medium, low) to filter to that severity; click again to clear the filter.
- Status filter — toggle between Open, Approved, Rejected, and All.
- Batch-run refresh — click the
refresh button to re-evaluate all alert rules. - Approve / Dismiss — each alert row has action buttons to approve or dismiss it.
- Drill-down — click an alert's item name to navigate to the Series detail view.
Help Tab¶
The Help tab is a built-in quick-reference covering:
- What Mirabelle can do (capabilities list)
- Sample prompts to try
- Architecture overview (how retrieval → SQL → execution works)
- Privacy and security notes
- How to rate an answer with the thumbs
No internet access is required — the help content is part of the application.
Privacy & Security¶
| Concern | Meaning |
|---|---|
| Model calls | Ollama can be hosted on your own network. If an administrator chooses OpenRouter, the chat prompt and any explanation sample and aggregates are sent to that external service. |
| SQL safety | Generated SQL is restricted to SELECT / WITH only; DDL, DML, and destructive keywords are blocked by the validator. |
| Conversation history | Recent context is held in server memory, and displayed messages are cached in the browser tab. |
| Data access | Mirabelle runs Chat queries in read-only mode; the model provider does not connect to ClickHouse. Human actions in the Exceptions tab are separate. |
| Ratings | A rating keeps your name and e-mail, the question, the answer text and the query for an administrator to review. It never keeps the rows of the result. |
| LanceDB index rebuild | Requires admin role and is triggered through POST /api/mirabelle/index. |
Technology¶
| Layer | Technology | Notes |
|---|---|---|
| Local inference | Ollama | Serves the LLM on-prem, entirely on your network (the default connection) |
| LLM | Ollama or OpenRouter | The tenant's provider, endpoint, model, and credentials are configured in Settings → AI. Qwen2.5-Coder 7B is the built-in Ollama model default. |
| Vector store | LanceDB | On-disk, embedded; stores schema, glossary, SQL examples, sample values |
| Embeddings | sentence-transformers/all-MiniLM-L6-v2 | 384-dim, ~80 MB, CPU-friendly. Falls back to hash vectors if unavailable. |
| Data warehouse | ClickHouse | Read-only queries over the APS schema |
| Backend | FastAPI | Exposes /api/mirabelle/* endpoints |
| Frontend | React + Plotly.js | MirabellePanel component with inline chart rendering |
Pipeline overview¶
The answer flow shows where the model fits. The retriever builds the context before the provider call. After the model drafts a query, Mirabelle applies its deterministic fixes before validation and read-only execution.
Troubleshooting¶
The Mirabelle status indicator (at the top of the Chat tab) shows the current health of the stack. Common issues and fixes:
| Symptom | Status indicator | Resolution |
|---|---|---|
| Ollama not running | ollama_available=false |
Start the Ollama service: ollama serve |
| LanceDB index missing | lancedb_ready=false |
Rebuild the index: POST /api/mirabelle/index (requires admin role) |
| Embedding fallback active | embedding_fallback=true |
Install sentence-transformers: pip install -r requirements.txt |
| Generation failed | Chat shows an error | Verify the model and provider in Settings → AI. For OpenRouter, also check the key and model access; Test connection alone does not validate them. |
| Slow first response | N/A | A local model may need to load on the first request. Speed also depends on the model and question. |
| Model not pulled | model_warning in status |
Run ollama pull qwen2.5-coder:7b-instruct-q3_K_M, or pick a pulled model in Settings → AI |
| Index pending indicator | "index pending" in status bar | The index is building on first chat. Wait a few seconds, or trigger manually via the API. |
Connection changes
An administrator configures the tenant's connection in Settings → AI. See the setup walkthrough to choose a model, obtain the right key, and verify the connection. The Anthropic setup is separate and only needed for the plain-English segment builder.
LanceDB index rebuild
The index should be rebuilt whenever the APS schema changes (new tables, columns, or glossary entries). Use POST /api/mirabelle/index from an admin session, or run python -m files.mirabelle.indexer build on the server.