Package chat.octet.model.utils
Class ChatFormatter
java.lang.Object
chat.octet.model.utils.ChatFormatter
Chat formatter.
Provides a standardized method for handling and displaying chat prompts,
ensuring consistency and readability of the chat messages.
- Author:
- William
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChatFormatter(String template) ChatFormatter(String template, String bos, String eos) -
Method Summary
Modifier and TypeMethodDescriptionformat(boolean addGenerationPrompt, ChatMessage... messages) Formats a prompt text based on the provided chat messages.format(ChatMessage... messages) Formats a prompt text based on the provided chat messages.Formats a prompt text based on the provided user question.Formats a prompt text based on the provided system prompt and user question.
-
Field Details
-
DEFAULT_COMMON_SYSTEM
Default system prompt.- See Also:
-
CHATML_CHAT_TEMPLATE
- See Also:
-
CHATML_BOS_TOKEN
- See Also:
-
CHATML_EOS_TOKEN
- See Also:
-
-
Constructor Details
-
ChatFormatter
-
ChatFormatter
-
ChatFormatter
public ChatFormatter()
-
-
Method Details
-
format
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
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
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
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.
-