From d6d8bf021f55a1abc5717d02ae0bd2b34beae31f Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 23 Apr 2026 18:24:39 +0800 Subject: [PATCH] feat: add bltcy unified video provider --- .../settings/admin-settings-client.tsx | 103 ++++ app/(chat)/api/chat/route.ts | 5 +- app/api/admin/ai-providers/route.ts | 20 +- app/api/admin/bltcy-video-models/route.ts | 139 +++++ lib/ai/bltcy-video-models.ts | 550 ++++++++++++++++++ lib/ai/dynamic-provider.ts | 10 + lib/ai/model-classification.ts | 1 + lib/ai/model-router.ts | 2 +- lib/ai/providers/bltcy-video.ts | 530 +++++++++++++++++ 9 files changed, 1355 insertions(+), 5 deletions(-) create mode 100644 app/api/admin/bltcy-video-models/route.ts create mode 100644 lib/ai/bltcy-video-models.ts create mode 100644 lib/ai/providers/bltcy-video.ts diff --git a/app/(admin)/settings/admin-settings-client.tsx b/app/(admin)/settings/admin-settings-client.tsx index 5f639e2ae..a67682771 100644 --- a/app/(admin)/settings/admin-settings-client.tsx +++ b/app/(admin)/settings/admin-settings-client.tsx @@ -214,6 +214,10 @@ import { BLTCY_IMAGE_OPENAI_BASE_URL, BLTCY_IMAGE_PROVIDER_PRESET, } from "@/lib/ai/bltcy-image-models"; +import { + BLTCY_VIDEO_MODEL_PRESETS, + BLTCY_VIDEO_PROVIDER_PRESET, +} from "@/lib/ai/bltcy-video-models"; import { CANVAS_SKILL_ICON_OPTIONS, getCanvasSkillIconComponent, @@ -455,6 +459,7 @@ type AiProvider = { | "custom" | "local" | "gemini" + | "bltcy-video" | "grsai-gpt-image" | "grsai-video" | "huanke-gemini" @@ -1188,6 +1193,7 @@ const PROVIDER_TYPES = [ { value: "ruxa-image", label: "RUXA生图" }, { value: "fal-image", label: "FAL 生图模型" }, { value: "openai-image", label: "OpenAI 图片兼容" }, + { value: "bltcy-video", label: "柏拉图统一视频" }, { value: "grsai-gpt-image", label: "Grsai GPT Image" }, { value: "grsai-video", label: "Grsai 视频模型" }, { value: "midjourney", label: "Midjourney" }, @@ -1219,6 +1225,7 @@ const PROVIDER_DEFAULT_BASE_URL: Record = { "ruxa-image": "https://api.ruxa.ai", "fal-image": "https://fal.run", "openai-image": "https://api.openai.com/v1", + "bltcy-video": "https://api.bltcy.ai", "grsai-gpt-image": "https://grsai.dakka.com.cn", "grsai-video": "https://grsai.dakka.com.cn", midjourney: "https://your-midjourney-api.example.com", @@ -3014,6 +3021,7 @@ export function AdminSettingsClient() { | "custom" | "local" | "gemini" + | "bltcy-video" | "grsai-gpt-image" | "grsai-video" | "huanke-gemini" @@ -4985,6 +4993,7 @@ export function AdminSettingsClient() { const isNewProvider = !editingProvider; const isVolcanoVideo = providerForm.type === "volcano-video"; const isKreaProvider = providerForm.type === "krea"; + const isBltcyVideoProvider = providerForm.type === "bltcy-video"; const isLemonProvider = providerForm.type === "openai" && isLemonApiBaseUrl( @@ -5089,6 +5098,17 @@ export function AdminSettingsClient() { } } + if (isNewProvider && isBltcyVideoProvider && providerId) { + try { + await handleQuickAddBltcyVideoModels(providerId, { skipConfirm: true }); + } catch (modelError) { + console.error("[Auto Add BLTCY Video Models] Error:", modelError); + toast.warning( + '柏拉图视频预设模型添加失败,请手动点击"快速添加视频预设"按钮' + ); + } + } + if (isNewProvider && isLemonProvider && providerId) { try { await handleQuickAddLemonModels(providerId); @@ -5871,6 +5891,63 @@ export function AdminSettingsClient() { } }; + const handleUseBltcyVideoProviderPreset = () => { + setProviderForm({ + id: "", + name: BLTCY_VIDEO_PROVIDER_PRESET.name, + type: BLTCY_VIDEO_PROVIDER_PRESET.type, + baseUrl: BLTCY_VIDEO_PROVIDER_PRESET.baseUrl, + apiKey: "", + isEnabled: true, + }); + setEditingProvider(null); + setShowProviderDialog(true); + }; + + const handleQuickAddBltcyVideoModels = async ( + providerId: string, + options?: { skipConfirm?: boolean } + ) => { + if ( + !options?.skipConfirm && + !confirm( + `将为此服务商添加 ${BLTCY_VIDEO_MODEL_PRESETS.length} 个柏拉图统一视频模型预设。\n\n继续吗?` + ) + ) { + return; + } + + try { + toast.info("正在添加柏拉图统一视频预设模型..."); + + const response = await fetch("/api/admin/bltcy-video-models", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ providerId }), + }); + + const data = await response.json(); + + if (!response.ok) { + throw new Error(data.error || "添加失败"); + } + + const { addedCount, errors } = data; + + if (addedCount > 0) { + toast.success(`成功添加 ${addedCount} 个柏拉图视频预设模型`); + mutateModels(); + } + + if (errors && errors.length > 0) { + toast.warning(`${errors.length} 个模型添加失败(可能已存在)`); + } + } catch (error: any) { + console.error("[Quick Add BLTCY Video Models] Error:", error); + toast.error(error.message || "添加柏拉图视频预设模型失败"); + } + }; + const handleUseBltcyImageProviderPreset = () => { setProviderForm({ id: "", @@ -8012,6 +8089,7 @@ export function AdminSettingsClient() { {(() => { const providerColors: Record = { gemini: "bg-purple-500", + "bltcy-video": "bg-cyan-500", "volcano-vision": "bg-orange-500", "volcano-video": "bg-red-500", "doubao-video": "bg-red-400", @@ -12733,6 +12811,12 @@ export function AdminSettingsClient() { 配置 AI 服务提供商
+ )} + {provider.type === "bltcy-video" && ( + + )} {provider.type === "openai-image" && isBltcyImageBaseUrl(provider.baseUrl) && (