Package dev.dokimos.springai.alibaba
Record Class SpringAiAlibabaSupport.AlibabaAgentResponse
java.lang.Object
java.lang.Record
dev.dokimos.springai.alibaba.SpringAiAlibabaSupport.AlibabaAgentResponse
- Record Components:
text- the agent's output text, or null (stored as an empty string)tokensIn- prompt tokens, or null if not availabletokensOut- completion tokens, or null if not available
- Enclosing class:
SpringAiAlibabaSupport
public static record SpringAiAlibabaSupport.AlibabaAgentResponse(String text, Integer tokensIn, Integer tokensOut)
extends Record
A Spring AI Alibaba agent run's output text paired with optional token usage, consumed by
SpringAiAlibabaSupport.measuredAsyncTask(Function, String, PriceTable).
A graph/agent run does not surface Spring AI Usage
on its result (see the class-level "Measured tasks" note), so this carrier lets you supply the
counts you obtain from your own Alibaba setup (a usage callback on the underlying
ChatModel, the AssistantMessage metadata, etc.). Leave
tokensIn()/tokensOut() null when you have no counts: latency is still captured
automatically and the Cost/Tokens cards simply stay dark. Counts you do supply are taken at face
value — an explicit 0 is recorded as zero, not coalesced to null the way the
framework-reading adapters (LangChain4j, Spring AI, Embabel) treat an all-zero usage sentinel,
since here the caller owns the values.
-
Constructor Summary
ConstructorsConstructorDescriptionAlibabaAgentResponse(String text, Integer tokensIn, Integer tokensOut) Creates an instance of aAlibabaAgentResponserecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Creates a response carrying output text only, with no token counts (latency-only metrics).text()Returns the value of thetextrecord component.tokensIn()Returns the value of thetokensInrecord component.Returns the value of thetokensOutrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
of
Creates a response carrying output text only, with no token counts (latency-only metrics).- Parameters:
text- the agent's output text, or null- Returns:
- a response with null token counts
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
text
Returns the value of thetextrecord component.- Returns:
- the value of the
textrecord component
-
tokensIn
Returns the value of thetokensInrecord component.- Returns:
- the value of the
tokensInrecord component
-
tokensOut
Returns the value of thetokensOutrecord component.- Returns:
- the value of the
tokensOutrecord component
-