AI API
Every public member of <oge-grid-assistant>, its config provider, the transports and the shared types. Back to the demos →
Properties Methods Events Types
OgeGridAssistant
oge-grid-assistantProperties 10
Target and transport
| Name | Type | Default | Description |
|---|---|---|---|
target | OgeGridAssistantTarget | null | undefined | The grid to drive — an OgeGrid template reference ([target]="grid"), or any object with state(), applyState() and describeColumns(). |
transport | OgeAiTransport | null | undefined | Replaces the configured transport for this assistant. Without either, a request ends in the noTransport error. |
Behaviour (undefined = config)
| Name | Type | Default | Description |
|---|---|---|---|
mode | OgeGridAssistantMode | 'preview' | "preview" asks before applying (Apply / Discard), "apply" applies at once. |
suggestions | readonly string[] | [] | One-click prompts shown as chips until the first change is applied. |
capabilities | Partial<OgeGridAiCapabilities> | undefined | Turns parts of the state off for the model ({ columns: false }), merged over the config. |
instructions | string | undefined | Domain vocabulary appended to the system prompt (““open” means status 1”). |
columns | readonly OgeAiGridColumn[] | undefined | Column descriptions to send instead of the grid’s own — add descriptions, or leave a column out to keep it from the model. |
locale | string | undefined | BCP 47 locale of plurals, passed to the model as the user’s locale; falls back to the config, then LOCALE_ID. |
messages | OgeGridAssistantMessagesInput | undefined | Per-instance string overrides, merged over the catalog. |
disabled | boolean | false | Disables the field, the chips and every action. |
Methods 7
| Name | Type | Description |
|---|---|---|
submit(text?) | (text?: string) => Promise<void> | Sends the prompt — or text, which also becomes the prompt. Resolves when the reply is handled; never rejects (failures land in the status). |
apply() | void | Applies the pending proposal (the Apply button). |
discard() | void | Drops the pending proposal; the grid stays as it is. |
undo() | void | Reverts the latest applied change, one step per call (up to undoLimit). |
cancel() | void | Aborts the request in flight (the Stop button, Escape). |
reset() | void | Clears the prompt, the proposal, the conversation and the undo history. |
focus() | void | Moves focus to the prompt field. |
Events 4
| Name | Type | Description |
|---|---|---|
applying | OgeGridAssistantApplyingEvent | A change is about to reach the grid — set cancel to veto it (e.g. confirm a destructive filter). |
applied | OgeGridAssistantAppliedEvent | A change was applied: { prompt, summary, snapshot, previousSnapshot, slices } — log it, or persist snapshot as a saved view. |
undone | OgeGridAssistantUndoneEvent | Undo restored the previous state. |
errorOccurred | OgeGridAssistantErrorEvent | A request failed: "no-transport", an OgeAiError code, or "invalid-reply". |
Types 28
Providers
| Name | Type | Description |
|---|---|---|
provideOgeAiConfig(config) | (config: OgeAiConfigInput | (() => OgeAiConfigInput)) => Provider | Sets the transport and the AI defaults for an application or a route; a function makes the config live (switch the language without a reload). |
OGE_AI_CONFIG | InjectionToken<OgeAiConfig> | The token every AI component reads its defaults from. |
Transports
| Name | Type | Description |
|---|---|---|
createOgeAiHttpTransport(options) | (options: OgeAiHttpTransportOptions) => OgeAiTransport | Posts every OgeAiRequest as JSON to your endpoint ({ url, headers?, credentials?, fetch? }), which calls the model with a key the browser never sees and answers { "text": "…" } or plain text. The production shape. |
createOgeOpenAiTransport(options) | (options: OgeAiOpenAiTransportOptions) => OgeAiTransport | OpenAI Chat Completions and every compatible server — Azure OpenAI (query: { "api-version": … } + an api-key header), Ollama (baseUrl: "http://localhost:11434/v1"), vLLM, LM Studio, OpenRouter. structuredOutput: "json_schema" (default), "json_object" or "none". |
createOgeAnthropicTransport(options) | (options: OgeAiAnthropicTransportOptions) => OgeAiTransport | The Anthropic Messages API (Claude): system messages go to system, text blocks are joined. { model, baseUrl?, apiKey?, apiVersion?, maxTokens? }. |
dangerouslyAllowBrowser | boolean | Required by the vendor transports to send an apiKey from a browser — without it they reject with code: "browser-key". A key in client code is readable by every visitor: prototypes and internal tools only. |
OgeAiTransport | { complete(request: OgeAiRequest, options?: { signal?: AbortSignal }): Promise<OgeAiResponse> } | The whole contract — implement it to plug in any provider or SDK. Requests are abortable; the assistant aborts on Stop and when a newer prompt supersedes an older one. |
OgeAiRequest | { feature; messages: readonly OgeAiMessage[]; responseSchema?; responseName?; temperature?; maxTokens? } | What a feature sends: feature ("grid-assistant") lets a backend route or rate-limit, responseSchema is the JSON Schema of the reply. |
OgeAiResponse | { text: string; usage?: { inputTokens?; outputTokens? } } | The model’s reply as text (JSON text for a schema). |
OgeAiMessage | { role: 'system' | 'user' | 'assistant'; content: string } | One message of the conversation. |
OgeAiError | Error & { code: 'aborted' | 'network' | 'http' | 'invalid-response' | 'browser-key'; status? } | What every built-in transport rejects with; status carries the HTTP status of "http" errors. |
OgeAiFetch | (input: string, init) => Promise<{ ok; status; headers; text() }> | The fetch shape the adapters call — pass fetch in the options for tests or a custom client. |
Grid assistant
| Name | Type | Description |
|---|---|---|
OgeGridAssistantTarget | { state(): GridStateSnapshot; applyState(snapshot): void; describeColumns(): readonly OgeAiGridColumn[] } | What the assistant drives — the grid’s own state API. The Angular OgeGrid and the React grid handle both satisfy it. |
OgeAiGridColumn | { field; caption; dataType; sortable; filterable; groupable; visible; values?; description? } | What the model is told about a column — never row data. values are a lookup’s items (texts map back to values); description adds meaning (“net amount in EUR”). |
OgeGridAiCapabilities | { sort; filter; group; search; columns: boolean } | Which parts of the state the assistant may change; a reply touching a switched-off part is dropped with a not-allowed warning. |
OgeGridAssistantMode | 'preview' | 'apply' | "preview" shows the proposed change with Apply / Discard; "apply" applies at once. Undo works in both. |
OgeGridAssistantStatus | 'idle' | 'thinking' | 'preview' | 'applied' | 'unchanged' | 'clarify' | 'unsupported' | 'invalid' | 'error' | 'aborted' | Where the assistant is; the status line renders the matching message and is a polite live region. |
OgeGridAssistantProposal | { prompt; summary; snapshot: GridStateSnapshot; slices: readonly OgeGridAiSlice[]; warnings } | A validated change: the complete next state, already through sanitizeGridStateSnapshot, and the parts that differ. |
OgeGridAiSlice | 'sort' | 'group' | 'filter' | 'search' | 'columns' | A part of the grid state; shown as chips on a proposal. |
OgeGridAiWarning | { kind: 'unknown-field' | 'not-allowed' | 'invalid-operator' | 'invalid-value' | 'too-complex'; slice; field? } | A part of the reply that was dropped instead of applied (the ignored message counts them). |
OgeGridAssistantApplyingEvent | { prompt; summary; snapshot; slices; cancel: boolean } | Cancelable: set cancel to keep the grid as it is. |
OgeGridAssistantAppliedEvent | { prompt; summary; snapshot; previousSnapshot; slices } | A change reached the grid. |
OgeGridAssistantUndoneEvent | { summary; snapshot } | Undo restored snapshot. |
OgeGridAssistantErrorEvent | { prompt; code: OgeAiErrorCode | 'no-transport' | 'invalid-reply'; error } | A request failed — no transport configured, a transport error, or a reply that was not a usable object. |
Config and messages
| Name | Type | Description |
|---|---|---|
OgeAiConfig | { transport: OgeAiTransport | null; locale; gridAssistant: OgeGridAssistantConfig; messages: OgeAiMessages } | Package defaults. OGE_DEFAULT_AI_CONFIG has no transport — the application configures one. |
OgeGridAssistantConfig | { mode; suggestions; historyLimit; undoLimit; capabilities; instructions } | Assistant defaults: "preview", no suggestions, the last 4 exchanges replayed, 20 undo steps, every capability on. |
OgeAiMessages | { gridAssistant: OgeGridAssistantMessages } | Every string, grouped per component. OGE_DEFAULT_AI_MESSAGES is the English catalog; @oge-ui/locales packs carry an ai slice to merge into your config. |
OgeGridAssistantMessages | { label; placeholder; submit; stop; apply; discard; undo; suggestions; proposal; thinking; applied; proposed; unchanged; clarify; unsupported; invalid; error; noTransport; aborted; discarded; undone; ignored; slices } | applied / proposed / clarify / unsupported take {summary}; ignored is an ICU plural over {count}. |