mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-09 22:31:05 +00:00
refactor: clarify auto resource routing structure
This commit is contained in:
parent
b3b9dd7cdf
commit
fe4098cfb8
10 changed files with 12 additions and 17 deletions
|
|
@ -67,7 +67,7 @@ The corresponding flow is:
|
|||
important facts to a topic-named `daily/<date>/<generated_name>.md`. The note keeps `session_id` and
|
||||
`source_conversation` in frontmatter for stable lookup and provenance.
|
||||
- `resource_watch_loop` watches supported text and image changes under `resource/` and triggers `auto_resource_step` to
|
||||
write a daily note with `source_resource`. Text resources use an agent, while images use a vision model. The generated
|
||||
write a daily note with `source_resource`. Text resources use the agent, while images use a vision model. The generated
|
||||
content-based filename is sanitized and de-duplicated; it is not guaranteed to match the resource filename.
|
||||
- Auto Memory, Auto Resource, and Auto Dream refresh `daily/<date>.md` after writing.
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,8 @@ from agentscope.message import Base64Source, DataBlock, TextBlock, UserMsg
|
|||
from agentscope.model import ChatModelBase
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from ..file_io import is_image_file
|
||||
from ..file_io._path import IMAGE_MIME_BY_EXT, IMAGE_SUFFIXES
|
||||
from ._auto_resource import _SOURCE_RESOURCE_KEY, _sanitize_note_name, BaseAutoResourceStep
|
||||
from .base_auto_resource import _SOURCE_RESOURCE_KEY, _sanitize_note_name, BaseAutoResourceStep
|
||||
from ...components import R
|
||||
from ...enumeration import ComponentEnum
|
||||
|
||||
|
|
@ -294,7 +293,7 @@ class AutoImageResourceStep(BaseAutoResourceStep):
|
|||
|
||||
async def _handle_change(self, file_path: str, raw_change) -> dict:
|
||||
"""Skip non-image changes; isolate per-change failures so the batch continues."""
|
||||
if file_path and not is_image_file(file_path):
|
||||
if file_path and not self.matches_change({"path": file_path}):
|
||||
file_path = self.to_workspace_relative(file_path) if Path(file_path).is_absolute() else file_path
|
||||
self.context.response.metadata = {}
|
||||
answer = f"Skipped non-image resource file: {file_path}"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import inspect
|
|||
from ...components import R
|
||||
from ...enumeration import ComponentEnum
|
||||
from ..base_step import BaseStep
|
||||
from ._auto_resource import BaseAutoResourceStep, _results_answer
|
||||
from .base_auto_resource import BaseAutoResourceStep, _results_answer
|
||||
|
||||
_ProcessorSpec = str | dict
|
||||
_IndexedChange = tuple[int, dict]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import aiofiles
|
|||
|
||||
from ...components import R
|
||||
from ._evolve import agent_reply_result_text
|
||||
from ._auto_resource import BaseAutoResourceStep
|
||||
from .base_auto_resource import BaseAutoResourceStep
|
||||
|
||||
|
||||
def _compute_agent_session_id(path: str) -> str:
|
||||
|
|
@ -18,6 +18,8 @@ def _compute_agent_session_id(path: str) -> str:
|
|||
class AutoTextResourceStep(BaseAutoResourceStep):
|
||||
"""Interpret text resource files into daily notes via an Agent."""
|
||||
|
||||
# Preserve the pre-router AutoResourceStep behavior for direct calls and
|
||||
# custom watcher suffixes; the default watcher still limits normal inputs.
|
||||
resource_fallback = True
|
||||
router_inherit_keys = BaseAutoResourceStep.router_inherit_keys | frozenset(
|
||||
{"agent_wrapper", "max_file_bytes", "prompt_dict"},
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from ._daily_index import extract_daily_date, parse_daily_date, refresh_day_index, validate_session_id
|
||||
from ._file_io import get_path_lock, write_file_safe
|
||||
from ._path import is_image_file, validate_filename_component
|
||||
from ._path import validate_filename_component
|
||||
from .daily_list import DailyListStep
|
||||
from .daily_reindex import DailyReindexStep
|
||||
from .daily_write import DailyWriteStep
|
||||
|
|
@ -26,7 +26,6 @@ __all__ = [
|
|||
"parse_daily_date",
|
||||
"validate_session_id",
|
||||
"validate_filename_component",
|
||||
"is_image_file",
|
||||
"get_path_lock",
|
||||
"write_file_safe",
|
||||
"DailyListStep",
|
||||
|
|
|
|||
|
|
@ -31,11 +31,6 @@ IMAGE_MIME_BY_EXT: dict[str, str] = {
|
|||
IMAGE_SUFFIXES = frozenset(IMAGE_MIME_BY_EXT)
|
||||
|
||||
|
||||
def is_image_file(path: str | Path) -> bool:
|
||||
"""Return True when ``path`` carries a known image file suffix."""
|
||||
return Path(path).suffix.lower() in IMAGE_SUFFIXES
|
||||
|
||||
|
||||
_INVALID_CHARS = re.compile(r'[<>:"/\\|?*\x00-\x1f]')
|
||||
_RESERVED_NAMES = {
|
||||
"CON",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ sys.path.insert(0, str(INTEGRATION_DIR))
|
|||
# pylint: disable=wrong-import-position
|
||||
from _workspace_fixture import workspace_env # noqa: E402
|
||||
|
||||
from reme.steps.evolve._auto_resource import _compute_note_stem # noqa: E402
|
||||
from reme.steps.evolve.base_auto_resource import _compute_note_stem # noqa: E402
|
||||
from reme.steps.evolve.auto_text_resource import _compute_agent_session_id # noqa: E402
|
||||
|
||||
RESOURCE_FILENAME = "project-roadmap.md"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ from reme.components.file_store import LocalFileStore
|
|||
from reme.components.job import BaseJob
|
||||
from reme.components.runtime_context import RuntimeContext
|
||||
from reme.enumeration import ComponentEnum
|
||||
from reme.steps.evolve._auto_resource import BaseAutoResourceStep
|
||||
from reme.steps.evolve.base_auto_resource import BaseAutoResourceStep
|
||||
from reme.steps.evolve.auto_image_resource import (
|
||||
AutoImageResourceStep,
|
||||
_build_image_request_payload,
|
||||
|
|
@ -956,7 +956,7 @@ def test_auto_image_reports_modified_when_index_refresh_fails_after_write():
|
|||
async def fail_refresh(*_args, **_kwargs):
|
||||
raise RuntimeError("index refresh failed")
|
||||
|
||||
with patch("reme.steps.evolve._auto_resource.refresh_day_index", new=fail_refresh):
|
||||
with patch("reme.steps.evolve.base_auto_resource.refresh_day_index", new=fail_refresh):
|
||||
resp = await _run_step(step, [{"change": "added", "path": str(source)}])
|
||||
|
||||
result = resp.metadata["results"][0]
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from reme.components.file_store import LocalFileStore
|
|||
from reme.components.runtime_context import RuntimeContext
|
||||
from reme.enumeration import ComponentEnum
|
||||
from reme.steps.evolve.auto_memory import AutoMemoryStep
|
||||
from reme.steps.evolve._auto_resource import _compute_note_stem
|
||||
from reme.steps.evolve.base_auto_resource import _compute_note_stem
|
||||
from reme.steps.evolve.auto_resource import AutoResourceStep
|
||||
from reme.steps.evolve.auto_text_resource import AutoTextResourceStep
|
||||
from reme.steps.file_io.daily_list import DailyListStep
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue