ReMe/reme/steps/common/chat.py
jinliyl 54fa3381d7
Some checks failed
CI and Release / Docker / Build and test / amd64 (push) Has been cancelled
CI and Release / Docker / Build and test / arm64 (push) Has been cancelled
Security / CodeQL / Analyze python (push) Has been cancelled
CI / Python quality / Pre-commit (push) Has been cancelled
CI / Python tests / Unit Tests - py3.12 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.13 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.14 (push) Has been cancelled
CI / Python packages / Build and verify distributions (push) Has been cancelled
CI / Python quality / GitHub Actions (push) Has been cancelled
CI / Python tests / Hermes embedded - ubuntu-latest (push) Has been cancelled
CI / Python tests / Hermes embedded - windows-latest (push) Has been cancelled
CI / Python tests / Unit Tests - py3.11 (push) Has been cancelled
CI / ReMe Studio / Studio checks (push) Has been cancelled
Deploy / Documentation / Build documentation (push) Has been cancelled
CI / Windows / CLI smoke - py3.11 (push) Has been cancelled
Security / CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI and Release / Docker / Publish multi-platform tags (push) Has been cancelled
Deploy / Documentation / deploy (push) Has been cancelled
refactor(core): reorganize the ReMe runtime and shared helpers (#769)
* refactor(core): reorganize the ReMe runtime and shared helpers

* test(status): import the base component from its canonical module

* test: remove redundant unit checks

* refactor(core): use canonical runtime imports and shared CLI discovery

Restore evolve behavior to the base branch and update its imports. Use Application as the runtime entry point and encode SSE in the HTTP service.

* fix(cli): honor caller config when service replay is incomplete

Use partial startup overrides for port probes and resolve named configs before requesting the service process working directory.
2026-11-20 22:06:46 +08:00

39 lines
1.6 KiB
Python

"""Workspace-aware streaming chat step for the ReMe web interface."""
from ..base_step import BaseStep
from ...core.registry import R
from ...schema import collect_reply
@R.register("chat_step")
class ChatStep(BaseStep):
"""Stream a workspace conversation with read-only-by-default tools and an empty prompt unless configured."""
READ_ONLY_TOOLS = ["search", "list", "read", "read_image", "frontmatter_read", "stat", "traverse"]
async def execute(self):
assert self.context is not None
query = str(self.context.get("query") or "").strip()
if not query:
self.context.response.success = False
self.context.response.answer = "Skipped: empty query"
return self.context.response
if self.agent_wrapper is None:
raise RuntimeError("chat_step requires an agent_wrapper")
wrapper_kwargs = {
"system_prompt": str(self.context.get("system_prompt") or ""),
"job_tools": self.kwargs.get("job_tools", self.READ_ONLY_TOOLS),
"builtin_tools": [],
}
if session_id := self.context.get("session_id"):
wrapper_kwargs["resume"] = str(session_id)
result = await collect_reply(
self.agent_wrapper.reply_stream(query, **wrapper_kwargs),
on_chunk=self.context.add_stream_chunk,
)
self.context.response.success = result["status"] == "completed" and self.context.stream_error is None
self.context.response.answer = result["result"]
self.context.response.metadata.update(result)
return self.context.response