Class GPTConfiguration
- java.lang.Object
-
- com.composum.ai.backend.base.service.chat.GPTConfiguration
-
public class GPTConfiguration extends Object
A configuration to use for accessing the external LLM service. That currently contains the API key for ChatGPT, but could later include information about which LLM to use, template language, rate limiting, etc. This can be a separate parameter to a request, or implicitly contained in a passed GPTChatRequest.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GPTConfiguration.AnswerType
static class
GPTConfiguration.Mode
-
Field Summary
Fields Modifier and Type Field Description static GPTConfiguration
CHAT
static GPTConfiguration
DEBUG
If set, the AI services will not call the AI but return the JSON request as response, for debugging purposes.static GPTConfiguration
GENERATE
static GPTConfiguration
HIGH_INTELLIGENCE
Requests slower and more expensive "high intelligence" model - use sparingly.static GPTConfiguration
HTML
static GPTConfiguration
JSON
static GPTConfiguration
MARKDOWN
static GPTConfiguration
STANDARD_INTELLIGENCE
Requests faster and less expensive "normal intelligence" model.
-
Constructor Summary
Constructors Constructor Description GPTConfiguration(String apiKey, String organizationId, GPTConfiguration.AnswerType answerType)
GPTConfiguration(String apiKey, String organizationId, GPTConfiguration.AnswerType answerType, String additionalInstructions)
GPTConfiguration(String apiKey, String organizationId, GPTConfiguration.AnswerType answerType, String additionalInstructions, GPTConfiguration.Mode mode)
GPTConfiguration(String apiKey, String organizationId, GPTConfiguration.AnswerType answerType, String additionalInstructions, GPTConfiguration.Mode mode, Boolean highIntelligenceNeeded)
GPTConfiguration(String apiKey, String organizationId, GPTConfiguration.AnswerType answerType, String additionalInstructions, GPTConfiguration.Mode mode, Boolean highIntelligenceNeeded, Boolean debug)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
String
getAdditionalInstructions()
Optionally, additional instructions to add to the system prompt.GPTConfiguration.AnswerType
getAnswerType()
The type of answer we want from the LLM.String
getApiKey()
The API key to use with ChatGPT or another service.Boolean
getDebug()
If this is set, then the services will not call the AI and return the JSON request instead of the AI response.GPTConfiguration.Mode
getMode()
String
getOrganizationId()
The organization id to use with ChatGPT.int
hashCode()
boolean
highIntelligenceNeededIsSet()
If true, this requires to uses the slower and more expensive high intelligence model - use sparingly for more challenging tasks.boolean
highIntelligenceNeededIsUnset()
If true, there is no information whether a "high intelligence model" is used - uses the default.boolean
isHtml()
GPTConfiguration
merge(GPTConfiguration other)
Creates a configuration that joins the values.GPTConfiguration
merge(GPTConfiguration other, boolean override)
Creates a configuration that joins the values.static GPTConfiguration
merge(GPTConfiguration first, GPTConfiguration second)
merge(GPTConfiguration)
several configurations.static GPTConfiguration
ofAdditionalInstructions(String additionalInstructions)
static GPTConfiguration
ofRichText(boolean richText)
String
toString()
-
-
-
Field Detail
-
MARKDOWN
public static final GPTConfiguration MARKDOWN
-
HTML
public static final GPTConfiguration HTML
-
JSON
public static final GPTConfiguration JSON
-
CHAT
public static final GPTConfiguration CHAT
-
GENERATE
public static final GPTConfiguration GENERATE
-
HIGH_INTELLIGENCE
public static final GPTConfiguration HIGH_INTELLIGENCE
Requests slower and more expensive "high intelligence" model - use sparingly.
-
STANDARD_INTELLIGENCE
public static final GPTConfiguration STANDARD_INTELLIGENCE
Requests faster and less expensive "normal intelligence" model.
-
DEBUG
public static final GPTConfiguration DEBUG
If set, the AI services will not call the AI but return the JSON request as response, for debugging purposes.
-
-
Constructor Detail
-
GPTConfiguration
public GPTConfiguration(@Nullable String apiKey, @Nullable String organizationId, @Nullable GPTConfiguration.AnswerType answerType)
-
GPTConfiguration
public GPTConfiguration(@Nullable String apiKey, @Nullable String organizationId, @Nullable GPTConfiguration.AnswerType answerType, @Nullable String additionalInstructions)
-
GPTConfiguration
public GPTConfiguration(@Nullable String apiKey, @Nullable String organizationId, @Nullable GPTConfiguration.AnswerType answerType, @Nullable String additionalInstructions, @Nullable GPTConfiguration.Mode mode)
-
GPTConfiguration
public GPTConfiguration(@Nullable String apiKey, @Nullable String organizationId, @Nullable GPTConfiguration.AnswerType answerType, @Nullable String additionalInstructions, @Nullable GPTConfiguration.Mode mode, @Nullable Boolean highIntelligenceNeeded)
-
-
Method Detail
-
getApiKey
public String getApiKey()
The API key to use with ChatGPT or another service. If this isnot set, we will try to fall back to global configurations.
-
getOrganizationId
public String getOrganizationId()
The organization id to use with ChatGPT. If this is not set, we will try to fall back to global configurations.
-
getAnswerType
public GPTConfiguration.AnswerType getAnswerType()
The type of answer we want from the LLM.
-
getAdditionalInstructions
public String getAdditionalInstructions()
Optionally, additional instructions to add to the system prompt.
-
isHtml
public boolean isHtml()
-
getMode
public GPTConfiguration.Mode getMode()
-
highIntelligenceNeededIsSet
public boolean highIntelligenceNeededIsSet()
If true, this requires to uses the slower and more expensive high intelligence model - use sparingly for more challenging tasks.
-
highIntelligenceNeededIsUnset
public boolean highIntelligenceNeededIsUnset()
If true, there is no information whether a "high intelligence model" is used - uses the default.
-
getDebug
public Boolean getDebug()
If this is set, then the services will not call the AI and return the JSON request instead of the AI response.
-
merge
public GPTConfiguration merge(@Nullable GPTConfiguration other) throws IllegalArgumentException
Creates a configuration that joins the values.- Throws:
IllegalArgumentException
- if values conflict - that's checked for apiKey and organizationId and answerType.
-
merge
public GPTConfiguration merge(@Nullable GPTConfiguration other, boolean override) throws IllegalArgumentException
Creates a configuration that joins the values.- Parameters:
override
- if true, values set in this configuration will override values set in the other configuration. Otherwise, a conflict will throw an exception.other
- the other configuration to merge with (optional)- Returns:
- a new configuration
- Throws:
IllegalArgumentException
- if values conflict
-
merge
@Nullable public static GPTConfiguration merge(@Nullable GPTConfiguration first, @Nullable GPTConfiguration second)
merge(GPTConfiguration)
several configurations.
-
ofRichText
@Nonnull public static GPTConfiguration ofRichText(boolean richText)
-
ofAdditionalInstructions
@Nonnull public static GPTConfiguration ofAdditionalInstructions(@Nullable String additionalInstructions)
-
-