Class OpenAIServiceSettings.Builder
- All Implemented Interfaces:
WithJson<OpenAIServiceSettings.Builder>,ObjectBuilder<OpenAIServiceSettings>
- Enclosing class:
- OpenAIServiceSettings
OpenAIServiceSettings.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionA valid API key of your OpenAI account.build()Builds aOpenAIServiceSettings.For OAuth 2.0 authorization using the client credentials grant flow.clientSecret(String value) For OAuth 2.0 authorization using the client credentials grant flow.dimensions(Integer value) For atext_embeddingorembeddingtask, the number of dimensions the resulting output embeddings should have.Required - The name of the model to use for the inference task.organizationId(String value) The unique identifier for your organization.rateLimit(RateLimitSetting value) This setting helps to minimize the number of rate limit errors returned from OpenAI.This setting helps to minimize the number of rate limit errors returned from OpenAI.For OAuth 2.0 authorization using the client credentials grant flow.For OAuth 2.0 authorization using the client credentials grant flow.protected OpenAIServiceSettings.Builderself()similarity(OpenAISimilarityType value) For atext_embeddingorembeddingtask, the similarity measure.For OAuth 2.0 authorization using the client credentials grant flow.The URL endpoint to use for the requests.Methods inherited from class co.elastic.clients.util.WithJsonObjectBuilderBase
withJsonMethods inherited from class co.elastic.clients.util.ObjectBuilderBase
_checkSingleUse, _listAdd, _listAddAll, _mapPut, _mapPutAll
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
apiKey
A valid API key of your OpenAI account. You can find your OpenAI API keys in your OpenAI account under the API keys section.IMPORTANT: You must specify either
api_keyorclient_secret. If you do not provide one or you provide more than one of them, you will receive an error when you try to create your endpoint.API name:
api_key -
clientId
For OAuth 2.0 authorization using the client credentials grant flow. The application ID that's assigned to your app.IMPORTANT: To configure OAuth 2.0, you must specify
client_id,scopes,token_url, andclient_secrettogether. If one of the fields is missing, you will receive an error when you try to create your endpoint.API name:
client_id -
clientSecret
For OAuth 2.0 authorization using the client credentials grant flow. The application secret that you created for your app.IMPORTANT: You must specify either
api_keyorclient_secret. If you do not provide one or you provide more than one of them, you will receive an error when you try to create your endpoint.IMPORTANT: To configure OAuth 2.0, you must specify
client_id,scopes,token_url, andclient_secrettogether. If one of the fields is missing, you will receive an error when you try to create your endpoint.API name:
client_secret -
dimensions
For atext_embeddingorembeddingtask, the number of dimensions the resulting output embeddings should have. It is supported only intext-embedding-3and later models. If it is not set, the OpenAI defined default for the model is used.API name:
dimensions -
modelId
Required - The name of the model to use for the inference task. Refer to the OpenAI documentation for the list of available text embedding models.API name:
model_id -
organizationId
The unique identifier for your organization. You can find the Organization ID in your OpenAI account under Settings > Organizations.API name:
organization_id -
rateLimit
This setting helps to minimize the number of rate limit errors returned from OpenAI. Theopenaiservice sets a default number of requests allowed per minute depending on the task type. Fortext_embeddingandembedding, it is set to3000. Forcompletionandchat_completion, it is set to500.API name:
rate_limit -
rateLimit
public final OpenAIServiceSettings.Builder rateLimit(Function<RateLimitSetting.Builder, ObjectBuilder<RateLimitSetting>> fn) This setting helps to minimize the number of rate limit errors returned from OpenAI. Theopenaiservice sets a default number of requests allowed per minute depending on the task type. Fortext_embeddingandembedding, it is set to3000. Forcompletionandchat_completion, it is set to500.API name:
rate_limit -
scopes
For OAuth 2.0 authorization using the client credentials grant flow. The resource identifier of the resource you want. For example:"scopes": [ "scope1", "scope2" ]IMPORTANT: To configure OAuth 2.0, you must specify
client_id,scopes,token_url, andclient_secrettogether. If one of the fields is missing, you will receive an error when you try to create your endpoint.API name:
scopesAdds all elements of
listtoscopes. -
scopes
For OAuth 2.0 authorization using the client credentials grant flow. The resource identifier of the resource you want. For example:"scopes": [ "scope1", "scope2" ]IMPORTANT: To configure OAuth 2.0, you must specify
client_id,scopes,token_url, andclient_secrettogether. If one of the fields is missing, you will receive an error when you try to create your endpoint.API name:
scopesAdds one or more values to
scopes. -
similarity
For atext_embeddingorembeddingtask, the similarity measure. One ofcosine,dot_product,l2_norm. Defaults todot_product.API name:
similarity -
tokenUrl
For OAuth 2.0 authorization using the client credentials grant flow. An OAuth2 token endpoint where Elasticsearch sends a request to exchange client credentials for an access token.IMPORTANT: To configure OAuth 2.0, you must specify
client_id,scopes,token_url, andclient_secrettogether. If one of the fields is missing, you will receive an error when you try to create your endpoint.API name:
token_url -
url
The URL endpoint to use for the requests. It can be changed for testing purposes. Default value ishttps://api.openai.com/v1/embeddingsfor atext_embeddingorembeddingtask,https://api.openai.com/v1/chat/completionsfor acompletionorchat_completiontask.API name:
url -
self
- Specified by:
selfin classWithJsonObjectBuilderBase<OpenAIServiceSettings.Builder>
-
build
Builds aOpenAIServiceSettings.- Specified by:
buildin interfaceObjectBuilder<OpenAIServiceSettings>- Throws:
NullPointerException- if some of the required fields are null.
-