Vaadin provides a set of UI interfaces and a coordination engine for building AI-powered UIs. The AIOrchestrator wires UI components to an LLM provider, handling streaming responses, conversation history, file attachments, and tool calling behind a simple builder API.
|
Note
|
Preview Feature
This is a preview version of AI support features. You need to enable it with the feature flag |
Overview
The AI support module consists of three parts:
-
Orchestrator —
AIOrchestratoris a non-visual coordination engine that connects UI components to an LLM provider. It has no DOM element and should not be added to a layout. -
Provider —
LLMProvideris the interface for communicating with LLM frameworks. Use the staticLLMProvider.from(…)factory methods to create a provider from a Spring AI or LangChain4j model. You can also implement this interface to connect to any other LLM framework. -
Component interfaces —
AIInput,AIMessageList,AIMessage, andAIFileReceiverdefine contracts for UI components that the orchestrator can work with. The builder also accepts standard Vaadin components (MessageInput,MessageList,UploadManager,Upload) directly.
Add the UI components to your layout and pass them to the orchestrator through its builder. The orchestrator wires them together and manages the LLM interaction.
Basic Usage
Create an AI Orchestrator by passing an LLM provider and optional UI components to the builder. The following example uses a mock provider — replace it with a real provider via LLMProvider.from(…) in production (see LLM Providers).
When the user submits a message through the Message Input, the orchestrator automatically:
-
Displays the user message in the Message List
-
Sends the message to the LLM provider
-
Streams the response tokens into the Message List in real time
-
Records the exchange in the conversation history
By default, user messages are labeled "You" and assistant messages are labeled "Assistant". Use withUserName() and withAssistantName() on the builder to customize these display names.
Server Push
Streaming mode pushes partial responses to the UI as tokens arrive. This requires server push to be enabled. Annotate your application shell with @Push:
Source code
Java
@Push
@SpringBootApplication
public class Application implements AppShellConfigurator {
}|
Tip
| Synchronous mode does not require push. If push is not available in your environment, disable streaming on the provider. A warning is logged at runtime if push is not enabled when using streaming mode. |
Topics
- Component Interfaces
- AI interface contracts for input, message list, message, and file receiver components used by the AIOrchestrator.
- LLM Providers
- Connect the AIOrchestrator to Spring AI, LangChain4j, or a custom LLM framework using the LLMProvider interface.
- File Attachments
- Enable file uploads in the AIOrchestrator to send attachments to the LLM with user prompts.
- Tool Calling & Programmatic Prompts
- Register tool objects for LLM invocation and send prompts programmatically without a Message Input component.
- Conversation History & Session Persistence
- Persist and restore conversation history, and reconnect the AIOrchestrator after session deserialization.