Package akka.javasdk.decision
Record Class DecisionModelProvider.OpenAi
- Record Components:
apiKey- the API key, sent as a bearer token. A call without an API key fails.modelName- the model name, for examplegpt-6-lunabaseUrl- the base URL of the API, including the version path, for examplehttps://api.openai.com/v1connectionTimeout- fail the request when connecting takes longer than thisresponseTimeout- fail the request when the answer takes longer than this. The timeout applies to each attempt.maxRetries- if the request fails with a rate limit, a server error, a timeout or a connection failure, retry this many timesadditionalModelRequestHeaders- HTTP headers added to each request
- All Implemented Interfaces:
DecisionModelProvider
- Enclosing interface:
DecisionModelProvider
public static record DecisionModelProvider.OpenAi(String apiKey, String modelName, String baseUrl, Duration connectionTimeout, Duration responseTimeout, int maxRetries, List<akka.http.javadsl.model.HttpHeader> additionalModelRequestHeaders)
extends Record
implements DecisionModelProvider
A model of the OpenAI Decisions API. The request goes to
/decisions under the base URL.-
Nested Class Summary
Nested classes/interfaces inherited from interface akka.javasdk.decision.DecisionModelProvider
DecisionModelProvider.Custom, DecisionModelProvider.DecisionRequest, DecisionModelProvider.FromConfig, DecisionModelProvider.OpenAi, DecisionModelProvider.SystemOne -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<akka.http.javadsl.model.HttpHeader> Returns the value of theadditionalModelRequestHeadersrecord component.apiKey()Returns the value of theapiKeyrecord component.baseUrl()Returns the value of thebaseUrlrecord component.Returns the value of theconnectionTimeoutrecord component.final booleanIndicates whether some other object is "equal to" this one.static DecisionModelProvider.OpenAifromConfig(com.typesafe.config.Config config) Read the provider from a configuration section such asopenai.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxRetriesrecord component.Returns the value of themodelNamerecord component.Returns the value of theresponseTimeoutrecord component.final StringtoString()Returns a string representation of this record class.withAdditionalModelRequestHeaders(List<akka.http.javadsl.model.HttpHeader> headers) withApiKey(String apiKey) withBaseUrl(String baseUrl) withConnectionTimeout(Duration connectionTimeout) withMaxRetries(int maxRetries) withModelName(String modelName) withResponseTimeout(Duration responseTimeout)
-
Constructor Details
-
OpenAi
public OpenAi(String apiKey, String modelName, String baseUrl, Duration connectionTimeout, Duration responseTimeout, int maxRetries, List<akka.http.javadsl.model.HttpHeader> additionalModelRequestHeaders) Creates an instance of aOpenAirecord class.- Parameters:
apiKey- the value for theapiKeyrecord componentmodelName- the value for themodelNamerecord componentbaseUrl- the value for thebaseUrlrecord componentconnectionTimeout- the value for theconnectionTimeoutrecord componentresponseTimeout- the value for theresponseTimeoutrecord componentmaxRetries- the value for themaxRetriesrecord componentadditionalModelRequestHeaders- the value for theadditionalModelRequestHeadersrecord component
-
-
Method Details
-
fromConfig
Read the provider from a configuration section such asopenai. -
withApiKey
-
withModelName
-
withBaseUrl
-
withConnectionTimeout
-
withResponseTimeout
-
withMaxRetries
-
withAdditionalModelRequestHeaders
public DecisionModelProvider.OpenAi withAdditionalModelRequestHeaders(List<akka.http.javadsl.model.HttpHeader> headers) -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
apiKey
Returns the value of theapiKeyrecord component.- Returns:
- the value of the
apiKeyrecord component
-
modelName
Returns the value of themodelNamerecord component.- Returns:
- the value of the
modelNamerecord component
-
baseUrl
Returns the value of thebaseUrlrecord component.- Returns:
- the value of the
baseUrlrecord component
-
connectionTimeout
Returns the value of theconnectionTimeoutrecord component.- Returns:
- the value of the
connectionTimeoutrecord component
-
responseTimeout
Returns the value of theresponseTimeoutrecord component.- Returns:
- the value of the
responseTimeoutrecord component
-
maxRetries
public int maxRetries()Returns the value of themaxRetriesrecord component.- Returns:
- the value of the
maxRetriesrecord component
-
additionalModelRequestHeaders
Returns the value of theadditionalModelRequestHeadersrecord component.- Returns:
- the value of the
additionalModelRequestHeadersrecord component
-