Class ChatGPTInput

java.lang.Object
com.intellijava.core.model.input.ChatModelInput
com.intellijava.core.model.input.ChatGPTInput

public class ChatGPTInput extends ChatModelInput
ChatGPTInput contains a list of messages to continue the conversation with the chatbot.
Author:
github.com/Barqawiz
  • Constructor Details

    • ChatGPTInput

      public ChatGPTInput(ChatGPTMessage systemMessage)
      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

      public ChatGPTInput(String systemPrompt)
      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

      public void addMessage(ChatGPTMessage message)
      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

      public void addUserMessage(String prompt)
      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

      public boolean deleteLastMessage(ChatGPTMessage message)
      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

      public List<ChatGPTMessage> 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

      public String getModel()
      Gets the model.
      Returns:
      model
    • setModel

      public void setModel(String model)
      Sets the model.
      Parameters:
      model - chatGPT model name, default is gpt-3.5-turbo.