Skip to main content
Premium

SchemaPredictiveTextInput

A text input that suggests a continuation of what you are typing; Tab accepts it.

Premium

This input ships in habarico-enterprise. The ai and ai-text formats stay in the free vocabulary — without the paid package they fall back to a plain text input.

The suggestion is rendered as ghost text behind the caret and comes from the resource's prediction/ endpoint — the AI integration must be enabled on the backend for the field to differ from a plain TextInput.

Example​

<SchemaPredictiveTextInput source="description" multiline />

Props​

The component wraps React Admin's TextInput, so it accepts the same props.

NameTypeDefaultDescription
source (required)string—Name of the field in the form record
multilinebooleanfalseRenders a textarea; also raises the requested completion length from 100 to 200 characters
labelstring | ReactElement | falselabel from the schemafalse hides the label
helperTextstring | ReactElement | falsehelpText from the schemaText under the input

How the request is built​

  1. Typing is debounced by 1.5 s; leaving the field cancels a pending request.
  2. The other form values are collected as context — filtered to options.ai.sourceFields when the schema names them, otherwise all non-empty values are sent.
  3. Nothing is requested while there is neither context nor at least 10 characters of text.
  4. A suggestion that arrives after the value has changed again is discarded.
caution

The form values sent as context leave the browser and reach the configured AI provider. Name the fields explicitly in sourceFields for any resource holding personal or otherwise sensitive data — the default is “everything filled in”.

Schema mapping​

type: "string" with format: "ai" (single line) or "ai-text" (multiline):

{
"name": "description",
"type": "string",
"format": "ai-text",
"options": {"ai": {"sourceFields": ["name", "category"]}}
}
from habarico.contrib.ai.fields import PredictiveTextField
from habarico.serializers import AdminModelSerializer


class ProductSerializer(AdminModelSerializer):
description = PredictiveTextField(source_fields=["name", "category"], required=False)

class Meta:
model = Product
fields = ["id", "name", "category", "description"]

The viewset also has to expose the prediction endpoint — see AI integration.

See also​