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 available
tokensOut - 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 Details

    • AlibabaAgentResponse

      public AlibabaAgentResponse(String text, Integer tokensIn, Integer tokensOut)
      Creates an instance of a AlibabaAgentResponse record class.
      Parameters:
      text - the value for the text record component
      tokensIn - the value for the tokensIn record component
      tokensOut - the value for the tokensOut record component
  • 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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • tokensIn

      public Integer tokensIn()
      Returns the value of the tokensIn record component.
      Returns:
      the value of the tokensIn record component
    • tokensOut

      public Integer tokensOut()
      Returns the value of the tokensOut record component.
      Returns:
      the value of the tokensOut record component