mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-27 23:58:47 +00:00
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 * 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.
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
"""Demo for typed probabilistic decisions over text or JSON state."""
|
|
|
|
import json
|
|
from dataclasses import asdict
|
|
|
|
from ..base_step import BaseStep, Ref
|
|
from ...core.registry import R
|
|
from ...components.as_decision_model import BaseAsDecisionModel
|
|
from ...enumeration import ComponentEnum
|
|
|
|
|
|
@R.register("decision_demo_step")
|
|
class DecisionDemoStep(BaseStep):
|
|
"""Return complete decision model output and share it with subsequent Steps."""
|
|
|
|
as_decision_model = Ref(BaseAsDecisionModel, ComponentEnum.AS_DECISION_MODEL)
|
|
|
|
@staticmethod
|
|
def default_questions() -> dict:
|
|
"""Create independent demo questions for each invocation."""
|
|
return {
|
|
"urgent": {"type": "binary", "instructions": "Does this customer request need urgent attention?"},
|
|
"route": {
|
|
"type": "choice",
|
|
"instructions": "Select the team that should handle this customer request.",
|
|
"criteria": {"billing": "Payments and charges", "support": "Technical help", "other": "Other requests"},
|
|
},
|
|
"priority": {
|
|
"type": "score",
|
|
"instructions": "Rate the priority of this customer request.",
|
|
"criteria": ["Low", "Medium", "High"],
|
|
},
|
|
}
|
|
|
|
async def execute(self):
|
|
assert self.context is not None
|
|
# Explicit null/empty questions are invalid; only omission enables the demo defaults.
|
|
questions = self.context.get("questions", self.default_questions())
|
|
result = await self.as_decision_model(state=self.context.get("state"), questions=questions)
|
|
answer = json.loads(json.dumps(asdict(result), ensure_ascii=False, allow_nan=False))
|
|
self.context.data["decision_result"] = answer
|
|
self.context.response.answer = answer
|
|
return self.context.response
|