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
  • Constructor Details

    • CompletionOperatorOutputBuilder

      public CompletionOperatorOutputBuilder(BytesRefBlock.Builder outputBlockBuilder, Page inputPage)
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.elasticsearch.core.Releasable
    • addInferenceResponse

      public void addInferenceResponse(InferenceAction.Response inferenceResponse)
      Adds an inference response to the output builder.

      If the response is null or not of type ChatCompletionResults an IllegalStateException is 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:
      addInferenceResponse in interface InferenceOperator.OutputBuilder
      Parameters:
      inferenceResponse - The inference response to include.
    • buildOutput

      public Page buildOutput()
      Builds the final output page by appending the completion output block to a shallow copy of the input page.
      Specified by:
      buildOutput in interface InferenceOperator.OutputBuilder
      Returns:
      The constructed output page.