Class GPTChatRequest
- java.lang.Object
-
- com.composum.ai.backend.base.service.chat.GPTChatRequest
-
public class GPTChatRequest extends Object
A request to ChatGPT.
-
-
Constructor Summary
Constructors Constructor Description GPTChatRequest()
GPTChatRequest(GPTConfiguration configuration)
GPTChatRequest(List<GPTChatMessage> messages)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GPTChatRequest
addMessage(GPTMessageRole role, String content)
Builder style adding of messages.GPTChatRequest
addMessages(List<GPTChatMessage> messages)
Builder style adding of messages.boolean
equals(Object o)
GPTConfiguration
getConfiguration()
Sets the LLM configurationInteger
getMaxTokens()
Optionally the maximum number of tokens (approx.List<GPTChatMessage>
getMessages()
Returns the chat messages set withaddMessage(GPTMessageRole, String)
.int
hashCode()
void
mergeIn(GPTChatRequest additionalParameters)
Merges in additional parameters: maxtokens overwrites, if there is a system message it's appended to the current one, and the other messages are added at the back.static GPTChatRequest
ofMaxTokens(Integer maxTokens)
Returns a new request with either maxTokens set if that's given, or just an empty request.GPTChatRequest
setConfiguration(GPTConfiguration configuration)
Optionally, sets the configuration.GPTChatRequest
setMaxTokens(Integer maxTokens)
Optionally, sets the maximum number of tokens (approx.String
toString()
-
-
-
Constructor Detail
-
GPTChatRequest
public GPTChatRequest()
-
GPTChatRequest
public GPTChatRequest(List<GPTChatMessage> messages)
-
GPTChatRequest
public GPTChatRequest(GPTConfiguration configuration)
-
-
Method Detail
-
addMessage
public GPTChatRequest addMessage(GPTMessageRole role, String content)
Builder style adding of messages.- Returns:
- this
-
addMessages
public GPTChatRequest addMessages(List<GPTChatMessage> messages)
Builder style adding of messages.- Returns:
- this
-
getMessages
@Nonnull public List<GPTChatMessage> getMessages()
Returns the chat messages set withaddMessage(GPTMessageRole, String)
.
-
setMaxTokens
public GPTChatRequest setMaxTokens(Integer maxTokens)
Optionally, sets the maximum number of tokens (approx. 0.75 words).
-
ofMaxTokens
@Nonnull public static GPTChatRequest ofMaxTokens(@Nullable Integer maxTokens)
Returns a new request with either maxTokens set if that's given, or just an empty request.
-
setConfiguration
public GPTChatRequest setConfiguration(@Nullable GPTConfiguration configuration)
Optionally, sets the configuration.
-
getConfiguration
@Nullable public GPTConfiguration getConfiguration()
Sets the LLM configuration
-
getMaxTokens
public Integer getMaxTokens()
Optionally the maximum number of tokens (approx. 0.75 words).
-
mergeIn
public void mergeIn(@Nullable GPTChatRequest additionalParameters)
Merges in additional parameters: maxtokens overwrites, if there is a system message it's appended to the current one, and the other messages are added at the back.- Throws:
IllegalArgumentException
- if we already have a configuration and the additional parameters have a different one
-
-