Module org.elasticsearch.server
Class ReasoningDetail
java.lang.Object
org.elasticsearch.inference.completion.ReasoningDetail
- All Implemented Interfaces:
NamedWriteable,Writeable,ChunkedToXContent,ChunkedToXContentObject,ToXContent,ToXContentObject
- Direct Known Subclasses:
ReasoningDetail.EncryptedReasoningDetail,ReasoningDetail.SummaryReasoningDetail,ReasoningDetail.TextReasoningDetail
public abstract sealed class ReasoningDetail
extends Object
implements ToXContentObject, ChunkedToXContentObject, NamedWriteable
permits ReasoningDetail.EncryptedReasoningDetail, ReasoningDetail.SummaryReasoningDetail, ReasoningDetail.TextReasoningDetail
This class represents the reasoning detail for a message. It is a sealed class that has three implementations:
ReasoningDetail.EncryptedReasoningDetail: contains encrypted reasoning data.ReasoningDetail.SummaryReasoningDetail: contains a summary of the reasoning.ReasoningDetail.TextReasoningDetail: may contain the reasoning in text form and/or a signature for the reasoning.
The type of the reasoning detail is determined by the type field, which is required for all reasoning details.
Depending on the value of the type field, different fields are required or optional for the reasoning detail.
Used for both request and response Chat Completion objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThis class represents a reasoning detail, which contains encrypted reasoning data.static enumThe type of the reasoning detail, which determines the required and optional fields for the detail.static final classThis class represents a reasoning detail, which contains a summary of the reasoning.static final classThis class represents a reasoning detail, which may contain the reasoning in text form and/or a signature for the reasoning.Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConstructingObjectParser<ReasoningDetail, Void> The request parser does not ignore unknown fields, as we want to enforce strict validation of the reasoning details in the request.static final ConstructingObjectParser<ReasoningDetail, Void> The response parser ignores unknown fields to allow flexibility as the provider may add additional fields to the reasoning details, and we don't want to break parsing of the response if that happens.Fields inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
EMPTYFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedReasoningDetail(String format, String id, Long index) protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanformat()inthashCode()id()index()booleantoXContent(XContentBuilder builder, ToXContent.Params params) Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params) Create an iterator ofToXContentchunks for a REST response.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
toXContentChunked, toXContentChunkedV8Methods inherited from interface org.elasticsearch.common.io.stream.NamedWriteable
getWriteableName
-
Field Details
-
REQUEST_PARSER
The request parser does not ignore unknown fields, as we want to enforce strict validation of the reasoning details in the request. -
RESPONSE_PARSER
The response parser ignores unknown fields to allow flexibility as the provider may add additional fields to the reasoning details, and we don't want to break parsing of the response if that happens. Validation of fields is not enforced for the response parser, as the response is generated by the provider
-
-
Constructor Details
-
ReasoningDetail
-
ReasoningDetail
- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
toXContentChunked
Description copied from interface:ChunkedToXContentCreate an iterator ofToXContentchunks for a REST response. Each chunk is serialized with the sameXContentBuilderandToXContent.Params, which is also the same as theToXContent.Paramspassed as theparamsargument. For best results, all chunks should beO(1)size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelperfor some handy utilities.Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
- Specified by:
toXContentChunkedin interfaceChunkedToXContent- Returns:
- iterator over chunks of
ToXContent
-
format
-
id
-
index
-
equals
-
hashCode
public int hashCode() -
isFragment
public boolean isFragment()- Specified by:
isFragmentin interfaceChunkedToXContent- Specified by:
isFragmentin interfaceChunkedToXContentObject- Specified by:
isFragmentin interfaceToXContent- Specified by:
isFragmentin interfaceToXContentObject- Returns:
- true iff this instance serializes as a fragment. See
ToXContentObjectfor additional details.
-