2025-03-17 19:19:54 +08:00
|
|
|
import { AiLocateElement } from '@/ai-model';
|
2025-03-07 17:20:18 +08:00
|
|
|
import { getContextFromFixture } from 'tests/evaluation';
|
2025-02-10 16:36:12 +08:00
|
|
|
import { expect, test } from 'vitest';
|
|
|
|
|
|
|
|
test(
|
|
|
|
'basic inspect',
|
|
|
|
async () => {
|
|
|
|
const { context } = await getContextFromFixture('todo');
|
|
|
|
|
|
|
|
const startTime = Date.now();
|
2025-03-17 19:19:54 +08:00
|
|
|
const { parseResult } = await AiLocateElement({
|
2025-02-10 16:36:12 +08:00
|
|
|
context,
|
|
|
|
targetElementDescription: 'input 输入框',
|
|
|
|
});
|
|
|
|
console.log('parseResult', JSON.stringify(parseResult, null, 2));
|
|
|
|
const endTime = Date.now();
|
|
|
|
const cost = endTime - startTime;
|
|
|
|
expect(parseResult.elements.length).toBe(1);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
timeout: 1000000,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
test('use quick answer', async () => {
|
|
|
|
const { context } = await getContextFromFixture('todo');
|
|
|
|
|
|
|
|
const startTime = Date.now();
|
2025-03-17 19:19:54 +08:00
|
|
|
const { parseResult } = await AiLocateElement({
|
2025-02-10 16:36:12 +08:00
|
|
|
context,
|
|
|
|
targetElementDescription: 'never mind',
|
|
|
|
quickAnswer: {
|
|
|
|
id: context.content[0].id,
|
|
|
|
reason: 'never mind',
|
|
|
|
text: 'never mind',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
console.log('parseResult', parseResult);
|
|
|
|
const endTime = Date.now();
|
|
|
|
const cost = endTime - startTime;
|
|
|
|
expect(parseResult.elements.length).toBe(1);
|
|
|
|
expect(cost).toBeLessThan(100);
|
|
|
|
});
|