Class StreamingChatModelSupplier
- All Implemented Interfaces:
Supplier<dev.langchain4j.model.chat.StreamingChatModel>
This supplier extends AbstractModelSupplier to provide streaming chat model
instances for conversational AI interactions. It supports dynamic model selection
based on configuration and maintains cached instances for efficient reuse.
The supplier integrates with various AI service providers through the
ModelProvider interface, supporting models from OpenAI, OCI GenAI,
Ollama, and other providers. Models are identified using the standard
"provider/model" naming convention.
Configuration:
- Default model: "OpenAI/gpt-4o-mini"
- Configuration property:
model.chat - Supports runtime configuration changes
Usage example:
// Get default chat model
StreamingChatModel model = chatModelSupplier.get();
// Get specific model
StreamingChatModel specificModel = chatModelSupplier.get("oci/meta.llama-3.1-70b-instruct");
- Since:
- 25.09
- Author:
- Aleks Seovic 2025.07.04
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default chat model used when no specific model is configured.Fields inherited from class com.oracle.coherence.rag.model.AbstractModelSupplier
coherenceConfig, config -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringReturns the configuration property key for chat models.dev.langchain4j.model.chat.StreamingChatModelCreates a new streaming chat model instance for the specified model name.protected StringReturns the default model name when no configuration is provided.protected StringReturns a human-readable description of the model type.Methods inherited from class com.oracle.coherence.rag.model.AbstractModelSupplier
defaultModelName, get, get, get
-
Field Details
-
DEFAULT_CHAT_MODEL
The default chat model used when no specific model is configured.This represents a balanced choice between performance and cost for general-purpose conversational AI tasks.
- See Also:
-
-
Constructor Details
-
StreamingChatModelSupplier
public StreamingChatModelSupplier()
-
-
Method Details
-
description
Returns a human-readable description of the model type.This description is used in logging and error messages to identify the type of models this supplier manages.
- Specified by:
descriptionin classAbstractModelSupplier<dev.langchain4j.model.chat.StreamingChatModel>- Returns:
- "chat" identifying this as a chat model supplier
-
defaultModel
Returns the default model name when no configuration is provided.This method provides the fallback chat model that will be used when no explicit configuration is available.
- Specified by:
defaultModelin classAbstractModelSupplier<dev.langchain4j.model.chat.StreamingChatModel>- Returns:
- the default chat model name
-
configProperty
Returns the configuration property key for chat models.This property can be used to configure the default chat model at runtime through various configuration sources.
- Specified by:
configPropertyin classAbstractModelSupplier<dev.langchain4j.model.chat.StreamingChatModel>- Returns:
- "model.chat" as the configuration property key
-
create
Creates a new streaming chat model instance for the specified model name.This method uses the model provider framework to create chat model instances. It looks up the appropriate
ModelProviderbased on the model name's provider component and delegates model creation to that provider.- Specified by:
createin classAbstractModelSupplier<dev.langchain4j.model.chat.StreamingChatModel>- Parameters:
modelName- the name of the chat model to create- Returns:
- a new StreamingChatModel instance
- Throws:
io.helidon.config.ConfigException- if the specified model provider is not supported or if the model cannot be created
-