Views
No views yet
| Piece | How it's implemented |
|---|---|
| Query routing | Small PyTorch neural network (MLP) trained on Router Training Example records |
| Knowledge retrieval (RAG) | ChromaDB, one isolated collection per AI Agent |
| Answer generation | Local LLM via Hugging Face transformers (configurable in AI Dispatch Settings) |
| Agents | AI Agent DocType — add/edit/disable agents from the Desk, no code changes |
| Knowledge base | AI Agent Document DocType — auto-embeds into ChromaDB on save |
| Chat history | AI Chat Message DocType — every turn logged with routing confidence + retrieved context |
| Chatbot UI | Frappe www page at /ai-dispatch, uses your existing login session |
| Agent | Key | Covers |
|---|---|---|
| Accounts | accounts | Journal entries, payments, invoices, tax templates, GL reports |
| Buying | buying | Purchase orders, RFQs, supplier quotations, purchase receipts |
| Selling | selling | Sales orders, quotations, pricing rules, delivery notes |
| Stock | stock | Stock entries, warehouses, batch/serial tracking, reconciliation |
| Manufacturing | manufacturing | BOMs, work orders, job cards, production plans |
| HR | hr | Leave, attendance, payroll, appraisals, onboarding |
| Projects | projects | Tasks, timesheets, project billing, Gantt tracking |
| Assets | assets | Asset registration, depreciation, maintenance, disposal |
| Quality Management | quality | Quality inspections, non-conformance reports, procedures |
| CRM | crm | Leads, opportunities, pipeline, campaigns |
| Support / Tech Support | support | HD Tickets, SLAs, and general Frappe/ERPNext troubleshooting |
1# From your frappe-bench directory
2
3# 1. Get the app (copy this folder into apps/, or push it to a git repo
4# and use bench get-app <repo-url>)
5cp -r /path/to/ai_dispatch apps/ai_dispatch
6
7# 2. Install Python dependencies into the bench's virtualenv
8# (these are heavy -- torch, transformers, chromadb -- expect this to
9# take a few minutes and download several hundred MB)
10./env/bin/pip install -r apps/ai_dispatch/requirements.txt
11
12# 3. Install the app on your site
13bench --site <your-site> install-app ai_dispatch
14
15# 4. Run migrations (creates the DocTypes, loads AI Agent + Router
16# Training Example fixtures automatically)
17bench --site <your-site> migrate1# 1. Warm up the models -- this is the ONE step that needs internet
2# access, and it's the local LLM setup, made explicit and visible
3# (with progress bars) instead of happening silently mid-chat.
4bench --site <your-site> execute ai_dispatch.setup.warm_up_models.run
5
6# 2. Seed sample ERPNext knowledge base documents for the 11 default
7# agents (Accounts, Buying, Selling, Stock, Manufacturing, HR,
8# Projects, Assets, Quality, CRM, Support)
9bench --site <your-site> execute ai_dispatch.setup.seed_sample_data.run
10
11# 3. Train the router classifier on the 275 ERPNext-flavored example
12# queries that ship as fixtures
13bench --site <your-site> train-routerTrained router on 275 examples.
Labels: ['accounts', 'assets', 'buying', 'crm', 'hr', 'manufacturing',
'projects', 'quality', 'selling', 'stock', 'support']
Validation accuracy: 91.2%Qwen2.5-0.5B-Instruct via
Hugging Face transformers (PyTorch backend, see llm/generator.py).
It is NOT a wrapper around OpenAI, Anthropic, or any other hosted API --
every response is generated on your own machine.~/.cache/huggingface) and reused on every request after that with zero
internet dependency. Running warm_up_models.run (step 1 above) makes
this download happen predictably during setup instead of surprising you
during your first chat message.llm_model_name in
AI Dispatch Settings in the Desk to any transformers-compatible
causal LM, then re-run the warm-up step.https://<your-site>/ai-dispatch in your browser while logged
into your Frappe site. That's the chatbot UI — it shows the routing
confidence per agent live, and lets you expand the exact knowledge base
chunks used for each answer.AI Agent — add a new agent (e.g. "Billing"), give it a system
prompt and a color, mark it enabled.Router Training Example — add 20-30+ example queries for your
new agent so the router learns to recognize it, then retrain:
bench --site <your-site> train-routerAI Agent Document — add knowledge base entries for any agent.
Saving a document automatically embeds it into that agent's ChromaDB
collection (check the "Embedded" checkbox afterward to confirm).AI Dispatch Settings — change the LLM model, embedding model,
how many chunks are retrieved (top_k), or max response length.AI Chat Message — full conversation log, filterable by session,
user, agent, or role. Useful for reviewing routing accuracy over time.agent_key = billing, label "Billing", write
a system prompt, save.billing agent.billing.bench --site <your-site> train-router/ai-dispatch — Billing now shows up as a routable agent.train-router, using whatever Router Training Example records exist
at that moment, so it always reflects your current set of agents.Qwen2.5-0.5B-Instruct) runs on CPU by
default and is intentionally small. For production-quality answers,
swap in a larger model with GPU inference, or point
llm/generator.py at a hosted API instead.