Class WatsonxStreamingChatModel

java.lang.Object
dev.langchain4j.model.watsonx.WatsonxStreamingChatModel
All Implemented Interfaces:
dev.langchain4j.model.chat.StreamingChatModel

public class WatsonxStreamingChatModel extends Object implements dev.langchain4j.model.chat.StreamingChatModel
A StreamingChatModel implementation that integrates IBM watsonx.ai with LangChain4j.

Example usage:


StreamingChatModel chatModel = WatsonxStreamingChatModel.builder()
    .url("https://...") // or use CloudRegion
    .apiKey("...")
    .projectId("...")
    .modelName("ibm/granite-3-8b-instruct")
    .maxOutputTokens(0)
    .temperature(0.7)
    .build();
  • Field Details

    • THINKING

      protected static final com.ibm.watsonx.ai.chat.model.ControlMessage THINKING
    • chatService

      protected final com.ibm.watsonx.ai.chat.ChatService chatService
    • listeners

      protected final List<dev.langchain4j.model.chat.listener.ChatModelListener> listeners
    • defaultRequestParameters

      protected final dev.langchain4j.model.chat.request.ChatRequestParameters defaultRequestParameters
    • supportedCapabilities

      protected final Set<dev.langchain4j.model.chat.Capability> supportedCapabilities
    • tags

      protected final com.ibm.watsonx.ai.chat.model.ExtractionTags tags
  • Method Details

    • doChat

      public void doChat(dev.langchain4j.model.chat.request.ChatRequest chatRequest, dev.langchain4j.model.chat.response.StreamingChatResponseHandler handler)
      Specified by:
      doChat in interface dev.langchain4j.model.chat.StreamingChatModel
    • listeners

      public List<dev.langchain4j.model.chat.listener.ChatModelListener> listeners()
      Specified by:
      listeners in interface dev.langchain4j.model.chat.StreamingChatModel
    • defaultRequestParameters

      public dev.langchain4j.model.chat.request.ChatRequestParameters defaultRequestParameters()
      Specified by:
      defaultRequestParameters in interface dev.langchain4j.model.chat.StreamingChatModel
    • supportedCapabilities

      public Set<dev.langchain4j.model.chat.Capability> supportedCapabilities()
      Specified by:
      supportedCapabilities in interface dev.langchain4j.model.chat.StreamingChatModel
    • provider

      public dev.langchain4j.model.ModelProvider provider()
      Specified by:
      provider in interface dev.langchain4j.model.chat.StreamingChatModel
    • builder

      public static WatsonxStreamingChatModel.Builder builder()
      Returns a new WatsonxStreamingChatModel.Builder instance.

      Example usage:

      StreamingChatModel chatModel = WatsonxStreamingChatModel.builder()
          .url("https://...") // or use CloudRegion
          .apiKey("...")
          .projectId("...")
          .modelName("ibm/granite-3-8b-instruct")
          .maxOutputTokens(0)
          .temperature(0.7)
          .build();
      
      Returns:
      WatsonxStreamingChatModel.Builder instance.