Class AIOrchestrator.Reconnector

java.lang.Object
com.vaadin.flow.component.ai.orchestrator.AIOrchestrator.Reconnector
Enclosing class:
AIOrchestrator

public static class AIOrchestrator.Reconnector extends Object
Fluent API for restoring transient dependencies on an AIOrchestrator after deserialization. Obtain an instance via AIOrchestrator.reconnect(LLMProvider).

The provider is specified when the reconnector is created. Optional transient dependencies (tools and file attachments) can be restored via chained methods before calling apply(). The apply() call replays the existing conversation history onto the new provider but does not modify the UI.

 orchestrator.reconnect(provider).withTools(toolObj) // optional
         .withAttachments(attachmentsByMsgId) // optional
         .apply();
 
  • Method Details

    • withTools

      public AIOrchestrator.Reconnector withTools(Object... tools)
      Sets the objects containing vendor-specific tool-annotated methods that will be available to the LLM.
      Parameters:
      tools - the objects containing tool methods
      Returns:
      this reconnector
    • withAttachments

      public AIOrchestrator.Reconnector withAttachments(Map<String,List<AIAttachment>> attachmentsByMessageId)
      Sets the file attachments to restore on the new provider's conversation memory. The map is keyed by ChatMessage.messageId() and contains the list of AIAttachment objects for each message.

      Attachments are not stored in the orchestrator's conversation history. If the application persisted attachment data via AttachmentSubmitListener before serialization, pass it here so the new provider can reconstruct multimodal context. Pass Collections.emptyMap() (the default) if there are no attachments to restore.

      The UI is not affected by this method; attachment thumbnails in the message list are preserved across serialization automatically.

      Parameters:
      attachmentsByMessageId - a map from message ID to attachment list
      Returns:
      this reconnector
    • apply

      public void apply()
      Applies the reconnection, restoring the provider, tools, and conversation history on the new provider. The existing conversation history is replayed onto the new provider's memory so that it has full context for subsequent prompts.

      The UI (message list, input, file receiver) is not modified -- those components survive serialization and retain their state automatically.