Class ChatCompletionAccumulator

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • chatCompletion

         final ChatCompletion chatCompletion()

        Gets the final accumulated chat completion. Until the last chunk has been accumulated, a ChatCompletion will not be available. Wait until all chunks have been handled by accumulate before calling this method. See that method for more details on how the last chunk is detected.

      • accumulate

         final ChatCompletionChunk accumulate(ChatCompletionChunk chunk)

        Accumulates a streamed chunk and uses it to construct a ChatCompletion. When all chunks have been accumulated, the chat completion can be retrieved by calling chatCompletion.

        The last chunk is identified as that which provides the finishReason. At that point, the ChatCompletion is created and available. However, if the request was configured to include the usage details, one additional chunk may be accumulated which provides those usage details and the ChatCompletion will be recreated to reflect them. After that, no more chunks of any kind may be accumulated.

        Returns:

        The given chunk for convenience, such as when chaining method calls.