通过本地API(端口6400)调用ChatDev能力单元(工作流)。适用于用户需要专业代理工作流的场景,如数据可视化(从CSV)...
ChatDev 能力单位是一项面向实际任务的技能,主要用于能力单位代表能力单位;您可以浏览可用的设备, 检查;
它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。该技能适合需要稳定复用相关能力的场景,可作为自动化工作流的一部分,也便于后续检查、调整和扩展。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
能力单元代表可复用的功能模块。你可以浏览当前可用的能力单元、查看其所需参数、执行它们,或上传新的能力单元。当需要通过本地 API 调用预定义的能力单元(例如:论文评审、数据可视化)时,请使用以下接口。
通过本地 API 运行能力单元,并从 JSON 响应中提取并返回 final_message 字段值。
curl --noproxy 127.0.0.1 -v http://127.0.0.1:6400/api/workflows
curl --noproxy 127.0.0.1 -v
http://127.0.0.1:6400/api/workflows/test.yaml/get
curl --noproxy 127.0.0.1 -v -X GET
http://127.0.0.1:6400/api/workflows/test.yaml/args
方法:POST
Content-Type:application/json
SSE 支持:设置请求头 Accept: text/event-stream 可启用事件流(支持 started、log、completed、error 等事件)。若省略该请求头,则返回标准 JSON 响应。
输出处理:解析响应 JSON,提取并返回 final_message 字段;若缺失该字段,则视为失败,需报告错误并包含任意 error 字段。获取到 output_dir 后,请将其移动至你的工作目录(workspace)中。
当前可用能力单元:
yaml_instance/paper_review.yamlcurl --noproxy 127.0.0.1 -v -X POST http://127.0.0.1:6400/api/workflow/run
-H "Content-Type: application/json"
-H "Accept: text/event-stream"
-d '{
"yaml_file": "yaml_instance/paper_review.yaml",
"task_prompt": "https://arxiv.org/abs/1706.03762"
}'
yaml_instance/data_visualization_basic.yamlcurl --noproxy 127.0.0.1 -v -X POST http://127.0.0.1:6400/api/workflow/run
-H "Content-Type: application/json"
-d '{
"yaml_file": "yaml_instance/data_visualization_basic.yaml",
"task_prompt": "please analyze and visualize the data",
"attachments": ["/Users/yufan/Projects/bugfix/ChatDev/sample_sales.csv"]
}'
filename 必须以 .yaml 结尾;content 必须为合法 YAML 字符串,且必须包含 version、vars 和 graph 字段;其中 graph 需包含 id、start、nodes 与 edges(结构参见下方示例)。curl --noproxy 127.0.0.1 -v -X POST
http://127.0.0.1:6400/api/workflows/upload/content
-H "Content-Type: application/json"
-d @- <<'EOF'
{
"filename": "test.yaml",
"content": "version: 0.4.0nvars: {}ngraph:n id: paper_reviewn description: Three agents collaboratively review academic papers from different perspectives. Input can be an arxiv URL or paper title.n is_majority_voting: falsen start:n - Paper Fetchern nodes:n - id: Paper Fetchern type: agentn config:n name: gpt-4on provider: openain role: |n You are a paper content fetcher.n base_url: ${BASE_URL}n api_key: ${API_KEY}n description: Fetches paper content from arxivn context_window: 0n edges: []"
}
EOF
filename 和 YAML 格式的 content 字符串)。curl --noproxy 127.0.0.1 -v -X PUT
http://127.0.0.1:6400/api/workflows/test.yaml/update
-H "Content-Type: application/json"
-d @- <<'EOF'
{
"filename": "test.yaml",
"content": "version: 0.4.0nvars: {}ngraph:n id: paper_reviewn description: Update example.n is_majority_voting: falsen start:n - Paper Fetchern nodes:n - id: Paper Fetchern type: agentn config:n name: gpt-4on provider: openain role: |n You are a paper content fetcher.n base_url: ${BASE_URL}n api_key: ${API_KEY}n description: Fetches paper content from arxivn context_window: 0n edges: []"
}
EOF
{ "new_filename": "new_name.yaml" }curl --noproxy 127.0.0.1 -v -X POST
http://127.0.0.1:6400/api/workflows/test.yaml/rename
-H "Content-Type: application/json"
-d '{"new_filename":"renamed.yaml"}'
{ "new_filename": "copy.yaml" }curl --noproxy 127.0.0.1 -v -X POST
http://127.0.0.1:6400/api/workflows/test.yaml/copy
-H "Content-Type: application/json"
-d '{"new_filename":"test-copy.yaml"}'
curl --noproxy 127.0.0.1 -v -X DELETE
http://127.0.0.1:6400/api/workflows/test.yaml/delete
curl --noproxy 127.0.0.1 -X GET http://127.0.0.1:6400/api/tools/local
本地函数工具由同一后端服务(端口 6400)统一管理。
相关接口:
GET http://127.0.0.1:6400/api/tools/localPOST http://127.0.0.1:6400/api/tools/local创建示例:
curl --noproxy 127.0.0.1 -X POST http://127.0.0.1:6400/api/tools/local
-H "Content-Type: application/json"
-d '{
"filename": "add.py",
"content": "def add(a: int, b: int) -> dict:n return {"result": a + b}n",
"overwrite": true
}'
YAML 示例(用于 local function_calling):
tooling:
- type: function
config:
tools:
- name: add
web_search 工具。read_webpage_content 工具。describe_available_files 和 list_directory 工具。read_text_file_snippet 或 read_file_segment 工具。save_file 工具。以下为可直接复制并适配的高级 YAML 模板,涵盖辩论循环(debate loop)、子图复用(subgraph reuse)、条件边(conditional edges)及选择性载荷路由(selective payload routing)等模式。
version: 0.4.0
vars: {}
graph:
id: debate_loop
description: Two agents debate until the judge outputs "Verdict: STOP".
is_majority_voting: false
start:
- Topic
nodes:
- id: Topic
type: passthrough
config: {}
- id: Pro
type: agent
config:
provider: openai
base_url: ${BASE_URL}
api_key: ${API_KEY}
name: gpt-4o
role: |
You are the PRO debater. Respond with arguments and counterpoints.
- id: Con
type: agent
config:
provider: openai
base_url: ${BASE_URL}
api_key: ${API_KEY}
name: gpt-4o
role: |
You are the CON debater. Respond with arguments and counterpoints.
- id: Judge
type: agent
config:
provider: openai
base_url: ${BASE_URL}
api_key: ${API_KEY}
name: gpt-4o
role: |
Evaluate the debate. Output:
Score: <0-1>
Notes:
Verdict: CONTINUE|STOP
- id: Final
type: agent
config:
provider: openai
base_url: ${BASE_URL}
api_key: ${API_KEY}
name: gpt-4o
role: |
Produce the final summary of the debate and recommendation.
edges:
- from: Topic
to: Pro
keep_message: true
- from: Topic
to: Con
keep_message: true
- from: Pro
to: Judge
- from: Con
to: Judge
- from: Judge
to: Pro
condition: need_reflection_loop
- from: Judge
to: Con
condition: need_reflection_loop
- from: Judge
to: Final
condition: should_stop_loop
version: 0.4.0
vars: {}
graph:
id: parent_with_subgraph
description: Uses a subgraph and only forwards the "Summary" section.
start:
- Request
nodes:
- id: Request
type: passthrough
config: {}
- id: ResearchSubgraph
type: subgraph
config:
type: file
config:
path: "subgraphs/deep_research_executor_sub.yaml"
- id: Writer
type: agent
config:
provider: openai
base_url: ${BASE_URL}
api_key: ${API_KEY}
name: gpt-4o
role: |
Write the final report using only the provided Summary.
edges:
- from: Request
to: ResearchSubgraph
keep_message: true
- from: ResearchSubgraph
to: Writer
process:
type: regex_extract
config:
pattern: "Summary:\s*(.*)"
group: 1
multiline: true
dotall: true
on_no_match: pass
version: 0.4.0
vars: {}
graph:
id: router_with_conditions
description: Route to different nodes based on tags; forward only CONTENT block.
start:
- Router
nodes:
- id: Router
type: agent
config:
provider: openai
base_url: ${BASE_URL}
api_key: ${API_KEY}
name: gpt-4o
role: |
Decide the route. Output exactly:
ROUTE: QA|REPORT
CONTENT:
- id: QA
type: agent
config:
provider: openai
base_url: ${BASE_URL}
api_key: ${API_KEY}
name: gpt-4o
role: |
Answer the question concisely.
- id: REPORT
type: agent
config:
provider: openai
base_url: ${BASE_URL}
api_key: ${API_KEY}
name: gpt-4o
role: |
Write a structured report.
edges:
- from: Router
to: QA
condition:
type: keyword
config:
any: ["ROUTE: QA"]
process:
type: regex_extract
config:
pattern: "CONTENT:\s*(.*)"
group: 1
dotall: true
on_no_match: drop
- from: Router
to: REPORT
condition:
type: keyword
config:
any: ["ROUTE: REPORT"]
process:
type: regex_extract
config:
pattern: "CONTENT:\s*(.*)"
group: 1
dotall: true
on_no_match: drop
- id: Research Subgraph
type: subgraph
config:
type: file
config:
path: "yaml_instance/deep_research_v1.yaml"