Class OpenAiStreamingChatModel

java.lang.Object
dev.langchain4j.model.openai.OpenAiStreamingChatModel
All Implemented Interfaces:
dev.langchain4j.model.chat.StreamingChatLanguageModel, dev.langchain4j.model.chat.TokenCountEstimator

public class OpenAiStreamingChatModel extends Object implements dev.langchain4j.model.chat.StreamingChatLanguageModel, dev.langchain4j.model.chat.TokenCountEstimator
Represents an OpenAI language model with a chat completion interface, such as gpt-3.5-turbo and gpt-4. The model's response is streamed token by token and should be handled with StreamingResponseHandler. You can find description of parameters here.
  • Constructor Details

  • Method Details

    • modelName

      @Deprecated(forRemoval=true) public String modelName()
      Deprecated, for removal: This API element is subject to removal in a future version.
      please use defaultRequestParameters() and then ChatRequestParameters.modelName() instead
    • defaultRequestParameters

      public OpenAiChatRequestParameters defaultRequestParameters()
      Specified by:
      defaultRequestParameters in interface dev.langchain4j.model.chat.StreamingChatLanguageModel
    • 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.StreamingChatLanguageModel
    • listeners

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

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

      public int estimateTokenCount(List<dev.langchain4j.data.message.ChatMessage> messages)
      Specified by:
      estimateTokenCount in interface dev.langchain4j.model.chat.TokenCountEstimator
    • withApiKey

      @Deprecated(forRemoval=true) public static OpenAiStreamingChatModel withApiKey(String apiKey)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Please use builder() instead, and explicitly set the model name and, if necessary, other parameters. The default values for the model name and temperature will be removed in future releases!
    • builder