Record Class ProviderResponse

java.lang.Object
java.lang.Record
ai.doctruth.ProviderResponse
Record Components:
rawJson - the raw JSON body returned by the provider, untouched.
usage - token-usage + model-version metadata for the call.

public record ProviderResponse(String rawJson, ProviderUsage usage) extends Record
What an LlmProvider returns on a successful call: the raw JSON the LLM produced plus the per-call ProviderUsage. The library parses rawJson into the caller's target type via Jackson; providers do not interpret it.

Invariants (compact constructor):

  • rawJson non-null and non-blank.
  • usage non-null.
Since:
0.1.0
  • Constructor Details

    • ProviderResponse

      public ProviderResponse(String rawJson, ProviderUsage usage)
      Creates an instance of a ProviderResponse record class.
      Parameters:
      rawJson - the value for the rawJson record component
      usage - the value for the usage record component
  • Method Details

    • 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.
    • rawJson

      public String rawJson()
      Returns the value of the rawJson record component.
      Returns:
      the value of the rawJson record component
    • usage

      public ProviderUsage usage()
      Returns the value of the usage record component.
      Returns:
      the value of the usage record component