Class AbstractSchemaPromptAssist

java.lang.Object
com.inductiveautomation.ignition.designer.ai.datasource.AbstractSchemaPromptAssist
All Implemented Interfaces:
PromptAssist
Direct Known Subclasses:
NamedQuerySchemaPromptAssist, QueryBrowserSchemaPromptAssist

public abstract class AbstractSchemaPromptAssist extends Object implements PromptAssist
Base PromptAssist that browses the schema of a single datasource — first a table list, then a column list for a chosen table. Subclasses supply the active datasource name by implementing datasource(); returning null or blank causes options(String) to return an empty list immediately.

Query format. The query is resolved against the datasource's table list: the longest table name the query continues with a . selects that table and the rest of the query filters its columns; a query that names no table filters the table list by name prefix. A drill-in's <table>. nextQuery therefore routes back through this same path with an empty column filter, without special-casing the drill case. Matching against the table list rather than splitting on . is what keeps schema-qualified names working — a datasource with 'include schema in table name' set reports tables as <schema>.<table>, so the name carries a dot of its own.

Literal contract. Options carry a path shaped <table> for a table reference and <table>.<column> for a column reference — or, when the table is schema-qualified, <schema>.<table> and <schema>.<table>.<column>. The assist never includes a prefix in path; the framework prepends this assist's id to build the token actually spliced into the prompt, e.g. @schema:users.email. The dot separator mirrors SQL's natural table.column shape so the token reads like the popup path the user drilled through.

  • Constructor Details

    • AbstractSchemaPromptAssist

      public AbstractSchemaPromptAssist()
  • Method Details

    • datasource

      protected abstract @Nullable String datasource()
    • label

      public String label()
      Specified by:
      label in interface PromptAssist
      Returns:
      a short friendly label for this assist to show in the UI.
    • separator

      public String separator()
      Description copied from interface: PromptAssist
      Separator the embedded controller places between this assist's PromptAssist.label() and its query when building the routing prefix, and that the assist itself should use inside its PromptAssist.Option.DrillIn.nextQuery values.

      Default is "/".

      Specified by:
      separator in interface PromptAssist
      Returns:
      a non-empty separator string the controller uses both to recognize the routing prefix this assist owns and to re-prefix child PromptAssist.Option.DrillIns on the way back out.
    • id

      public String id()
      Specified by:
      id in interface PromptAssist
      Returns:
      the machine identifier owning this assist's @<id>: token namespace. Lowercase [a-z0-9-]+, short (e.g. "tag", "opc").
      See Also:
    • agentContext

      public Optional<String> agentContext()
      Description copied from interface: PromptAssist
      Self-description appended to the embedded agent's system prompt. The embed concatenates the fragments from every mounted assist into a single addendum so each provider documents its own token shape and reference-body schema in one place, decoupled from any specific agent's translation rules. Fragments are expected to be Markdown; the embed adds a heading for each assist using PromptAssist.label() and joins them with blank lines.

      The embed's framing already tells the model every token is shaped @<id>:<path> and announces this assist's @<id>: prefix in its section heading, so the fragment should not restate the generic shape. It should cover:

      • the grammar of the <path> portion, with a concrete example token;
      • the schema of the <reference token="...">body</reference> body the embed will attach when one of those tokens appears — the line names (Path:, Type:, …) the agent should look for and what they mean;
      • a one-line statement of what the reference represents semantically (so the agent can reason about it without knowing this assist exists).
      Fragments should stay host-language-agnostic — say what the reference is, not how to spell it in a particular tool's syntax. The hosting agent's own system prompt is responsible for translating the body's identifier into whatever expression/script/query syntax it speaks.
      Specified by:
      agentContext in interface PromptAssist
      Returns:
      the Markdown fragment, or Optional.empty() when the assist has nothing to contribute (e.g. unit-test stubs).
    • options

      Description copied from interface: PromptAssist
      Fetch the rows to show for query.
      Specified by:
      options in interface PromptAssist
      Parameters:
      query - the text the user has typed past the trigger character, or the PromptAssist.Option.DrillIn.nextQuery of a row the user just selected. Empty when the user has just typed the trigger and has not yet typed anything else.
      Returns:
      the rows to render. The framework discards stale results silently, so an implementation that completes after a newer query has been issued does not need to special-case the race.