Unified maintenance of model capabilities and provision of model lists
1 files added
12 files modified
| | |
| | | StandardPipelineRequest, |
| | | ) |
| | | from config import BASE_DIR |
| | | from models.config_model import get_models_by_type, model_type_capabilities |
| | | from pipelines.api_media import list_api_workflows |
| | | from pipelines.events import task_event_stream |
| | | from pipelines.runner import PIPELINE_REGISTRY, run_pipeline_task |
| | |
| | | @router.get("/api/models") |
| | | async def get_api_models( |
| | | media_type: Optional[str] = Query(None, pattern="^(image|video)$"), |
| | | model_type: Optional[str] = Query(None, pattern="^(llm|vlm|t2i|i2i|video)$"), |
| | | ability: Optional[str] = Query(None), |
| | | verified_only: bool = False, |
| | | ): |
| | | if model_type: |
| | | models = [] |
| | | for model in get_models_by_type(model_type): |
| | | capabilities = model_type_capabilities(model_type, model) |
| | | models.append({ |
| | | "id": model["id"], |
| | | "label": model.get("name") or model["id"], |
| | | "provider": model.get("provider"), |
| | | "family": model.get("family"), |
| | | "model_type": model_type, |
| | | "type": model.get("type", []), |
| | | "concurrency": model.get("concurrency"), |
| | | "ability_type": capabilities.get("ability_type"), |
| | | "ability_types": capabilities.get("ability_types", []), |
| | | "adapter_ability_types": capabilities.get("adapter_ability_types", []), |
| | | "input_modalities": capabilities.get("input_modalities", []), |
| | | "adapter_input_modalities": capabilities.get("adapter_input_modalities", []), |
| | | "api_contract_verified": capabilities.get("api_contract_verified", False), |
| | | "capabilities": capabilities, |
| | | }) |
| | | return { |
| | | "models": models |
| | | } |
| | | |
| | | required = [ability] if ability else None |
| | | workflows = list_api_workflows( |
| | | media_type=media_type, |
| | |
| | | "id": workflow["model"], |
| | | "label": workflow.get("display_name") or workflow["model"], |
| | | "provider": workflow.get("provider"), |
| | | "family": workflow.get("family"), |
| | | "media_type": workflow.get("media_type"), |
| | | "ability_type": workflow.get("ability_type"), |
| | | "ability_types": workflow.get("ability_types", []), |
| | |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.03, |
| | | 'price_per_1k_output_token': 0.12}, |
| | | 'qwen3.7-max': {'name': 'Qwen 3.7 Max', |
| | | 'provider': 'dashscope', |
| | | 'family': 'qwen', |
| | | 'type': ['llm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.006, |
| | | 'price_per_1k_output_token': 0.024}, |
| | | 'qwen3.7-plus': {'name': 'Qwen 3.7 Plus', |
| | | 'provider': 'dashscope', |
| | | 'family': 'qwen', |
| | | 'type': ['vlm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.0008, |
| | | 'price_per_1k_output_token': 0.002}, |
| | | 'qwen3.5-plus': {'name': 'Qwen 3.5 Plus', |
| | | 'provider': 'dashscope', |
| | | 'family': 'qwen', |
| | | 'type': ['vlm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.0008, |
| | | 'price_per_1k_output_token': 0.002}, |
| | | 'qwen3.6-max-preview': {'name': 'Qwen 3.6 Max Preview', |
| | | 'provider': 'qwen', |
| | | 'provider': 'dashscope', |
| | | 'family': 'qwen', |
| | | 'type': ['llm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.006, |
| | | 'price_per_1k_output_token': 0.024}, |
| | | 'qwen3-max': {'name': 'Qwen 3 Max', |
| | | 'provider': 'qwen', |
| | | 'provider': 'dashscope', |
| | | 'family': 'qwen', |
| | | 'type': ['llm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.006, |
| | | 'price_per_1k_output_token': 0.024}, |
| | | 'deepseek-v3.2': {'name': 'DeepSeek V3.2 (DashScope)', |
| | | 'provider': 'qwen', |
| | | 'provider': 'dashscope', |
| | | 'family': 'deepseek', |
| | | 'type': ['llm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.002, |
| | | 'price_per_1k_output_token': 0.008}, |
| | | 'qwen3.6-plus': {'name': 'Qwen 3.6 Plus', |
| | | 'provider': 'qwen', |
| | | 'provider': 'dashscope', |
| | | 'family': 'qwen', |
| | | 'type': ['vlm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.0008, |
| | | 'price_per_1k_output_token': 0.002}, |
| | | 'qwen3.6-flash': {'name': 'Qwen 3.6 Flash', |
| | | 'provider': 'qwen', |
| | | 'provider': 'dashscope', |
| | | 'family': 'qwen', |
| | | 'type': ['vlm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.0001, |
| | | 'price_per_1k_output_token': 0.0001}, |
| | | 'kimi-k2.6': {'name': 'Kimi K2.6', |
| | | 'provider': 'qwen', |
| | | 'provider': 'dashscope', |
| | | 'family': 'kimi', |
| | | 'type': ['llm', 'vlm'], |
| | | 'concurrency': 10, |
| | | 'price_per_1k_input_token': 0.001, |
| | |
| | | 'price_per_1k_output_token': 0.01}, |
| | | 'wan2.7-image': {'name': 'Wan 2.7 Image', |
| | | 'provider': 'dashscope', |
| | | 'family': 'wan', |
| | | 'type': ['t2i', 'i2i'], |
| | | 'concurrency': 5, |
| | | 'price_per_image': 0.2, |
| | |
| | | 'ratios': ['16:9', '9:16', '1:1', '4:3', '3:4']}}, |
| | | 'wan2.7-image-pro': {'name': 'Wan 2.7 Image Pro', |
| | | 'provider': 'dashscope', |
| | | 'family': 'wan', |
| | | 'type': ['t2i', 'i2i'], |
| | | 'concurrency': 5, |
| | | 'price_per_image': 0.4, |
| | |
| | | 'ratios': ['16:9', '9:16', '1:1', '4:3', '3:4']}}, |
| | | 'wan2.6-t2i': {'name': 'Wan 2.6 T2I', |
| | | 'provider': 'dashscope', |
| | | 'family': 'wan', |
| | | 'type': ['t2i'], |
| | | 'concurrency': 5, |
| | | 'price_per_image': 0.2, |
| | |
| | | 'resolutions': ['720P', '1080P', '2K', '4K'], |
| | | 'ratios': ['16:9', '9:16', '1:1', '4:3', '3:4']}}, |
| | | 'doubao-seedream-5-0-260128': {'name': 'Seedream 5.0', |
| | | 'provider': 'seedream', |
| | | 'provider': 'ark', |
| | | 'family': 'seedream', |
| | | 'type': ['t2i', 'i2i'], |
| | | 'concurrency': 10, |
| | | 'price_per_image': 0.22, |
| | |
| | | 'resolutions': ['720P', '1080P', '2K', '4K'], |
| | | 'ratios': ['16:9', '9:16', '1:1', '4:3', '3:4']}}, |
| | | 'doubao-seedream-4-5-251128': {'name': 'Seedream 4.5', |
| | | 'provider': 'seedream', |
| | | 'provider': 'ark', |
| | | 'family': 'seedream', |
| | | 'type': ['t2i', 'i2i'], |
| | | 'concurrency': 10, |
| | | 'price_per_image': 0.25, |
| | |
| | | 'resolutions': ['720P', '1080P', '2K', '4K'], |
| | | 'ratios': ['16:9', '9:16', '1:1', '4:3', '3:4']}}, |
| | | 'doubao-seedream-4-0-250828': {'name': 'Seedream 4.0', |
| | | 'provider': 'seedream', |
| | | 'provider': 'ark', |
| | | 'family': 'seedream', |
| | | 'type': ['t2i', 'i2i'], |
| | | 'concurrency': 10, |
| | | 'price_per_image': 0.2, |
| | |
| | | 'api_contract_verified': True}}, |
| | | 'wan2.6-i2v-flash': {'name': 'Wan 2.6 I2V Flash', |
| | | 'provider': 'dashscope', |
| | | 'family': 'wan', |
| | | 'type': ['video'], |
| | | 'concurrency': 5, |
| | | 'price_per_second': 0.6, |
| | |
| | | 'api_contract_verified': True}}, |
| | | 'wan2.7-i2v': {'name': 'Wan 2.7 I2V', |
| | | 'provider': 'dashscope', |
| | | 'family': 'wan', |
| | | 'type': ['video'], |
| | | 'concurrency': 5, |
| | | 'price_per_second': 0.8, |
| | |
| | | 'api_contract_verified': True}}, |
| | | 'happyhorse-1.0-i2v': {'name': 'Happy Horse 1.0 I2V', |
| | | 'provider': 'dashscope', |
| | | 'family': 'happyhorse', |
| | | 'type': ['video'], |
| | | 'concurrency': 5, |
| | | 'price_per_second': 1.0, |
| | |
| | | 'adapter_input_modalities': ['text', 'image'], |
| | | 'api_contract_verified': False}}, |
| | | 'doubao-seedance-2-0-260128': {'name': 'Seedance 2.0', |
| | | 'provider': 'seedance', |
| | | 'provider': 'ark', |
| | | 'family': 'seedance', |
| | | 'type': ['video'], |
| | | 'concurrency': 10, |
| | | 'price_per_second': 0.5, |
| | |
| | | 'adaptive'], |
| | | 'api_contract_verified': True}}, |
| | | 'doubao-seedance-2-0-fast-260128': {'name': 'Seedance 2.0 Fast', |
| | | 'provider': 'seedance', |
| | | 'provider': 'ark', |
| | | 'family': 'seedance', |
| | | 'type': ['video'], |
| | | 'concurrency': 10, |
| | | 'price_per_second': 0.3, |
| | |
| | | 'api_contract_verified': True}}, |
| | | 'wan2.7-r2v': {'name': 'Wan 2.7 R2V', |
| | | 'provider': 'dashscope', |
| | | 'family': 'wan', |
| | | 'type': ['video'], |
| | | 'concurrency': 5, |
| | | 'price_per_second': 0.8, |
| | |
| | | 'api_contract_verified': True}}, |
| | | 'wan2.7-videoedit': {'name': 'Wan 2.7 Video Edit', |
| | | 'provider': 'dashscope', |
| | | 'family': 'wan', |
| | | 'type': ['video'], |
| | | 'concurrency': 5, |
| | | 'price_per_second': 0.8, |
| | |
| | | 'api_contract_verified': True}}, |
| | | 'happyhorse-1.0-r2v': {'name': 'Happy Horse 1.0 R2V', |
| | | 'provider': 'dashscope', |
| | | 'family': 'happyhorse', |
| | | 'type': ['video'], |
| | | 'concurrency': 5, |
| | | 'price_per_second': 1.0, |
| | |
| | | 'api_contract_verified': True}}, |
| | | 'happyhorse-1.0-video-edit': {'name': 'Happy Horse 1.0 Video Edit', |
| | | 'provider': 'dashscope', |
| | | 'family': 'happyhorse', |
| | | 'type': ['video'], |
| | | 'concurrency': 5, |
| | | 'price_per_second': 1.0, |
| | |
| | | 'resolutions': ['720P', '1080P'], |
| | | 'api_contract_verified': True}}, |
| | | 'seedance-1-0-pro': {'name': 'Seedance 1.0 Pro', |
| | | 'provider': 'seedance', |
| | | 'provider': 'ark', |
| | | 'family': 'seedance', |
| | | 'type': ['video'], |
| | | 'concurrency': 10, |
| | | 'price_per_second': 0.5, |
| | |
| | | 'adapter_ability_types': ['first_frame_i2v'], |
| | | 'api_contract_verified': False}}, |
| | | 'seedance-1-0-lite': {'name': 'Seedance 1.0 Lite', |
| | | 'provider': 'seedance', |
| | | 'provider': 'ark', |
| | | 'family': 'seedance', |
| | | 'type': ['video'], |
| | | 'concurrency': 10, |
| | | 'price_per_second': 0.3, |
| | |
| | | if model_type in (metadata.get("type") or []): |
| | | result.append({"id": model_id, **metadata}) |
| | | return result |
| | | |
| | | |
| | | def model_type_capabilities(model_type: str, metadata: Optional[dict[str, Any]] = None) -> dict[str, Any]: |
| | | """Return normalized capability metadata for non-media model selectors.""" |
| | | metadata = metadata or {} |
| | | if metadata.get("capabilities"): |
| | | return deepcopy(metadata["capabilities"]) |
| | | if model_type == "llm": |
| | | return { |
| | | "ability_type": "text_generation", |
| | | "ability_types": ["text_generation"], |
| | | "adapter_ability_types": ["text_generation"], |
| | | "input_modalities": ["text"], |
| | | "adapter_input_modalities": ["text"], |
| | | "api_contract_verified": bool(metadata.get("api_contract_verified", False)), |
| | | } |
| | | if model_type == "vlm": |
| | | return { |
| | | "ability_type": "vision_language", |
| | | "ability_types": ["vision_language", "image_understanding"], |
| | | "adapter_ability_types": ["vision_language", "image_understanding"], |
| | | "input_modalities": ["text", "image"], |
| | | "adapter_input_modalities": ["text", "image"], |
| | | "api_contract_verified": bool(metadata.get("api_contract_verified", False)), |
| | | } |
| | | return media_capabilities(metadata.get("provider", ""), metadata.get("id", ""), "video" if model_type == "video" else "image") |
| | | |
| | | |
| | | def model_records(media_type: Optional[str] = None) -> list[dict[str, Any]]: |
| | |
| | | "display_name": f"{metadata.get('name') or model_id} - API {provider.title()}", |
| | | "source": "api", |
| | | "provider": provider, |
| | | "family": metadata.get("family"), |
| | | "model": model_id, |
| | | "media_type": media_type, |
| | | "type": metadata.get("type", []), |
| | |
| | | # -*- coding: utf-8 -*- |
| | | """ |
| | | Qwen LLM API 客户端(DashScope Generation API) |
| | | 支持 qwen3.5-plus, qwen3.5-max 等模型 |
| | | 支持 qwen3.7-max、qwen3.6-max-preview、qwen3-max 等文本生成模型 |
| | | """ |
| | | |
| | | import os |
| | |
| | | |
| | | :param prompt: Text prompt |
| | | :param image_urls: Ignored in this LLM implementation (use VLM for multimodal) |
| | | :param model: Model name (e.g., qwen3.5-vl, qwen3.5-plus, qwen3.5-max) |
| | | :param model: Model name (e.g., qwen3.7-max, qwen3.6-max-preview, qwen3-max) |
| | | :param web_search: If True, adds enable_search: True to API call |
| | | """ |
| | | if dashscope is None: |
| | |
| | | |
| | | # 支持的模型列表 |
| | | |
| | | MODELS = ["qwen3.6-max-preview", "qwen3-max", "deepseek-v3.2"] |
| | | MODELS = ["qwen3.7-max", "qwen3.6-max-preview", "qwen3-max", "deepseek-v3.2"] |
| | | |
| | | print("=== DashScope LLM 可用性测试 ===") |
| | | api_key = Config.DASHSCOPE_API_KEY |
| | |
| | | from config import Config |
| | | |
| | | # 支持的 VLM 模型列表 |
| | | MODELS = ["qwen3.6-plus", "qwen3.6-flash", "kimi-k2.6"] |
| | | MODELS = ["qwen3.7-plus", "qwen3.6-plus", "qwen3.6-flash", "qwen3.5-plus", "kimi-k2.6"] |
| | | |
| | | print("=== Qwen VL (DashScope) 多模态可用性测试 ===") |
| | | api_key = Config.DASHSCOPE_API_KEY |
| | |
| | | return min(max(int(duration), int(contract.get("min", duration))), int(contract.get("max", duration))) |
| | | if provider == "dashscope": |
| | | return 10 if duration >= 8 else 5 |
| | | if provider == "seedance": |
| | | if provider == "seedance" or "seedance" in (model or "").lower(): |
| | | return min(max(duration, 5), 10) |
| | | return max(duration, 1) |
| | | |
| | |
| | | import { useEffect, useState } from 'react'; |
| | | import { CheckCircle, Loader2, Save, Settings, XCircle } from 'lucide-react'; |
| | | import BrandHeader from '@/components/BrandHeader'; |
| | | import { fetchModelGroupsByType } from '@/lib/modelRegistry'; |
| | | import { |
| | | I2I_PROVIDERS, |
| | | LLM_PROVIDERS, |
| | | T2I_PROVIDERS, |
| | | VIDEO_PROVIDERS, |
| | | VIDEO_RATIOS, |
| | | VIDEO_RESOLUTIONS, |
| | | VLM_PROVIDERS, |
| | | STYLES, |
| | | type ProviderGroup, |
| | | } from '@/config/models'; |
| | |
| | | options?: Array<{ id: string; label: string }> | ProviderGroup[]; |
| | | }; |
| | | |
| | | const MODEL_SELECTS = { |
| | | llm: LLM_PROVIDERS, |
| | | vlm: VLM_PROVIDERS, |
| | | image_it2i: I2I_PROVIDERS, |
| | | image_t2i: T2I_PROVIDERS, |
| | | video: VIDEO_PROVIDERS, |
| | | eval: LLM_PROVIDERS, |
| | | type ModelSelectKey = 'llm' | 'vlm' | 'image_it2i' | 'image_t2i' | 'video' | 'eval'; |
| | | |
| | | const EMPTY_MODEL_SELECTS: Record<ModelSelectKey, ProviderGroup[]> = { |
| | | llm: [], |
| | | vlm: [], |
| | | image_it2i: [], |
| | | image_t2i: [], |
| | | video: [], |
| | | eval: [], |
| | | }; |
| | | |
| | | const GROUPS: Array<{ title: string; description: string; fields: Field[] }> = [ |
| | |
| | | title: 'Default Models', |
| | | description: '主流程和 Pipeline 使用的默认模型。', |
| | | fields: [ |
| | | { path: 'models.llm', label: 'llm', type: 'select', options: MODEL_SELECTS.llm }, |
| | | { path: 'models.vlm', label: 'vlm', type: 'select', options: MODEL_SELECTS.vlm }, |
| | | { path: 'models.image_it2i', label: 'image_it2i', type: 'select', options: MODEL_SELECTS.image_it2i }, |
| | | { path: 'models.image_t2i', label: 'image_t2i', type: 'select', options: MODEL_SELECTS.image_t2i }, |
| | | { path: 'models.video', label: 'video', type: 'select', options: MODEL_SELECTS.video }, |
| | | { path: 'models.eval', label: 'eval', type: 'select', options: MODEL_SELECTS.eval }, |
| | | { path: 'models.llm', label: 'llm', type: 'select', options: [] }, |
| | | { path: 'models.vlm', label: 'vlm', type: 'select', options: [] }, |
| | | { path: 'models.image_it2i', label: 'image_it2i', type: 'select', options: [] }, |
| | | { path: 'models.image_t2i', label: 'image_t2i', type: 'select', options: [] }, |
| | | { path: 'models.video', label: 'video', type: 'select', options: [] }, |
| | | { path: 'models.eval', label: 'eval', type: 'select', options: [] }, |
| | | ], |
| | | }, |
| | | { |
| | |
| | | const [message, setMessage] = useState(''); |
| | | const [error, setError] = useState(''); |
| | | const [secretDrafts, setSecretDrafts] = useState<Record<string, string>>({}); |
| | | const [modelSelects, setModelSelects] = useState<Record<ModelSelectKey, ProviderGroup[]>>(EMPTY_MODEL_SELECTS); |
| | | |
| | | useEffect(() => { |
| | | const load = async () => { |
| | |
| | | }; |
| | | load(); |
| | | }, []); |
| | | |
| | | useEffect(() => { |
| | | let cancelled = false; |
| | | Promise.all([ |
| | | fetchModelGroupsByType('llm'), |
| | | fetchModelGroupsByType('vlm'), |
| | | fetchModelGroupsByType('i2i'), |
| | | fetchModelGroupsByType('t2i'), |
| | | fetchModelGroupsByType('video'), |
| | | ]) |
| | | .then(([llm, vlm, imageIt2i, imageT2i, video]) => { |
| | | if (cancelled) return; |
| | | setModelSelects({ |
| | | llm, |
| | | vlm, |
| | | image_it2i: imageIt2i, |
| | | image_t2i: imageT2i, |
| | | video, |
| | | eval: llm, |
| | | }); |
| | | }) |
| | | .catch(() => {}); |
| | | return () => { cancelled = true; }; |
| | | }, []); |
| | | |
| | | const groups = GROUPS.map(group => { |
| | | if (group.title !== 'Default Models') return group; |
| | | return { |
| | | ...group, |
| | | fields: group.fields.map(field => { |
| | | if (field.path === 'models.llm') return { ...field, options: modelSelects.llm }; |
| | | if (field.path === 'models.vlm') return { ...field, options: modelSelects.vlm }; |
| | | if (field.path === 'models.image_it2i') return { ...field, options: modelSelects.image_it2i }; |
| | | if (field.path === 'models.image_t2i') return { ...field, options: modelSelects.image_t2i }; |
| | | if (field.path === 'models.video') return { ...field, options: modelSelects.video }; |
| | | if (field.path === 'models.eval') return { ...field, options: modelSelects.eval }; |
| | | return field; |
| | | }), |
| | | }; |
| | | }); |
| | | |
| | | const updateField = (field: Field, raw: string | boolean) => { |
| | | const value = field.type === 'number' ? Number(raw) || 0 : raw; |
| | |
| | | </div> |
| | | ) : ( |
| | | <div className="space-y-5"> |
| | | {GROUPS.map(group => ( |
| | | {groups.map(group => ( |
| | | <section key={group.title} className="rounded-2xl border border-gray-200 bg-white p-5 shadow-sm"> |
| | | <div className="mb-4"> |
| | | <h2 className="text-sm font-semibold text-gray-800">{group.title}</h2> |
| | |
| | | import { Sparkles, Play, Settings2, Clock, ArrowRight, Zap, CheckCircle, Trash2, X, Lock, Globe, ListOrdered, Upload, Loader2 } from 'lucide-react'; |
| | | import clsx from 'clsx'; |
| | | import { PROMPT_EXAMPLES } from '@/config/examples'; |
| | | import { STYLES, VIDEO_RATIOS, VIDEO_RESOLUTIONS, LLM_PROVIDERS, T2I_PROVIDERS, I2I_PROVIDERS, VIDEO_PROVIDERS, VLM_PROVIDERS } from '@/config/models'; |
| | | import { STYLES, VIDEO_RATIOS, VIDEO_RESOLUTIONS, type ProviderGroup } from '@/config/models'; |
| | | import { STAGES } from './TopBar'; |
| | | import { fetchModelGroupsByType } from '@/lib/modelRegistry'; |
| | | |
| | | export interface ProjectParams { |
| | | idea: string; |
| | |
| | | const [deleteTarget, setDeleteTarget] = useState<string | null>(null); |
| | | const [deleteError, setDeleteError] = useState(''); |
| | | const [deleting, setDeleting] = useState(false); |
| | | const [llmProviders, setLlmProviders] = useState<ProviderGroup[]>([]); |
| | | const [vlmProviders, setVlmProviders] = useState<ProviderGroup[]>([]); |
| | | const [t2iProviders, setT2iProviders] = useState<ProviderGroup[]>([]); |
| | | const [i2iProviders, setI2iProviders] = useState<ProviderGroup[]>([]); |
| | | const [videoProviders, setVideoProviders] = useState<ProviderGroup[]>([]); |
| | | const modelConfigReady = Boolean(selectedLLM && selectedVLM && selectedT2I && selectedI2I && selectedVideo && selectedRatio && selectedResolution); |
| | | const canStart = Boolean((idea.trim() || uploadedFile) && modelConfigReady && !configLoading); |
| | | |
| | | useEffect(() => { |
| | | let cancelled = false; |
| | | fetchModelGroupsByType('llm') |
| | | .then(groups => { if (!cancelled) setLlmProviders(groups); }) |
| | | .catch(() => {}); |
| | | fetchModelGroupsByType('vlm') |
| | | .then(groups => { if (!cancelled) setVlmProviders(groups); }) |
| | | .catch(() => {}); |
| | | fetchModelGroupsByType('t2i') |
| | | .then(groups => { if (!cancelled) setT2iProviders(groups); }) |
| | | .catch(() => {}); |
| | | fetchModelGroupsByType('i2i') |
| | | .then(groups => { if (!cancelled) setI2iProviders(groups); }) |
| | | .catch(() => {}); |
| | | fetchModelGroupsByType('video') |
| | | .then(groups => { if (!cancelled) setVideoProviders(groups); }) |
| | | .catch(() => {}); |
| | | return () => { cancelled = true; }; |
| | | }, []); |
| | | |
| | | useEffect(() => { |
| | | let cancelled = false; |
| | |
| | | onChange={e => setSelectedLLM(e.target.value)} |
| | | className="bg-white border border-gray-200 rounded-lg px-2.5 py-2 text-gray-700 outline-none" |
| | | > |
| | | {LLM_PROVIDERS.map(pg => ( |
| | | {llmProviders.map(pg => ( |
| | | <optgroup key={pg.provider} label={pg.label}> |
| | | {pg.models.map(m => ( |
| | | <option key={m.id} value={m.id}>{m.label}</option> |
| | |
| | | onChange={e => setSelectedVLM(e.target.value)} |
| | | className="bg-white border border-gray-200 rounded-lg px-2.5 py-2 text-gray-700 outline-none" |
| | | > |
| | | {VLM_PROVIDERS.map(pg => ( |
| | | {vlmProviders.map(pg => ( |
| | | <optgroup key={pg.provider} label={pg.label}> |
| | | {pg.models.map(m => ( |
| | | <option key={m.id} value={m.id}>{m.label}</option> |
| | |
| | | onChange={e => setSelectedT2I(e.target.value)} |
| | | className="bg-white border border-gray-200 rounded-lg px-2.5 py-2 text-gray-700 outline-none" |
| | | > |
| | | {T2I_PROVIDERS.map(pg => ( |
| | | {t2iProviders.map(pg => ( |
| | | <optgroup key={pg.provider} label={pg.label}> |
| | | {pg.models.map(m => ( |
| | | <option key={m.id} value={m.id}>{m.label}</option> |
| | |
| | | onChange={e => setSelectedI2I(e.target.value)} |
| | | className="bg-white border border-gray-200 rounded-lg px-2.5 py-2 text-gray-700 outline-none" |
| | | > |
| | | {I2I_PROVIDERS.map(pg => ( |
| | | {i2iProviders.map(pg => ( |
| | | <optgroup key={pg.provider} label={pg.label}> |
| | | {pg.models.map(m => ( |
| | | <option key={m.id} value={m.id}>{m.label}</option> |
| | |
| | | onChange={e => setSelectedVideo(e.target.value)} |
| | | className="bg-white border border-gray-200 rounded-lg px-2.5 py-2 text-gray-700 outline-none" |
| | | > |
| | | {VIDEO_PROVIDERS.map(pg => ( |
| | | {videoProviders.map(pg => ( |
| | | <optgroup key={pg.provider} label={pg.label}> |
| | | {pg.models.map(m => ( |
| | | <option key={m.id} value={m.id}>{m.label}</option> |
| | |
| | | import { useState, useEffect, useRef, DragEvent } from 'react'; |
| | | import { Sparkles, Image, Video, MessageSquare, Zap, Loader2, Copy, Check, Trash2, X, FolderOpen, Upload, Globe, Hexagon } from 'lucide-react'; |
| | | import { useSearchParams } from 'next/navigation'; |
| | | import { LLM_MODELS, T2I_MODELS, I2I_MODELS, VIDEO_MODELS, VLM_MODELS } from '@/config/models'; |
| | | import type { ModelOption, ProviderGroup } from '@/config/models'; |
| | | import BrandHeader from '@/components/BrandHeader'; |
| | | import { fetchSandboxTasks, uploadMedia } from '@/lib/workflowApi'; |
| | | import { fetchModelGroupsByType } from '@/lib/modelRegistry'; |
| | | |
| | | // 辅助函数:将相对路径转换为完整 URL |
| | | const toMediaUrl = (path: string) => { |
| | |
| | | |
| | | // 工具类型 |
| | | type ToolType = 'llm' | 'vlm' | 't2i' | 'i2i' | 'video'; |
| | | |
| | | const EMPTY_MODEL_GROUPS: Record<ToolType, ProviderGroup[]> = { |
| | | llm: [], |
| | | vlm: [], |
| | | t2i: [], |
| | | i2i: [], |
| | | video: [], |
| | | }; |
| | | |
| | | interface Tool { |
| | | id: ToolType; |
| | |
| | | |
| | | export default function SandboxPage() { |
| | | const [activeTool, setActiveTool] = useState<ToolType>('llm'); |
| | | const [modelGroups, setModelGroups] = useState<Record<ToolType, ProviderGroup[]>>(EMPTY_MODEL_GROUPS); |
| | | const [prompt, setPrompt] = useState(''); |
| | | const [imageUrl, setImageUrl] = useState(''); |
| | | const [loading, setLoading] = useState(false); |
| | |
| | | const [deleting, setDeleting] = useState<string | null>(null); |
| | | const [selectedRecord, setSelectedRecord] = useState<HistoryRecord | null>(null); |
| | | const searchParams = useSearchParams(); |
| | | |
| | | const flattenModels = (groups: ProviderGroup[]): ModelOption[] => groups.flatMap(group => group.models); |
| | | |
| | | const getModels = () => flattenModels(modelGroups[activeTool] || []); |
| | | |
| | | const firstModelId = (groups: ProviderGroup[]) => { |
| | | const models = flattenModels(groups); |
| | | return models.find(model => model.default)?.id || models[0]?.id || ''; |
| | | }; |
| | | |
| | | const [selectedModel, setSelectedModel] = useState(''); |
| | | const [webSearch, setWebSearch] = useState(false); |
| | | |
| | | // 获取历史记录 |
| | | const fetchHistory = async () => { |
| | |
| | | |
| | | useEffect(() => { |
| | | fetchHistory(); |
| | | }, []); |
| | | |
| | | useEffect(() => { |
| | | let cancelled = false; |
| | | Promise.all([ |
| | | fetchModelGroupsByType('llm'), |
| | | fetchModelGroupsByType('vlm'), |
| | | fetchModelGroupsByType('t2i'), |
| | | fetchModelGroupsByType('i2i'), |
| | | fetchModelGroupsByType('video'), |
| | | ]) |
| | | .then(([llm, vlm, t2i, i2i, video]) => { |
| | | if (cancelled) return; |
| | | const groups = { llm, vlm, t2i, i2i, video }; |
| | | setModelGroups(groups); |
| | | setSelectedModel(current => current || firstModelId(groups[activeTool])); |
| | | }) |
| | | .catch(() => {}); |
| | | return () => { cancelled = true; }; |
| | | }, []); |
| | | |
| | | const applyRecord = (record: HistoryRecord) => { |
| | |
| | | } |
| | | }; |
| | | |
| | | // 根据工具类型获取模型列表 |
| | | const getModels = () => { |
| | | switch (activeTool) { |
| | | case 'llm': return LLM_MODELS; |
| | | case 'vlm': return VLM_MODELS; |
| | | case 't2i': return T2I_MODELS; |
| | | case 'i2i': return I2I_MODELS; |
| | | case 'video': return VIDEO_MODELS; |
| | | default: return LLM_MODELS; |
| | | } |
| | | }; |
| | | |
| | | const [selectedModel, setSelectedModel] = useState(getModels().find(m => m.default)?.id || getModels()[0]?.id || ''); |
| | | const [webSearch, setWebSearch] = useState(false); |
| | | |
| | | // 工具切换时重置模型选择 |
| | | const handleToolChange = (tool: ToolType) => { |
| | | setActiveTool(tool); |
| | | // 立即更新模型选择 |
| | | const models = (() => { |
| | | switch (tool) { |
| | | case 'llm': return LLM_MODELS; |
| | | case 'vlm': return VLM_MODELS; |
| | | case 't2i': return T2I_MODELS; |
| | | case 'i2i': return I2I_MODELS; |
| | | case 'video': return VIDEO_MODELS; |
| | | default: return LLM_MODELS; |
| | | } |
| | | })(); |
| | | setSelectedModel(models.find(m => m.default)?.id || models[0]?.id || ''); |
| | | setSelectedModel(firstModelId(modelGroups[tool])); |
| | | setResult(null); |
| | | setCurrentOutput(null); |
| | | setError(null); |
| | |
| | | |
| | | // 监听工具变化,确保模型选择同步 |
| | | useEffect(() => { |
| | | const models = (() => { |
| | | switch (activeTool) { |
| | | case 'llm': return LLM_MODELS; |
| | | case 'vlm': return VLM_MODELS; |
| | | case 't2i': return T2I_MODELS; |
| | | case 'i2i': return I2I_MODELS; |
| | | case 'video': return VIDEO_MODELS; |
| | | default: return LLM_MODELS; |
| | | } |
| | | })(); |
| | | const models = getModels(); |
| | | // 只有当前模型不在新工具的模型列表中时才更新 |
| | | const currentInList = models.some(m => m.id === selectedModel); |
| | | if (!currentInList) { |
| | | setSelectedModel(models.find(m => m.default)?.id || models[0]?.id || ''); |
| | | } |
| | | }, [activeTool]); |
| | | }, [activeTool, modelGroups, selectedModel]); |
| | | |
| | | // 检查是否可以提交 |
| | | const canSubmit = () => { |
| | | if (!selectedModel) return false; |
| | | if (!prompt.trim() && activeTool !== 't2i') return false; |
| | | if ((activeTool === 'i2i') && !imageUrl) return false; |
| | | return true; |
| | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { CheckCircle, Circle, Loader, Edit3, AlertCircle, Square, Zap, Settings2, ChevronDown } from 'lucide-react'; |
| | | import clsx from 'clsx'; |
| | | import { LLM_PROVIDERS, T2I_PROVIDERS, I2I_PROVIDERS, VIDEO_PROVIDERS, VLM_PROVIDERS, VIDEO_RATIOS, VIDEO_RESOLUTIONS, ProviderGroup } from '@/config/models'; |
| | | import { VIDEO_RATIOS, VIDEO_RESOLUTIONS, type ProviderGroup } from '@/config/models'; |
| | | import { fetchModelGroupsByType } from '@/lib/modelRegistry'; |
| | | |
| | | export type StageStatus = 'pending' | 'running' | 'waiting' | 'completed' | 'error' | 'stopped'; |
| | | |
| | |
| | | }) { |
| | | const [open, setOpen] = useState(false); |
| | | const ref = useRef<HTMLDivElement>(null); |
| | | const [llmProviders, setLlmProviders] = useState<ProviderGroup[]>([]); |
| | | const [vlmProviders, setVlmProviders] = useState<ProviderGroup[]>([]); |
| | | const [t2iProviders, setT2iProviders] = useState<ProviderGroup[]>([]); |
| | | const [i2iProviders, setI2iProviders] = useState<ProviderGroup[]>([]); |
| | | const [videoProviders, setVideoProviders] = useState<ProviderGroup[]>([]); |
| | | |
| | | useEffect(() => { |
| | | const handler = (e: MouseEvent) => { |
| | |
| | | if (open) document.addEventListener('mousedown', handler); |
| | | return () => document.removeEventListener('mousedown', handler); |
| | | }, [open]); |
| | | |
| | | useEffect(() => { |
| | | let cancelled = false; |
| | | fetchModelGroupsByType('llm') |
| | | .then(groups => { if (!cancelled) setLlmProviders(groups); }) |
| | | .catch(() => {}); |
| | | fetchModelGroupsByType('vlm') |
| | | .then(groups => { if (!cancelled) setVlmProviders(groups); }) |
| | | .catch(() => {}); |
| | | fetchModelGroupsByType('t2i') |
| | | .then(groups => { if (!cancelled) setT2iProviders(groups); }) |
| | | .catch(() => {}); |
| | | fetchModelGroupsByType('i2i') |
| | | .then(groups => { if (!cancelled) setI2iProviders(groups); }) |
| | | .catch(() => {}); |
| | | fetchModelGroupsByType('video') |
| | | .then(groups => { if (!cancelled) setVideoProviders(groups); }) |
| | | .catch(() => {}); |
| | | return () => { cancelled = true; }; |
| | | }, []); |
| | | |
| | | const update = (key: keyof ModelConfig, val: string | boolean) => { |
| | | onChange({ ...config, [key]: val }); |
| | |
| | | <div className="absolute right-0 top-full mt-1 w-72 bg-white rounded-xl shadow-lg border border-gray-200 p-3 z-50 space-y-2.5"> |
| | | <label className="flex flex-col gap-1"> |
| | | <span className="text-[10px] text-gray-400 font-medium">LLM 模型</span> |
| | | <ProviderSelect value={config.llm_model} providers={LLM_PROVIDERS} onChange={v => update('llm_model', v)} /> |
| | | <ProviderSelect value={config.llm_model} providers={llmProviders} onChange={v => update('llm_model', v)} /> |
| | | </label> |
| | | <label className="flex flex-col gap-1"> |
| | | <span className="text-[10px] text-gray-400 font-medium">VLM 评估模型</span> |
| | | <ProviderSelect value={config.vlm_model} providers={VLM_PROVIDERS} onChange={v => update('vlm_model', v)} /> |
| | | <ProviderSelect value={config.vlm_model} providers={vlmProviders} onChange={v => update('vlm_model', v)} /> |
| | | </label> |
| | | <label className="flex flex-col gap-1"> |
| | | <span className="text-[10px] text-gray-400 font-medium">文生图</span> |
| | | <ProviderSelect value={config.image_t2i_model} providers={T2I_PROVIDERS} onChange={v => update('image_t2i_model', v)} /> |
| | | <ProviderSelect value={config.image_t2i_model} providers={t2iProviders} onChange={v => update('image_t2i_model', v)} /> |
| | | </label> |
| | | <label className="flex flex-col gap-1"> |
| | | <span className="text-[10px] text-gray-400 font-medium">图生图</span> |
| | | <ProviderSelect value={config.image_it2i_model} providers={I2I_PROVIDERS} onChange={v => update('image_it2i_model', v)} /> |
| | | <ProviderSelect value={config.image_it2i_model} providers={i2iProviders} onChange={v => update('image_it2i_model', v)} /> |
| | | </label> |
| | | <label className="flex flex-col gap-1"> |
| | | <span className="text-[10px] text-gray-400 font-medium">视频模型</span> |
| | | <ProviderSelect value={config.video_model} providers={VIDEO_PROVIDERS} onChange={v => update('video_model', v)} /> |
| | | <ProviderSelect value={config.video_model} providers={videoProviders} onChange={v => update('video_model', v)} /> |
| | | </label> |
| | | <label className="flex flex-col gap-1"> |
| | | <span className="text-[10px] text-gray-400 font-medium">视频比例</span> |
| | |
| | | type ApiModelOption, |
| | | type StandardTemplateOption, |
| | | } from '@/lib/workflowApi'; |
| | | import { fetchModelGroupsByType, groupModelOptions } from '@/lib/modelRegistry'; |
| | | import { |
| | | I2I_PROVIDERS, |
| | | LLM_PROVIDERS, |
| | | T2I_PROVIDERS, |
| | | VIDEO_PROVIDERS, |
| | | VIDEO_RATIOS, |
| | | VIDEO_RESOLUTIONS, |
| | | type ProviderGroup, |
| | |
| | | title: string; |
| | | subtitle: string; |
| | | } |
| | | |
| | | const DEFAULTS = { |
| | | llm: LLM_PROVIDERS.flatMap(p => p.models).find(m => m.default)?.id || LLM_PROVIDERS[0].models[0].id, |
| | | image: T2I_PROVIDERS.flatMap(p => p.models).find(m => m.default)?.id || T2I_PROVIDERS[0].models[0].id, |
| | | editImage: I2I_PROVIDERS.flatMap(p => p.models).find(m => m.default)?.id || I2I_PROVIDERS[0].models[0].id, |
| | | video: VIDEO_PROVIDERS.flatMap(p => p.models).find(m => m.default)?.id || VIDEO_PROVIDERS[0].models[0].id, |
| | | }; |
| | | |
| | | const STANDARD_STYLE_PRESETS = [ |
| | | { |
| | |
| | | ); |
| | | } |
| | | |
| | | function groupApiModels(models: ApiModelOption[], fallback: ProviderGroup[]): ProviderGroup[] { |
| | | if (!models.length) return fallback; |
| | | const providerLabels: Record<string, string> = { |
| | | dashscope: 'DashScope', |
| | | openai: 'OpenAI', |
| | | seedream: 'Seedream', |
| | | seedance: 'Seedance', |
| | | kling: 'Kling', |
| | | }; |
| | | const groups = new Map<string, ProviderGroup>(); |
| | | for (const model of models) { |
| | | if (!groups.has(model.provider)) { |
| | | groups.set(model.provider, { |
| | | provider: model.provider, |
| | | label: providerLabels[model.provider] || model.provider, |
| | | models: [], |
| | | }); |
| | | } |
| | | groups.get(model.provider)!.models.push({ |
| | | id: model.id, |
| | | label: model.label || model.id, |
| | | default: model.api_contract_verified, |
| | | }); |
| | | } |
| | | return Array.from(groups.values()); |
| | | function groupApiModels(models: ApiModelOption[]): ProviderGroup[] { |
| | | return groupModelOptions(models).map(group => ({ |
| | | ...group, |
| | | models: group.models.map(model => { |
| | | const source = models.find(item => item.id === model.id); |
| | | return { ...model, default: Boolean(source?.api_contract_verified) }; |
| | | }), |
| | | })); |
| | | } |
| | | |
| | | function firstModelId(groups: ProviderGroup[], preferred?: string) { |
| | |
| | | const [running, setRunning] = useState(false); |
| | | const [error, setError] = useState(''); |
| | | const [task, setTask] = useState<PipelineTask | null>(null); |
| | | const [imageModelGroups, setImageModelGroups] = useState<ProviderGroup[]>(pipeline === 'digital_human' ? I2I_PROVIDERS : T2I_PROVIDERS); |
| | | const [videoModelGroups, setVideoModelGroups] = useState<ProviderGroup[]>(VIDEO_PROVIDERS); |
| | | const [imageModelGroups, setImageModelGroups] = useState<ProviderGroup[]>([]); |
| | | const [videoModelGroups, setVideoModelGroups] = useState<ProviderGroup[]>([]); |
| | | const [llmModelGroups, setLlmModelGroups] = useState<ProviderGroup[]>([]); |
| | | |
| | | const [text, setText] = useState(''); |
| | | const [standardMode, setStandardMode] = useState<'inspiration' | 'copy'>('inspiration'); |
| | |
| | | const [goodsTitle, setGoodsTitle] = useState(''); |
| | | const [goodsText, setGoodsText] = useState(''); |
| | | |
| | | const [llmModel, setLlmModel] = useState(DEFAULTS.llm); |
| | | const [imageModel, setImageModel] = useState(DEFAULTS.image); |
| | | const [videoModel, setVideoModel] = useState( |
| | | pipeline === 'action_transfer' ? 'wan2.7-videoedit' : pipeline === 'digital_human' ? 'wan2.7-r2v' : DEFAULTS.video |
| | | ); |
| | | const [llmModel, setLlmModel] = useState(''); |
| | | const [imageModel, setImageModel] = useState(''); |
| | | const [videoModel, setVideoModel] = useState(''); |
| | | const [ratio, setRatio] = useState('9:16'); |
| | | const [videoResolution, setVideoResolution] = useState('720P'); |
| | | const [duration, setDuration] = useState(5); |
| | |
| | | |
| | | fetchApiModels({ mediaType: 'image', ability: imageAbility, verifiedOnly: true }) |
| | | .then(models => { |
| | | const groups = groupApiModels(models, pipeline === 'digital_human' ? I2I_PROVIDERS : T2I_PROVIDERS); |
| | | const groups = groupApiModels(models); |
| | | setImageModelGroups(groups); |
| | | setImageModel(current => firstModelId(groups, current || DEFAULTS.image)); |
| | | setImageModel(current => firstModelId(groups, current)); |
| | | }) |
| | | .catch(() => {}); |
| | | |
| | | if (pipeline !== 'standard' || standardVideoMode === 'dynamic_video' || (templateMode && templateMediaKind === 'video')) { |
| | | fetchApiModels({ mediaType: 'video', ability: videoAbility, verifiedOnly: true }) |
| | | .then(models => { |
| | | const groups = groupApiModels(models, VIDEO_PROVIDERS); |
| | | const groups = groupApiModels(models); |
| | | setVideoModelGroups(groups); |
| | | const preferred = pipeline === 'standard' |
| | | ? DEFAULTS.video |
| | | : pipeline === 'action_transfer' |
| | | ? 'wan2.7-videoedit' |
| | | : 'wan2.7-r2v'; |
| | | setVideoModel(current => firstModelId(groups, current || preferred)); |
| | | setVideoModel(current => firstModelId(groups, current)); |
| | | }) |
| | | .catch(() => {}); |
| | | } |
| | | }, [pipeline, standardVideoMode, templateMode, templateMediaKind]); |
| | | |
| | | useEffect(() => { |
| | | let cancelled = false; |
| | | fetchModelGroupsByType('llm') |
| | | .then(groups => { |
| | | if (cancelled) return; |
| | | setLlmModelGroups(groups); |
| | | setLlmModel(current => firstModelId(groups, current)); |
| | | }) |
| | | .catch(() => {}); |
| | | return () => { cancelled = true; }; |
| | | }, []); |
| | | |
| | | useEffect(() => { |
| | | if (pipeline !== 'standard') return; |
| | |
| | | <div className="mt-4 p-4 bg-gray-50 rounded-xl space-y-3"> |
| | | <div className="grid grid-cols-1 md:grid-cols-2 gap-3"> |
| | | {(pipeline === 'digital_human' || pipeline === 'standard') && ( |
| | | <SelectField label="LLM 模型" value={llmModel} onChange={setLlmModel} groups={LLM_PROVIDERS} /> |
| | | <SelectField label="LLM 模型" value={llmModel} onChange={setLlmModel} groups={llmModelGroups} /> |
| | | )} |
| | | {pipeline !== 'action_transfer' && ( |
| | | <SelectField label="图片模型" value={imageModel} onChange={setImageModel} groups={imageModelGroups} /> |
| | |
| | | models: ModelOption[]; |
| | | } |
| | | |
| | | /* ─── LLM 模型(按 Provider 分组) ─── */ |
| | | export const LLM_PROVIDERS: ProviderGroup[] = [ |
| | | { |
| | | provider: 'qwen', |
| | | label: 'Qwen (DashScope)', |
| | | models: [ |
| | | { id: 'qwen3.6-max-preview', label: 'qwen3.6-max-preview' }, |
| | | { id: 'qwen3-max', label: 'qwen3-max' }, |
| | | { id: 'deepseek-v3.2', label: 'deepseek-v3.2 (DashScope)', default: true }, |
| | | { id: 'kimi-k2.6', label: 'kimi-k2.6 (DashScope)' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'deepseek', |
| | | label: 'DeepSeek', |
| | | models: [ |
| | | { id: 'deepseek-chat', label: 'deepseek-chat' }, |
| | | { id: 'deepseek-reasoner', label: 'deepseek-reasoner' }, |
| | | { id: 'deepseek-v4-flash', label: 'deepseek-v4-flash' }, |
| | | { id: 'deepseek-v4-pro', label: 'deepseek-v4-pro' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'openai', |
| | | label: 'OpenAI', |
| | | models: [ |
| | | { id: 'gpt-4o', label: 'gpt-4o' }, |
| | | { id: 'gpt-5', label: 'gpt-5' }, |
| | | { id: 'gpt-5.4', label: 'gpt-5.4' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'gemini', |
| | | label: 'Gemini', |
| | | models: [ |
| | | { id: 'gemini-2.5-flash', label: 'gemini-2.5-flash' }, |
| | | { id: 'gemini-2.0-flash', label: 'gemini-2.0-flash' }, |
| | | ], |
| | | }, |
| | | ]; |
| | | |
| | | /** 扁平 LLM 列表(向后兼容) */ |
| | | export const LLM_MODELS: ModelOption[] = LLM_PROVIDERS.flatMap(p => p.models); |
| | | |
| | | /* ─── 文生图 ─── */ |
| | | export const T2I_PROVIDERS: ProviderGroup[] = [ |
| | | { |
| | | provider: 'dashscope', |
| | | label: 'DashScope', |
| | | models: [ |
| | | { id: 'wan2.7-image', label: 'wan2.7-image', default: true }, |
| | | { id: 'wan2.7-image-pro', label: 'wan2.7-image-pro' }, |
| | | { id: 'wan2.6-t2i', label: 'wan2.6-t2i' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'seedream', |
| | | label: 'Seedream', |
| | | models: [ |
| | | { id: 'doubao-seedream-5-0-260128', label: 'Seedream 5.0' }, |
| | | { id: 'doubao-seedream-4-5-251128', label: 'Seedream 4.5' }, |
| | | { id: 'doubao-seedream-4-0-250828', label: 'Seedream 4.0' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'openai', |
| | | label: 'OpenAI', |
| | | models: [ |
| | | { id: 'gpt-image-2', label: 'gpt-image-2' }, |
| | | ], |
| | | }, |
| | | ]; |
| | | |
| | | export const T2I_MODELS: ModelOption[] = T2I_PROVIDERS.flatMap(p => p.models); |
| | | |
| | | /* ─── 图生图 ─── */ |
| | | export const I2I_PROVIDERS: ProviderGroup[] = [ |
| | | { |
| | | provider: 'dashscope', |
| | | label: 'DashScope', |
| | | models: [ |
| | | { id: 'wan2.7-image', label: 'wan2.7-image', default: true }, |
| | | { id: 'wan2.7-image-pro', label: 'wan2.7-image-pro' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'seedream', |
| | | label: 'Seedream', |
| | | models: [ |
| | | { id: 'doubao-seedream-5-0-260128', label: 'Seedream 5.0' }, |
| | | { id: 'doubao-seedream-4-5-251128', label: 'Seedream 4.5' }, |
| | | { id: 'doubao-seedream-4-0-250828', label: 'Seedream 4.0' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'openai', |
| | | label: 'OpenAI', |
| | | models: [ |
| | | { id: 'gpt-image-2', label: 'gpt-image-2' }, |
| | | ], |
| | | }, |
| | | ]; |
| | | |
| | | export const I2I_MODELS: ModelOption[] = I2I_PROVIDERS.flatMap(p => p.models); |
| | | |
| | | /* ─── 视频 ─── */ |
| | | export const VIDEO_PROVIDERS: ProviderGroup[] = [ |
| | | { |
| | | provider: 'dashscope', |
| | | label: 'DashScope', |
| | | models: [ |
| | | { id: 'wan2.7-i2v', label: 'wan2.7-i2v', default: true }, |
| | | { id: 'wan2.7-videoedit', label: 'wan2.7-videoedit' }, |
| | | { id: 'wan2.7-r2v', label: 'wan2.7-r2v' }, |
| | | { id: 'wan2.6-i2v-flash', label: 'wan2.6-i2v-flash' }, |
| | | { id: 'happyhorse-1.0-i2v', label: 'happyhorse-1.0-i2v' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'seedance', |
| | | label: 'Seedance', |
| | | models: [ |
| | | { id: 'doubao-seedance-2-0-260128', label: 'Seedance 2.0' }, |
| | | { id: 'doubao-seedance-2-0-fast-260128', label: 'Seedance 2.0 Fast' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'kling', |
| | | label: 'Kling', |
| | | models: [ |
| | | { id: 'kling-v3', label: 'kling-v3' }, |
| | | { id: 'kling-v2-6', label: 'kling-v2-6' }, |
| | | { id: 'kling-v2-5-turbo', label: 'kling-v2-5-turbo' }, |
| | | ], |
| | | }, |
| | | ]; |
| | | |
| | | export const VIDEO_MODELS: ModelOption[] = VIDEO_PROVIDERS.flatMap(p => p.models); |
| | | |
| | | /* ─── VLM 评估模型 ─── */ |
| | | export const VLM_PROVIDERS: ProviderGroup[] = [ |
| | | { |
| | | provider: 'qwen', |
| | | label: 'Qwen/Kimi (DashScope)', |
| | | models: [ |
| | | { id: 'qwen3.6-plus', label: 'qwen3.6-plus', default: true }, |
| | | { id: 'qwen3.6-flash', label: 'qwen3.6-flash' }, |
| | | { id: 'kimi-k2.6', label: 'kimi-k2.6' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'openai', |
| | | label: 'OpenAI', |
| | | models: [ |
| | | { id: 'gpt-5.4', label: 'gpt-5.4' }, |
| | | ], |
| | | }, |
| | | { |
| | | provider: 'gemini', |
| | | label: 'Gemini (Google)', |
| | | models: [ |
| | | { id: 'gemini-2.5-flash-image', label: 'gemini-2.5-flash-image' }, |
| | | { id: 'gemini-2.0-flash', label: 'gemini-2.0-flash' }, |
| | | ], |
| | | }, |
| | | ]; |
| | | |
| | | export const VLM_MODELS: ModelOption[] = VLM_PROVIDERS.flatMap(p => p.models); |
| | | |
| | | export const STYLES = [ |
| | | { id: 'comic-book', label: 'Comic Book / 漫画' }, |
| | | { id: 'anime', label: 'Anime / 动漫' }, |
| New file |
| | |
| | | import type { ProviderGroup } from '@/config/models'; |
| | | import { fetchApiModels } from '@/lib/workflowApi'; |
| | | |
| | | const PROVIDER_LABELS: Record<string, string> = { |
| | | dashscope: 'DashScope', |
| | | ark: 'ARK (Volcengine)', |
| | | deepseek: 'DeepSeek', |
| | | openai: 'OpenAI', |
| | | gemini: 'Gemini', |
| | | kling: 'Kling', |
| | | }; |
| | | |
| | | export function groupModelOptions( |
| | | models: Array<{ id: string; label?: string; provider?: string }>, |
| | | ): ProviderGroup[] { |
| | | const groups = new Map<string, ProviderGroup>(); |
| | | for (const model of models) { |
| | | const provider = model.provider || 'unknown'; |
| | | if (!groups.has(provider)) { |
| | | groups.set(provider, { |
| | | provider, |
| | | label: PROVIDER_LABELS[provider] || provider, |
| | | models: [], |
| | | }); |
| | | } |
| | | groups.get(provider)!.models.push({ |
| | | id: model.id, |
| | | label: model.label || model.id, |
| | | }); |
| | | } |
| | | return Array.from(groups.values()); |
| | | } |
| | | |
| | | export async function fetchModelGroupsByType( |
| | | modelType: 'llm' | 'vlm' | 't2i' | 'i2i' | 'video', |
| | | ): Promise<ProviderGroup[]> { |
| | | const models = await fetchApiModels({ modelType }); |
| | | return groupModelOptions(models); |
| | | } |
| | |
| | | id: string; |
| | | label: string; |
| | | provider: string; |
| | | media_type: 'image' | 'video'; |
| | | family?: string; |
| | | media_type?: 'image' | 'video'; |
| | | model_type?: 'llm' | 'vlm' | 't2i' | 'i2i' | 'video'; |
| | | type?: string[]; |
| | | ability_type?: string; |
| | | ability_types?: string[]; |
| | | adapter_ability_types?: string[]; |
| | |
| | | |
| | | export async function fetchApiModels(params: { |
| | | mediaType?: 'image' | 'video'; |
| | | modelType?: 'llm' | 'vlm' | 't2i' | 'i2i' | 'video'; |
| | | ability?: string; |
| | | verifiedOnly?: boolean; |
| | | } = {}): Promise<ApiModelOption[]> { |
| | | const search = new URLSearchParams(); |
| | | if (params.mediaType) search.set('media_type', params.mediaType); |
| | | if (params.modelType) search.set('model_type', params.modelType); |
| | | if (params.ability) search.set('ability', params.ability); |
| | | if (params.verifiedOnly) search.set('verified_only', 'true'); |
| | | const resp = await fetch(`/api/models${search.toString() ? `?${search.toString()}` : ''}`); |