Package dev.langchain4j.model.googleai
Class GoogleAiGeminiChatModel
java.lang.Object
dev.langchain4j.model.googleai.GoogleAiGeminiChatModel
- All Implemented Interfaces:
ChatModel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
protected final String
protected final dev.langchain4j.model.googleai.GeminiService
protected final boolean
protected final List
<ChatModelListener> protected final Integer
protected final Integer
protected final String
protected final ResponseFormat
protected final List
<GeminiSafetySetting> protected final Double
protected final GeminiFunctionCallingConfig
protected final Integer
protected final Double
-
Constructor Summary
ConstructorsConstructorDescriptionGoogleAiGeminiChatModel
(String apiKey, String modelName, Integer maxRetries, Double temperature, Integer topK, Double topP, Integer maxOutputTokens, Duration timeout, ResponseFormat responseFormat, List<String> stopSequences, GeminiFunctionCallingConfig toolConfig, Boolean allowCodeExecution, Boolean includeCodeExecutionOutput, Boolean logRequestsAndResponses, List<GeminiSafetySetting> safetySettings, List<ChatModelListener> listeners) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
chat
(ChatRequest chatRequest) This is the main API to interact with the chat model.protected static String
computeMimeType
(ResponseFormat responseFormat) protected dev.langchain4j.model.googleai.GeminiGenerateContentRequest
createGenerateContentRequest
(List<ChatMessage> messages, List<ToolSpecification> toolSpecifications, ResponseFormat responseFormat, ChatRequestParameters requestParameters) protected ChatRequest
createListenerRequest
(String modelName, List<ChatMessage> messages, List<ToolSpecification> toolSpecifications, ChatRequestParameters requestParameters) protected void
notifyListenersOnError
(Exception exception, ChatRequest listenerRequest, ModelProvider modelProvider, Map<Object, Object> attributes) protected void
protected void
notifyListenersOnResponse
(Response<AiMessage> response, ChatRequest listenerRequest, ModelProvider modelProvider, Map<Object, Object> attributes) provider()
-
Field Details
-
geminiService
protected final dev.langchain4j.model.googleai.GeminiService geminiService -
apiKey
-
modelName
-
temperature
-
topK
-
topP
-
maxOutputTokens
-
stopSequences
-
responseFormat
-
toolConfig
-
allowCodeExecution
protected final boolean allowCodeExecution -
includeCodeExecutionOutput
protected final boolean includeCodeExecutionOutput -
safetySettings
-
listeners
-
maxRetries
-
-
Constructor Details
-
GoogleAiGeminiChatModel
public GoogleAiGeminiChatModel(String apiKey, String modelName, Integer maxRetries, Double temperature, Integer topK, Double topP, Integer maxOutputTokens, Duration timeout, ResponseFormat responseFormat, List<String> stopSequences, GeminiFunctionCallingConfig toolConfig, Boolean allowCodeExecution, Boolean includeCodeExecutionOutput, Boolean logRequestsAndResponses, List<GeminiSafetySetting> safetySettings, List<ChatModelListener> listeners)
-
-
Method Details
-
builder
-
chat
Description copied from interface:ChatModel
This is the main API to interact with the chat model.- Specified by:
chat
in interfaceChatModel
- Parameters:
chatRequest
- aChatRequest
, containing all the inputs to the LLM- Returns:
- a
ChatResponse
, containing all the outputs from the LLM
-
supportedCapabilities
- Specified by:
supportedCapabilities
in interfaceChatModel
-
listeners
-
provider
-
createGenerateContentRequest
protected dev.langchain4j.model.googleai.GeminiGenerateContentRequest createGenerateContentRequest(List<ChatMessage> messages, List<ToolSpecification> toolSpecifications, ResponseFormat responseFormat, ChatRequestParameters requestParameters) -
createListenerRequest
protected ChatRequest createListenerRequest(String modelName, List<ChatMessage> messages, List<ToolSpecification> toolSpecifications, ChatRequestParameters requestParameters) -
computeMimeType
-
notifyListenersOnRequest
-
notifyListenersOnResponse
protected void notifyListenersOnResponse(Response<AiMessage> response, ChatRequest listenerRequest, ModelProvider modelProvider, Map<Object, Object> attributes) -
notifyListenersOnError
protected void notifyListenersOnError(Exception exception, ChatRequest listenerRequest, ModelProvider modelProvider, Map<Object, Object> attributes)
-