Class WatsonxDeploymentStreamingChatModel
java.lang.Object
dev.langchain4j.model.watsonx.WatsonxDeploymentStreamingChatModel
- All Implemented Interfaces:
StreamingChatModel
A
StreamingChatModel implementation that integrates the IBM watsonx.ai Deployment with LangChain4j.
Example usage:
StreamingChatModel chatModel = WatsonxDeploymentStreamingChatModel.builder()
.baseUrl("https://...") // or use CloudRegion
.apiKey("...")
.deploymentId("...")
.maxOutputTokens(0)
.temperature(0.7)
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructingWatsonxDeploymentStreamingChatModelinstances with configurable parameters. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ChatRequestParametersprotected final Stringprotected final com.ibm.watsonx.ai.deployment.DeploymentServiceprotected final List<ChatModelListener> protected final booleanprotected final Set<Capability> -
Method Summary
Modifier and TypeMethodDescriptionprotected static final voidapplyCommonParameters(DefaultChatRequestParameters.Builder<?> target, dev.langchain4j.model.watsonx.WatsonxChatBase.Builder<?> builder) protected static voidapplyTextChatParameters(WatsonxChatRequestParameters.Builder target, dev.langchain4j.model.watsonx.WatsonxTextChatBase.Builder<?> builder) Merges intotargetthe builder values and the default request parameters that both services accept.protected com.ibm.watsonx.ai.deployment.DeploymentChatRequestbuildChatRequest(List<com.ibm.watsonx.ai.chat.model.ChatMessage> messages, List<com.ibm.watsonx.ai.chat.model.Tool> tools, ChatRequestParameters parameters) builder()Returns a newWatsonxDeploymentStreamingChatModel.Builderinstance.protected com.ibm.watsonx.ai.chat.ChatProvider<com.ibm.watsonx.ai.deployment.DeploymentChatRequest, com.ibm.watsonx.ai.chat.TextChatResponse> voiddoChat(ChatRequest chatRequest, StreamingChatResponseHandler handler) protected final ChatResponseexecuteChat(ChatRequest chatRequest) protected final voidexecuteChatStreaming(ChatRequest chatRequest, StreamingChatResponseHandler handler) 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, defaultRequestParameters, listeners, provider, supportedCapabilities
-
Field Details
-
deploymentService
protected final com.ibm.watsonx.ai.deployment.DeploymentService deploymentService -
deploymentId
-
listeners
-
defaultRequestParameters
-
supportedCapabilities
-
strictJsonSchema
protected final boolean strictJsonSchema
-
-
Method Details
-
doChat
- Specified by:
doChatin interfaceStreamingChatModel
-
builder
Returns a newWatsonxDeploymentStreamingChatModel.Builderinstance.Example usage:
StreamingChatModel chatModel = WatsonxDeploymentStreamingChatModel.builder() .baseUrl("https://...") // or use CloudRegion .apiKey("...") .deploymentId("...") .maxOutputTokens(0) .temperature(0.7) .build();- Returns:
WatsonxDeploymentStreamingChatModel.Builderinstance.
-
buildChatRequest
protected com.ibm.watsonx.ai.deployment.DeploymentChatRequest buildChatRequest(List<com.ibm.watsonx.ai.chat.model.ChatMessage> messages, List<com.ibm.watsonx.ai.chat.model.Tool> tools, ChatRequestParameters parameters) -
chatProvider
protected com.ibm.watsonx.ai.chat.ChatProvider<com.ibm.watsonx.ai.deployment.DeploymentChatRequest, com.ibm.watsonx.ai.chat.TextChatResponse> chatProvider() -
applyTextChatParameters
protected static void applyTextChatParameters(WatsonxChatRequestParameters.Builder target, dev.langchain4j.model.watsonx.WatsonxTextChatBase.Builder<?> builder) Merges intotargetthe builder values and the default request parameters that both services accept.- Parameters:
target- the parameters builder to fillbuilder- the model builder holding the values set by the caller
-
listeners
-
defaultRequestParameters
-
supportedCapabilities
-
provider
-
executeChat
-
executeChatStreaming
protected final void executeChatStreaming(ChatRequest chatRequest, StreamingChatResponseHandler handler) -
applyCommonParameters
protected static final void applyCommonParameters(DefaultChatRequestParameters.Builder<?> target, dev.langchain4j.model.watsonx.WatsonxChatBase.Builder<?> builder)
-