Crema

Frappe Crema

Install Crema

bench get-app https://github.com/amsys/crema

Add the Frappe Gems badge to your README

Maintain Crema? Paste this into your README:

[![Listed on Frappe Gems](https://frappegems.com/api/method/frappe_gems.seo.badge?app=amsys%2Fcrema)](https://frappegems.com/gems/apps/amsys/crema)

About Crema

Frappe Crema

A hardened LLM interface and security layer for Frappe apps — not a chatbot.

License Frappe Python Status

Alpha. Crema is version 0.0.1. The public API, the doctype fields, and the interface set can change without a migration path. Do not run it in production yet.

Frappe Crema gives every app in your bench one route to OpenAI-compatible LLM providers — OpenAI, OpenRouter, Groq, Mistral, DeepSeek, Ollama, and more. Named interfaces (one per use-case: translation, OCR, extraction, ...) bind a provider, a model, a system prompt, an isolation user, and a security layer. There is no other way to reach a provider from application code — every call goes through from crema import ask.

Crema is a security and integration layer, not a conversational agent. Building a chatbot on top is explicitly out of scope — see ROADMAP.md.

Quick start

  1. Add a provider. Open Crema Settings (Crema's default landing page), click New from Template in the Providers panel, pick a preset, paste your API key, and create — this wizard also sets it as the default provider.
  2. Set the default model. Pick a Default Model above the Model Assignments grid. A Default Isolation User is already filled in (install creates one for you). Save — every interface now works; the grid stays collapsed unless you open a row to override one interface's provider, model, or isolation user individually.
  3. Call it:

    from crema import ask
    ask("Fix grammar: helo wrld")
    

See docs/ for full setup, usage, and automation guides.

Desk UI

A robot button on every list view and every form, plus Ask … in the awesomebar. Runs as the signed-in user, never a service account.

  • List → view. Type a request to filter, sort, limit, group, or switch to Report or Kanban. If the result is empty, one more database query finds which text field holds your words and filters on that — no second model call.
  • List → records. Drop a document to get one or more prefilled new records (the model decides how many).
  • Form → diff. Type an instruction to get a proposed diff for the open document.

Nothing is written until you save it. A blocked prompt, a budget cap, or any other failure surfaces as a message — never a silent no-op.

Interfaces

Interface Purpose Fallback
simple General-purpose, lightweight calls none — end of the fallback chain
translation Faithful translation, preserving tone and meaning simple
complex Careful, thorough reasoning for demanding tasks simple
ocr Extract text from images / scanned PDFs none
advanced_ocr Stronger retry when ocr is low-confidence none — escalation target only
security Layer 2 guard: classifies a prompt's risk none — fails loud if unresolved
extraction Pull structured data out of content complex
classification Classify / label content simple
summarization Concise, accurate summaries simple
transform Propose a diff for an ERP document (never auto-writes) complex
view Turn a prompt into a List/Report/Kanban view for the desk UI complex
transcribe Speech-to-text for audio files none

Features

  • One entry point — no public function accepts a model, provider, or API key; only an interface name. ask() also takes context, files (File URLs or in-memory (bytes, mime) tuples), and multi-turn history.
  • 12 named interfaces with an automatic fallback chain. Other apps register their own interfaces through a crema_interfaces hook; a predefined name can never be overridden.
  • Three security layers — a local regex/unicode prompt scan, an optional LLM guard that classifies risk, and an output-trap nonce that catches a hijacked response.
  • Isolation user sandbox — document access runs under a fenced, low-privilege Frappe user; Frappe's own permission engine enforces it, not Crema's.
  • OCR for images, scanned PDFs, and text PDFs, with a confidence score and automatic escalation to a stronger model.
  • Transcriptiontranscribe() turns an audio file into text, with the same budget checks and audit log as every other call.
  • Propose, never writeextract() proposes one or more new documents from a file (how many is the model's own call); transform() proposes a diff for an existing document. Neither writes anything; the caller applies the result.
  • Scheduled automation — fetch a URL, self-plan once, extract, upsert, on a cron schedule. The plan is data, never code.
  • Health probehealth() and is_configured() let a consuming app show its own status page; the caller applies its own role check.
  • Cost control and audit — an optional monthly USD budget per interface and per provider, response caching per interface or per call, a usage dashboard, and a full audit log: interface, model, user, status, duration, tokens, cost, and a prompt hash — never the prompt or document content itself.
  • HTTP endpoints for ask, extract, and transform, rate-limited per IP and per user.
  • Admin in one place — Crema Settings holds the providers (a template wizard for OpenAI, OpenRouter, Groq, Mistral, DeepSeek, or Ollama, with live model autocomplete and connection checks) and the per-interface model assignments; a default provider, model, and isolation user cover every interface out of the box. A Desk workspace adds the doctypes and the usage report.

Requirements

Requirement Notes
Frappe v16 installed and managed by bench
Python 3.14
litellm the provider call layer
pymupdf PDF text extraction and rendering
croniter validates automation schedules — ships with Frappe itself

Documentation

Full guides live in docs/: install, configure, use, automate, and the security model.

License

MIT — see LICENSE.

Related Developer Tools apps for Frappe & ERPNext

  • Frappe — Low code web framework for real world applications, in Python and Javascript
  • Frappe Docker — Docker environment for developing, deploying, and running Frappe applications (ERPNext and custom apps) in production and development
  • Builder — Craft beautiful websites effortlessly with an intuitive visual builder and publish them instantly
  • Bench — CLI to manage Multi-tenant deployments for Frappe apps
  • Frappe Ui — A set of components and utilities for rapid UI development
  • Press — Full service cloud hosting for the Frappe stack - powers Frappe Cloud
  • Gameplan — Open Source Discussions Platform for Remote Teams
  • Doppio — A Frappe app (CLI) to magically setup single page applications and Vue/React powered desk pages on your custom Frappe apps.