Skip to content

Commit

Permalink
Prompt Optimization (#165)
Browse files Browse the repository at this point in the history
* feat: scroll 2/3 of page instead of half for faster browsing

* feat: optimize prompt for better results
  • Loading branch information
mondaychen authored May 16, 2024
1 parent 68b7562 commit 338a2bf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/helpers/rpc/domActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ export class DomActions {
public async scrollUp() {
await this.sendCommand("Runtime.evaluate", {
expression:
'window.scrollBy({left: 0, top: -window.innerHeight/2, behavior: "smooth"})',
'window.scrollBy({left: 0, top: -window.innerHeight/1.5, behavior: "smooth"})',
});
await sleep(300);
}

public async scrollDown() {
await this.sendCommand("Runtime.evaluate", {
expression:
'window.scrollBy({left: 0, top: window.innerHeight/2, behavior: "smooth"})',
'window.scrollBy({left: 0, top: window.innerHeight/1.5, behavior: "smooth"})',
});
await sleep(300);
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/vision-agent/determineNextAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can use the following tools:
${allToolsDescriptions}
You will be given a task to perform, and an image. The image will contain two parts: on the left is a clean screenshot of the current page, and on the right is the same screenshot with interactive elements annotated with corresponding label.
You will also be given previous actions that you have taken. You may retry a failed action up to one time.
You will also be given previous actions that you have taken. If something does not work, try find an alternative solution. For example, instead of searching for a specific item that the user requested, perform a general search and apply filters, or simply browse the results page.
You will also be given additional information of annotations.
This is one example of expected response from you:
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/vision-agent/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const scrollSchema = z.object({
name: z.literal("scroll"),
description: z
.literal(
'Scroll the page to see the other parts. Use "up" or "down" to scroll half the height of the window. Use "top" or "bottom" to quickly scroll to the top or bottom of the page.',
'Scroll the page to see the other parts. Use "up" or "down" to scroll 2/3 of height of the window. Use "top" or "bottom" to quickly scroll to the top or bottom of the page.',
)
.optional(),
args: z.object({
Expand Down

0 comments on commit 338a2bf

Please sign in to comment.