feat: 增加指定模型和查看可指定模型功能

This commit is contained in:
foxhui
2025-11-24 19:07:02 +08:00
Unverified
parent 55377de092
commit 4e37ff272e
8 changed files with 228 additions and 10 deletions
+20 -3
View File
@@ -1,6 +1,7 @@
import readline from 'readline';
import config from './config.js';
import { initBrowser, generateImage } from './lmarena.js';
import { MODEL_MAPPING } from './models.js';
/**
* 创建命令行交互接口
@@ -47,12 +48,28 @@ async function main() {
continue;
}
// 3. 获取模型 ID
const modelInput = await ask('>>> [CLI] 请输入模型 ID (回车跳过使用默认): ');
const modelName = modelInput.trim();
let modelId = null;
if (modelName) {
if (MODEL_MAPPING[modelName]) {
modelId = MODEL_MAPPING[modelName];
console.log(`>>> [CLI] 使用模型: ${modelName} (${modelId})`);
} else {
console.log(`>>> [Warn] 未找到模型 "${modelName}",将尝试直接使用默认模型。`);
}
} else {
console.log('>>> [CLI] 未指定模型,使用默认值。');
}
console.log(`>>> [CLI] 开始任务: Prompt="${prompt}", Images=${imagePaths.length}`);
// 3. 调用生图逻辑
const result = await generateImage(browserContext, prompt, imagePaths);
// 4. 调用生图逻辑
const result = await generateImage(browserContext, prompt, imagePaths, modelId);
// 4. 显示结果
// 5. 显示结果
if (result.error) {
console.error('>>> [Error]', result.error);
} else if (result.image) {