Class GoogleAiGeminiChatModel

java.lang.Object
dev.langchain4j.model.googleai.GoogleAiGeminiChatModel
All Implemented Interfaces:
dev.langchain4j.model.chat.ChatLanguageModel, dev.langchain4j.model.chat.TokenCountEstimator

public class GoogleAiGeminiChatModel extends Object implements dev.langchain4j.model.chat.ChatLanguageModel, dev.langchain4j.model.chat.TokenCountEstimator
  • Field Details

    • geminiService

      protected final dev.langchain4j.model.googleai.GeminiService geminiService
    • apiKey

      protected final String apiKey
    • modelName

      protected final String modelName
    • temperature

      protected final Double temperature
    • topK

      protected final Integer topK
    • topP

      protected final Double topP
    • maxOutputTokens

      protected final Integer maxOutputTokens
    • stopSequences

      protected final List<String> stopSequences
    • responseFormat

      protected final dev.langchain4j.model.chat.request.ResponseFormat responseFormat
    • toolConfig

      protected final GeminiFunctionCallingConfig toolConfig
    • allowCodeExecution

      protected final boolean allowCodeExecution
    • includeCodeExecutionOutput

      protected final boolean includeCodeExecutionOutput
    • safetySettings

      protected final List<GeminiSafetySetting> safetySettings
    • listeners

      protected final List<dev.langchain4j.model.chat.listener.ChatModelListener> listeners
    • maxRetries

      protected final Integer maxRetries
  • Constructor Details

  • Method Details

    • generate

      public dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> generate(List<dev.langchain4j.data.message.ChatMessage> messages)
      Specified by:
      generate in interface dev.langchain4j.model.chat.ChatLanguageModel
    • generate

      public dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> generate(List<dev.langchain4j.data.message.ChatMessage> messages, dev.langchain4j.agent.tool.ToolSpecification toolSpecification)
      Specified by:
      generate in interface dev.langchain4j.model.chat.ChatLanguageModel
    • generate

      public dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> generate(List<dev.langchain4j.data.message.ChatMessage> messages, List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications)
      Specified by:
      generate in interface dev.langchain4j.model.chat.ChatLanguageModel
    • chat

      public dev.langchain4j.model.chat.response.ChatResponse chat(dev.langchain4j.model.chat.request.ChatRequest chatRequest)
      Specified by:
      chat in interface dev.langchain4j.model.chat.ChatLanguageModel
    • estimateTokenCount

      public int estimateTokenCount(List<dev.langchain4j.data.message.ChatMessage> messages)
      Specified by:
      estimateTokenCount in interface dev.langchain4j.model.chat.TokenCountEstimator
    • supportedCapabilities

      public Set<dev.langchain4j.model.chat.Capability> supportedCapabilities()
      Specified by:
      supportedCapabilities in interface dev.langchain4j.model.chat.ChatLanguageModel
    • createGenerateContentRequest

      protected dev.langchain4j.model.googleai.GeminiGenerateContentRequest createGenerateContentRequest(List<dev.langchain4j.data.message.ChatMessage> messages, List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications, dev.langchain4j.model.chat.request.ResponseFormat responseFormat)
    • createChatModelRequest

      protected dev.langchain4j.model.chat.listener.ChatModelRequest createChatModelRequest(List<dev.langchain4j.data.message.ChatMessage> messages, List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications)
    • computeMimeType

      protected static String computeMimeType(dev.langchain4j.model.chat.request.ResponseFormat responseFormat)
    • notifyListenersOnRequest

      protected void notifyListenersOnRequest(dev.langchain4j.model.chat.listener.ChatModelRequestContext context)
    • notifyListenersOnResponse

      protected void notifyListenersOnResponse(dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> response, dev.langchain4j.model.chat.listener.ChatModelRequest request, ConcurrentHashMap<Object,Object> attributes)
    • notifyListenersOnError

      protected void notifyListenersOnError(Exception exception, dev.langchain4j.model.chat.listener.ChatModelRequest request, ConcurrentHashMap<Object,Object> attributes)