Class CompletionOperatorOutputBuilder
java.lang.Object
org.elasticsearch.xpack.esql.inference.completion.CompletionOperatorOutputBuilder
- All Implemented Interfaces:
Closeable,AutoCloseable,org.elasticsearch.core.Releasable,InferenceOperator.OutputBuilder
public class CompletionOperatorOutputBuilder
extends Object
implements InferenceOperator.OutputBuilder
CompletionOperatorOutputBuilder builds the output page for CompletionOperator by converting ChatCompletionResults
into a BytesRefBlock.-
Constructor Summary
ConstructorsConstructorDescriptionCompletionOperatorOutputBuilder(BytesRefBlock.Builder outputBlockBuilder, Page inputPage) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInferenceResponse(InferenceAction.Response inferenceResponse) Adds an inference response to the output builder.Builds the final output page by appending the completion output block to the input page.voidclose()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.xpack.esql.inference.InferenceOperator.OutputBuilder
releasePageOnAnyThread
-
Constructor Details
-
CompletionOperatorOutputBuilder
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.elasticsearch.core.Releasable
-
addInferenceResponse
Adds an inference response to the output builder.If the response is null or not of type
ChatCompletionResultsanIllegalStateExceptionis thrown. Else, the result text is added to the output block.The responses must be added in the same order as the corresponding inference requests were generated. Failing to preserve order may lead to incorrect or misaligned output rows.
- Specified by:
addInferenceResponsein interfaceInferenceOperator.OutputBuilder- Parameters:
inferenceResponse- The inference response to include.
-
buildOutput
Builds the final output page by appending the completion output block to the input page.- Specified by:
buildOutputin interfaceInferenceOperator.OutputBuilder- Returns:
- The constructed output page.
-