feat: 豆包3模型接入(doubao-2.1-pro/seedream-5.0/speech-2.0)+llm/uapi/pricing
This commit is contained in:
parent
1802d7b52b
commit
b78c6854c2
83
scripts/doubao_models_migration.sql
Normal file
83
scripts/doubao_models_migration.sql
Normal file
@ -0,0 +1,83 @@
|
||||
-- ============================================================
|
||||
-- 豆包大模型接入: 火山方舟 ARK API
|
||||
--
|
||||
-- 模型:
|
||||
-- 1. doubao-2.1-pro — 豆包大模型2.1 Pro (文本对话)
|
||||
-- 2. doubao-seedream-5.0 — 豆包图像创作模型5.0 (文生图)
|
||||
-- 3. doubao-speech-2.0 — 豆包语音识别模型2.0 (语音识别)
|
||||
--
|
||||
-- Provider: 豆包 (Cy-zrc4DgLIFuA0KMQzlw)
|
||||
-- Upapp: huoshanfangzhou (火山方舟, baseurl: https://ark.cn-beijing.volces.com/api/v3)
|
||||
-- ============================================================
|
||||
|
||||
-- ===================== Part 1: llm =====================
|
||||
INSERT INTO llm (id,name,model,description,iconid,upappid,providerid,ownerid,enabled_date,expired_date,min_balance,status) VALUES
|
||||
('llm_doubao_21_pro','doubao-2.1-pro','doubao-seed-2-1-pro-256k','豆包大模型2.1 Pro — 256K上下文,文本对话',NULL,'huoshanfangzhou','Cy-zrc4DgLIFuA0KMQzlw','0','2025-01-01','2099-12-31',0.00,'published'),
|
||||
('llm_doubao_seedream_5','doubao-seedream-5.0','doubao-seedream-5.0-250828','豆包图像创作模型5.0 — 文生图',NULL,'huoshanfangzhou','Cy-zrc4DgLIFuA0KMQzlw','0','2025-01-01','2099-12-31',0.00,'published'),
|
||||
('llm_doubao_speech_2','doubao-speech-2.0','doubao-speech-2.0','豆包语音识别模型2.0 — 语音转文字',NULL,'huoshanfangzhou','Cy-zrc4DgLIFuA0KMQzlw','0','2025-01-01','2099-12-31',0.00,'published')
|
||||
ON DUPLICATE KEY UPDATE model=VALUES(model), description=VALUES(description);
|
||||
|
||||
-- ===================== Part 2: llm_api_map =====================
|
||||
INSERT INTO llm_api_map (id,llmid,llmcatelogid,apiname,query_apiname,query_period,ppid,isdefaultcatelog) VALUES
|
||||
-- 豆包2.1 Pro → 文本对话 (t2t)
|
||||
('map_doubao_21_pro','llm_doubao_21_pro','t2t','doubao-chat',NULL,NULL,'pp_doubao_21_pro','1'),
|
||||
-- 豆包图像5.0 → 文生图 (t2i)
|
||||
('map_doubao_seedream_5','llm_doubao_seedream_5','t2i','doubao-image',NULL,NULL,'pp_doubao_seedream_5','1'),
|
||||
-- 豆包语音2.0 → 语音识别 (asr)
|
||||
('map_doubao_speech_2','llm_doubao_speech_2','asr','doubao-asr',NULL,NULL,'pp_doubao_speech_2','1')
|
||||
ON DUPLICATE KEY UPDATE apiname=VALUES(apiname), ppid=VALUES(ppid);
|
||||
|
||||
-- ===================== Part 3: uapi =====================
|
||||
-- 3a. 文本对话 (OpenAI-compatible chat) — sync
|
||||
INSERT INTO uapi (id,name,title,description,need_auth,stream,path,httpmethod,chunk_match,headers,params,data,response,ioid,callbackurl,upappid) VALUES
|
||||
('uapi_doubao_chat','doubao-chat','豆包大模型对话','豆包2.1 Pro文本对话','0','sync','/chat/completions','POST',NULL,'{"Content-Type":"application/json"}',NULL,
|
||||
'{%if stream==True%}"stream_options":{"include_usage":true},"stream":true,{%endif%}
|
||||
"messages":[
|
||||
{%if sys_prompt%}{"role":"system","content":{{json.dumps(sys_prompt,ensure_ascii=False)}}},{%endif%}
|
||||
{"role":"user","content":[{%if image_file%}{"type":"image_url","image_url":"{{b64media2url(request,image_file)}}"},{%endif%}{%if video_file%}{"type":"video_url","video_url":"{{b64media2url(request,video_file)}}"},{%endif%}{%if audio_file%}{"type":"audio_url","audio_url":"{{b64media2url(request,audio_file)}}"},{%endif%}{"type":"text","text":{{json.dumps(prompt,ensure_ascii=False)}}}]}
|
||||
],
|
||||
"model":"{{model}}"',
|
||||
'{"id":"{{id}}","object":"chat.completion","created":{{created}},"model":"{{model}}","choices":{{json.dumps(choices,ensure_ascii=False)}},"usage":{{json.dumps(usage,ensure_ascii=False)}}}',
|
||||
NULL,NULL,'huoshanfangzhou')
|
||||
ON DUPLICATE KEY UPDATE data=VALUES(data), response=VALUES(response);
|
||||
|
||||
-- 3b. 图像生成 (async, ARK contents/generations) — async
|
||||
INSERT INTO uapi (id,name,title,description,need_auth,stream,path,httpmethod,chunk_match,headers,params,data,response,ioid,callbackurl,upappid) VALUES
|
||||
('uapi_doubao_image','doubao-image','豆包图像创作','豆包Seedream5.0图像生成','0','async','/contents/generations/tasks','POST',NULL,'{"Content-Type":"application/json"}',NULL,
|
||||
'{"model":"{{model}}","content":[{"type":"text","text":{{json.dumps(prompt,ensure_ascii=False)}}}],"size":"{{size or \"1024x1024\"}}"}',
|
||||
'{"taskid":"{{id}}","taskstatus":"PENDING","status":"PENDING"}',
|
||||
NULL,NULL,'huoshanfangzhou')
|
||||
ON DUPLICATE KEY UPDATE data=VALUES(data), response=VALUES(response);
|
||||
|
||||
-- 3c. 语音识别 (sync, ARK audio/transcriptions) — sync
|
||||
INSERT INTO uapi (id,name,title,description,need_auth,stream,path,httpmethod,chunk_match,headers,params,data,response,ioid,callbackurl,upappid) VALUES
|
||||
('uapi_doubao_asr','doubao-asr','豆包语音识别','豆包Speech2.0语音转文字','0','sync','/audio/transcriptions','POST',NULL,'{"Content-Type":"multipart/form-data"}',NULL,
|
||||
'{"model":"{{model}}"{%if audio_file%},"file":"{{b64media2url(request,audio_file)}}"{%endif%}{%if language%},"language":"{{language}}"{%endif%}}',
|
||||
'{"text":"{{text}}"{%if segments%},"segments":{{json.dumps(segments,ensure_ascii=False)}}{%endif%}{%if usage%},"usage":{{json.dumps(usage,ensure_ascii=False)}}{%endif%}}',
|
||||
NULL,NULL,'huoshanfangzhou')
|
||||
ON DUPLICATE KEY UPDATE data=VALUES(data), response=VALUES(response);
|
||||
|
||||
-- ===================== Part 4: pricing_program =====================
|
||||
INSERT INTO pricing_program (id,name,ownerid,providerid,pricing_belong,description) VALUES
|
||||
('pp_doubao_21_pro','豆包大模型2.1 Pro',NULL,'Cy-zrc4DgLIFuA0KMQzlw',NULL,'文本对话·按token计费'),
|
||||
('pp_doubao_seedream_5','豆包图像创作5.0',NULL,'Cy-zrc4DgLIFuA0KMQzlw',NULL,'文生图·按张计费'),
|
||||
('pp_doubao_speech_2','豆包语音识别2.0',NULL,'Cy-zrc4DgLIFuA0KMQzlw',NULL,'语音识别·按秒计费')
|
||||
ON DUPLICATE KEY UPDATE name=VALUES(name);
|
||||
|
||||
-- ===================== Part 5: pricing_program_timing =====================
|
||||
INSERT INTO pricing_program_timing (id,ppid,name,pricing_data,enabled_date,expired_date) VALUES
|
||||
-- 文本对话: 按1K tokens计费
|
||||
('pt_doubao_21_pro','pp_doubao_21_pro','豆包2.1 Pro定价',
|
||||
'unit_values:\n completion_tokens: 1000\n prompt_tokens: 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: completion_tokens\n unit_prices: 0.001\n unit: 1K tokens\n- price_factors: prompt_tokens\n unit_prices: 0.0005\n unit: 1K tokens',
|
||||
'2025-01-01','9999-12-31'),
|
||||
|
||||
-- 图像生成: 按张计费
|
||||
('pt_doubao_seedream_5','pp_doubao_seedream_5','豆包Seedream5.0定价',
|
||||
'unit_values:\n image_count: 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: image_count\n unit_prices: 0.02\n unit: image_count',
|
||||
'2025-01-01','9999-12-31'),
|
||||
|
||||
-- 语音识别: 按秒计费
|
||||
('pt_doubao_speech_2','pp_doubao_speech_2','豆包Speech2.0定价',
|
||||
'unit_values:\n audio_seconds: 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: audio_seconds\n unit_prices: 0.004\n unit: audio_seconds',
|
||||
'2025-01-01','9999-12-31')
|
||||
ON DUPLICATE KEY UPDATE ppid=VALUES(ppid), pricing_data=VALUES(pricing_data);
|
||||
Loading…
x
Reference in New Issue
Block a user