MCPcopy Create free account
hub / github.com/OpenDCAI/Paper2Any / create_artifact

Function create_artifact

dataflow_agent/cli.py:34–156  ·  view source on GitHub ↗

dfa create --wf_name xxx dfa create --agent_name yyy dfa create --gradio_name zzz dfa create --prompt_name zzz dfa create --agent_as_tool_name aaa dfa create --state_name bbb

(wf_name: Optional[str] = None,
                    agent_name: Optional[str] = None,
                    gradio_name: Optional[str] = None,
                    prompt_name: Optional[str] = None,
                    agent_as_tool_name: Optional[str] = None,
                    state_name: Optional[str] = None)

Source from the content-addressed store, hash-verified

32@click.option("--agent_as_tool_name", help="要创建的 agent-as-tool 名称")
33@click.option("--state_name", help="要创建的 state 名称")
34def create_artifact(wf_name: Optional[str] = None,
35 agent_name: Optional[str] = None,
36 gradio_name: Optional[str] = None,
37 prompt_name: Optional[str] = None,
38 agent_as_tool_name: Optional[str] = None,
39 state_name: Optional[str] = None):
40 """
41 dfa create --wf_name xxx
42 dfa create --agent_name yyy
43 dfa create --gradio_name zzz
44 dfa create --prompt_name zzz
45 dfa create --agent_as_tool_name aaa
46 dfa create --state_name bbb
47 """
48 opts = [bool(wf_name), bool(agent_name), bool(gradio_name), bool(prompt_name), bool(agent_as_tool_name), bool(state_name)]
49 if sum(opts) != 1:
50 click.echo(" --wf_name / --agent_name / --gradio_name / --prompt_name / --agent_as_tool_name / --state_name 必须且只能选一个", err=True)
51 raise SystemExit(1)
52
53 timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
54
55 # ------------------------------------------------------------------
56 # 1. Workflow
57 # ------------------------------------------------------------------
58 if wf_name:
59 wf_name_snake = to_snake(wf_name)
60
61 # 1.1 workflow 源码
62 wf_dest = Path(__file__).parent / "workflow" / f"wf_{wf_name_snake}.py"
63 wf_tpl_path = TEMPLATE_DIR / "workflow.py.jinja"
64 wf_context = dict(
65 wf_name=wf_name,
66 wf_name_snake=wf_name_snake,
67 entry="step1",
68 timestamp=timestamp,
69 )
70 _generate_file(wf_dest, wf_tpl_path, wf_context, "workflow")
71
72 # 1.2 对应测试
73 project_root = Path(__file__).parent.parent
74 test_dest = project_root / "tests" / f"test_{wf_name_snake}.py"
75 test_tpl = TEMPLATE_DIR / "test_workflow.py.jinja"
76 test_ctx = dict(
77 wf_name=wf_name,
78 wf_name_snake=wf_name_snake,
79 timestamp=timestamp,
80 )
81 _generate_file(test_dest, test_tpl, test_ctx, "test")
82
83 # ------------------------------------------------------------------
84 # 2. Agent
85 # ------------------------------------------------------------------
86 elif agent_name:
87 agent_snake = to_snake(agent_name)
88 dest = Path(__file__).parent / "agentroles" / "common_agents" / f"{agent_snake}_agent.py"
89 tpl_path = TEMPLATE_DIR / "agent.py.jinja"
90 ctx = dict(
91 agent_name=agent_name,

Callers

nothing calls this directly

Calls 3

to_snakeFunction · 0.85
_generate_fileFunction · 0.85
to_camelFunction · 0.85

Tested by

no test coverage detected