mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-17 23:51:19 +00:00
Some checks are pending
Pre-commit / run (ubuntu-latest) (push) Waiting to run
- Introduce BaseAsTokenCounter and EstimatedAsTokenCounter for token estimation - Add AsMsgStat and AsBlockStat schema for message statistics tracking - Implement FileIO class with read/write/append/edit operations - Create file utility functions for safe async file reading and truncation - Add MemorySearch component for semantic search in memory files - Register new component types in ComponentEnum and update imports - Add constants for default host, port, and truncation limits - Create BaseService abstract base class for service implementations - Implement BaseStep with component accessors and lifecycle management - Add proper __all__ exports for all new modules and components
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
"""Application context for initializing and managing all configured components."""
|
|
|
|
from ..enumeration import ComponentEnum
|
|
from ..schema import ApplicationConfig
|
|
|
|
|
|
class ApplicationContext:
|
|
"""Application context that initializes and manages all configured components.
|
|
|
|
This class is responsible for parsing the application configuration,
|
|
resolving backend implementations for each component via the registry,
|
|
and instantiating services, components, and jobs.
|
|
"""
|
|
|
|
def __init__(self, **kwargs):
|
|
"""Initialize the application context from configuration kwargs.
|
|
|
|
Args:
|
|
**kwargs: Keyword arguments that form the ApplicationConfig,
|
|
including app_name, service, components, and jobs.
|
|
|
|
Raises:
|
|
ValueError: If a required backend is missing for the service, any component, or any job,
|
|
or if a service, component, or job references an unregistered backend type.
|
|
"""
|
|
self.app_config: ApplicationConfig = ApplicationConfig(**kwargs)
|
|
|
|
from .base_component import BaseComponent
|
|
from .job.base_job import BaseJob
|
|
|
|
self.service = None
|
|
self.components: dict[ComponentEnum, dict[str, BaseComponent]] = {}
|
|
self.jobs: dict[str, BaseJob] = {}
|