AI Rewrite for TextEdit widgets

With TextEdit widgets, the GBC integrates AI capabilities to assist users when writing content.

The AI Rewrite feature is available for TextEdit widgets with a toolbar. Users can rewrite selected text or entire field content, with options to adjust tone or length. The rewrite can draw on values from the current form as context.

Figure: Accessing the AI Rewrite tool

Screenshot showing the location of the magic wand icon and the dropdown chevron.

In the toolbar,

  • A magic wand icon triggers the rewrite action.
  • A dropdown chevron provides additional actions, to include:
    • Rewrite text (default action; selected when user simply clicks on the AI rewrite icon / magic wand)
    • Make tone more professional
    • Make tone more casual
    • Make the text longer
    • Make the text shorter

If the user selects a portion of the text, only the selected part will be rewritten; if no text is selected, the rewrite applies to the entire content.

When a rewrite is triggered:

  1. A floating banner appears indicating that the context is being analyzed. The AI collects relevant information from the current form context, including values from other widgets.
  2. A second banner then appears and displays the rewritten version of the text in an editable field.
Figure: Before AI rewrite

Form showing text in a textedit field that has been set up for AI rewrite.
Figure: After AI rewrite

Floating banner showing the rewrite suggestion with the three choice icons.

The user then uses the icons in the toolbar of the floating banner to:

  • Apply — Replace the original text with the improved version
  • Refresh — Generate a new rewrite
  • Cancel — Close the rewrite interface

The GBC project package includes the sample textEditAIRewriter, located in the directory tests\genero_samples\public. This sample shows a form with a TextEdit widget set up to use the AI Rewrite feature, once AI is enabled for the GBC.

Preparing your form to benefit AI rewrite

AI rewrite can use the values from the fields of the current form as context, but it needs guidance as to what each value represents. To assist, provide details about each field with the COMMENT or TITLE attributes (if using a text-based .per file) or properties (if using a graphical form design .4fd file).

Providing this extra description of the field will help the AI model better understand what each field value represents and what kind of data it contains.

...
ATTRIBUTES
  EDIT order_number = FORMONLY.order_number,
    DEFAULT = "123456789",
    COMMENT = "Unique number that identifies the order";
  EDIT customer = FORMONLY.customer,
    DEFAULT = "YesCompany",
    COMMENT = "Name of the customer who placed the order";
  TEXTEDIT textedit_ai = FORMONLY.textedit_ai, STYLE="textFormat_html", STRETCH=both;
END
...
In this example, the context sent to AI would include the following information:
FORMONLY.order_number(Unique number that identifies the order)=123456789
FORMONLY.customer(Name of the customer who placed the order)=YesCompany

For more information on the COMMENT or TITLE attributes, refer to the Genero Business Development Language User Guide.

AI Rewrite Presentation Style

Use the aiWritingAssistant presentation style to enable or disable the AI Rewrite feature for a specific TextEdit field.

  • When set to yes, the AI Rewrite feature is enabled for the TextEdit field where this presentation style attribute is applied, but only if the GBC has the theme variable gbc-ai-enabled set to true.
  • When set to no, the AI Rewrite feature is disabled for the TextEdit field where this presentation style attribute is applied.

For more information on the aiWritingAssistant presentation style and how to use it, refer to the Genero Business Development Language User Guide.

Enabling AI in the GBC

AI features are disabled by default; they must be enabled using the theme variable gbc-ai-enabled. To activate AI features, set the theme variable to true. To set theme variables, you must create or edit a GBC customization project.

Configuring AI

Connect to your AI provider in the AI section of the GBC Settings dialog.

Figure: AI configuration in the GBC Settings dialog

Settings dialog with the AI Mode section highlighted.

For more information on completing the AI section of the Settings dialog, refer to GBC Settings.

Note:

AI configuration on the end-user side is subject to change. This setting allows you to evaluate GBC AI features today; however, Four Js is working to integrate AI such that configuration will not be needed on the end-user side.

Add an AI provider

By default, a GBC project includes six default AI providers; GBC allows adding new AI providers through customization.

You implement a custom provider with a JavaScript module that extends the base class: AIProviderBase. Once you register the provider, it becomes available in the AI section of the Settings dialog.

The GBC project package includes a customizaton named custo_ai that serves as an example of how to add a custom provider.

Enabling Chrome AI for local mode

To use the AI Rewrite feature with Chrome (local) mode, Chrome's experimental AI features must be enabled in the browser. For more information, go to the official Chrome documentation.

To enable Chrome AI:
  1. Open Google Chrome.
  2. Navigate to each of the following Chrome flags in the address bar:
    chrome://flags/#optimization-guide-on-device-model
    chrome://flags/#prompt-api-for-gemini-nano-multimodal-input
    chrome://flags/#writer-api-for-gemini-nano
    chrome://flags/#rewriter-api-for-gemini-nano
  3. Set all flags to Enabled, or Enabled Multilingual when available.
  4. Restart Chrome.

Once enabled, the AI Rewrite feature can be used locally via Chrome. On first use, the rewrite action may be slower, as Chrome needs to download the AI model. This configuration is required only once per browser profile.

AI rewrite-related theme variables (core)

The AI rewrite-related core theme variables apply to all AI providers. Redefining any of these theme variables will impact all TextEdit fields that use AI rewrite.

Theme variable Description

gbc-ai-rewrite-instructions

Defines the base prompt used for AI rewriting.

Line breaks in prompts are inserted using:
{{BR}}

gbc-ai-rewrite-input-template

Defines how the prompt is structured before being sent to the AI.

Available placeholders include:
Placeholder Description
{{context}} Context extracted from the interface.
{{tone}} Tone constraint; dynamically replaced based on the selected rewrite action and the corresponding gbc-ai-rewrite-tone-* variables.
{{length}} Length constraint; dynamically replaced based on the selected rewrite action and the corresponding gbc-ai-rewrite-length-* variables.
{{text}} Original text.

gbc-ai-rewrite-tone-as-is

gbc-ai-rewrite-tone-more-formal

gbc-ai-rewrite-tone-more-casual

These variables define the prompt fragments used to control the tone.

These fragments are used when the user selects the rewrite actions of:
  • Rewrite text
  • Make tone more professional
  • Make tone more casual

gbc-ai-rewrite-length-as-is

gbc-ai-rewrite-length-longer

gbc-ai-rewrite-length-shorter

These variables define the prompt fragments to control how the AI adjusts text length.

These fragments are used when the user selects the rewrite actions of:
  • Rewrite text
  • Make the text longer
  • Make the text shorter

These core theme variables impact the AI rewrite options as their values are what get injected into the {{tone}} and {{length}} placeholders, which are part of the CONSTRAINTS section of the template (gbc-ai-rewrite-input-template).

We can map these theme variables to the choices presented by the drop-down chevron:

  • 1st option (Rewrite) → injects into {{tone}} and {{length}} placeholders the values of gbc-ai-rewrite-tone-as-is + gbc-ai-rewrite-length-as-is, respectively.
  • 2nd option (Make tone professional) → injects into {{tone}} placeholder the value of gbc-ai-rewrite-tone-more-formal.

  • 3rd option (Make tone casual) → injects into {{tone}} placeholder the value of gbc-ai-rewrite-tone-more-casual.

  • 4th option (Make shorter) → injects into {{length}} placeholder the value of gbc-ai-rewrite-length-shorter.

  • 5th option (Make longer) → injects into {{length}} placeholder the value of gbc-ai-rewrite-length-longer.

AI rewrite-related theme variables (provider-specific)

Each AI provider can override the default rewrite prompts and templates.

AI user interface (UI) color theme variables

Theme variable Description
ui-ai-color

Identifies AI-related elements in the user interface.

The interface uses this color for:
  • AI indicators
  • AI actions
  • AI highlights

FloatingBanner theme variable

The FloatingBanner is not a Genero BDL widget. It is an internal GBC component used by features such as AI Rewrite and Offline Mode.

Theme variable Description
gbc-FloatingBannerWidget-shadow-color Controls the shadow color of the FloatingBanner component.