Class DeltaChoice

java.lang.Object
nl.dannyj.mistral.models.completion.DeltaChoice

public class DeltaChoice extends Object
Represents a delta update within a choice during a streamed chat completion. Contains partial information about the message delta.
  • Constructor Details

    • DeltaChoice

      public DeltaChoice(int index, DeltaMessage delta, @Nullable FinishReason finishReason)
      Creates a new DeltaChoice instance.
      Parameters:
      index - The index of the choice. Starts at 0.
      delta - The delta message object.
      finishReason - Reason for the completion to finish. Can be null if the stream is not finished.
    • DeltaChoice

      public DeltaChoice()
  • Method Details

    • getTextContent

      @Nullable public String getTextContent()
      Gets the text content of the delta. This is a convenience method that extracts the text from all TextChunks, ignoring other types of content.
      Returns:
      The concatenated text content of the message from the delta, or null if the delta is null.
    • getIndex

      public int getIndex()
      The index of the choice. Starts at 0.
      Returns:
      the index of the choice
    • getDelta

      public DeltaMessage getDelta()
      The delta containing partial message updates.
      Returns:
      The delta message object.
    • getFinishReason

      @Nullable public FinishReason getFinishReason()
      Reason for the completion to finish. Can be null if the stream is not finished.
      Returns:
      the reason for the completion to finish, or null.
    • toString

      public String toString()
      Overrides:
      toString in class Object