ReMe/reme/steps/common/demo.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

53 lines
1.8 KiB
Python

"""Demo steps for integration-testing the application stack."""
from ..base_step import BaseStep
from ...core.registry import R
@R.register("demo_echo_step1")
class DemoEchoStep1(BaseStep):
"""Read query/min_score from context, normalize, and write back for Step2."""
async def execute(self):
assert self.context is not None
query = self.context.get("query", "")
min_score = self.context.get("min_score", 0.5)
self.logger.info(f"[{self.name}] query={query!r}, min_score={min_score}")
processed_query = query.strip().lower()
adjusted_min_score = float(min_score) * 0.9
self.context["processed_query"] = processed_query
self.context["adjusted_min_score"] = adjusted_min_score
return self.context.response
@R.register("demo_echo_step2")
class DemoEchoStep2(BaseStep):
"""Consume Step1's outputs from context and emit the final response."""
async def execute(self):
assert self.context is not None
query = self.context.get("query", "")
min_score = self.context.get("min_score", 0.5)
processed_query = self.context.get("processed_query", "")
adjusted_min_score = self.context.get("adjusted_min_score", min_score)
self.logger.info(
f"[{self.name}] query={query!r}, min_score={min_score}, "
f"processed_query={processed_query!r}, adjusted_min_score={adjusted_min_score}",
)
self.context.response.answer = f"echo: {processed_query} (min_score={adjusted_min_score})"
self.context.response.metadata.update(
{
"step": self.name,
"query": query,
"min_score": min_score,
"processed_query": processed_query,
"adjusted_min_score": adjusted_min_score,
},
)
return self.context.response