Class VertexAiGeminiChatModel

java.lang.Object
dev.langchain4j.model.vertexai.VertexAiGeminiChatModel
All Implemented Interfaces:
dev.langchain4j.model.chat.ChatLanguageModel, Closeable, AutoCloseable

public class VertexAiGeminiChatModel extends Object implements dev.langchain4j.model.chat.ChatLanguageModel, Closeable
Represents a Google Vertex AI Gemini language model with a chat completion interface, such as gemini-pro. See details here.
Please follow these steps before using this model:
1. Authentication
When developing locally, you can use one of:
a) Google Cloud SDK
b) Service account When using service account, ensure that GOOGLE_APPLICATION_CREDENTIALS environment variable points to your JSON service account key.
2. Authorization
3. Prerequisites
  • Constructor Details

    • VertexAiGeminiChatModel

      public VertexAiGeminiChatModel(String project, String location, String modelName, Float temperature, Integer maxOutputTokens, Integer topK, Float topP, Integer seed, Integer maxRetries, String responseMimeType, com.google.cloud.vertexai.api.Schema responseSchema, Map<HarmCategory,SafetyThreshold> safetySettings, Boolean useGoogleSearch, String vertexSearchDatastore, ToolCallingMode toolCallingMode, List<String> allowedFunctionNames, Boolean logRequests, Boolean logResponses, List<dev.langchain4j.model.chat.listener.ChatModelListener> listeners)
    • VertexAiGeminiChatModel

      public VertexAiGeminiChatModel(com.google.cloud.vertexai.generativeai.GenerativeModel generativeModel, com.google.cloud.vertexai.api.GenerationConfig generationConfig)
    • VertexAiGeminiChatModel

      public VertexAiGeminiChatModel(com.google.cloud.vertexai.generativeai.GenerativeModel generativeModel, com.google.cloud.vertexai.api.GenerationConfig generationConfig, Integer maxRetries)
  • 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, List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications)
      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
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • builder