Lime Web Components API Documentation - v6.24.0
    Preparing search index...

    Interface AIContextRegistryAlpha

    Registry for AI context providers.

    The AIContextRegistry manages context providers that contribute information to the AI chat. Components register providers to share their state, and the AI chat gathers context from all providers when needed.

    Gathering context for an AI request

    const registry = platform.get(PlatformServiceName.AIContextRegistry);
    const contributions = registry.gatherContext();
    interface AIContextRegistry {
        gatherContext(): GatheredAIContext[];
        getProviders(): AIContextProvider[];
        register(
            provider: AIContextProvider,
            element: HTMLElement & LimeWebComponent,
        ): () => void;
    }
    Index

    Methods

    • Alpha

      Gather context from all registered providers.

      Calls getContext() on each provider and collects the results. Providers that return null (indicating no context available) and providers that throw errors are skipped (errors log a warning).

      Each contribution is enriched with the component's LimeWebComponentContext.

      Returns GatheredAIContext[]

      An array of enriched context contributions, one from each provider that returned a non-null contribution.

    • Alpha

      Get all registered providers.

      Useful for debugging or introspection.

      Returns AIContextProvider[]

      Array of all registered providers.

    • Alpha

      Register a context provider.

      The provider will be called when context is gathered via gatherContext(). Multiple providers with the same contextType can coexist - each registration gets a unique internal key.

      Parameters

      • provider: AIContextProvider

        The provider to register.

      • element: HTMLElement & LimeWebComponent

        The host element of the component registering this provider. Enables the registry to:

        • Read the component's LimeWebComponentContext to enrich contributions
        • Skip providers whose elements are not currently connected to the DOM

      Returns () => void

      A function to unregister the provider. Call this when the component is disconnected or the context is no longer relevant.

      const unregister = registry.register({
      contextType: 'deal-card',
      getContext: () => ({
      purpose: 'Shows full details of a deal record. ' +
      'Users can edit fields and manage related records.',
      data: {
      limetype: 'deal',
      id: this.dealId,
      descriptive: this.deal.descriptive
      }
      })
      }, this.host);

      // Later, when component is disconnected:
      unregister();