Class ChatResponse
java.lang.Object
com.codename1.ai.ChatResponse
The terminal response from a chat call. For streaming requests, the
ChatResponse carries the aggregated final assistant message --
the individual deltas were delivered through StreamingListener
before this object was produced.
finishReason is one of: "stop", "length", "tool_calls",
"content_filter", "error" (normalized across providers).
-
Constructor Summary
ConstructorsConstructorDescriptionChatResponse(ChatMessage assistantMessage, List<ToolCall> toolCalls, String finishReason, Usage usage, String modelUsed) Creates a normalized terminal response. -
Method Summary
-
Constructor Details
-
ChatResponse
public ChatResponse(ChatMessage assistantMessage, List<ToolCall> toolCalls, String finishReason, Usage usage, String modelUsed) Creates a normalized terminal response.- Parameters:
assistantMessage- aggregated assistant output, ornulltoolCalls- requested tool calls;nullbecomes emptyfinishReason- normalized provider finish reasonusage- token accounting, ornullmodelUsed- provider-reported model id, ornull
-
-
Method Details
-
getAssistantMessage
- Returns:
- normalized assistant message, including any multimodal parts
-
getToolCalls
-
getText
Convenience: the assembled assistant text. Equivalent togetAssistantMessage().getText()when there is one.- Returns:
- assistant text, or an empty string without a message
-
getFinishReason
- Returns:
- provider finish reason such as
stoporlength
-
getUsage
- Returns:
- token accounting, or
nullwhen the provider omitted it
-
getModelUsed
- Returns:
- provider-reported model id, or
nullwhen omitted
-