MAIDR JavaScript API
    Preparing search index...

    Class ChatService

    Service for managing chat interactions with different LLM providers.

    Index

    Constructors

    Methods

    • Sends a message to the specified LLM model and returns the response.

      Parameters

      • model: Llm

        The LLM provider to use

      • request: LlmRequest

        The request containing the message and configuration

      Returns Promise<LlmResponse>

      The response from the LLM

    • Returns the serialized chart data shared with all LLM providers, serializing on first use after a data change and caching thereafter.

      Exposed for the LLM model suppliers and tests; the caching strategy is an implementation detail and not part of the stable public API.

      Returns string

      The current chart data as a JSON string

    • Freezes what the AI is grounded on: the plot image exactly as it looks now (highlight on the focused point included), the verbose description of that point, and the MAIDR JSON.

      Call it at the moment the user triggers a question and hand the result to every provider answering it, so they share one rasterisation and none of them sees a plot the user has since navigated away from. The plot is serialised synchronously inside this call; only the decode and JPEG encoding that follow are asynchronous, and they work from that copy.

      Returns ChatSnapshot

      The frozen context for one question

    • Refreshes the chart data shared with the LLM providers after a live data update, so AI answers reflect the data currently on screen. Serialization is deferred until the next LLM request.

      Parameters

      • maidr: Maidr

        The updated MAIDR data structure

      Returns void

    • Aborts any in-flight LLM requests and releases their resources. Invoked from Controller.dispose() when the plot loses focus, so a slow provider cannot keep the request continuation (and its waiting tone) alive for the full request timeout after disposal.

      Returns void