Skip to main content
Premium

AI integration

Optional AI features for an admin: fields that suggest their own content, an assistant that fills a whole form, and a fulltext filter that understands intent rather than substrings.

Everything here lives in habarico-enterprise — habarico_enterprise.ai — and is opt-in — a project that does not configure a key keeps the plain behaviour.

Setup​

pip install habarico-enterprise
# settings.py
OPENAI_API_KEY = "…"

Then use the AI variants of the base classes:

from habarico_enterprise.ai.admin import AIModelAdmin

from .models import Product


class ProductAdmin(AIModelAdmin):
model = Product
search_fields = ["name", "description"]
fields = ["name", "sku", "description", "short_description", "status", "category"]

AIModelAdmin wires the AI fulltext filter and the prediction endpoint; predictive fields work from that point on.

caution

Every AI call is billed by the provider. The endpoints are therefore open only to an authenticated caller on a resource that somebody may write to (can_create or can_update), and each part of the request is size-capped — see Usage. A resource that gets 405 from the AI endpoints is missing one of those two flags.

caution

Field values are sent to the AI provider to produce a suggestion. On a resource holding personal data, name the source fields explicitly with source_fields instead of letting the default “everything filled in” apply — see Custom AI fields.

Pages​

PageWhat it covers
UsageAIModelAdmin and what it turns on
Custom AI fieldsPredictiveCharField and PredictiveTextField
ViewsetOverriding the AI viewset
SerializerOverriding the AI serializer
FiltersetOverriding the AI filterset
AI clientCalling the provider directly

See also​