integrate official Tripo async models

This commit is contained in:
wlx committed 2026-09-27 16:45:36 +08:00
1 parent a022162382
commit 962eef26e5
11 files changed
+160 -20

No files matched your search

@@ -0,0 +1,109 @@
-- Tripo's current official international API is openapi.tripo3d.com.
-- The API key is intentionally supplied outside migrations through the
-- encrypted provider credential or TRIPO_API_KEY in the deployment secret.
UPDATE model_providers
SET base_url = 'https://openapi.tripo3d.com',
name = 'Tripo 官方',
description = 'Tripo 官方异步 3D 生成 API。',
updated_at = now()
WHERE id = 'provider-vast'
AND code = 'vast-tripo'
AND deleted_at IS NULL;
DO $$
DECLARE
item record;
provider_id_value varchar(64);
provider_status_value varchar(16);
logical_id_value varchar(64);
route_status_value varchar(16);
tripo_price jsonb := jsonb_build_object(
'price', 1.44,
'unit', 'CNY / task',
'upstreamCredits', 20,
'exchangeRate', 7.2,
'priceSource', 'Tripo 官方 API 定价',
'pricingNote', 'H 系列文生 3D,标准贴图;未加平台服务费'
);
BEGIN
SELECT id, status INTO provider_id_value, provider_status_value
FROM model_providers
WHERE id = 'provider-vast' AND code = 'vast-tripo' AND deleted_at IS NULL;
IF provider_id_value IS NULL THEN
RETURN;
END IF;
FOR item IN
SELECT * FROM (VALUES
('tripo-v3', 'Tripo H v3.1 文生 3D', 'v3.1-20260211'),
('tripo-h-v3-0', 'Tripo H v3.0 文生 3D', 'v3.0-20250812'),
('tripo-h-v2-5', 'Tripo H v2.5 文生 3D', 'v2.5-20250123')
) AS models(model_key_value, public_name_value, upstream_model_value)
LOOP
INSERT INTO model_definitions (
id, model_key, public_name, vendor_name, model_type, call_mode,
description, input_types, output_types, status
)
SELECT 'tripo-def-' || replace(item.model_key_value, '.', '-') || '-' || substr(md5(item.model_key_value), 1, 8),
item.model_key_value, item.public_name_value, 'Tripo', '3d', 'async',
'Tripo 官方 H 系列异步文生 3D 模型。',
'["text"]'::jsonb, '["model", "thumbnail"]'::jsonb, 'active'
WHERE NOT EXISTS (
SELECT 1 FROM model_definitions d
WHERE d.model_key = item.model_key_value AND d.deleted_at IS NULL
);
SELECT d.id INTO logical_id_value
FROM model_definitions d
WHERE d.model_key = item.model_key_value AND d.deleted_at IS NULL
ORDER BY d.created_at
LIMIT 1;
route_status_value := CASE WHEN provider_status_value = 'active' THEN 'active' ELSE 'disabled' END;
INSERT INTO model_catalog (
id, provider_id, model_key, source_label, public_name, upstream_model,
model_type, call_mode, description, input_types, output_types,
capabilities, pricing, priority, max_concurrency, logical_model_id, status
)
SELECT 'tripo-route-' || replace(item.model_key_value, '.', '-') || '-' || substr(md5(item.upstream_model_value), 1, 8),
provider_id_value, item.model_key_value, 'Tripo 官方', item.public_name_value,
item.upstream_model_value, '3d', 'async',
'Tripo 官方 H 系列异步文生 3D 模型。',
'["text"]'::jsonb, '["model", "thumbnail"]'::jsonb,
'{"taskPolling":true,"formats":["glb","obj","fbx"]}'::jsonb,
tripo_price, 100, 1, logical_id_value, route_status_value
WHERE NOT EXISTS (
SELECT 1 FROM model_catalog m
WHERE m.logical_model_id = logical_id_value
AND m.provider_id = provider_id_value
AND m.upstream_model = item.upstream_model_value
AND m.deleted_at IS NULL
);
UPDATE model_catalog
SET source_label = 'Tripo 官方',
public_name = item.public_name_value,
description = 'Tripo 官方 H 系列异步文生 3D 模型。',
input_types = '["text"]'::jsonb,
output_types = '["model", "thumbnail"]'::jsonb,
capabilities = '{"taskPolling":true,"formats":["glb","obj","fbx"]}'::jsonb,
pricing = tripo_price,
priority = 100,
max_concurrency = 1,
status = route_status_value,
updated_at = now()
WHERE provider_id = provider_id_value
AND upstream_model = item.upstream_model_value
AND deleted_at IS NULL;
END LOOP;
END $$;
-- Keep the existing logical model's manufacturer and public metadata aligned
-- even when an earlier deployment created it before V16.
UPDATE model_definitions
SET vendor_name = 'Tripo',
public_name = CASE WHEN model_key = 'tripo-v3' THEN 'Tripo H v3.1 文生 3D' ELSE public_name END,
updated_at = now()
WHERE model_key IN ('tripo-v3', 'tripo-h-v3-0', 'tripo-h-v2-5')
AND deleted_at IS NULL;