workflows/merico/chatflow/util/workflow_guide.md
2025-03-11 13:29:58 +08:00

1.9 KiB
Raw Blame History

一个工作流对应一个目录目录可以进行嵌套每个工作流在UI视图中对应了一个斜杠命令例如/github.commit。

github工作流目录结构简化后示意如下 github -- commit |-- command.yml |-- command.py

    |-- README.md

-- new_pr |-- command.yml |-- command.py ......

"command.yml"文件定义了工作流命令的元信息,例如命令的名称、描述、参数等。 "command.py"文件定义了工作流命令的实现逻辑。

拿一个hello world工作流命令为例目录结构如下 helloworld -- command.yml -- command.py -- README.md

"command.yml"文件内容如下:

description: Hello Workflow, use as /helloworld <name>
input: required
steps:
  - run: $devchat_python $command_path/command.py "$input"

"command.py"文件内容如下:

import sys
print(sys.argv[1])

使用一个工作流时在DevChat AI智能问答视图中输入斜杠命令例如/helloworld ,即可执行该工作流命令。/helloworld表示对应系统可用的工作流。表示工作流的输入是可选的如果工作流定义中input为required则必须输入否则可以不输入。

工作流命令有重载优先级merico目录下工作流 < community目录下工作流 < custom目录下工作流。 例如如果merico与community目录下都有github工作流那么在DevChat AI智能问答视图中输入/github命令时会优先执行community目录下的github工作流命令。

在custom目录下通过config.yml文件定义custom目录下的工作流目录。例如 namespaces:

  • bobo 那么custom/bobo就是一个工作流存储目录可以在该目录下定义工作流命令。 例如: custom/bobo | ---- hello |------ command.yml |------ command.py 那么custom/bobo/hello对应的工作流命令就是/hello.