feat: add WorkflowResult#76
Merged
HairlessVillager merged 1 commit intoFellouAI:developfrom Feb 27, 2025
Merged
Conversation
Contributor
Author
|
经过下游调用者审查通过,这个 PR 合并。 After being reviewed and approved by downstream callers, this PR will be merged. |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
注意:这个 PR 修改了
Eko.execute的签名,请下游调用者注意适配。这个 PR 增加了 Workflow Result 的功能,让工作流结束时返回一个结果,包括以下字段:
isSuccessful:指示工作流最终是否执行成功;summary:对工作流本身的简短的总结;payload:工作流的产物,目前支持纯文本产物,同时预留了其他格式产物的类型,当工作流需要返回结果时(例如“给我生成一个述职报告”)非空,当工作流不需要返回结果时(例如“帮我打开 OpenAI 的官网”)为空,以下是实现思路:
WorkflowResult类型,涵盖以上字段;DocumentAgentToolInput工具,让它实现文书 Agent 工作,负责生成纯文本产物,通过修改工具的description来提示模型在合适的时候调用;SummaryWorkflow工具,新增输入参数isSuccessful,并微调 prompt;context.variables的写入逻辑:DocumentAgentToolInput工具会把返回值写入workflow_transcript键中,SummaryWorkflow工具会把返回值写入workflow_is_successful和workflow_summary中;context.variables的读取逻辑:WorkflowImpl.execute方法会读取workflow_is_successful,workflow_summary,workflow_transcript的值并组装成WorkflowResult类型的值。以下是主要的修改:
Eko.execute方法和WorkflowImpl.execute方法的返回类型修改为Promise<WorkflowResult>,不再返回Promise<NodeOutput[]>;createWorkflowPrompts()),使其不再工作流最后加入一个 Workflow Summary 的节点,而且不允许使用summary_workflow工具;WorkflowGenerator.doGenerateWorkflow方法中,把一个 Workflow Summary 的节点通过硬编码的形式加入工作流;WorkflowResult,WorkflowTranscript,WorkflowArtifact,DocumentAgentToolInput,DocumentAgentToolOutput;SummaryWorkflowInput新增了一个isSuccessful: boolean的字段;DocumentAgentTool工具,用来生成工作流产物(纯文本),通过详尽的参数利用大模型生成长文本;你可以通过以下方式来验证这个 PR:
Search Sam Altman's information on wikipedia and summarize it, you should only search 1 result)并运行,期望行为是工作流返回值为WorkflowResult类型,且isSuccessful为true,summary为对工作流状态的简短总结,payload为对 Sam Altman 的总结;Open the official website of OpenAI for me)并运行,期望行为是工作流返回值为WorkflowResult类型,且isSuccessful为true,summary为对工作流状态的简短总结,payload为空。NOTE: This PR modifies the signature of
Eko.execute. Please pay attention to compatibility for downstream callers.This PR enhances the functionality of Workflow Result, enabling it to return a result at the end of a workflow. The result includes the following fields:
isSuccessful: Indicates whether the workflow executed successfully in the end;summary: A brief summary of the workflow itself;payload: The output of the workflow. Currently, it supports plain text output and reserves types for outputs in other formats. Thepayloadis non-empty when the workflow needs to return a result (e.g., "Generate a performance report for me") and empty when the workflow does not need to return a result (e.g., "Open the official website of OpenAI for me").Here is the implementation plan:
WorkflowResulttype, encompassing the above fields;DocumentAgentToolInputtool to handle document-related tasks and generate plain text outputs. The tool'sdescriptionwill be modified to prompt the model to invoke it at appropriate times;SummaryWorkflowtool by adding an input parameterisSuccessfuland slightly adjusting the prompt;context.variables: TheDocumentAgentToolInputtool writes the return value to theworkflow_transcriptkey, while theSummaryWorkflowtool writes the return values toworkflow_is_successfulandworkflow_summary;context.variables: TheWorkflowImpl.executemethod reads the values ofworkflow_is_successful,workflow_summary, andworkflow_transcriptand assembles them into aWorkflowResulttype value.Here are the main changes:
Eko.executeandWorkflowImpl.executemethods have been changed toPromise<WorkflowResult>, instead ofPromise<NodeOutput[]>;createWorkflowPrompts()) has been modified to no longer add a Workflow Summary node at the end of the workflow and to disallow the use of thesummary_workflowtool;WorkflowGenerator.doGenerateWorkflowmethod, a Workflow Summary node is hard-coded into the workflow;WorkflowResult,WorkflowTranscript,WorkflowArtifact,DocumentAgentToolInput,DocumentAgentToolOutput;SummaryWorkflowInputhas a new fieldisSuccessful: boolean;DocumentAgentToolto generate workflow outputs (plain text) by leveraging a large model with detailed parameters to generate long texts.You can verify this PR by:
WorkflowResulttype value withisSuccessfulastrue,summaryas a brief overview of the workflow status, andpayloadas a summary of Sam Altman;WorkflowResulttype value withisSuccessfulastrue,summaryas a brief overview of the workflow status, andpayloadas empty.