Case study 05

AI Integration (Python + LLM APIs)

PROTOTYPE — not in production
AI Integration (Python + LLM APIs) — case study visual

The challenge

Managers wanted quick answers about sales, stock and finance without waiting for custom reports. An earlier in-ERP assistant had serious problems:

  • Its sales figures ignored POS sales.
  • It used the wrong sales-rep field.
  • It leaked figures through generated briefs.
  • It rendered unsanitised HTML.

My analysis and approach

  • I audited the earlier assistant and documented each defect.
  • I designed a new assistant around permissions and confirmation, not prompts. The model never sees data the user couldn't see in the ERP, and it can't act on its own.

Technical implementation

  • Provider abstraction in Python (requests): OpenAI, Anthropic, Gemini, Ollama (local) and any OpenAI-compatible endpoint.
  • Pipeline: intent router, then permission service, then tool executor, then prompt/context builder.
  • 38 ERP tools across sales, inventory, accounting, CRM and projects. They are read-only, and any action requires explicit user confirmation.
  • Guardrails: payroll data is never sent to a provider; API keys are redacted from error messages; model "thinking" blocks are stripped.
  • UI: an OWL chat systray and dashboard.

Earlier experiments (clearly experiments)

  • Calling the Gemini API from an Odoo module: fixed a client-lifecycle bug and moved the API key to an environment variable. The real API returned recommendations and 3072-dimension embeddings.
  • Running local LLMs with Ollama (general and code models).

Verified result

  • 59/59 automated tests, including a browser tour, run with a mocked provider on a database copy. Figures were cross-checked against the ledger on that copy.
  • Not in production. It is presented here as a tested prototype.

← API & External System IntegrationDevOps & Infrastructure →