Configuration
Overview
The ConfigManager
manages the configuration and dependency injection of the language models used within the library.
This documentation explains how the configuration system works, for both contributors and users of the library.
How Configuration Works
For Library Users:
Initialize
Users must initialize the ConfigManager
and configure it to use specific values before utilizing them in their
application. This is achieved by invoking the configure()
method and passing a configuration dictionary.
Current Configuration Dictionary:
config_dict = {
'open_ai_chat_model': 'your_desired_chat_model',
'open_ai_embedding_model': 'your_desired_embedding_model',
}
Initializing and Configuring:
config_manager = ConfigManager()
config_manager.configure(config_dict)
For Library Contributors:
Understanding ConfigManager
-
Singleton Pattern:
ConfigManager
employs a singleton pattern, ensuring that a single instance is utilized across the entire application, preserving a consistent configuration state. -
Dependency Injection: Using the
injector
module, it defines classes (e.g.ChatModule
orEmbeddingModule
) to handle dependency injection and configuration for models (e.g.OpenAIChat
orOpenAIEmbedding
). -
Lazy Initialization: Models are not instantiated until they are requested, ensuring configuration is only needed, when you intend to use a model that requires that specific configuration.
Additional Information
Look at cognaize.melody.language_models.chat.open_ai_chat
or
cognaize.melody.language_models.embedding.open_ai_embedding
modules to understand injection implementations and
extend them as per your needs.