Class GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder
java.lang.Object
dev.langchain4j.model.googleai.GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder
- Enclosing class:
GoogleAiGeminiDecisionModel
- Since:
- 1.24.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe Gemini API key, sent in thex-goog-api-keyheader.The base URL of the Gemini API, including its version.build()customHeaders(@Nullable Map<String, String> customHeaders) Sets custom HTTP headers, added to every request.customHeaders(@Nullable Supplier<Map<String, String>> customHeadersSupplier) Sets a supplier for custom HTTP headers.customParameters(@Nullable Map<String, Object> customParameters) Custom parameters added to the body of every request, for example to use a feature of the Gemini Decisions API that this class does not support yet.httpClientBuilder(@Nullable HttpClientBuilder httpClientBuilder) Sets theHttpClientBuilderused to create the HTTP client that communicates with Gemini.listeners(DecisionModelListener... listeners) Sets the listeners that are notified of every request, response and error.listeners(@Nullable List<DecisionModelListener> listeners) Sets the listeners that are notified of every request, response and error.logger(@Nullable org.slf4j.Logger logger) An alternateLoggerto be used instead of the default one for logging requests and responses.logRequests(@Nullable Boolean logRequests) Whether to log requests.logRequestsAndResponses(@Nullable Boolean logRequestsAndResponses) Whether to log both requests and responses, in addition tologRequests(Boolean)andlogResponses(Boolean).logResponses(@Nullable Boolean logResponses) Whether to log responses.maxRetries(@Nullable Integer maxRetries) The number of retries after the first attempt, for transient errors such as timeouts, rate limits and server errors.The decision model to use when a request does not specify one, for examplegemini-decision-1.The connect and read timeout.
-
Constructor Details
-
GoogleAiGeminiDecisionModelBuilder
public GoogleAiGeminiDecisionModelBuilder()
-
-
Method Details
-
httpClientBuilder
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder httpClientBuilder(@Nullable HttpClientBuilder httpClientBuilder) Sets theHttpClientBuilderused to create the HTTP client that communicates with Gemini. When not set (null), the HTTP client found on the classpath is used.NOTE:
timeout(Duration)overrides timeouts set on theHttpClientBuilder. -
apiKey
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder apiKey(@Nullable String apiKey) The Gemini API key, sent in thex-goog-api-keyheader. When not set (null), nox-goog-api-keyheader is sent, for example when the request is authenticated withcustomHeaders(Map). Gemini rejects a request without any credentials with anAuthenticationException(HTTP 403), and a wrong key with anInvalidRequestException(HTTP 400, "API key not valid"). -
baseUrl
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder baseUrl(@Nullable String baseUrl) The base URL of the Gemini API, including its version. When not set (null),https://generativelanguage.googleapis.com/v1betais used. Requests are sent to<baseUrl>/decisions. -
modelName
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder modelName(@Nullable String modelName) The decision model to use when a request does not specify one, for examplegemini-decision-1. The model name must be set either here or on each request. -
timeout
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder timeout(@Nullable Duration timeout) The connect and read timeout. When not set (null), the timeouts of thehttpClientBuilder(HttpClientBuilder)are used, or 15 seconds (connect) and 60 seconds (read). -
maxRetries
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder maxRetries(@Nullable Integer 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
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder logRequests(@Nullable Boolean logRequests) Whether to log requests. The API key is masked. Default value isfalse. -
logResponses
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder logResponses(@Nullable Boolean logResponses) Whether to log responses. Default value isfalse. -
logRequestsAndResponses
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder logRequestsAndResponses(@Nullable Boolean logRequestsAndResponses) Whether to log both requests and responses, in addition tologRequests(Boolean)andlogResponses(Boolean). Default value isfalse. -
logger
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder logger(@Nullable org.slf4j.Logger logger) An alternateLoggerto be used instead of the default one for logging requests and responses. When not set (null), the default logger is used. -
customHeaders
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder customHeaders(@Nullable Map<String, String> customHeaders) Sets custom HTTP headers, added to every request. When not set (null), no custom headers are added. -
customHeaders
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder customHeaders(@Nullable 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 OAuth2 tokens that expire and need refreshing. When not set (null), or when the supplier returnsnull, no custom headers are added. -
customParameters
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder customParameters(@Nullable Map<String, Object> customParameters) Custom parameters added to the body of every request, for example to use a feature of the Gemini Decisions API that this class does not support yet. A custom parameter namedmodelorinput, which this class also sets, replaces it. A custom parameter namedquestionsis rejected with anIllegalArgumentExceptionbefore calling the API: the answers are mapped back to the questions of theDecisionRequestby their position. When not set (null) or empty, no custom parameters are added. The custom parameters set here can be replaced for a single request withGoogleAiGeminiDecisionRequestParameters.Builder.customParameters(Map). -
listeners
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder listeners(@Nullable List<DecisionModelListener> listeners) Sets the listeners that are notified of every request, response and error. When not set (null), no listeners are notified. -
listeners
public GoogleAiGeminiDecisionModel.GoogleAiGeminiDecisionModelBuilder listeners(DecisionModelListener... listeners) Sets the listeners that are notified of every request, response and error. -
build
-