Class Generator

java.lang.Object
chat.octet.model.Generator
All Implemented Interfaces:
Iterator<Token>

public class Generator extends Object implements Iterator<Token>
Generation iterator, which outputs tokens one by one in a stream format.
Author:
William
  • Constructor Details

    • Generator

      protected Generator(GenerateParameter generateParams, String prompt, Status srcStatus)
      Create continuous conversation generator
      Parameters:
      generateParams - Specify a generation parameter.
      prompt - Prompt
      srcStatus - Source status.
    • Generator

      protected Generator(GenerateParameter generateParams, String text)
      Create regular generator
      Parameters:
      generateParams - Specify a generation parameter.
      text - Input text or prompt.
  • Method Details

    • getStatus

      protected Status getStatus()
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Token>
    • next

      public Token next()
      Output next token.
      Specified by:
      next in interface Iterator<Token>
      Returns:
      Token
      See Also:
    • getGeneratedCompleteText

      public String getGeneratedCompleteText()
      Return the generated complete text.
      Returns:
      String
    • getFinishReason

      public FinishReason getFinishReason()
      Return the finished reason for the last token.
      Returns:
      FinishReason, Last token finished reason.
      See Also:
    • clearCache

      public void clearCache()
      Clear context cache at the end of generation