Package dev.langchain4j.model.vertexai
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
2. Authorization
3. Prerequisites
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Constructor Summary
ConstructorsConstructorDescriptionVertexAiGeminiChatModel(com.google.cloud.vertexai.generativeai.GenerativeModel generativeModel, com.google.cloud.vertexai.api.GenerationConfig generationConfig) VertexAiGeminiChatModel(com.google.cloud.vertexai.generativeai.GenerativeModel generativeModel, com.google.cloud.vertexai.api.GenerationConfig generationConfig, Integer maxRetries) 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) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()voidclose()dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> dev.langchain4j.model.output.Response<dev.langchain4j.data.message.AiMessage> generate(List<dev.langchain4j.data.message.ChatMessage> messages, dev.langchain4j.agent.tool.ToolSpecification toolSpecification) 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) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.langchain4j.model.chat.ChatLanguageModel
chat, generate, generate, supportedCapabilities
-
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:
generatein interfacedev.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:
generatein interfacedev.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:
generatein interfacedev.langchain4j.model.chat.ChatLanguageModel
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
builder
-