Skip to content

Commit

Permalink
feat: press enter to submit after typing
Browse files Browse the repository at this point in the history
  • Loading branch information
mondaychen committed Mar 22, 2024
1 parent 425a973 commit acf4847
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/helpers/rpc/performAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ function createOperateTool(
}
break;
}
case "setValueAndSubmit": {
const success = await setValue(
domActions,
action.args.label,
(action.args.value || "") + "\n",
);
if (!success) {
console.error(
"Unable to find element with label: ",
action.args.label,
);
}
break;
}
default:
console.error("Invalid action name", action);
}
Expand Down
13 changes: 13 additions & 0 deletions src/helpers/vision-agent/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ export const setValueSchema = z.object({
value: z.string(),
}),
});
export const setValueAndSubmitSchema = z.object({
name: z.literal("setValueAndSubmit"),
description: z
.literal(
'Like "setValue", except then it presses ENTER to submit the form.',
)
.optional(),
args: z.object({
label: z.string(),
value: z.string(),
}),
});

export const navigateSchema = z.object({
name: z.literal("navigate"),
Expand Down Expand Up @@ -74,6 +86,7 @@ export const failSchema = z.object({
export const toolSchemaUnion = z.discriminatedUnion("name", [
clickSchema,
setValueSchema,
setValueAndSubmitSchema,
navigateSchema,
scrollSchema,
waitSchema,
Expand Down

0 comments on commit acf4847

Please sign in to comment.