Class OpenAIRequestBody

java.lang.Object
com.developer.nefarious.zjoule.plugin.chat.openai.OpenAIRequestBody

public class OpenAIRequestBody extends Object
Represents the request body for an OpenAI chat completion API call. This class encapsulates the parameters required by the OpenAI API, including chat messages, maximum tokens, temperature, penalties, and stop sequences.
  • Constructor Details

    • OpenAIRequestBody

      public OpenAIRequestBody()
  • Method Details

    • getFrequencyPenalty

      public double getFrequencyPenalty()
      Retrieves the frequency penalty applied to the response.
      Returns:
      the frequency penalty as a double.
    • getMaxTokens

      public int getMaxTokens()
      Retrieves the maximum number of tokens allowed in the response.
      Returns:
      the maximum token limit as an int.
    • getMessages

      public List<IChatMessage> getMessages()
      Retrieves the list of chat messages in the request.
      Returns:
      a List of IChatMessage objects.
    • getPresencePenalty

      public double getPresencePenalty()
      Retrieves the presence penalty applied to the response.
      Returns:
      the presence penalty as a double.
    • getStop

      public String getStop()
      Retrieves the stop sequence used to terminate the AI's response.
      Returns:
      the stop sequence as a String.
    • getTemperature

      public double getTemperature()
      Retrieves the temperature parameter for the AI's response.
      Returns:
      the temperature as a double.
    • setFrequencyPenalty

      public void setFrequencyPenalty(double frequencyPenalty)
      Sets the frequency penalty applied to the response.
      Parameters:
      frequencyPenalty - the frequency penalty as a double.
    • setMaxTokens

      public void setMaxTokens(int maxTokens)
      Sets the maximum number of tokens allowed in the response.
      Parameters:
      maxTokens - the maximum token limit as an int.
    • setMessages

      public void setMessages(List<IChatMessage> messages)
      Sets the list of chat messages in the request.
      Parameters:
      messages - a List of IChatMessage objects.
    • setPresencePenalty

      public void setPresencePenalty(double presencePenalty)
      Sets the presence penalty applied to the response.
      Parameters:
      presencePenalty - the presence penalty as a double.
    • setStop

      public void setStop(String stop)
      Sets the stop sequence used to terminate the AI's response.
      Parameters:
      stop - the stop sequence as a String.
    • setTemperature

      public void setTemperature(double temperature)
      Sets the temperature parameter for the AI's response.
      Parameters:
      temperature - the temperature as a double.
    • toString

      public String toString()
      Serializes this object to its JSON representation using Gson. The Role.RoleSerializer is registered to handle role serialization.
      Overrides:
      toString in class Object
      Returns:
      the JSON representation of this request body as a String.