* feat: add yolo mode support to auto vision model switch * feat: add cli args & env variables for switch behavoir * fix: use dedicated model names and settings * docs: add vision model instructions * fix: failed test case * fix: setModel failure
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Qwen
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
export type AvailableModel = {
|
|
id: string;
|
|
label: string;
|
|
isVision?: boolean;
|
|
};
|
|
|
|
export const MAINLINE_VLM = 'vision-model';
|
|
export const MAINLINE_CODER = 'coder-model';
|
|
|
|
export const AVAILABLE_MODELS_QWEN: AvailableModel[] = [
|
|
{ id: MAINLINE_CODER, label: MAINLINE_CODER },
|
|
{ id: MAINLINE_VLM, label: MAINLINE_VLM, isVision: true },
|
|
];
|
|
|
|
/**
|
|
* Get available Qwen models filtered by vision model preview setting
|
|
*/
|
|
export function getFilteredQwenModels(
|
|
visionModelPreviewEnabled: boolean,
|
|
): AvailableModel[] {
|
|
if (visionModelPreviewEnabled) {
|
|
return AVAILABLE_MODELS_QWEN;
|
|
}
|
|
return AVAILABLE_MODELS_QWEN.filter((model) => !model.isVision);
|
|
}
|
|
|
|
/**
|
|
* Currently we use the single model of `OPENAI_MODEL` in the env.
|
|
* In the future, after settings.json is updated, we will allow users to configure this themselves.
|
|
*/
|
|
export function getOpenAIAvailableModelFromEnv(): AvailableModel | null {
|
|
const id = process.env['OPENAI_MODEL']?.trim();
|
|
return id ? { id, label: id } : null;
|
|
}
|
|
|
|
/**
|
|
/**
|
|
* Hard code the default vision model as a string literal,
|
|
* until our coding model supports multimodal.
|
|
*/
|
|
export function getDefaultVisionModel(): string {
|
|
return MAINLINE_VLM;
|
|
}
|
|
|
|
export function isVisionModel(modelId: string): boolean {
|
|
return AVAILABLE_MODELS_QWEN.some(
|
|
(model) => model.id === modelId && model.isVision,
|
|
);
|
|
}
|