UNPKG

@grafana/assistant

Version:

Type definitions and helper functions for Grafana Assistant

37 lines (36 loc) 1.41 kB
import { ContextTypeRegistry } from './factory'; import { ChatContextItem } from './types'; /** * Creates a new chat context item that can be added to conversations. * * This function creates structured context items that provide additional information * to the AI assistant during conversations. Context items can include: * - Datasources (metrics, logs, traces) * - Labels and their values * - Dashboards and folders * - Structured data objects * * The created context item includes display metadata (title, icon, image) and * the underlying data that will be formatted and sent to the LLM when the * context is included in a conversation. * * @param type - The type of context to create (Datasource, Label, Dashboard etc.) * @param params - Type-specific parameters for creating the context item * @returns A ChatContextItem that can be added to conversation context * * @example * ```typescript * // Create a context that will be passed into the function triggering an assistant open * openAssistant({ * ... * origin: 'my-feature', * context: [ * createAssistantContextItem('datasource', { * datasourceUid: datasource.uid, * img: datasource.meta?.info?.logos?.small, * }), * ], * }); * ``` */ export declare function createAssistantContextItem<T extends keyof ContextTypeRegistry>(type: T, params: ContextTypeRegistry[T]['params']): ChatContextItem;