SchemaPredictiveTextInput
A text input that suggests a continuation of what you are typing; Tab accepts it.
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.
| Name | Type | Default | Description |
|---|---|---|---|
source (required) | string | — | Name of the field in the form record |
multiline | boolean | false | Renders a textarea; also raises the requested completion length from 100 to 200 characters |
label | string | ReactElement | false | label from the schema | false hides the label |
helperText | string | ReactElement | false | helpText from the schema | Text under the input |
How the request is built
- Typing is debounced by 1.5 s; leaving the field cancels a pending request.
- The other form values are collected as context — filtered to
options.ai.sourceFieldswhen the schema names them, otherwise all non-empty values are sent. - Nothing is requested while there is neither context nor at least 10 characters of text.
- A suggestion that arrives after the value has changed again is discarded.
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"]}}
}
- Python
- Ruby
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
- AI integration — enabling the prediction endpoint
- AI assistant button — generating a whole field instead of completing it
- TextInput — the plain counterpart