Class ChatFormatter

java.lang.Object
chat.octet.model.utils.ChatFormatter

public class ChatFormatter extends Object
Chat formatter. Provides a standardized method for handling and displaying chat prompts, ensuring consistency and readability of the chat messages.
Author:
William
  • Field Details

  • Constructor Details

    • ChatFormatter

      public ChatFormatter(String template, String bos, String eos)
    • ChatFormatter

      public ChatFormatter(String template)
    • ChatFormatter

      public ChatFormatter()
  • Method Details

    • format

      public String format(boolean addGenerationPrompt, ChatMessage... messages)
      Formats a prompt text based on the provided chat messages.
      Parameters:
      addGenerationPrompt - A flag indicating whether to add a generation prompt. If true, a generation prompt will be added to the generated text.
      messages - The chat messages to be formatted. This is a variable argument parameter, allowing for the passing of multiple chat messages.
      Returns:
      The formatted prompt text string.
      Throws:
      NullPointerException - if the chat messages array is null.
    • format

      public String format(ChatMessage... messages)
      Formats a prompt text based on the provided chat messages.
      Parameters:
      messages - The chat messages to be formatted. This is a variable argument parameter, allowing for the passing of multiple chat messages.
      Returns:
      The formatted prompt text string.
      Throws:
      NullPointerException - if the chat messages array is null.
    • format

      public String format(String system, String question)
      Formats a prompt text based on the provided system prompt and user question.
      Parameters:
      system - The system prompt text.
      question - The user's question to be incorporated into the prompt text.
      Returns:
      The formatted prompt text string.
      Throws:
      NullPointerException - If the user question is null.
    • format

      public String format(String question)
      Formats a prompt text based on the provided user question.
      Parameters:
      question - The user's question to be incorporated into the prompt text.
      Returns:
      The formatted prompt text string.
      Throws:
      NullPointerException - If the user question is null.