mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-22 00:32:49 +00:00
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
docs: add ReMe2 architecture design documentation - Add comprehensive design document (reme2.md) detailing the three-layer architecture (L1/L2/L3) for the vault system - Document new protocols for folder notes and memory management - Specify interface contracts for memory_* and vault_* tools - Outline implementation phases from current state to target refactor: fix typo in personal retriever class - Correct spelling error: 'retri eved_nodes' -> 'retrieved_nodes' in PersonalRetriever.result assignment chore: update gitignore with vault-related patterns - Add '/vault' to ignore vault directory - Add '/reme-plugin' to ignore plugin files - Add '/reme2/vault' to ignore new vault implementation ```
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""Abstract base class for service implementations."""
|
|
|
|
from abc import abstractmethod
|
|
from typing import TYPE_CHECKING
|
|
|
|
from ..base_component import BaseComponent
|
|
from ..job.base_job import BaseJob
|
|
from ...enumeration import ComponentEnum
|
|
|
|
if TYPE_CHECKING:
|
|
from ...application import Application
|
|
|
|
|
|
class BaseService(BaseComponent):
|
|
"""Abstract base class for services that expose jobs (HTTP, MCP, etc.)."""
|
|
|
|
component_type = ComponentEnum.SERVICE
|
|
|
|
def __init__(self, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self.service = None
|
|
|
|
@abstractmethod
|
|
def build_service(self, app: "Application") -> None: ...
|
|
|
|
@abstractmethod
|
|
def add_job(self, job: BaseJob) -> None: ...
|
|
|
|
@abstractmethod
|
|
def start_service(self, app: "Application") -> None: ...
|
|
|
|
def add_jobs(self, app: "Application") -> None:
|
|
for name, job in app.context.jobs.items():
|
|
try:
|
|
self.add_job(job)
|
|
self.logger.info(f"Successfully Added job {name}")
|
|
except Exception as e:
|
|
self.logger.error(f"Failed to add job {name}: {e}")
|
|
|
|
def run_app(self, app: "Application") -> None:
|
|
self.build_service(app)
|
|
self.add_jobs(app)
|
|
self.start_service(app)
|