





















对于workflow 的持久化处理,在执行中还是很重要的,官方提供了一些思路
实际上就是通过存储彬变量在三方中,复用使用
class DbWorkflow(Workflow):
def __init__(self, db: Client, *args, **kwargs):
self.db = db
super().__init__(*args, **kwargs)
@step
def count(self, ev: StartEvent) -> StopEvent:
num_rows = self.db.exec("select COUNT(*) from t;")
return StopEvent(result=num_rows)
w = MyWorkflow()
handler = w.run()
context = handler.ctx
# Save the context to a database
db.save("id", context.to_dict())
#
# Restart the Python process...
#
w = MyWorkflow()
# Load the context from the database
context = Context.from_dict(w, db.load("id"))
# Pass the context containing the state to the workflow
result = await w.run(ctx=context)
实际上就是使用resource(可以是各类共享存储)
持久运行还是比较重要的,尤其是需要可靠执行的场景,官方提供了一些思路可以学习下
https://developers.llamaindex.ai/python/llamaagents/workflows/durable_workflows/
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。