Class AiOrchestrator
This class is a generic coordination engine that connects UI components with an LLM provider. 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
.withAiName(aiName) // 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 Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic AiOrchestrator.Builderbuilder(LLMProvider provider) Creates a new builder for AiOrchestrator.static 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.- Parameters:
provider- the LLM provider- Returns:
- a new builder
-
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
-