agent就是智能体 ...
何为智?就是善假于物
这里的物就是工具箱,定义了一系列工具,让大模型调用...
大模型负责调度,具体细节由工具实现...
|
|
|
|
|
|
|
|
#创建一个工作流
wf = Agently.Workflow()
@wf.chunk()
def add1(inputs, storage):
a = inputs["default"]
return a +1
@wf.chunk()
def add10(inputs, storage):
a = inputs["default"]
return a + 10
(
wf
.connect_to("add1")
.connect_to("add10")
.connect_to("END")
)
wf.start(1)
{'default': 12}
---------------------------------------------------------------------------
|
#创建一个工作流
wf = Agently.Workflow()
@wf.chunk()
def add1(inputs, storage):
a = inputs["default"]
storage.set("step1", f"step1:a=a+1={a+1}")
return a +1
@wf.chunk()
def add10(inputs, storage):
a = inputs["default"]
storage.set("step2", f"step2:a=a+10={a+10}")
return a + 10
@wf.chunk()
def print_step(inputs, storage):
print(storage.get("step1"))
print(storage.get("step2"))
return inputs["default"]
(
wf
.connect_to("add1")
.connect_to("add10")
.connect_to("print_step")
.connect_to("END")
)
wf.start(1)
step1:a=a+1=2
step2:a=a+10=12
{'default': 12}
每个方法必须有return,workflow把上一个方法return的值,传递给下一个方法的inputs的default 而 storage则是流程中固定的字典 |
|
|
|
|
|
|
Huggingface 镜像站