Skip to content

Commit da2f68c

Browse files
committed
feat(core): support config VQA related model
1 parent 5b1930d commit da2f68c

File tree

11 files changed

+874
-155
lines changed

11 files changed

+874
-155
lines changed

packages/core/src/ai-model/common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
AIUsageInfo,
33
BaseElement,
44
ElementTreeNode,
5+
IModelPreferences,
56
MidsceneYamlFlowItem,
67
PlanningAction,
78
PlanningActionParamInputOrKeyPress,
@@ -45,10 +46,12 @@ export enum AIActionType {
4546
export async function callAiFn<T>(
4647
msgs: AIArgs,
4748
AIActionTypeValue: AIActionType,
49+
modelPreferences?: IModelPreferences,
4850
): Promise<{ content: T; usage?: AIUsageInfo }> {
4951
const { content, usage } = await callToGetJSONObject<T>(
5052
msgs,
5153
AIActionTypeValue,
54+
modelPreferences,
5255
);
5356
return { content, usage };
5457
}

packages/core/src/ai-model/inspect.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
AIUsageInfo,
88
BaseElement,
99
ElementById,
10+
IModelPreferences,
1011
InsightExtractOption,
1112
Rect,
1213
ReferenceImage,
@@ -385,8 +386,15 @@ export async function AiExtractElementInfo<
385386
multimodalPrompt?: TMultimodalPrompt;
386387
context: UIContext<ElementType>;
387388
extractOption?: InsightExtractOption;
389+
modelPreferences?: IModelPreferences;
388390
}) {
389-
const { dataQuery, context, extractOption, multimodalPrompt } = options;
391+
const {
392+
dataQuery,
393+
context,
394+
extractOption,
395+
multimodalPrompt,
396+
modelPreferences,
397+
} = options;
390398
const systemPrompt = systemPromptToExtract();
391399

392400
const { screenshotBase64 } = context;
@@ -445,6 +453,7 @@ export async function AiExtractElementInfo<
445453
const result = await callAiFn<AIDataExtractionResponse<T>>(
446454
msgs,
447455
AIActionType.EXTRACT_DATA,
456+
modelPreferences,
448457
);
449458
return {
450459
parseResult: result.content,

packages/core/src/ai-model/prompt/playwright-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ ${PLAYWRIGHT_EXAMPLE_CODE}`;
206206

207207
if (options.stream && options.onChunk) {
208208
// Use streaming
209-
return await callAi(prompt, AIActionType.EXTRACT_DATA, undefined, {
209+
return await callAi(prompt, AIActionType.EXTRACT_DATA, {
210210
stream: true,
211211
onChunk: options.onChunk,
212212
});

packages/core/src/ai-model/prompt/yaml-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ Respond with YAML only, no explanations.`,
425425

426426
if (options.stream && options.onChunk) {
427427
// Use streaming
428-
return await callAi(prompt, AIActionType.EXTRACT_DATA, undefined, {
428+
return await callAi(prompt, AIActionType.EXTRACT_DATA, {
429429
stream: true,
430430
onChunk: options.onChunk,
431431
});

0 commit comments

Comments
 (0)