mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-17 23:51:19 +00:00
- Integrate AnthropicChatModel with new AnthropicAsLLM component - Add component formatters for OpenAI and Anthropic chat models - Implement token counter component with estimated token counting - Create base client component for ReMe service communication - Refactor BaseComponent to remove app_context parameter from _start/_close - Update embedding model base class to remove retry logic and use npz cache - Add job component for sequential step execution with BaseJob - Implement step component base class for LLM workflow execution - Enhance application context with proper type annotations - Update component initialization to pass app_context automatically - Remove asyncio dependency from embedding model cache operations
34 lines
1.3 KiB
Python
34 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 import BaseJob
|
|
from .service import BaseService
|
|
|
|
self.service: BaseService | None = None
|
|
self.components: dict[ComponentEnum, dict[str, BaseComponent]] = {}
|
|
self.jobs: dict[str, BaseJob] = {}
|