Class OpenAiStreamingLanguageModel

java.lang.Object
dev.langchain4j.model.openai.OpenAiStreamingLanguageModel
All Implemented Interfaces:
dev.langchain4j.model.language.StreamingLanguageModel, dev.langchain4j.model.language.TokenCountEstimator

public class OpenAiStreamingLanguageModel extends Object implements dev.langchain4j.model.language.StreamingLanguageModel, dev.langchain4j.model.language.TokenCountEstimator
Represents an OpenAI language model with a completion interface, such as gpt-3.5-turbo-instruct. The model's response is streamed token by token and should be handled with StreamingResponseHandler. However, it's recommended to use OpenAiStreamingChatModel instead, as it offers more advanced features like function calling, multi-turn conversations, etc.
  • Constructor Details

  • Method Details

    • modelName

      public String modelName()
    • generate

      public void generate(String prompt, dev.langchain4j.model.StreamingResponseHandler<String> handler)
      Specified by:
      generate in interface dev.langchain4j.model.language.StreamingLanguageModel
    • estimateTokenCount

      public int estimateTokenCount(String prompt)
      Specified by:
      estimateTokenCount in interface dev.langchain4j.model.language.TokenCountEstimator
    • withApiKey

      @Deprecated public static OpenAiStreamingLanguageModel withApiKey(String apiKey)
      Deprecated.
      use builder() instead and explicitly set the model name and, if required, other parameters.
    • builder