max task steps for task v2 (#1877)

This commit is contained in:
Shuchang Zheng
2025-03-04 01:07:07 -05:00
committed by GitHub
parent 618070840f
commit d31e4bf268
15 changed files with 90 additions and 40 deletions

View File

@@ -42,6 +42,7 @@ import {
generateUniqueEmail,
} from "../data/sampleTaskData";
import { ExampleCasePill } from "./ExampleCasePill";
import { MAX_STEPS_DEFAULT } from "@/routes/workflows/editor/nodes/Taskv2Node/types";
function createTemplateTaskFromTaskGenerationParameters(
values: TaskGenerationApiResponse,
@@ -167,7 +168,7 @@ function PromptBox() {
},
{
headers: {
"x-max-iterations-override": maxStepsOverride,
"x-max-steps-override": maxStepsOverride,
},
},
);
@@ -402,6 +403,7 @@ function PromptBox() {
</div>
<Input
value={maxStepsOverride ?? ""}
placeholder={`Default: ${MAX_STEPS_DEFAULT}`}
onChange={(event) => {
setMaxStepsOverride(event.target.value);
}}

View File

@@ -41,8 +41,8 @@ export const helpTooltips = {
task: baseHelpTooltipContent,
taskv2: {
...baseHelpTooltipContent,
maxIterations:
"The maximum number of iterations this task will take to achieve its goal.",
maxSteps:
"The maximum number of steps this task will take to achieve its goal.",
},
navigation: baseHelpTooltipContent,
extraction: {

View File

@@ -19,7 +19,7 @@ import { useIsFirstBlockInWorkflow } from "../../hooks/useIsFirstNodeInWorkflow"
import { NodeActionMenu } from "../NodeActionMenu";
import { WorkflowBlockIcon } from "../WorkflowBlockIcon";
import { EditableNodeTitle } from "../components/EditableNodeTitle";
import { MAX_ITERATIONS_DEFAULT, type Taskv2Node } from "./types";
import { MAX_STEPS_DEFAULT, type Taskv2Node } from "./types";
function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
const { updateNodeData } = useReactFlow();
@@ -37,7 +37,7 @@ function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
url: data.url,
totpVerificationUrl: data.totpVerificationUrl,
totpIdentifier: data.totpIdentifier,
maxIterations: data.maxIterations,
maxSteps: data.maxSteps,
});
function handleChange(key: string, value: unknown) {
@@ -132,19 +132,17 @@ function Taskv2Node({ id, data, type }: NodeProps<Taskv2Node>) {
<div className="space-y-2">
<div className="flex gap-2">
<Label className="text-xs text-slate-300">
Max Iterations
Max Steps
</Label>
<HelpTooltip
content={helpTooltips[type]["maxIterations"]}
/>
<HelpTooltip content={helpTooltips[type]["maxSteps"]} />
</div>
<Input
type="number"
placeholder="10"
className="nopan text-xs"
value={data.maxIterations ?? MAX_ITERATIONS_DEFAULT}
value={data.maxSteps ?? MAX_STEPS_DEFAULT}
onChange={(event) => {
handleChange("maxIterations", Number(event.target.value));
handleChange("maxSteps", Number(event.target.value));
}}
/>
</div>

View File

@@ -1,14 +1,14 @@
import { Node } from "@xyflow/react";
import { NodeBaseData } from "../types";
export const MAX_ITERATIONS_DEFAULT = 10;
export const MAX_STEPS_DEFAULT = 25;
export type Taskv2NodeData = NodeBaseData & {
prompt: string;
url: string;
totpVerificationUrl: string | null;
totpIdentifier: string | null;
maxIterations: number | null;
maxSteps: number | null;
};
export type Taskv2Node = Node<Taskv2NodeData, "taskv2">;
@@ -21,7 +21,7 @@ export const taskv2NodeDefaultData: Taskv2NodeData = {
url: "",
totpIdentifier: null,
totpVerificationUrl: null,
maxIterations: 10,
maxSteps: MAX_STEPS_DEFAULT,
};
export function isTaskV2Node(node: Node): node is Taskv2Node {

View File

@@ -219,7 +219,7 @@ function convertToNode(
...commonData,
prompt: block.prompt,
url: block.url ?? "",
maxIterations: block.max_iterations,
maxSteps: block.max_steps,
totpIdentifier: block.totp_identifier,
totpVerificationUrl: block.totp_verification_url,
},
@@ -928,7 +928,7 @@ function getWorkflowBlock(node: WorkflowBlockNode): BlockYAML {
...base,
block_type: "task_v2",
prompt: node.data.prompt,
max_iterations: node.data.maxIterations,
max_steps: node.data.maxSteps,
totp_identifier: node.data.totpIdentifier,
totp_verification_url: node.data.totpVerificationUrl,
url: node.data.url,
@@ -1608,7 +1608,7 @@ function convertBlocksToBlockYAML(
block_type: "task_v2",
prompt: block.prompt,
url: block.url,
max_iterations: block.max_iterations,
max_steps: block.max_steps,
totp_identifier: block.totp_identifier,
totp_verification_url: block.totp_verification_url,
};

View File

@@ -255,7 +255,7 @@ export type Taskv2Block = WorkflowBlockBase & {
url: string | null;
totp_verification_url: string | null;
totp_identifier: string | null;
max_iterations: number | null;
max_steps: number | null;
};
export type ForLoopBlock = WorkflowBlockBase & {

View File

@@ -140,7 +140,7 @@ export type Taskv2BlockYAML = BlockYAMLBase & {
prompt: string;
totp_verification_url: string | null;
totp_identifier: string | null;
max_iterations: number | null;
max_steps: number | null;
};
export type ValidationBlockYAML = BlockYAMLBase & {