Package ai.picovoice.picollm
Class PicoLLMDialog
- java.lang.Object
-
- ai.picovoice.picollm.PicoLLMDialog
-
- Direct Known Subclasses:
GemmaChatDialog,Llama2ChatDialog,Llama3ChatDialog,MistralChatDialog,Phi2Dialog,Phi3ChatDialog
public class PicoLLMDialog extends java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPicoLLMDialog.BuilderBuilder class for constructing instances of PicoLLMDialog.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Integerhistoryprotected java.util.ArrayList<java.lang.String>humanRequestsprotected java.util.ArrayList<java.lang.String>llmResponsesprotected java.lang.Stringsystem
-
Constructor Summary
Constructors Modifier Constructor Description protectedPicoLLMDialog(java.lang.Integer history, java.lang.String system)Constructs a new instance of PicoLLMDialog with the specified history and system settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHumanRequest(java.lang.String content)Adds a human request to the dialog.voidaddLLMResponse(java.lang.String content)Adds an LLM response to the dialog.java.lang.StringgetPrompt()Creates a prompt string given parameters passed the constructor and dialog's content.
-
-
-
Constructor Detail
-
PicoLLMDialog
protected PicoLLMDialog(java.lang.Integer history, java.lang.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 Detail
-
addHumanRequest
public void addHumanRequest(java.lang.String content) throws PicoLLMInvalidStateExceptionAdds 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(java.lang.String content) throws PicoLLMInvalidStateExceptionAdds 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 java.lang.String getPrompt() throws PicoLLMExceptionCreates a prompt string given parameters passed the constructor and dialog's content.- Returns:
- Formatted prompt.
- Throws:
PicoLLMException- if called from the base PicoLLMDialog class.
-
-