Class OpenAiDecisionModel.OpenAiDecisionModelBuilder
java.lang.Object
dev.langchain4j.model.openai.OpenAiDecisionModel.OpenAiDecisionModelBuilder
- Enclosing class:
OpenAiDecisionModel
- Since:
- 1.22.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe base URL of the API.build()customHeaders(Supplier<Map<String, String>> customHeadersSupplier) Sets a supplier for custom HTTP headers.customHeaders(Map<String, String> customHeaders) Sets custom HTTP headers.customParameters(Map<String, Object> customParameters) Custom parameters added to the body of every request, for example to use a feature of the OpenAI Decisions API that this class does not support yet.customQueryParams(Map<String, String> customQueryParams) httpClientBuilder(HttpClientBuilder httpClientBuilder) Sets a custom HTTP client builder, allowing fine-grained control over the HTTP client configuration such as timeouts and proxy settings.listeners(DecisionModelListener... listeners) listeners(List<DecisionModelListener> listeners) logger(org.slf4j.Logger logger) logRequests(Boolean logRequests) Whether to log requests.logResponses(Boolean logResponses) Whether to log responses.maxRetries(Integer maxRetries) The number of retries after the first attempt, for transient errors such as timeouts, rate limits and server errors.modelName(OpenAiDecisionModelName modelName) The model to use when a request does not specify one.The model to use when a request does not specify one, for examplegpt-6-luna.organizationId(String organizationId) promptCacheKey(String promptCacheKey) A key that separates prompt caching between groups of requests, sent asprompt_cache_key.The connect and read timeout.
-
Constructor Details
-
OpenAiDecisionModelBuilder
public OpenAiDecisionModelBuilder()
-
-
Method Details
-
httpClientBuilder
public OpenAiDecisionModel.OpenAiDecisionModelBuilder httpClientBuilder(HttpClientBuilder httpClientBuilder) Sets a custom HTTP client builder, allowing fine-grained control over the HTTP client configuration such as timeouts and proxy settings. -
baseUrl
The base URL of the API. Defaults tohttps://api.openai.com/v1. -
apiKey
-
organizationId
-
projectId
-
modelName
The model to use when a request does not specify one, for examplegpt-6-luna. The model name must be set either here or on each request. -
modelName
The model to use when a request does not specify one. The model name must be set either here or on each request. -
timeout
The connect and read timeout. Default values are 15 seconds (connect) and 60 seconds (read). -
maxRetries
The number of retries after the first attempt, for transient errors such as timeouts, rate limits and server errors. Default value is 2. -
logRequests
Whether to log requests. Default value isfalse. -
logResponses
Whether to log responses. Default value isfalse. -
logger
- Parameters:
logger- an alternateLoggerto be used instead of the default one provided by LangChain4j for logging requests and responses.- Returns:
this.
-
customHeaders
public OpenAiDecisionModel.OpenAiDecisionModelBuilder customHeaders(Map<String, String> customHeaders) Sets custom HTTP headers. -
customHeaders
public OpenAiDecisionModel.OpenAiDecisionModelBuilder customHeaders(Supplier<Map<String, String>> customHeadersSupplier) Sets a supplier for custom HTTP headers. The supplier is called before each request, allowing dynamic header values. For example, this is useful for OAuth2 tokens that expire and need refreshing. -
customQueryParams
public OpenAiDecisionModel.OpenAiDecisionModelBuilder customQueryParams(Map<String, String> customQueryParams) -
promptCacheKey
A key that separates prompt caching between groups of requests, sent asprompt_cache_key. OpenAI caches the shared input of requests automatically, also without a key. With a key, only requests with the same key reuse each other's cached input, for example to keep cache reuse and the cached token counts separate per customer or user. Not set by default.It can be replaced for a single request with
OpenAiDecisionRequestParameters.Builder.promptCacheKey(String). See the prompt caching guide. -
customParameters
public OpenAiDecisionModel.OpenAiDecisionModelBuilder customParameters(Map<String, Object> customParameters) Custom parameters added to the body of every request, for example to use a feature of the OpenAI Decisions API that this class does not support yet. A custom parameter with the same name as a parameter set by this class replaces it. They can be replaced for a single request withOpenAiDecisionRequestParameters.Builder.customParameters(Map). -
listeners
public OpenAiDecisionModel.OpenAiDecisionModelBuilder listeners(List<DecisionModelListener> listeners) -
listeners
-
build
-