mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
feat: 增加指定模型和查看可指定模型功能
This commit is contained in:
+20
-3
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user