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 ```
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
"""Base job component for sequential step execution."""
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from ..base_component import BaseComponent
|
|
from ..component_registry import R
|
|
from ..runtime_context import RuntimeContext
|
|
from ...enumeration import ComponentEnum
|
|
from ...schema import Response, ComponentConfig
|
|
|
|
if TYPE_CHECKING:
|
|
from ..base_step import BaseStep
|
|
|
|
|
|
@R.register("base")
|
|
class BaseJob(BaseComponent):
|
|
"""Job that executes steps sequentially."""
|
|
|
|
component_type = ComponentEnum.JOB
|
|
|
|
def __init__(
|
|
self,
|
|
description: str = "",
|
|
parameters: dict | None = None,
|
|
steps: list[ComponentConfig] | None = None,
|
|
**kwargs,
|
|
):
|
|
super().__init__(**kwargs)
|
|
self.description = description
|
|
self.parameters = parameters or {}
|
|
self.step_configs = steps or []
|
|
self.step_components: list["BaseStep"] = []
|
|
|
|
async def _start(self) -> None:
|
|
assert self.app_context is not None, "app_context must be provided"
|
|
for raw in self.step_configs:
|
|
config = raw if isinstance(raw, ComponentConfig) else ComponentConfig(**raw)
|
|
if not config.backend:
|
|
raise ValueError(f"Step is missing the required 'backend' field")
|
|
step_cls = R.get(ComponentEnum.STEP, config.backend)
|
|
if not step_cls:
|
|
raise ValueError(
|
|
f"Step references an unregistered backend '{config.backend}' " f"of type '{ComponentEnum.STEP}'",
|
|
)
|
|
params = config.model_dump()
|
|
params["app_context"] = self.app_context
|
|
self.step_components.append(step_cls(**params))
|
|
|
|
async def _close(self) -> None:
|
|
self.step_components.clear()
|
|
|
|
async def __call__(self, **kwargs) -> Response:
|
|
context = RuntimeContext(**kwargs)
|
|
for step_component in self.step_components:
|
|
await step_component(context)
|
|
return context.response
|