Package dev.langchain4j.model.googleai
Class GoogleAiGeminiChatModel
java.lang.Object
dev.langchain4j.model.googleai.GoogleAiGeminiChatModel
- All Implemented Interfaces:
ChatLanguageModel
-
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()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.model.chat.ChatLanguageModel
chat, chat, chat, defaultRequestParameters, doChat
-
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:ChatLanguageModel
This is the main API to interact with the chat model. A temporary default implementation of this method is necessary until allChatLanguageModel
implementations adopt it. It should be removed once that occurs.- Specified by:
chat
in interfaceChatLanguageModel
- 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 interfaceChatLanguageModel
-
listeners
- Specified by:
listeners
in interfaceChatLanguageModel
-
provider
- Specified by:
provider
in interfaceChatLanguageModel
-
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)
-