Class VertexAiGeminiChatClient
java.lang.Object
org.springframework.ai.model.function.AbstractFunctionCallSupport<com.google.cloud.vertexai.api.Content,VertexAiGeminiChatClient.GeminiRequest,com.google.cloud.vertexai.api.GenerateContentResponse>
org.springframework.ai.vertexai.gemini.VertexAiGeminiChatClient
- All Implemented Interfaces:
ChatClient
,StreamingChatClient
,ModelClient<Prompt,
,ChatResponse> StreamingModelClient<Prompt,
,ChatResponse> org.springframework.beans.factory.DisposableBean
public class VertexAiGeminiChatClient
extends AbstractFunctionCallSupport<com.google.cloud.vertexai.api.Content,VertexAiGeminiChatClient.GeminiRequest,com.google.cloud.vertexai.api.GenerateContentResponse>
implements ChatClient, StreamingChatClient, org.springframework.beans.factory.DisposableBean
- Since:
- 0.8.1
- Author:
- Christian Tzolov
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
static final record
-
Field Summary
Fields inherited from class org.springframework.ai.model.function.AbstractFunctionCallSupport
functionCallbackContext, functionCallbackRegister
-
Constructor Summary
ConstructorDescriptionVertexAiGeminiChatClient
(com.google.cloud.vertexai.VertexAI vertexAI) VertexAiGeminiChatClient
(com.google.cloud.vertexai.VertexAI vertexAI, VertexAiGeminiChatOptions options) VertexAiGeminiChatClient
(com.google.cloud.vertexai.VertexAI vertexAI, VertexAiGeminiChatOptions options, FunctionCallbackContext functionCallbackContext) -
Method Summary
Modifier and TypeMethodDescriptionExecutes a method call to the AI model.void
destroy()
protected com.google.cloud.vertexai.api.GenerateContentResponse
protected VertexAiGeminiChatClient.GeminiRequest
doCreateToolResponseRequest
(VertexAiGeminiChatClient.GeminiRequest previousRequest, com.google.cloud.vertexai.api.Content responseMessage, List<com.google.cloud.vertexai.api.Content> conversationHistory) protected com.google.cloud.vertexai.api.Content
doGetToolResponseMessage
(com.google.cloud.vertexai.api.GenerateContentResponse response) protected List
<com.google.cloud.vertexai.api.Content> protected boolean
isToolFunctionCall
(com.google.cloud.vertexai.api.GenerateContentResponse response) reactor.core.publisher.Flux
<ChatResponse> Executes a method call to the AI model.Methods inherited from class org.springframework.ai.model.function.AbstractFunctionCallSupport
callWithFunctionSupport, getFunctionCallbackRegister, handleFunctionCallbackConfigurations, handleFunctionCallOrReturn, resolveFunctionCallbacks
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.chat.ChatClient
call
Methods inherited from interface org.springframework.ai.chat.StreamingChatClient
stream
-
Constructor Details
-
VertexAiGeminiChatClient
public VertexAiGeminiChatClient(com.google.cloud.vertexai.VertexAI vertexAI) -
VertexAiGeminiChatClient
public VertexAiGeminiChatClient(com.google.cloud.vertexai.VertexAI vertexAI, VertexAiGeminiChatOptions options) -
VertexAiGeminiChatClient
public VertexAiGeminiChatClient(com.google.cloud.vertexai.VertexAI vertexAI, VertexAiGeminiChatOptions options, FunctionCallbackContext functionCallbackContext)
-
-
Method Details
-
call
Description copied from interface:ModelClient
Executes a method call to the AI model.- Specified by:
call
in interfaceChatClient
- Specified by:
call
in interfaceModelClient<Prompt,
ChatResponse> - Parameters:
prompt
- the request object to be sent to the AI model- Returns:
- the response from the AI model
-
stream
Description copied from interface:StreamingModelClient
Executes a method call to the AI model.- Specified by:
stream
in interfaceStreamingChatClient
- Specified by:
stream
in interfaceStreamingModelClient<Prompt,
ChatResponse> - Parameters:
prompt
- the request object to be sent to the AI model- Returns:
- the streaming response from the AI model
-
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-
doCreateToolResponseRequest
protected VertexAiGeminiChatClient.GeminiRequest doCreateToolResponseRequest(VertexAiGeminiChatClient.GeminiRequest previousRequest, com.google.cloud.vertexai.api.Content responseMessage, List<com.google.cloud.vertexai.api.Content> conversationHistory) - Specified by:
doCreateToolResponseRequest
in classAbstractFunctionCallSupport<com.google.cloud.vertexai.api.Content,
VertexAiGeminiChatClient.GeminiRequest, com.google.cloud.vertexai.api.GenerateContentResponse>
-
doGetUserMessages
protected List<com.google.cloud.vertexai.api.Content> doGetUserMessages(VertexAiGeminiChatClient.GeminiRequest request) - Specified by:
doGetUserMessages
in classAbstractFunctionCallSupport<com.google.cloud.vertexai.api.Content,
VertexAiGeminiChatClient.GeminiRequest, com.google.cloud.vertexai.api.GenerateContentResponse>
-
doGetToolResponseMessage
protected com.google.cloud.vertexai.api.Content doGetToolResponseMessage(com.google.cloud.vertexai.api.GenerateContentResponse response) - Specified by:
doGetToolResponseMessage
in classAbstractFunctionCallSupport<com.google.cloud.vertexai.api.Content,
VertexAiGeminiChatClient.GeminiRequest, com.google.cloud.vertexai.api.GenerateContentResponse>
-
doChatCompletion
protected com.google.cloud.vertexai.api.GenerateContentResponse doChatCompletion(VertexAiGeminiChatClient.GeminiRequest request) - Specified by:
doChatCompletion
in classAbstractFunctionCallSupport<com.google.cloud.vertexai.api.Content,
VertexAiGeminiChatClient.GeminiRequest, com.google.cloud.vertexai.api.GenerateContentResponse>
-
isToolFunctionCall
protected boolean isToolFunctionCall(com.google.cloud.vertexai.api.GenerateContentResponse response) - Specified by:
isToolFunctionCall
in classAbstractFunctionCallSupport<com.google.cloud.vertexai.api.Content,
VertexAiGeminiChatClient.GeminiRequest, com.google.cloud.vertexai.api.GenerateContentResponse>
-