Skip to content

Allow packages to format their property values for the AI content tools #809

Backlog

Description

@Luuk1983

Problem

The content tools (get_umbraco_content and others built on ContentToolHelpers) pass every property through PropertyValueFormatter. That class is internal and has rules only for core editors:

  • rich text and Markdown are stripped to plain text;
  • media and content pickers are reduced to name and URL;
  • blocks are recursed;
  • strings are truncated.

Every other editor's converted value goes to the model unchanged.

For a package editor whose value converter builds a rich model, that has three effects:

  1. Large tool output. Our editor stores a small selection (about 200 bytes of JSON). Its converter turns that into the full content the front end renders, 9–34 KB per property. The model receives all of it on every page read: about 80 KB for one test page with five such properties, while a summary of a few hundred bytes would do.
  2. No access to the stored value. To edit the property, the model needs the stored value, but it only ever sees the converted one. We worked around this with our own tool that reads the stored value.
  3. The culture doesn't reach the converter. The property is read with GetValue(culture), but a converter that picks its output language from IVariationContextAccessor still sees the request's culture. On a culture-variant page the model gets the default language.

Proposal

An extension point that follows the existing IAIPropertyValueHandler pattern:

public interface IAIPropertyValueFormatter : IDiscoverable
{
    string ForPropertyEditorSchemaAlias { get; }

    // Return what the model should see for this property; null falls back to the built-in rules.
    object? Format(IPublishedProperty property, string? culture);
}

Registered through builder.AIPropertyValueFormatters() and discovered automatically, with the built-in rules as the fallback. A package could then give the model a compact, culture-aware summary of its value instead of the full model.

Setting the variation context to the requested culture while formatting would also solve point 3 for every converter, independently of this proposal.

Environment: Umbraco 17.6.2, Umbraco.AI 17.8.2 (confirmed against the v17/main source).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions