Class AzureOpenAiTokenCountEstimator

java.lang.Object
dev.langchain4j.model.azure.AzureOpenAiTokenCountEstimator
All Implemented Interfaces:
TokenCountEstimator

public class AzureOpenAiTokenCountEstimator extends Object implements TokenCountEstimator
This class can be used to estimate the cost (in tokens) before calling OpenAI or when using streaming. Magic numbers present in this class were found empirically while testing. There are integration tests in place that are making sure that the calculations here are very close to that of OpenAI.
  • Constructor Details

    • AzureOpenAiTokenCountEstimator

      @Deprecated(forRemoval=true) public AzureOpenAiTokenCountEstimator()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Please use other constructors and specify the model name explicitly.
      Creates an instance of the AzureOpenAiTokenCountEstimator for the "gpt-3.5-turbo" model.
    • AzureOpenAiTokenCountEstimator

      public AzureOpenAiTokenCountEstimator(AzureOpenAiChatModelName modelName)
      Creates an instance of the AzureOpenAiTokenCountEstimator for a given AzureOpenAiChatModelName.
    • AzureOpenAiTokenCountEstimator

      public AzureOpenAiTokenCountEstimator(AzureOpenAiEmbeddingModelName modelName)
      Creates an instance of the AzureOpenAiTokenCountEstimator for a given AzureOpenAiEmbeddingModelName.
    • AzureOpenAiTokenCountEstimator

      public AzureOpenAiTokenCountEstimator(AzureOpenAiLanguageModelName modelName)
      Creates an instance of the AzureOpenAiTokenCountEstimator for a given AzureOpenAiLanguageModelName.
    • AzureOpenAiTokenCountEstimator

      public AzureOpenAiTokenCountEstimator(String modelName)
      Creates an instance of the AzureOpenAiTokenCountEstimator for a given model name.
  • Method Details