fix: uapi response 全部带 usage 计费字段,pricing_data 匹配 usage

This commit is contained in:
yumoqing 2026-07-05 10:45:50 +08:00
parent d7f232d46f
commit fa2be8e9d1

View File

@ -2,6 +2,7 @@
-- FOMS / KTV产线服务 → Sage (uapi + llmage + pricing) 注册SQL
-- 供应商: 开元云(北京)科技有限公司
-- 服务器: opencomputing.net GPU集群
-- 所有 uapi response 均含 usage 字段用于自动计费
-- ============================================================
SET @provider_id = 'kaiyuanyun';
@ -11,7 +12,7 @@ SET @owner_org = 'foms_org_001';
-- 1. llmcatelog — 模型类目 (新增KTV专用类目)
-- ============================================================
INSERT IGNORE INTO llmcatelog (id, name, description) VALUES
('ktv_pipeline', 'KTV产线', 'KTV视频制作全流程:校准→合成→评估'),
('ktv_pipeline', 'KTV产线', 'KTV视频制作全流程'),
('video_eval', '视频评估', 'AI视频质量评估打分'),
('super_resolution', '超分辨率', '图像/视频超分辨率增强'),
('asr', '语音识别', '自动语音识别转文字'),
@ -24,14 +25,13 @@ INSERT IGNORE INTO llmcatelog (id, name, description) VALUES
('voice_convert', '声音转换', 'RVC声音克隆/转换');
-- ============================================================
-- 2. llmprovider — 模型供应商
-- 2. llmprovider
-- ============================================================
INSERT IGNORE INTO llmprovider (id, name) VALUES
('kaiyuanyun', '开元云(北京)科技有限公司');
-- ============================================================
-- 3. upapp — 上游应用 (每个服务一个upapp)
-- baseurl指向GPU服务器 opencomputing.net
-- 3. upapp
-- ============================================================
INSERT IGNORE INTO upapp (id, name, baseurl, ownerid, auth_apiname) VALUES
('ktv-media-server', 'KTV媒体服务器', 'http://opencomputing.net:9080', @owner_org, ''),
@ -47,7 +47,7 @@ INSERT IGNORE INTO upapp (id, name, baseurl, ownerid, auth_apiname) VALUES
('ktv-rvc', 'KTV声音转换', 'http://opencomputing.net:9085', @owner_org, '');
-- ============================================================
-- 4. llm — 模型定义
-- 4. llm
-- ============================================================
INSERT IGNORE INTO llm (id, name, model, providerid, ownerid, upappid, status) VALUES
('llm_ktv_pipeline', 'KTV产线流水线', 'ktv-media-server', @provider_id, @owner_org, 'ktv-media-server', 'published'),
@ -63,73 +63,72 @@ INSERT IGNORE INTO llm (id, name, model, providerid, ownerid, upappid, status) V
('llm_rvc', 'KTV声音克隆转换', 'ktv-rvc', @provider_id, @owner_org, 'ktv-rvc', 'published');
-- ============================================================
-- 5. uapi — API端点定义
-- name格式: {service}-{action}
-- 5. uapi — API端点 (所有 response 含 usage 计费字段)
-- ============================================================
-- 5.1 media-server APIs (12 endpoints)
-- 5.1 media-server (12 endpoints)
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('media-pipeline-submit', 'ktv-media-server', '/api/pipeline_submit/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"task_type":"{{task_type}}","params":{{json.dumps(params)}}}', '{"status":"ok","task_id":"{{task_id}}"}', NULL),
('media-pipeline-status', 'ktv-media-server', '/api/pipeline_status/index.dspy', 'GET', NULL, NULL, '{"status":"{{status}}","progress":{{progress}}}', NULL),
('media-status', 'ktv-media-server', '/api/status/index.dspy', 'GET', NULL, NULL, '{"status":"ok","gpu_available":{{gpu_available}}}', NULL),
('media-task', 'ktv-media-server', '/api/task/index.dspy', 'GET', NULL, NULL, '{"task_id":"{{task_id}}","status":"{{status}}"}', NULL),
('media-submit', 'ktv-media-server', '/api/submit/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"video_url":"{{video_url}}","audio_url":"{{audio_url}}"}', '{"status":"ok"}', NULL),
('media-ktv', 'ktv-media-server', '/api/ktv/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"song_name":"{{song_name}}","lyrics":"{{lyrics}}"}', '{"status":"ok","video_url":"{{video_url}}"}', NULL),
('media-demucs', 'ktv-media-server', '/api/demucs/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}"}', '{"status":"ok","vocals_url":"{{vocals_url}}","accompaniment_url":"{{accompaniment_url}}"}', NULL),
('media-subtitle', 'ktv-media-server', '/api/subtitle/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"lyrics":"{{lyrics}}","audio_url":"{{audio_url}}"}', '{"status":"ok","subtitle_url":"{{subtitle_url}}"}', NULL),
('media-calibrate', 'ktv-media-server', '/api/calibrate/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"video_url":"{{video_url}}","audio_url":"{{audio_url}}"}', '{"status":"ok","offset":{{offset}}}', NULL),
('media-lyric-calibrate', 'ktv-media-server', '/api/lyric_calibrate/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"lyrics":"{{lyrics}}","audio_url":"{{audio_url}}"}', '{"status":"ok","calibrated_lyrics":"{{calibrated_lyrics}}"}', NULL),
('media-merge', 'ktv-media-server', '/api/merge/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"video_url":"{{video_url}}","audio_url":"{{audio_url}}"}', '{"status":"ok","output_url":"{{output_url}}"}', NULL),
('media-gpu-lock', 'ktv-media-server', '/api/gpu_lock/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"gpu_id":{{gpu_id}},"duration":{{duration}}}', '{"status":"ok","locked":true}', NULL);
('media-pipeline-submit', 'ktv-media-server', '/api/pipeline_submit/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"task_type":"{{task_type}}","params":{{json.dumps(params)}}}', '{"status":"ok","task_id":"{{task_id}}","usage":{"call_count":1}}', NULL),
('media-pipeline-status', 'ktv-media-server', '/api/pipeline_status/index.dspy', 'GET', NULL, NULL, '{"status":"{{status}}","progress":{{progress}},"usage":{"call_count":1}}', NULL),
('media-status', 'ktv-media-server', '/api/status/index.dspy', 'GET', NULL, NULL, '{"status":"ok","gpu_available":{{gpu_available}},"usage":{"call_count":1}}', NULL),
('media-task', 'ktv-media-server', '/api/task/index.dspy', 'GET', NULL, NULL, '{"task_id":"{{task_id}}","status":"{{status}}","usage":{"call_count":1}}', NULL),
('media-submit', 'ktv-media-server', '/api/submit/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"video_url":"{{video_url}}","audio_url":"{{audio_url}}"}', '{"status":"ok","usage":{"call_count":1}}', NULL),
('media-ktv', 'ktv-media-server', '/api/ktv/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"song_name":"{{song_name}}","lyrics":"{{lyrics}}"}', '{"status":"ok","video_url":"{{video_url}}","usage":{"output_seconds":{{output_seconds}}}}', NULL),
('media-demucs', 'ktv-media-server', '/api/demucs/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}"}', '{"status":"ok","vocals_url":"{{vocals_url}}","accompaniment_url":"{{accompaniment_url}}","usage":{"audio_seconds":{{audio_seconds}}}}', NULL),
('media-subtitle', 'ktv-media-server', '/api/subtitle/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"lyrics":"{{lyrics}}","audio_url":"{{audio_url}}"}', '{"status":"ok","subtitle_url":"{{subtitle_url}}","usage":{"audio_seconds":{{audio_seconds}}}}', NULL),
('media-calibrate', 'ktv-media-server', '/api/calibrate/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"video_url":"{{video_url}}","audio_url":"{{audio_url}}"}', '{"status":"ok","offset":{{offset}},"usage":{"video_seconds":{{video_seconds}}}}', NULL),
('media-lyric-calibrate', 'ktv-media-server', '/api/lyric_calibrate/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"lyrics":"{{lyrics}}","audio_url":"{{audio_url}}"}', '{"status":"ok","calibrated_lyrics":"{{calibrated_lyrics}}","usage":{"audio_seconds":{{audio_seconds}}}}', NULL),
('media-merge', 'ktv-media-server', '/api/merge/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"video_url":"{{video_url}}","audio_url":"{{audio_url}}"}', '{"status":"ok","output_url":"{{output_url}}","usage":{"output_seconds":{{output_seconds}}}}', NULL),
('media-gpu-lock', 'ktv-media-server', '/api/gpu_lock/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"gpu_id":{{gpu_id}},"duration":{{duration}}}', '{"status":"ok","locked":true,"usage":{"call_count":1}}', NULL);
-- 5.2 video-eval API
-- 5.2 video-eval
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('video-eval-evaluate', 'ktv-video-eval', '/api/eval/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"video_url":"{{video_url}}"}', '{"status":"ok","score":{{score}},"details":{{json.dumps(details)}}}', NULL);
('video-eval-evaluate', 'ktv-video-eval', '/api/eval/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"video_url":"{{video_url}}"}', '{"status":"ok","score":{{score}},"details":{{json.dumps(details)}},"usage":{"video_seconds":{{video_seconds}}}}', NULL);
-- 5.3 realesrgan API
-- 5.3 realesrgan
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('realesrgan-upscale', 'ktv-realesrgan', '/api/submit/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"image_url":"{{image_url}}","scale":{{scale}}}', '{"status":"ok","output_url":"{{output_url}}"}', NULL),
('realesrgan-status', 'ktv-realesrgan', '/api/status/index.dspy', 'GET', NULL, NULL, '{"status":"{{status}}","gpu_available":{{gpu_available}}}', NULL);
('realesrgan-upscale', 'ktv-realesrgan', '/api/submit/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"image_url":"{{image_url}}","scale":{{scale}}}', '{"status":"ok","output_url":"{{output_url}}","usage":{"image_count":1}}', NULL),
('realesrgan-status', 'ktv-realesrgan', '/api/status/index.dspy', 'GET', NULL, NULL, '{"status":"{{status}}","gpu_available":{{gpu_available}},"usage":{"call_count":1}}', NULL);
-- 5.4 asr API
-- 5.4 asr
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('asr-transcribe', 'ktv-asr', '/api/transcribe/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}","language":"{{language}}"}', '{"status":"ok","text":"{{text}}","segments":{{json.dumps(segments)}}}', NULL);
('asr-transcribe', 'ktv-asr', '/api/transcribe/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}","language":"{{language}}"}', '{"status":"ok","text":"{{text}}","segments":{{json.dumps(segments)}},"usage":{"audio_seconds":{{audio_seconds}}}}', NULL);
-- 5.5 face API
-- 5.5 face
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('face-detect', 'ktv-face', '/api/detect', 'POST', '{"Content-Type":"application/json"}', '{"image_url":"{{image_url}}"}', '{"status":"ok","faces":{{json.dumps(faces)}}}', NULL),
('face-recognize', 'ktv-face', '/api/recognize', 'POST', '{"Content-Type":"application/json"}', '{"image_url":"{{image_url}}","face_id":"{{face_id}}"}', '{"status":"ok","identity":"{{identity}}","confidence":{{confidence}}}', NULL),
('face-compare', 'ktv-face', '/api/compare', 'POST', '{"Content-Type":"application/json"}', '{"image_url1":"{{url1}}","image_url2":"{{url2}}"}', '{"status":"ok","similarity":{{similarity}}}', NULL);
('face-detect', 'ktv-face', '/api/detect', 'POST', '{"Content-Type":"application/json"}', '{"image_url":"{{image_url}}"}', '{"status":"ok","faces":{{json.dumps(faces)}},"usage":{"detect_count":1}}', NULL),
('face-recognize', 'ktv-face', '/api/recognize', 'POST', '{"Content-Type":"application/json"}', '{"image_url":"{{image_url}}","face_id":"{{face_id}}"}', '{"status":"ok","identity":"{{identity}}","confidence":{{confidence}},"usage":{"detect_count":1}}', NULL),
('face-compare', 'ktv-face', '/api/compare', 'POST', '{"Content-Type":"application/json"}', '{"image_url1":"{{url1}}","image_url2":"{{url2}}"}', '{"status":"ok","similarity":{{similarity}},"usage":{"detect_count":1}}', NULL);
-- 5.6 graph API
-- 5.6 graph
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('graph-neighbors', 'ktv-graph', '/api/graph/neighbors', 'GET', NULL, NULL, '{"status":"ok","nodes":{{json.dumps(nodes)}}}', NULL),
('graph-add-node', 'ktv-graph', '/api/graph/add_node', 'POST', '{"Content-Type":"application/json"}', '{"node_id":"{{node_id}}","attrs":{{json.dumps(attrs)}}}', '{"status":"ok"}', NULL),
('graph-add-edge', 'ktv-graph', '/api/graph/add_edge', 'POST', '{"Content-Type":"application/json"}', '{"from":"{{from}}","to":"{{to}}","label":"{{label}}"}', '{"status":"ok"}', NULL);
('graph-neighbors', 'ktv-graph', '/api/graph/neighbors', 'GET', NULL, NULL, '{"status":"ok","nodes":{{json.dumps(nodes)}},"usage":{"query_count":1}}', NULL),
('graph-add-node', 'ktv-graph', '/api/graph/add_node', 'POST', '{"Content-Type":"application/json"}', '{"node_id":"{{node_id}}","attrs":{{json.dumps(attrs)}}}', '{"status":"ok","usage":{"write_count":1}}', NULL),
('graph-add-edge', 'ktv-graph', '/api/graph/add_edge', 'POST', '{"Content-Type":"application/json"}', '{"from":"{{from}}","to":"{{to}}","label":"{{label}}"}', '{"status":"ok","usage":{"write_count":1}}', NULL);
-- 5.7 ner API
-- 5.7 ner
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('ner-extract', 'ktv-ner', '/api/extract', 'POST', '{"Content-Type":"application/json"}', '{"text":"{{text}}"}', '{"status":"ok","entities":{{json.dumps(entities)}}}', NULL);
('ner-extract', 'ktv-ner', '/api/extract', 'POST', '{"Content-Type":"application/json"}', '{"text":"{{text}}"}', '{"status":"ok","entities":{{json.dumps(entities)}},"usage":{"char_count":{{char_count}}}}', NULL);
-- 5.8 songrate API
-- 5.8 songrate
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('songrate-evaluate', 'ktv-songrate', '/api/evaluate', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}","scene":"{{scene}}"}', '{"status":"ok","score":{{score}},"details":{{json.dumps(details)}}}', NULL);
('songrate-evaluate', 'ktv-songrate', '/api/evaluate', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}","scene":"{{scene}}"}', '{"status":"ok","score":{{score}},"details":{{json.dumps(details)}},"usage":{"audio_seconds":{{audio_seconds}}}}', NULL);
-- 5.9 ktv-synth API
-- 5.9 ktv-synth
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('synth-generate', 'ktv-synth', '/api/generate/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"lyrics":"{{lyrics}}","style":"{{style}}","reference_audio":"{{reference_audio}}"}', '{"status":"ok","task_id":"{{task_id}}"}', NULL),
('synth-status', 'ktv-synth', '/api/status/index.dspy', 'GET', NULL, NULL, '{"status":"{{status}}","audio_url":"{{audio_url}}"}', NULL);
('synth-generate', 'ktv-synth', '/api/generate/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"lyrics":"{{lyrics}}","style":"{{style}}","reference_audio":"{{reference_audio}}"}', '{"status":"ok","task_id":"{{task_id}}","usage":{"output_seconds":{{output_seconds}}}}', NULL),
('synth-status', 'ktv-synth', '/api/status/index.dspy', 'GET', NULL, NULL, '{"status":"{{status}}","audio_url":"{{audio_url}}","usage":{"call_count":1}}', NULL);
-- 5.10 demucs API
-- 5.10 demucs
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('demucs-separate', 'ktv-demucs', '/api/separate/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}"}', '{"status":"ok","vocals_url":"{{vocals_url}}","accompaniment_url":"{{accompaniment_url}}"}', NULL);
('demucs-separate', 'ktv-demucs', '/api/separate/index.dspy', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}"}', '{"status":"ok","vocals_url":"{{vocals_url}}","accompaniment_url":"{{accompaniment_url}}","usage":{"audio_seconds":{{audio_seconds}}}}', NULL);
-- 5.11 rvc API
-- 5.11 rvc
INSERT IGNORE INTO uapi (name, upappid, path, httpmethod, headers, data, response, ioid) VALUES
('rvc-convert', 'ktv-rvc', '/api/convert', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}","voice_model":"{{voice_model}}"}', '{"status":"ok","output_url":"{{output_url}}"}', NULL);
('rvc-convert', 'ktv-rvc', '/api/convert', 'POST', '{"Content-Type":"application/json"}', '{"audio_url":"{{audio_url}}","voice_model":"{{voice_model}}"}', '{"status":"ok","output_url":"{{output_url}}","usage":{"audio_seconds":{{audio_seconds}}}}', NULL);
-- ============================================================
-- 6. upappkey — API密钥 (服务间内部通信,使用统一密钥)
-- 6. upappkey
-- ============================================================
INSERT IGNORE INTO upappkey (id, upappid, apikey, secretkey) VALUES
('key_ktv_media', 'ktv-media-server', 'ktv-media-key-001', ''),
@ -145,77 +144,313 @@ INSERT IGNORE INTO upappkey (id, upappid, apikey, secretkey) VALUES
('key_ktv_rvc', 'ktv-rvc', 'ktv-rvc-key-001', '');
-- ============================================================
-- 7. llm_api_map — 模型能力映射 (每个模型绑定一个默认类目+API)
-- 7. llm_api_map
-- ============================================================
INSERT IGNORE INTO llm_api_map (id, llmid, llmcatelogid, apiname, isdefaultcatelog) VALUES
-- media-server: 默认KTV产线通用提交API
('map_ktv_pipeline', 'llm_ktv_pipeline', 'ktv_pipeline', 'media-pipeline-submit', '1'),
-- video-eval
('map_video_eval', 'llm_video_eval', 'video_eval', 'video-eval-evaluate', '1'),
-- realesrgan
('map_realesrgan', 'llm_realesrgan', 'super_resolution', 'realesrgan-upscale', '1'),
-- asr
('map_asr', 'llm_asr', 'asr', 'asr-transcribe', '1'),
-- face (多能力: detect默认)
('map_face_detect', 'llm_face', 'face_detect', 'face-detect', '1'),
('map_face_recognize','llm_face', 'face_detect', 'face-recognize', '0'),
-- graph
('map_graph', 'llm_graph', 'graph_process','graph-neighbors', '1'),
-- ner
('map_ner', 'llm_ner', 'ner', 'ner-extract', '1'),
-- songrate
('map_songrate', 'llm_songrate', 'song_eval', 'songrate-evaluate', '1'),
-- ktv-synth
('map_synth', 'llm_synth', 'music_gen', 'synth-generate', '1'),
-- demucs
('map_demucs', 'llm_demucs', 'audio_separate','demucs-separate', '1'),
-- rvc
('map_rvc', 'llm_rvc', 'voice_convert', 'rvc-convert', '1');
-- ============================================================
-- 8. pricing_program — 计价项目
-- 8. pricing_program
-- ============================================================
INSERT IGNORE INTO pricing_program (id, name, ownerid, providerid, pricing_belong, discount, description) VALUES
('pp_ktv_pipeline', 'KTV产线流水线', @owner_org, @provider_id, 'provider', 1.0, '次计费,含校准+合成+评估全流程'),
('pp_ktv_pipeline', 'KTV产线流水线', @owner_org, @provider_id, 'provider', 1.0, '调用次数+产出时长'),
('pp_video_eval', 'KTV视频评估', @owner_org, @provider_id, 'provider', 1.0, '按评估视频时长计费'),
('pp_realesrgan', 'KTV超分辨率增强', @owner_org, @provider_id, 'provider', 1.0, '按处理像素量计费'),
('pp_asr', 'KTV语音识别ASR', @owner_org, @provider_id, 'provider', 1.0, '按音频时长计费'),
('pp_face', 'KTV人脸识别', @owner_org, @provider_id, 'provider', 1.0, '调用次数计费'),
('pp_graph', 'KTV图谱处理', @owner_org, @provider_id, 'provider', 1.0, '查询/写入次数计费'),
('pp_ner', 'KTV命名实体识别', @owner_org, @provider_id, 'provider', 1.0, '文本长度计费'),
('pp_songrate', 'KTV歌曲评分', @owner_org, @provider_id, 'provider', 1.0, '评估次数计费'),
('pp_synth', 'KTV音乐合成', @owner_org, @provider_id, 'provider', 1.0, '按生成时长计费'),
('pp_demucs', 'KTV人声伴奏分离', @owner_org, @provider_id, 'provider', 1.0, '按音频时长计费'),
('pp_rvc', 'KTV声音克隆转换', @owner_org, @provider_id, 'provider', 1.0, '转换时长计费');
('pp_realesrgan', 'KTV超分辨率增强', @owner_org, @provider_id, 'provider', 1.0, '按处理图片张数计费'),
('pp_asr', 'KTV语音识别ASR', @owner_org, @provider_id, 'provider', 1.0, '按音频秒数计费'),
('pp_face', 'KTV人脸识别', @owner_org, @provider_id, 'provider', 1.0, '检测次数计费'),
('pp_graph', 'KTV图谱处理', @owner_org, @provider_id, 'provider', 1.0, '读写次数计费'),
('pp_ner', 'KTV命名实体识别', @owner_org, @provider_id, 'provider', 1.0, '字符数计费'),
('pp_songrate', 'KTV歌曲评分', @owner_org, @provider_id, 'provider', 1.0, '音频秒数计费'),
('pp_synth', 'KTV音乐合成', @owner_org, @provider_id, 'provider', 1.0, '按生成音频秒数计费'),
('pp_demucs', 'KTV人声伴奏分离', @owner_org, @provider_id, 'provider', 1.0, '按音频秒数计费'),
('pp_rvc', 'KTV声音克隆转换', @owner_org, @provider_id, 'provider', 1.0, '音频秒数计费');
-- ============================================================
-- 9. pricing_program_timing — 定价时段 (当前生效)
-- 9. pricing_program_timing — 定价时段
-- pricing_data 字段与 uapi response 中 usage 字段一一对应
-- ============================================================
-- KTV产线: 按次 + 按产出时长
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_ktv_pipeline', 'pp_ktv_pipeline', '默认定价', 'unit_values:\n 次: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_call\n unit_prices: 2.00\n unit: 次', '2025-01-01'),
('ppt_ktv_pipeline', 'pp_ktv_pipeline', '默认定价',
'unit_values:
: 1
: 1
fields:
call_count:
type: int
role: filter
label:
output_seconds:
type: float
role: factor
label: ()
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: call_count
unit_prices: 2.00
unit:
- price_factors: output_seconds
unit_prices: 0.03
unit: ', '2025-01-01');
('ppt_video_eval', 'pp_video_eval', '默认定价', 'unit_values:\n 秒: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_second\n unit_prices: 0.05\n unit: 秒', '2025-01-01'),
-- video-eval: 按视频秒数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_video_eval', 'pp_video_eval', '默认定价',
'unit_values:
: 1
fields:
video_seconds:
type: float
role: factor
label: ()
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: video_seconds
unit_prices: 0.05
unit: ', '2025-01-01');
('ppt_realesrgan', 'pp_realesrgan', '默认定价', 'unit_values:\n 次: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_call\n unit_prices: 0.50\n unit: 次', '2025-01-01'),
-- realesrgan: 按图片张数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_realesrgan', 'pp_realesrgan', '默认定价',
'unit_values:
: 1
fields:
image_count:
type: int
role: factor
label:
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: image_count
unit_prices: 0.50
unit: ', '2025-01-01');
('ppt_asr', 'pp_asr', '默认定价', 'unit_values:\n 秒: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_second\n unit_prices: 0.01\n unit: 秒', '2025-01-01'),
-- asr: 按音频秒数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_asr', 'pp_asr', '默认定价',
'unit_values:
: 1
fields:
audio_seconds:
type: float
role: factor
label: ()
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: audio_seconds
unit_prices: 0.01
unit: ', '2025-01-01');
('ppt_face', 'pp_face', '默认定价', 'unit_values:\n 次: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_call\n unit_prices: 0.10\n unit: 次', '2025-01-01'),
-- face: 按检测次数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_face', 'pp_face', '默认定价',
'unit_values:
: 1
fields:
detect_count:
type: int
role: factor
label:
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: detect_count
unit_prices: 0.10
unit: ', '2025-01-01');
('ppt_graph', 'pp_graph', '默认定价', 'unit_values:\n 次: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_call\n unit_prices: 0.05\n unit: 次', '2025-01-01'),
-- graph: 按读写次数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_graph', 'pp_graph', '默认定价',
'unit_values:
: 1
fields:
query_count:
type: int
role: filter
label:
write_count:
type: int
role: filter
label:
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: query_count
unit_prices: 0.05
unit:
- price_factors: write_count
unit_prices: 0.10
unit: ', '2025-01-01');
('ppt_ner', 'pp_ner', '默认定价', 'unit_values:\n 千字: 1000\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_kchars\n unit_prices: 0.50\n unit: 千字', '2025-01-01'),
-- ner: 按字符数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_ner', 'pp_ner', '默认定价',
'unit_values:
: 1000
fields:
char_count:
type: int
role: factor
label:
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: char_count
unit_prices: 0.50
unit: ', '2025-01-01');
('ppt_songrate', 'pp_songrate', '默认定价', 'unit_values:\n 次: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_call\n unit_prices: 0.30\n unit: 次', '2025-01-01'),
-- songrate: 按音频秒数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_songrate', 'pp_songrate', '默认定价',
'unit_values:
: 1
fields:
audio_seconds:
type: float
role: factor
label: ()
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: audio_seconds
unit_prices: 0.005
unit: ', '2025-01-01');
('ppt_synth', 'pp_synth', '默认定价', 'unit_values:\n 秒: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_second\n unit_prices: 0.20\n unit: 秒', '2025-01-01'),
-- ktv-synth: 按生成秒数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_synth', 'pp_synth', '默认定价',
'unit_values:
: 1
fields:
output_seconds:
type: float
role: factor
label: ()
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: output_seconds
unit_prices: 0.20
unit: ', '2025-01-01');
('ppt_demucs', 'pp_demucs', '默认定价', 'unit_values:\n 秒: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_second\n unit_prices: 0.02\n unit: 秒', '2025-01-01'),
-- demucs: 按音频秒数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_demucs', 'pp_demucs', '默认定价',
'unit_values:
: 1
fields:
audio_seconds:
type: float
role: factor
label: ()
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: audio_seconds
unit_prices: 0.02
unit: ', '2025-01-01');
('ppt_rvc', 'pp_rvc', '默认定价', 'unit_values:\n 秒: 1\nfields:\n price_factors:\n type: string\n role: factor\n label: 计价因子\n unit_prices:\n type: float\n role: factor\n label: 单位定价(元)\n unit:\n type: string\n role: factor\n label: 计价单位\npricings:\n - price_factors: per_second\n unit_prices: 0.15\n unit: 秒', '2025-01-01');
-- rvc: 按音频秒数
INSERT IGNORE INTO pricing_program_timing (id, ppid, name, pricing_data, enabled_date) VALUES
('ppt_rvc', 'pp_rvc', '默认定价',
'unit_values:
: 1
fields:
audio_seconds:
type: float
role: factor
label: ()
unit_prices:
type: float
role: factor
label: ()
unit:
type: string
role: factor
label:
pricings:
- price_factors: audio_seconds
unit_prices: 0.15
unit: ', '2025-01-01');
-- ============================================================
-- 10. 更新 llm_api_map 绑定 ppid
-- 10. 绑定 ppid → llm_api_map
-- ============================================================
UPDATE llm_api_map SET ppid = 'pp_ktv_pipeline' WHERE llmid = 'llm_ktv_pipeline';
UPDATE llm_api_map SET ppid = 'pp_video_eval' WHERE llmid = 'llm_video_eval';