Class PicoLLMDialog

java.lang.Object
ai.picovoice.picollm.PicoLLMDialog
Direct Known Subclasses:
GemmaChatDialog, Llama2ChatDialog, Llama3ChatDialog, MistralChatDialog, Phi2Dialog, Phi3ChatDialog

public class PicoLLMDialog extends Object
`PicoLLMDialog` is a helper class that stores a chat dialog and formats it according to an instruction-tuned LLM's chat template. `PicoLLMDialog` is the base class. Each supported instruction-tuned LLM has an accompanying concrete subclass.
  • Field Details

  • Constructor Details

    • PicoLLMDialog

      protected PicoLLMDialog(Integer history, String system)
      Constructs a new instance of PicoLLMDialog with the specified history and system settings.
      Parameters:
      history - The history length for the dialog.
      system - The system instruction for configuring the model's responses.
  • Method Details

    • addHumanRequest

      public void addHumanRequest(String content) throws PicoLLMInvalidStateException
      Adds a human request to the dialog.
      Parameters:
      content - The human request to add.
      Throws:
      PicoLLMInvalidStateException - if adding a human request without a corresponding LLM response.
    • addLLMResponse

      public void addLLMResponse(String content) throws PicoLLMInvalidStateException
      Adds an LLM response to the dialog.
      Parameters:
      content - The LLM response to add.
      Throws:
      PicoLLMInvalidStateException - if adding an LLM response without a corresponding human request.
    • getPrompt

      public String getPrompt() throws PicoLLMException
      Creates a prompt string given parameters passed the constructor and dialog's content.
      Returns:
      Formatted prompt.
      Throws:
      PicoLLMException - if called from the base PicoLLMDialog class.