Record Class AiResponse
java.lang.Object
java.lang.Record
com.shaft.pilot.ai.AiResponse
- Record Components:
schemaVersion- response contract versionstatus- normalized outcomeprovider- provider identifiermodel- model or configuration identifierstructuredPayload- validated provider payloadwarnings- safe warningsduration- request durationusage- provider-reported usagefallbackReason- safe fallback reasondeterministicFallback- 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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAiResponse(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 Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.JsonNodeReturns the value of thedeterministicFallbackrecord component.duration()Returns the value of thedurationrecord component.final booleanIndicates whether some other object is "equal to" this one.static AiResponsefailure(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.Returns the value of thefallbackReasonrecord component.final inthashCode()Returns a hash code value for this object.model()Returns the value of themodelrecord component.provider()Returns the value of theproviderrecord component.Returns the value of theschemaVersionrecord component.status()Returns the value of thestatusrecord component.com.fasterxml.jackson.databind.JsonNodeReturns the value of thestructuredPayloadrecord component.static AiResponsesuccess(String provider, String model, com.fasterxml.jackson.databind.JsonNode payload, Duration duration, AiUsage usage, com.fasterxml.jackson.databind.JsonNode fallback) Creates a successful response.booleanReturns whether provider output was accepted.final StringtoString()Returns a string representation of this record class.usage()Returns the value of theusagerecord component.warnings()Returns the value of thewarningsrecord component.
-
Field Details
-
CURRENT_SCHEMA_VERSION
- See Also:
-
-
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 identifiermodel- model identifierpayload- structured payloadduration- request durationusage- usage metadatafallback- 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 failureprovider- provider identifiermodel- model identifierreason- safe reasonduration- elapsed durationfallback- deterministic result- Returns:
- failure response
-
successful
public boolean successful()Returns whether provider output was accepted.- Returns:
trueonly for successful output
-
toString
-
hashCode
-
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). -
schemaVersion
Returns the value of theschemaVersionrecord component.- Returns:
- the value of the
schemaVersionrecord component
-
status
-
provider
-
model
-
structuredPayload
public com.fasterxml.jackson.databind.JsonNode structuredPayload()Returns the value of thestructuredPayloadrecord component.- Returns:
- the value of the
structuredPayloadrecord component
-
warnings
-
duration
-
usage
-
fallbackReason
Returns the value of thefallbackReasonrecord component.- Returns:
- the value of the
fallbackReasonrecord component
-
deterministicFallback
public com.fasterxml.jackson.databind.JsonNode deterministicFallback()Returns the value of thedeterministicFallbackrecord component.- Returns:
- the value of the
deterministicFallbackrecord component
-