This document provides a high-level overview of the Ember core architecture, its main components, extension points, and how dependency injection has been employed to improve testability and flexibility.
-
EmberAppContext:
The central application context responsible for aggregating and providing:ConfigManager
(for config, environment variable resolution)ModelRegistry
(handles discovery and registration of models)UsageService
(tracks API usage across calls)- A common
logger
instance
-
ConfigCore:
Centralized logic for merging configuration files, reading from environment variables, and validating settings. All configuration-related modules should delegate to this core. -
ModelService & Registry:
ModelService
acts as a high-level facade that pulls a model from theModelRegistry
, delegates API calls, and logs usage viaUsageService
. The registry itself is populated during application initialization using auto-discovery routines. -
Provider Extensions & Discovery:
New providers should subclassBaseProviderModel
and be registered via a unified ModelFactory. See the EXTENDING.md guide for step-by-step instructions.
ember.core.app_context
: Contains theEmberAppContext
class, which holds references to core services likeConfigManager
,ModelRegistry
, andUsageService
. This is the central point of access for the application.ember.core.configs
: Manages configuration loading and access. TheConfigManager
class handles reading configuration files, merging settings, and providing access to configuration values.ember.core.registry
: Handles the registration and instantiation of models.model
: Contains the core logic for model management, including theModelRegistry
,ModelService
,ModelFactory
, and provider-specific implementations.provider_registry
: Contains base classes and specific implementations for different model providers (e.g., OpenAI, Anthropic, Deepmind).
ember.core.exceptions
: Defines custom exception classes used throughout the library for consistent error handling.ember.core.non
:
When a language model call is made, the following sequence of events occurs:
- The user interacts with the
ModelService
, either directly or through a higher-level operator. ModelService
uses the provided model ID to retrieve the correspondingBaseProviderModel
instance from theModelRegistry
.ModelService
calls the__call__
method of theBaseProviderModel
instance, passing the prompt and any additional parameters.- The
BaseProviderModel
implementation handles the provider-specific API call and returns aChatResponse
. - If a
UsageService
is configured,ModelService
logs usage statistics from theChatResponse
.
Directory | Description |
---|---|
ember.core.configs |
Handles configuration loading, merging, and environment variable resolution. |
ember.core.registry.model |
Manages the registration, instantiation, and invocation of models. Includes core schemas, services (ModelService, UsageService), the ModelRegistry, ModelFactory, and provider-specific implementations. |
ember.core.registry.operator |
(Further description needed) |
ember.core.exceptions |
Defines custom exception classes for consistent error handling. |
ember.core.utils |
(Further description needed - contains data and eval base classes) |
ember.core.non |
(Further description needed - this seems to be a set of higher-level operators, potentially a "non-differentiable" module, but clarification is needed on the name and purpose) |
ember.examples |
Contains example scripts demonstrating various usage patterns of the library. |
For a deeper dive into the model registry and the "network-of-networks" approach, see model_readme.md.