Record Class AiResponse

java.lang.Object
java.lang.Record
com.shaft.pilot.ai.AiResponse
Record Components:
schemaVersion - response contract version
status - normalized outcome
provider - provider identifier
model - model or configuration identifier
structuredPayload - validated provider payload
warnings - safe warnings
duration - request duration
usage - provider-reported usage
fallbackReason - safe fallback reason
deterministicFallback - caller-owned deterministic result

public record AiResponse(String schemaVersion, AiResponseStatus status, String provider, String model, com.fasterxml.jackson.databind.JsonNode structuredPayload, List<String> warnings, Duration duration, AiUsage usage, String fallbackReason, com.fasterxml.jackson.databind.JsonNode deterministicFallback) extends Record
Provider-neutral AI result with deterministic fallback.
  • Field Details

  • Constructor Details

    • AiResponse

      public AiResponse(String schemaVersion, AiResponseStatus status, String provider, String model, com.fasterxml.jackson.databind.JsonNode structuredPayload, List<String> warnings, Duration duration, AiUsage usage, String fallbackReason, com.fasterxml.jackson.databind.JsonNode deterministicFallback)
      Creates an immutable response.
  • Method Details

    • success

      public static AiResponse success(String provider, String model, com.fasterxml.jackson.databind.JsonNode payload, Duration duration, AiUsage usage, com.fasterxml.jackson.databind.JsonNode fallback)
      Creates a successful response.
      Parameters:
      provider - provider identifier
      model - model identifier
      payload - structured payload
      duration - request duration
      usage - usage metadata
      fallback - deterministic fallback retained for caller reference
      Returns:
      successful response
    • failure

      public static AiResponse failure(AiResponseStatus status, String provider, String model, String reason, Duration duration, com.fasterxml.jackson.databind.JsonNode fallback)
      Creates a safe failure response that returns the deterministic result.
      Parameters:
      status - normalized failure
      provider - provider identifier
      model - model identifier
      reason - safe reason
      duration - elapsed duration
      fallback - deterministic result
      Returns:
      failure response
    • successful

      public boolean successful()
      Returns whether provider output was accepted.
      Returns:
      true only for successful output
    • 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.
    • schemaVersion

      public String schemaVersion()
      Returns the value of the schemaVersion record component.
      Returns:
      the value of the schemaVersion record component
    • status

      public AiResponseStatus status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • provider

      public String provider()
      Returns the value of the provider record component.
      Returns:
      the value of the provider record component
    • model

      public String model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component
    • structuredPayload

      public com.fasterxml.jackson.databind.JsonNode structuredPayload()
      Returns the value of the structuredPayload record component.
      Returns:
      the value of the structuredPayload record component
    • warnings

      public List<String> warnings()
      Returns the value of the warnings record component.
      Returns:
      the value of the warnings record component
    • duration

      public Duration duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration record component
    • usage

      public AiUsage usage()
      Returns the value of the usage record component.
      Returns:
      the value of the usage record component
    • fallbackReason

      public String fallbackReason()
      Returns the value of the fallbackReason record component.
      Returns:
      the value of the fallbackReason record component
    • deterministicFallback

      public com.fasterxml.jackson.databind.JsonNode deterministicFallback()
      Returns the value of the deterministicFallback record component.
      Returns:
      the value of the deterministicFallback record component