实例化
实例化过程包含三个关键步骤
- 根据指定的应用程序和指令,
选择一个模板文件。 - 使用当前屏幕截图
预填充任务。 筛选已建立的任务。
给定初始任务,数据流首先选择一个模板(阶段 1),然后根据 Word 环境预填充初始任务以获取任务-动作数据(阶段 2)。最后,它将筛选已建立的任务以评估任务-动作数据的质量。
1. 选择模板文件
您的应用程序的模板必须在 dataflow/templates/app 中定义和描述。例如,如果您想为 Word 应用程序实例化任务,请将相关的 .docx 文件放在 dataflow /templates/word 中,并附带一个 description.json 文件。将根据其描述与指令的匹配程度来选择合适的模板。
ChooseTemplateFlow 使用语义匹配,其中任务描述与模板描述通过嵌入和 FAISS 进行比较,以实现高效的最近邻搜索。如果语义匹配失败,则从可用文件中随机选择一个模板。
2. 预填充任务
预填充流程
PrefillFlow 类通过利用 PrefillAgent 进行任务规划和动作生成,协调任务计划和 UI 交互的完善。它自动化 UI 控件更新,捕获屏幕截图,并在执行期间管理消息和响应的日志。
预填充代理
PrefillAgent 类通过使用 PrefillPrompter 构建定制的提示消息,促进任务实例化和动作序列生成。它集成系统、用户和动态上下文,为下游工作流生成可操作的输入。
3. 筛选任务
筛选流程
FilterFlow 类旨在通过利用 FilterAgent 来处理和完善任务计划。FilterFlow 类充当任务实例化和过滤过程执行之间的桥梁,旨在根据预定义的过滤条件完善任务步骤并预填充任务相关文件。
筛选代理
FilterAgent 类是一个专门的代理,用于评估实例化任务是否正确。它继承自 BasicAgent 类,并包含多种方法和属性来处理其功能。
参考
选择模板流程
根据给定的任务上下文选择并复制最相关模板文件的类。
使用给定的任务上下文初始化流程。
| 参数 |
|
|---|
源代码位于 instantiation/workflow/choose_template_flow.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
execute()
执行流程并返回复制的模板路径。
| 返回 |
|
|---|
源代码位于 instantiation/workflow/choose_template_flow.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
预填充流程
基类:AppAgentProcessor
通过完善规划步骤和自动化 UI 交互来管理预填充过程的类
使用应用程序上下文初始化预填充流程。
| 参数 |
|
|---|
源代码位于 instantiation/workflow/prefill_flow.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
execute(template_copied_path, original_task, refined_steps)
通过检索实例化结果开始执行。
| 参数 |
|
|---|
| 返回 |
|
|---|
源代码位于 instantiation/workflow/prefill_flow.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
预填充代理
基类:BasicAgent
用于任务实例化和行动序列生成的代理。
初始化 PrefillAgent。
| 参数 |
|
|---|
源代码位于 instantiation/agent/prefill_agent.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
get_prompter(is_visual, main_prompt, example_prompt, api_prompt)
获取代理的提示。这是 BasicAgent 中需要实现的抽象方法。
| 参数 |
|
|---|
| 返回 |
|
|---|
源代码位于 instantiation/agent/prefill_agent.py
44 45 46 47 48 49 50 51 52 53 54 55 | |
message_constructor(dynamic_examples, given_task, reference_steps, log_path)
为 PrefillAgent 构建提示消息。
| 参数 |
|
|---|
| 返回 |
|
|---|
源代码位于 instantiation/agent/prefill_agent.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
process_comfirmation()
确认进程。这是 BasicAgent 中需要实现的抽象方法。
源代码位于 instantiation/agent/prefill_agent.py
86 87 88 89 90 91 92 | |
筛选流程
根据过滤条件完善计划步骤并预填充文件的类。
初始化任务的过滤流程。
| 参数 |
|
|---|
源代码位于 instantiation/workflow/filter_flow.py
21 22 23 24 25 26 27 28 29 30 31 32 | |
execute(instantiated_request)
执行过滤流程:过滤任务并保存结果。
| 参数 |
|
|---|
| 返回 |
|
|---|
源代码位于 instantiation/workflow/filter_flow.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
筛选代理
基类:BasicAgent
评估实例化任务是否正确的代理。
初始化 FilterAgent。
| 参数 |
|
|---|
源代码位于 instantiation/agent/filter_agent.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
get_prompter(is_visual, main_prompt, example_prompt, api_prompt)
获取代理的提示。
| 参数 |
|
|---|
| 返回 |
|
|---|
源代码位于 instantiation/agent/filter_agent.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
message_constructor(request, app)
为 FilterAgent 构建提示消息。
| 参数 |
|
|---|
| 返回 |
|
|---|
源代码位于 instantiation/agent/filter_agent.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
process_comfirmation()
确认进程。这是 BasicAgent 中需要实现的抽象方法。
源代码位于 instantiation/agent/filter_agent.py
77 78 79 80 81 82 83 | |