-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: fix e2e test * chore: ignore todo test * chore: fix e2e test * chore: upgrade gpt api version * chore: fix e2e test * chore: fix e2e test * chore: fix direction * chore: fix direction * chore: split test * chore: split test * chore: modify input info * fix: scroll param in ci * fix: lint * fix: ai test * fix: ai test --------- Co-authored-by: yutao <[email protected]>
- Loading branch information
1 parent
6d2abd9
commit 4c82eff
Showing
20 changed files
with
185 additions
and
70 deletions.
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
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
89 changes: 89 additions & 0 deletions
89
packages/midscene/tests/ai/evaluate/plan/__snapshots__/planning-input.test.ts.snap
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,89 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`automation - planning input > input value 1`] = ` | ||
[ | ||
{ | ||
"locate": { | ||
"id": "fbc2d002", | ||
"prompt": "the input field with placeholder 'What needs to be done?'", | ||
}, | ||
"param": { | ||
"value": "learning english", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`automation - planning input > input value 2`] = ` | ||
[ | ||
{ | ||
"locate": { | ||
"id": "fbc2d002", | ||
"prompt": "the input field labeled 'What needs to be done?'", | ||
}, | ||
"param": { | ||
"value": "learning english", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
{ | ||
"locate": null, | ||
"param": { | ||
"value": "Enter", | ||
}, | ||
"thought": undefined, | ||
"type": "KeyboardPress", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`automation - planning input > input value Add, delete, correct and check 1`] = ` | ||
[ | ||
{ | ||
"locate": { | ||
"id": "fbc2d002", | ||
"prompt": "the task input box with the content 'Learn English'", | ||
}, | ||
"param": { | ||
"value": "Learn English tomorrow", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`automation - planning input > input value Add, delete, correct and check 2`] = ` | ||
[ | ||
{ | ||
"locate": { | ||
"id": "fbc2d002", | ||
"prompt": "the input box containing 'Learn English'", | ||
}, | ||
"param": { | ||
"value": "Learn Skiing", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`automation - planning input > input value Add, delete, correct and check 3`] = ` | ||
[ | ||
{ | ||
"locate": { | ||
"id": "fbc2d002", | ||
"prompt": "the task input box containing 'Learn English'", | ||
}, | ||
"param": { | ||
"value": "Learn", | ||
}, | ||
"thought": undefined, | ||
"type": "Input", | ||
}, | ||
] | ||
`; |
13 changes: 13 additions & 0 deletions
13
packages/midscene/tests/ai/evaluate/plan/__snapshots__/planning.test.ts.snap
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,13 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`automation - planning > basic run 1`] = ` | ||
{ | ||
"timeMs": 3500, | ||
} | ||
`; | ||
|
||
exports[`automation - planning > basic run 2`] = ` | ||
{ | ||
"value": "Enter", | ||
} | ||
`; |
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
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 |
---|---|---|
@@ -1,58 +1,61 @@ | ||
import path from 'node:path'; | ||
import { vlmPlanning } from '@/ai-model/ui-tars-planning'; | ||
import { savePositionImg } from '@midscene/shared/img'; | ||
import { expect, test } from 'vitest'; | ||
import { expect, it, test } from 'vitest'; | ||
import { getPageTestData } from '../evaluate/test-suite/util'; | ||
|
||
test('inspect with quick answer', async () => { | ||
const { context } = await getPageTestData( | ||
path.join(__dirname, '../evaluate/test-data/todo'), | ||
); | ||
const isUiTars = process.env.MIDSCENE_USE_VLM_UI_TARS === '1'; | ||
|
||
const { width, height } = context.size; | ||
const startTime = Date.now(); | ||
const { realActions } = await vlmPlanning({ | ||
userInstruction: '删除第二条任务', | ||
conversationHistory: [ | ||
{ | ||
role: 'user', | ||
content: [ | ||
{ | ||
type: 'image_url', | ||
image_url: { | ||
url: context.originalScreenshotBase64, | ||
test.skipIf(!isUiTars)('only run in ui-tars', () => { | ||
it('plan to target', async () => { | ||
const { context } = await getPageTestData( | ||
path.join(__dirname, '../evaluate/test-data/todo'), | ||
); | ||
|
||
const { width, height } = context.size; | ||
const startTime = Date.now(); | ||
const { realActions } = await vlmPlanning({ | ||
userInstruction: '删除第二条任务', | ||
conversationHistory: [ | ||
{ | ||
role: 'user', | ||
content: [ | ||
{ | ||
type: 'image_url', | ||
image_url: { | ||
url: context.originalScreenshotBase64, | ||
}, | ||
}, | ||
}, | ||
], | ||
], | ||
}, | ||
], | ||
size: { | ||
width, | ||
height, | ||
}, | ||
], | ||
size: { | ||
width, | ||
height, | ||
}, | ||
}); | ||
}); | ||
|
||
const endTime = Date.now(); | ||
const cost = (endTime - startTime) / 1000; | ||
const start_box = | ||
'start_box' in realActions[0].action_inputs | ||
? realActions[0].action_inputs.start_box | ||
: '[]'; | ||
const box = JSON.parse(start_box); | ||
console.log('plan to target content:', { | ||
box, | ||
size: { | ||
width, | ||
height, | ||
}, | ||
cost: `${cost}s`, | ||
}); | ||
// expect(box).toEqual([0.397, 0.218, 0.397, 0.218]); | ||
expect(true).toBe(true); | ||
await savePositionImg({ | ||
inputImgBase64: context.originalScreenshotBase64, | ||
rect: { x: box[0] * width, y: box[1] * height }, | ||
outputPath: path.join(__dirname, 'output.png'), | ||
const endTime = Date.now(); | ||
const cost = (endTime - startTime) / 1000; | ||
const start_box = | ||
'start_box' in realActions[0].action_inputs | ||
? realActions[0].action_inputs.start_box | ||
: '[]'; | ||
const box = JSON.parse(start_box); | ||
console.log('plan to target content:', { | ||
box, | ||
size: { | ||
width, | ||
height, | ||
}, | ||
cost: `${cost}s`, | ||
}); | ||
// expect(box).toEqual([0.397, 0.218, 0.397, 0.218]); | ||
expect(true).toBe(true); | ||
await savePositionImg({ | ||
inputImgBase64: context.originalScreenshotBase64, | ||
rect: { x: box[0] * width, y: box[1] * height }, | ||
outputPath: path.join(__dirname, 'output.png'), | ||
}); | ||
}); | ||
// expect(cost).toBeLessThan(100); | ||
}); |
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
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.