Package com.intellijava.core.model.input
Class ChatGPTInput
java.lang.Object
com.intellijava.core.model.input.ChatModelInput
com.intellijava.core.model.input.ChatGPTInput
ChatGPTInput contains a list of messages to continue the conversation with
the chatbot.
- Author:
- github.com/Barqawiz
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder class for ChatGPTInput. -
Constructor Summary
ConstructorDescriptionChatGPTInput
(ChatGPTMessage systemMessage) Create ChatGPT input object with the system instruction.ChatGPTInput
(String systemPrompt) Create ChatGPT input object with the system instruction. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessage
(ChatGPTMessage message) Add input message.void
addUserMessage
(String prompt) Add input message for your prompt.void
Remove all messages except the system message.boolean
deleteLastMessage
(ChatGPTMessage message) Delete last added message with the same message.getContent() and message.getRole().int
Gets the maxTokens.Gets all messages.getModel()
Gets the model.int
Gets the number of model outputs.float
Gets the temperature of the ChatGPTInput object.void
setMaxTokens
(int maxTokens) Sets the maxTokens.void
Sets the model.void
setNumberOfOutputs
(int numberOfOutputs) Sets the numberOfOutputs.void
setTemperature
(float temperature) Sets the temperature.
-
Constructor Details
-
ChatGPTInput
Create ChatGPT input object with the system instruction. Example of general system instruction: You are a helpful assistant.- Parameters:
systemMessage
- the system instruction to define the chat mode/theme.
-
ChatGPTInput
Create ChatGPT input object with the system instruction. Example of general system instruction: You are a helpful assistant.- Parameters:
systemPrompt
- string input to define the chat mode/theme.
-
-
Method Details
-
addMessage
Add input message. Example of chat flow: system: You are a helpful assistant. user: Who won the world series in 2020? assistant: The Los Angeles Dodgers won the World Series in 2020. user: Where was it played?- Parameters:
message
- chat input element with defined role.
-
addUserMessage
Add input message for your prompt.- Parameters:
prompt
- users input (query).
-
cleanMessages
public void cleanMessages()Remove all messages except the system message. To start new system, create a new object. -
deleteLastMessage
Delete last added message with the same message.getContent() and message.getRole().- Parameters:
message
- The message to delete- Returns:
- true if a message was deleted, false otherwise
-
getMessages
Gets all messages.- Returns:
- list of messages
-
getTemperature
public float getTemperature()Gets the temperature of the ChatGPTInput object.- Returns:
- temperature.
-
setTemperature
public void setTemperature(float temperature) Sets the temperature.- Parameters:
temperature
- higher values means more risks and creativity.
-
getNumberOfOutputs
public int getNumberOfOutputs()Gets the number of model outputs.- Returns:
- numberOfOutputs
-
setNumberOfOutputs
public void setNumberOfOutputs(int numberOfOutputs) Sets the numberOfOutputs.- Parameters:
numberOfOutputs
- number of model outputs, default value is 1.
-
getMaxTokens
public int getMaxTokens()Gets the maxTokens.- Returns:
- maxTokens
-
setMaxTokens
public void setMaxTokens(int maxTokens) Sets the maxTokens.- Parameters:
maxTokens
- maximum size of the model input and output.
-
getModel
Gets the model.- Returns:
- model
-
setModel
Sets the model.- Parameters:
model
- chatGPT model name, default is gpt-3.5-turbo.
-