Interface ChatExecutor
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAn abstract base-builder class for constructing instances ofChatExecutor.static classStreamingToSynchronousBuilder for constructing instances ofChatExecutor.static classSynchronousBuilder for constructing instances ofChatExecutor. -
Method Summary
Modifier and TypeMethodDescriptionCreates a newChatExecutor.SynchronousBuilderinstance for constructingChatExecutorobjects that perform synchronous chat requests.builder(StreamingChatModel streamingChatModel) Creates a newChatExecutor.StreamingToSynchronousBuilderinstance for constructingChatExecutorobjects that perform streaming chat requests.execute()Execute a chat requestexecute(List<ChatMessage> chatMessages) Executes a chat request using the provided chat messagesdefault CompletableFuture<ChatResponse> Non-blocking counterpart ofexecute().default CompletableFuture<ChatResponse> executeAsync(List<ChatMessage> chatMessages) Non-blocking counterpart ofexecute(List).
-
Method Details
-
execute
-
execute
Executes a chat request using the provided chat messages- Parameters:
chatMessages- The chat messages containing the context of the conversation. It provides the history of messages required for proper interaction with the chat model- Returns:
- A response object containing the AI's response and additional metadata.
-
executeAsync
Non-blocking counterpart ofexecute().The default implementation returns a failed future carrying
AsyncNotSupportedException; the built-in executors override it to call the model without blocking (via the async/reactive model APIs). Used by output-guardrail reprompts on the non-blocking AI Service paths. Consistent withChatModel#doChatAsyncand the other async defaults, a blocking executor is not silently run on the calling thread.- Returns:
- a
CompletableFuturethat completes with the response - Since:
- 1.20.0
-
executeAsync
Non-blocking counterpart ofexecute(List).The default implementation returns a failed future carrying
AsyncNotSupportedException; the built-in executors override it to call the model without blocking (via the async/reactive model APIs). Used by output-guardrail reprompts on the non-blocking AI Service paths. Consistent withChatModel#doChatAsyncand the other async defaults, a blocking executor is not silently run on the calling thread.- Parameters:
chatMessages- The chat messages containing the context of the conversation.- Returns:
- a
CompletableFuturethat completes with the response - Since:
- 1.20.0
-
builder
Creates a newChatExecutor.SynchronousBuilderinstance for constructingChatExecutorobjects that perform synchronous chat requests.- Returns:
- A new
ChatExecutor.SynchronousBuilderinstance to configure and build aChatExecutor.
-
builder
Creates a newChatExecutor.StreamingToSynchronousBuilderinstance for constructingChatExecutorobjects that perform streaming chat requests.- Returns:
- A new
ChatExecutor.StreamingToSynchronousBuilderinstance to configure and build aChatExecutor.
-