Class VertexAiGeminiStreamingChatModel
- All Implemented Interfaces:
StreamingChatModel, Closeable, AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Constructor Summary
ConstructorsConstructorDescriptionVertexAiGeminiStreamingChatModel(com.google.cloud.vertexai.generativeai.GenerativeModel generativeModel, com.google.cloud.vertexai.api.GenerationConfig generationConfig) VertexAiGeminiStreamingChatModel(com.google.cloud.vertexai.generativeai.GenerativeModel generativeModel, com.google.cloud.vertexai.api.GenerationConfig generationConfig, Executor executor) VertexAiGeminiStreamingChatModel(VertexAiGeminiStreamingChatModel.VertexAiGeminiStreamingChatModelBuilder builder) VertexAiGeminiStreamingChatModel(String project, String location, String modelName, Float temperature, Integer maxOutputTokens, Integer topK, Float topP, 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<ChatModelListener> listeners, Map<String, String> customHeaders, Executor executor) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()voidchat(ChatRequest chatRequest, StreamingChatResponseHandler handler) This is the main API to interact with the chat model.voidclose()voiddoChat(ChatRequest chatRequest, StreamingChatResponseHandler handler) Provider-specific implementation ofStreamingChatModel.chat(ChatRequest, StreamingChatResponseHandler), which wraps it withChatModelListenerinvocation and failure reporting.provider()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface StreamingChatModel
chat, chat, chat, chat, chat, chat, chat, doChat, supportedCapabilities
-
Constructor Details
-
VertexAiGeminiStreamingChatModel
public VertexAiGeminiStreamingChatModel(VertexAiGeminiStreamingChatModel.VertexAiGeminiStreamingChatModelBuilder builder) -
VertexAiGeminiStreamingChatModel
@Deprecated(forRemoval=true, since="1.1.0-beta7") public VertexAiGeminiStreamingChatModel(String project, String location, String modelName, Float temperature, Integer maxOutputTokens, Integer topK, Float topP, 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<ChatModelListener> listeners, Map<String, String> customHeaders, Executor executor) Deprecated, for removal: This API element is subject to removal in a future version.please useVertexAiGeminiStreamingChatModel(VertexAiGeminiStreamingChatModelBuilder)instead -
VertexAiGeminiStreamingChatModel
public VertexAiGeminiStreamingChatModel(com.google.cloud.vertexai.generativeai.GenerativeModel generativeModel, com.google.cloud.vertexai.api.GenerationConfig generationConfig) -
VertexAiGeminiStreamingChatModel
public VertexAiGeminiStreamingChatModel(com.google.cloud.vertexai.generativeai.GenerativeModel generativeModel, com.google.cloud.vertexai.api.GenerationConfig generationConfig, Executor executor)
-
-
Method Details
-
chat
Description copied from interface:StreamingChatModelThis is the main API to interact with the chat model.This method does not throw: every failure, including an invalid request, is reported to
StreamingChatResponseHandler.onError(Throwable).onErrormay be called on the calling thread, before this method returns. IfonErroritself throws while a failure is reported on the calling thread, before this method returns, that exception is thrown from this method. If it throws on another thread, or after this method returned, the exception is logged. If the model implementation throws after the handler already received the complete response or an error, that exception is logged instead of being reported.- Specified by:
chatin interfaceStreamingChatModel- Parameters:
chatRequest- aChatRequest, containing all the inputs to the LLMhandler- aStreamingChatResponseHandlerthat will handle streaming response from the LLM; must not benull, otherwise anIllegalArgumentExceptionis thrown before anything is sent
-
doChat
Description copied from interface:StreamingChatModelProvider-specific implementation ofStreamingChatModel.chat(ChatRequest, StreamingChatResponseHandler), which wraps it withChatModelListenerinvocation and failure reporting.An implementation may throw a failure that it finds before the request is sent, for example an invalid request:
StreamingChatModel.chat(ChatRequest, StreamingChatResponseHandler)then reports it toStreamingChatResponseHandler.onError(Throwable). Every later failure goes tohandler.onError(...). An implementation does not need to care about what the user'sonErrorthrows: it never reaches the implementation. Core throws it fromchat(...)when it happens on the calling thread beforechat(...)returns, and logs it otherwise.- Specified by:
doChatin interfaceStreamingChatModel- Parameters:
chatRequest- the request, with the default request parameters of this model appliedhandler- the handler to send the streamed response and failures to
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
defaultRequestParameters
- Specified by:
defaultRequestParametersin interfaceStreamingChatModel
-
listeners
- Specified by:
listenersin interfaceStreamingChatModel
-
provider
- Specified by:
providerin interfaceStreamingChatModel
-
builder
-
VertexAiGeminiStreamingChatModel(VertexAiGeminiStreamingChatModelBuilder)instead