Package dev.langchain4j.model.openai
Class OpenAiStreamingChatModel
java.lang.Object
dev.langchain4j.model.openai.OpenAiStreamingChatModel
- All Implemented Interfaces:
StreamingChatLanguageModel
,TokenCountEstimator
public class OpenAiStreamingChatModel
extends Object
implements StreamingChatLanguageModel, 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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
-
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
void
doChat
(ChatRequest chatRequest, StreamingChatResponseHandler handler) int
estimateTokenCount
(List<ChatMessage> messages) Estimates the count of tokens in the specified list of messages.Deprecated, for removal: This API element is subject to removal in a future version.provider()
static OpenAiStreamingChatModel
withApiKey
(String apiKey) 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.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.chat.StreamingChatLanguageModel
chat, chat, chat, supportedCapabilities
Methods inherited from interface dev.langchain4j.model.chat.TokenCountEstimator
estimateTokenCount, estimateTokenCount, estimateTokenCount, estimateTokenCount
-
Constructor Details
-
OpenAiStreamingChatModel
-
-
Method Details
-
modelName
Deprecated, for removal: This API element is subject to removal in a future version.please usedefaultRequestParameters()
and thenChatRequestParameters.modelName()
instead -
defaultRequestParameters
- Specified by:
defaultRequestParameters
in interfaceStreamingChatLanguageModel
-
doChat
- Specified by:
doChat
in interfaceStreamingChatLanguageModel
-
listeners
- Specified by:
listeners
in interfaceStreamingChatLanguageModel
-
provider
- Specified by:
provider
in interfaceStreamingChatLanguageModel
-
estimateTokenCount
Description copied from interface:TokenCountEstimator
Estimates the count of tokens in the specified list of messages.- Specified by:
estimateTokenCount
in interfaceTokenCountEstimator
- Parameters:
messages
- the list of messages- 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
-
defaultRequestParameters()
and thenChatRequestParameters.modelName()
instead