Class WatsonxDeploymentChatModel
java.lang.Object
dev.langchain4j.model.watsonx.WatsonxDeploymentChatModel
- All Implemented Interfaces:
ChatModel
A
ChatModel implementation that integrates the IBM watsonx.ai Deployment with LangChain4j.
Example usage:
ChatModel chatModel = WatsonxDeploymentChatModel.builder()
.baseUrl("https://...") // or use CloudRegion
.apiKey("...")
.deploymentId("...")
.maxOutputTokens(0)
.temperature(0.7)
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructingWatsonxDeploymentChatModelinstances 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 newWatsonxDeploymentChatModel.Builderinstance.protected com.ibm.watsonx.ai.chat.ChatProvider<com.ibm.watsonx.ai.deployment.DeploymentChatRequest, com.ibm.watsonx.ai.chat.TextChatResponse> doChat(ChatRequest chatRequest) protected final ChatResponseexecuteChat(ChatRequest chatRequest) protected final voidexecuteChatStreaming(ChatRequest chatRequest, StreamingChatResponseHandler handler) provider()
-
Field Details
-
deploymentService
protected final com.ibm.watsonx.ai.deployment.DeploymentService deploymentService -
deploymentId
-
listeners
-
defaultRequestParameters
-
supportedCapabilities
-
strictJsonSchema
protected final boolean strictJsonSchema
-
-
Method Details
-
doChat
-
builder
Returns a newWatsonxDeploymentChatModel.Builderinstance.Example usage:
ChatModel chatModel = WatsonxDeploymentChatModel.builder() .baseUrl("https://...") // or use CloudRegion .apiKey("...") .deploymentId("...") .maxOutputTokens(0) .temperature(0.7) .build();- Returns:
WatsonxDeploymentChatModel.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)
-