Package dev.langchain4j.model.openai
Class OpenAiLanguageModel
java.lang.Object
dev.langchain4j.model.openai.OpenAiLanguageModel
- All Implemented Interfaces:
LanguageModel
,TokenCountEstimator
Represents an OpenAI language model with a completion interface, such as gpt-3.5-turbo-instruct.
However, it's recommended to use
OpenAiChatModel
instead,
as it offers more advanced features like function calling, multi-turn conversations, etc.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder class for constructing instances ofOpenAiLanguageModel
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuilder()
int
estimateTokenCount
(String prompt) Estimates the count of tokens in the given text.Generate a response to the given prompt.static OpenAiLanguageModel
withApiKey
(String apiKey) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.model.language.LanguageModel
generate
Methods inherited from interface dev.langchain4j.model.language.TokenCountEstimator
estimateTokenCount, estimateTokenCount
-
Constructor Details
-
OpenAiLanguageModel
-
-
Method Details
-
modelName
-
generate
Description copied from interface:LanguageModel
Generate a response to the given prompt.- Specified by:
generate
in interfaceLanguageModel
- Parameters:
prompt
- the prompt.- Returns:
- the response.
-
estimateTokenCount
Description copied from interface:TokenCountEstimator
Estimates the count of tokens in the given text.- Specified by:
estimateTokenCount
in interfaceTokenCountEstimator
- Parameters:
prompt
- the text.- Returns:
- the estimated count of tokens.
-
withApiKey
Deprecated, for removal: This API element is subject to removal in a future version.Please usebuilder()
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
-
builder()
instead, and explicitly set the model name and, if necessary, other parameters.