Class AIOrchestrator
This class is a non-visual coordination engine that connects UI components
with an LLM provider. It is not a UI component itself and should
not be added to a layout or the UI. Instead, add the individual UI
components (e.g. MessageInput, MessageList) to your layout
and pass them to the orchestrator through its AIOrchestrator.Builder. The
orchestrator then wires the components together and manages the LLM
interaction behind the scenes.
It provides:
- LLM integration
- Component wiring (input, message list, file receiver)
- Tool execution coordination
- Programmatic invocation via
prompt(String)
The orchestrator is configured via a fluent builder:
AIOrchestrator orchestrator = AIOrchestrator
.builder(llmProvider, systemPrompt).withInput(messageInput) // optional
.withMessageList(messageList) // optional
.withFileReceiver(upload) // optional
.withTools(toolObj) // optional, for @Tool annotations
.withUserName(userName) // optional
.withAssistantName(assistantName) // optional
.build();
Conversation history is managed internally by the LLMProvider
instance. Each orchestrator maintains its own conversation context through
its provider instance.
Note: AIOrchestrator is not serializable. If your application uses session persistence, you will need to create a new orchestrator instance after session restore.
- Author:
- Vaadin Ltd
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for configuring and creating anAIOrchestratorinstance. -
Method Summary
Modifier and TypeMethodDescriptionstatic AIOrchestrator.Builderbuilder(LLMProvider provider, String systemPrompt) Creates a new builder for AIOrchestrator with a system prompt.voidSends a prompt to the AI orchestrator programmatically.
-
Method Details
-
builder
Creates a new builder for AIOrchestrator with a system prompt.- Parameters:
provider- the LLM providersystemPrompt- the system prompt for the LLM- Returns:
- a new builder
-
prompt
Sends a prompt to the AI orchestrator programmatically. This method allows sending prompts without requiring an input component.This is useful for scenarios where you want to trigger AI interaction from button clicks or other UI events without using a message input component.
If a request is already being processed, this method will log a warning and return without processing the new prompt.
- Parameters:
userMessage- the prompt to send to the AI- Throws:
IllegalStateException- if no UI context is available
-