mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-07-25 01:41:21 +00:00
108 lines
3.0 KiB
TypeScript
108 lines
3.0 KiB
TypeScript
import { systemPromptToLocateElement } from '@/ai-model';
|
|
import {
|
|
automationUserPrompt,
|
|
generateTaskBackgroundContext,
|
|
planSchema,
|
|
systemPromptToTaskPlanning,
|
|
} from '@/ai-model/prompt/llm-planning';
|
|
import { systemPromptToLocateSection } from '@/ai-model/prompt/llm-section-locator';
|
|
import { uiTarsPlanningPrompt } from '@/ai-model/prompt/ui-tars-planning';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
describe('system prompts', () => {
|
|
it('planning - 4o', async () => {
|
|
const prompt = await systemPromptToTaskPlanning({
|
|
pageType: 'puppeteer',
|
|
vlMode: false,
|
|
});
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('planning - 4o - response format', () => {
|
|
const schema = planSchema;
|
|
expect(schema).toMatchSnapshot();
|
|
});
|
|
|
|
it('planning - qwen', async () => {
|
|
const prompt = await systemPromptToTaskPlanning({
|
|
pageType: 'puppeteer',
|
|
vlMode: 'qwen-vl',
|
|
});
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('planning - gemini', async () => {
|
|
const prompt = await systemPromptToTaskPlanning({
|
|
pageType: 'puppeteer',
|
|
vlMode: 'gemini',
|
|
});
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('planning - android', async () => {
|
|
const prompt = await systemPromptToTaskPlanning({
|
|
pageType: 'android',
|
|
vlMode: 'qwen-vl',
|
|
});
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('planning - background context', () => {
|
|
const context = generateTaskBackgroundContext(
|
|
'THIS IS USER INSTRUCTION',
|
|
'THIS IS WHAT HAS BEEN DONE',
|
|
'THIS IS BACKGROUND PROMPT',
|
|
);
|
|
expect(context).toMatchSnapshot();
|
|
});
|
|
|
|
it('planning - user prompt - 4o', async () => {
|
|
const prompt = automationUserPrompt(false);
|
|
const result = await prompt.format({
|
|
pageDescription: 'THIS IS PAGE DESCRIPTION',
|
|
taskBackgroundContext: 'THIS IS BACKGROUND CONTEXT',
|
|
userActionContext: 'THIS IS BACKGROUND PROMPT',
|
|
});
|
|
expect(result).toMatchSnapshot();
|
|
});
|
|
|
|
it('planning - user prompt - qwen', async () => {
|
|
const prompt = automationUserPrompt('qwen-vl');
|
|
const result = await prompt.format({
|
|
pageDescription: 'THIS IS PAGE DESCRIPTION',
|
|
taskBackgroundContext: 'THIS IS BACKGROUND CONTEXT',
|
|
});
|
|
expect(result).toMatchSnapshot();
|
|
});
|
|
|
|
it('section locator - gemini', () => {
|
|
const prompt = systemPromptToLocateSection('gemini');
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('section locator - qwen', () => {
|
|
const prompt = systemPromptToLocateSection('qwen-vl');
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('locator - 4o', () => {
|
|
const prompt = systemPromptToLocateElement(false);
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('locator - qwen', () => {
|
|
const prompt = systemPromptToLocateElement('qwen-vl');
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('locator - gemini', () => {
|
|
const prompt = systemPromptToLocateElement('gemini');
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
|
|
it('ui-tars planning', () => {
|
|
const prompt = uiTarsPlanningPrompt;
|
|
expect(prompt).toMatchSnapshot();
|
|
});
|
|
});
|