Skip to content
OGE logoOGE

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-assistant

Properties 10

Target and transport

Name Type DefaultDescription
targetOgeGridAssistantTarget | nullundefinedThe grid to drive — an OgeGrid template reference ([target]="grid"), or any object with state(), applyState() and describeColumns().
transportOgeAiTransport | nullundefinedReplaces the configured transport for this assistant. Without either, a request ends in the noTransport error.

Behaviour (undefined = config)

Name Type DefaultDescription
modeOgeGridAssistantMode'preview'"preview" asks before applying (Apply / Discard), "apply" applies at once.
suggestionsreadonly string[][]One-click prompts shown as chips until the first change is applied.
capabilitiesPartial<OgeGridAiCapabilities>undefinedTurns parts of the state off for the model ({ columns: false }), merged over the config.
instructionsstringundefinedDomain vocabulary appended to the system prompt (““open” means status 1”).
columnsreadonly OgeAiGridColumn[]undefinedColumn descriptions to send instead of the grid’s own — add descriptions, or leave a column out to keep it from the model.
localestringundefinedBCP 47 locale of plurals, passed to the model as the user’s locale; falls back to the config, then LOCALE_ID.
messagesOgeGridAssistantMessagesInputundefinedPer-instance string overrides, merged over the catalog.
disabledbooleanfalseDisables 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()voidApplies the pending proposal (the Apply button).
discard()voidDrops the pending proposal; the grid stays as it is.
undo()voidReverts the latest applied change, one step per call (up to undoLimit).
cancel()voidAborts the request in flight (the Stop button, Escape).
reset()voidClears the prompt, the proposal, the conversation and the undo history.
focus()voidMoves focus to the prompt field.

Events 4

Name Type Description
applyingOgeGridAssistantApplyingEventA change is about to reach the grid — set cancel to veto it (e.g. confirm a destructive filter).
appliedOgeGridAssistantAppliedEventA change was applied: { prompt, summary, snapshot, previousSnapshot, slices } — log it, or persist snapshot as a saved view.
undoneOgeGridAssistantUndoneEventUndo restored the previous state.
errorOccurredOgeGridAssistantErrorEventA request failed: "no-transport", an OgeAiError code, or "invalid-reply".

Types 28

Providers

Name Type Description
provideOgeAiConfig(config)(config: OgeAiConfigInput | (() => OgeAiConfigInput)) => ProviderSets 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_CONFIGInjectionToken<OgeAiConfig>The token every AI component reads its defaults from.

Transports

Name Type Description
createOgeAiHttpTransport(options)(options: OgeAiHttpTransportOptions) => OgeAiTransportPosts 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) => OgeAiTransportOpenAI 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) => OgeAiTransportThe Anthropic Messages API (Claude): system messages go to system, text blocks are joined. { model, baseUrl?, apiKey?, apiVersion?, maxTokens? }.
dangerouslyAllowBrowserbooleanRequired 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.
OgeAiErrorError & { 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}.