基础¶
最小化 TriggerFlow 流程示例。
源码¶
from agently import TriggerFlow, TriggerFlowEventData
## TriggerFlow Basics: chunks, to(), end(), start()
def triggerflow_basics():
# Idea: build the smallest flow and see data pass through one node.
# Flow: START -> greet -> END
# Expect: prints "Hello, Agently"
flow = TriggerFlow()
async def greet(data: TriggerFlowEventData):
return f"Hello, {data.value}"
flow.to(greet).end()
result = flow.start("Agently")
print(result)
# triggerflow_basics()
讲解¶
- START -> to -> end 的基本链路。
注释解读¶
- Idea 表示案例思路
- Flow 表示执行编排路径
- Expect 表示预期输出或行为
你学会了什么¶
- 掌握 TriggerFlow 最小链路与 end()
- 理解 START 到 END 的执行路径
练习任务¶
- 把输入改成 dict 并观察输出结构