Class AssistantMessage.Builder<B extends AssistantMessage.Builder<B>>
java.lang.Object
org.springframework.ai.chat.messages.AssistantMessage.Builder<B>
- Type Parameters:
B- the concrete builder type, for subclass builders
- Direct Known Subclasses:
DeepSeekAssistantMessage.AbstractBuilder
- Enclosing class:
- AssistantMessage
Builder for
AssistantMessage.
Parts added through part(MessagePart), parts(List) and
reasoning(ReasoningPart) come first, in the order they were added. The
legacy setters (content(String), toolCalls(List),
media(List)) are stored and materialized after them at build()
time in the legacy order (text, tool calls, media), so the setter call order does
not affect the result.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable Stringprotected final List<MessagePart>protected List<AssistantMessage.ToolCall> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()protected List<MessagePart>The parts this builder would put in the message: explicit parts first, then the legacy text, tool calls and media in that order.part(MessagePart part) Appends a content part.parts(List<MessagePart> parts) Appends content parts in order.properties(Map<String, Object> properties) reasoning(List<ReasoningPart> reasoning) Appends reasoning parts in order.reasoning(ReasoningPart reasoning) Appends a reasoning part.protected Bself()protected booleantoolCalls(List<AssistantMessage.ToolCall> toolCalls)
-
Field Details
-
explicitParts
-
-
properties
-
toolCalls
-
media
-
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
self
-
part
Appends a content part.- Parameters:
part- the part- Returns:
- this builder
- Since:
- 2.1.0
-
supportsParts
protected boolean supportsParts()Whetherbuild()of this builder honorspart(MessagePart),parts(List)andreasoning(ReasoningPart). The base builder does. A subclass builder that overridesbuild()must override this method to returntrueand construct its message frombuildParts(); otherwisepart(MessagePart)throws so parts are never dropped silently.- Returns:
- whether explicit parts are supported
- Since:
- 2.1.0
-
buildParts
The parts this builder would put in the message: explicit parts first, then the legacy text, tool calls and media in that order.- Returns:
- the parts, in message order
- Since:
- 2.1.0
-
parts
Appends content parts in order.- Parameters:
parts- the parts- Returns:
- this builder
- Since:
- 2.1.0
-
reasoning
- Parameters:
reasoning- the reasoning part- Returns:
- this builder
- Since:
- 2.1.0
-
reasoning
Appends reasoning parts in order.- Parameters:
reasoning- the reasoning parts- Returns:
- this builder
- Since:
- 2.1.0
-
content
-
properties
-
toolCalls
-
media
-
build
-