fix: 修复 auto-title API 模型查找
1. 正确访问 model 和 provider 对象结构 2. 直接使用返回的 provider 信息,无需再次查询 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
aac42de4c5
commit
1f26ec911c
@ -22,14 +22,14 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
// 从数据库获取支持视觉的模型(查找包含 qwen-vl 或 vision 的模型)
|
||||
const models = await getEnabledAiModelsWithProvider();
|
||||
console.log("[Auto-title] Available models count:", models.length);
|
||||
console.log("[Auto-title] All model IDs:", models.map(m => m.modelId));
|
||||
const modelsData = await getEnabledAiModelsWithProvider();
|
||||
console.log("[Auto-title] Available models count:", modelsData.length);
|
||||
console.log("[Auto-title] All model IDs:", modelsData.map(m => m.model.modelId));
|
||||
|
||||
// 查找千问VL模型(支持多种命名格式)
|
||||
const visionModel = models.find(m => {
|
||||
const id = m.modelId?.toLowerCase() || '';
|
||||
const name = m.displayName?.toLowerCase() || '';
|
||||
const visionModelData = modelsData.find(m => {
|
||||
const id = m.model.modelId?.toLowerCase() || '';
|
||||
const name = m.model.displayName?.toLowerCase() || '';
|
||||
return id.includes('qwen-vl') ||
|
||||
id.includes('qwen3-vl') ||
|
||||
id.includes('qwen2.5-vl') ||
|
||||
@ -38,15 +38,16 @@ export async function POST(request: NextRequest) {
|
||||
name.includes('视觉');
|
||||
});
|
||||
|
||||
console.log("[Auto-title] Found vision model:", visionModel?.modelId, visionModel?.displayName);
|
||||
console.log("[Auto-title] Found vision model:", visionModelData?.model.modelId, visionModelData?.model.displayName);
|
||||
|
||||
if (!visionModel || !visionModel.providerId) {
|
||||
if (!visionModelData) {
|
||||
console.log("[Auto-title] No vision model found, using default title");
|
||||
return NextResponse.json({ title: "未命名画布" });
|
||||
}
|
||||
|
||||
// 获取 provider 配置
|
||||
const provider = await getAiProviderById(visionModel.providerId);
|
||||
// 直接使用返回的 provider 信息
|
||||
const provider = visionModelData.provider;
|
||||
const visionModel = visionModelData.model;
|
||||
if (!provider || !provider.apiKey || !provider.baseUrl) {
|
||||
console.log("[Auto-title] Provider not configured");
|
||||
return NextResponse.json({ title: "未命名画布" });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user