-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Agent performance improvements #46
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ff6f718
feat: implement UFO annotation & prompting method
mondaychen a8f0fca
feat: add page progress in prompt
mondaychen 97842d8
refactor: clean-up & better typing when creating label
mondaychen be63554
refactor: extract screenshot building method
mondaychen 532672e
feat: add prior knowledge for twitter & improve attached debugger man…
mondaychen 37fbc67
feat: better data formatting to save token
mondaychen 50c0afe
style: remove useless logging
mondaychen 39ea08b
feat: allow scrolling directly to top or bottom
mondaychen cbec767
fix: typo in prompt
mondaychen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { sleep } from "./utils"; | ||
import { callRPCWithTab } from "./rpc/pageRPC"; | ||
import mergeImages from "@src/shared/images/mergeScreenshots"; | ||
import { type LabelData } from "../pages/content/drawLabels"; | ||
|
||
export default async function buildAnnotatedScreenshots( | ||
tabId: number, | ||
): Promise<[string, LabelData[]]> { | ||
const imgDataRaw = await chrome.tabs.captureVisibleTab({ | ||
format: "png", | ||
}); | ||
const labelData = await callRPCWithTab(tabId, "drawLabels", []); | ||
await sleep(300); | ||
const imgDataAnnotated = await chrome.tabs.captureVisibleTab({ | ||
format: "png", | ||
}); | ||
const imgData = await mergeImages([ | ||
{ src: imgDataRaw, caption: "Clean Screenshot" }, | ||
{ src: imgDataAnnotated, caption: "Annotated Screenshot" }, | ||
]); | ||
await sleep(300); | ||
await callRPCWithTab(tabId, "removeLabels", []); | ||
|
||
return [imgData, labelData]; | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"x.com": { | ||
"rules": [ | ||
{ | ||
"regexes": [".*"], | ||
"knowledge": [ | ||
"The website X (formerly Twitter) is a social media platform. Many people still call it Twitter and use the term \"tweet\" to refer to a post.", | ||
"Do not confuse \"post\" with \"message\". A post is a public message that can be seen by anyone, while a message is a private message that can only be seen by the recipient." | ||
] | ||
}, | ||
{ | ||
"regexes": ["/compose/post/?$"], | ||
"knowledge": [ | ||
"The \"Add post\" button is used to compose a thread. Do not confuse with the \"Post\" button that sends the composed tweet." | ||
] | ||
} | ||
] | ||
}, | ||
"twitter.com": { | ||
"redirect": "x.com" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import db from "./db.json"; | ||
|
||
type Data = { | ||
[host: string]: { | ||
redirect?: string; | ||
rules?: { | ||
regexes: string[]; | ||
knowledge: string[]; | ||
}[]; | ||
}; | ||
}; | ||
|
||
export type LocationInfo = { | ||
host: string; | ||
pathname: string; | ||
}; | ||
|
||
export function fetchKnowledge(location: LocationInfo): string[] { | ||
// TODO: fetch from a server | ||
const data = db as unknown as Data; | ||
let result: string[] = []; | ||
|
||
const { host, pathname } = location; | ||
const hostData = data[host]; | ||
if (hostData) { | ||
if (hostData.redirect != null) { | ||
return fetchKnowledge({ host: hostData.redirect, pathname }); | ||
} | ||
const rules = hostData.rules; | ||
if (rules != null) { | ||
for (const rule of rules) { | ||
for (const regex of rule.regexes) { | ||
if (new RegExp(regex, "i").test(pathname)) { | ||
result = result.concat(rule.knowledge); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return result; | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[not blocker] could define it as a constants rather than using a magic number