Skip to content

Commit 34f6e96

Browse files
suncadesundebiao
andauthored
feat: 新增 SiliconFlow 云模型厂家支持 (#20)
主要修改: 1. 更新 LazyLLM 子模块到 7e393da(添加 SiliconFlow API key 验证) 2. 在 model_list.py 中添加 SiliconFlow 云厂家配置: - 26 个 LLM 模型(Qwen、DeepSeek、GLM、Kimi、MiniMax 系列) - 6 个 Embedding 模型 - 5 个 Reranker 模型 - 7 个 VQA 视觉模型 - 3 个文生图(SD)模型 - 3 个 TTS 语音合成模型 - 2 个 STT 语音识别模型 3. 优化 appcmd.py 的 init-models 命令,避免重复创建模型 支持的模型类型:llm, embedding, reranker, sd, tts, stt, vqa API Base URL: https://api.siliconflow.cn/v1/ 参考文档: https://cloud.siliconflow.cn/me/models Co-authored-by: sundebiao <[email protected]>
1 parent f157a33 commit 34f6e96

3 files changed

Lines changed: 152 additions & 42 deletions

File tree

back/src/appcmd.py

Lines changed: 82 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,33 @@ def init():
210210

211211
@click.command("init-models", help="初始化内置模型清单")
212212
def init_models():
213-
# 内置厂商
213+
tenant_id = Account.get_administrator_id()
214+
existing_choice_tags = {
215+
(tag.type, tag.name)
216+
for tag in db.session.query(ChoiceTag)
217+
.filter(ChoiceTag.tenant_id == tenant_id)
218+
.all()
219+
}
220+
214221
choiseTags = []
215222
for firm, types in firms.items():
216223
for s in types:
217-
choiseTags.append(
218-
ChoiceTag(tenant_id=Account.get_administrator_id(), type=s, name=firm)
224+
if (s, firm) not in existing_choice_tags:
225+
choiseTags.append(
226+
ChoiceTag(tenant_id=tenant_id, type=s, name=firm)
227+
)
228+
229+
if choiseTags:
230+
db.session.add_all(choiseTags)
231+
db.session.commit()
232+
click.echo(
233+
click.style(
234+
f"已添加 {len(choiseTags)} 个厂商标签", fg="green"
219235
)
220-
db.session.add_all(choiseTags)
236+
)
237+
else:
238+
click.echo(click.style("厂商标签已是最新,无需更新", fg="yellow"))
239+
221240
# local_kind = ["localLLM", "VAQ", "SD", "TTS", "STT", "Embedding"]
222241
online_kind = {
223242
"llm": "OnlineLLM",
@@ -243,49 +262,71 @@ def init_models():
243262
existing_model_names = {model.model_name for model in existing_models}
244263

245264
# 内置在线模型
246-
account = AccountService.load_user(user_id=Account.get_administrator_id())
265+
account = AccountService.load_user(user_id=tenant_id)
247266
service = ModelService(account)
267+
created_count = 0
268+
error_count = 0
269+
248270
for firm, type_list in online_model_list.items():
249271
for type_key, models in type_list.items():
250272
model_kind = online_kind.get(type_key.split("_")[0], "")
251273
model_name = f"{firm}-{model_kind}"
252274
if model_kind != "" and model_name not in existing_model_names:
253-
service.create_model(
254-
data={
255-
"model_icon": "",
256-
"model_type": "online",
257-
"model_name": model_name,
258-
"description": "",
259-
"model_path": "",
260-
"model_from": "",
261-
"model_kind": model_kind,
262-
"model_list": json.dumps(
263-
[
264-
{
265-
"model_key": i["model_name"],
266-
"can_finetune": 1 if i["support_finetune"] else 0,
267-
}
268-
for i in models
269-
]
270-
),
271-
"model_brand": firm,
272-
}
273-
)
274-
275-
# 内置本地模型
276-
# for model_kind, model_list in local_model_builtins.items():
277-
# for model in model_list:
278-
# service.create_model(data={
279-
# "model_icon": "",
280-
# "model_type": "local",
281-
# "model_name": model["model_key"],
282-
# "model_key": model["model_key"],
283-
# "description": "",
284-
# "model_path": "",
285-
# "model_from": model["model_from"],
286-
# "model_kind": model_kind,
287-
# "model_brand": ''
288-
# })
275+
try:
276+
service.create_model(
277+
data={
278+
"model_icon": "",
279+
"model_type": "online",
280+
"model_name": model_name,
281+
"description": "",
282+
"model_path": "",
283+
"model_from": "",
284+
"model_kind": model_kind,
285+
"model_list": json.dumps(
286+
[
287+
{
288+
"model_key": i["model_name"],
289+
"can_finetune": 1 if i["support_finetune"] else 0,
290+
}
291+
for i in models
292+
]
293+
),
294+
"model_brand": firm,
295+
}
296+
)
297+
created_count += 1
298+
click.echo(
299+
click.style(
300+
f"已创建模型: {model_name} ({firm})", fg="green"
301+
)
302+
)
303+
except Exception as e:
304+
error_count += 1
305+
click.echo(
306+
click.style(
307+
f"创建模型失败 {model_name} ({firm}): {str(e)}",
308+
fg="red",
309+
)
310+
)
311+
logging.error(f"创建模型失败 {model_name} ({firm}): {e}", exc_info=True)
312+
313+
# 提交所有数据库更改
314+
try:
315+
db.session.commit()
316+
click.echo(
317+
click.style(
318+
f"模型初始化完成!成功创建 {created_count} 个模型,失败 {error_count} 个",
319+
fg="green",
320+
)
321+
)
322+
except Exception as e:
323+
db.session.rollback()
324+
click.echo(
325+
click.style(
326+
f"提交数据库更改时出错: {str(e)}", fg="red"
327+
)
328+
)
329+
raise
289330

290331

291332
@click.command("test-redis", help="test redis connection")

back/src/parts/models_hub/model_list.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"Doubao": ["llm", "embedding"],
2222
"Kimi": ["llm"],
2323
"OpenAI": ["llm", "embedding"],
24+
"SiliconFlow": ["llm", "embedding", "reranker", "sd", "tts", "stt", "vqa"],
2425
}
2526

2627
# 模型类别
@@ -411,6 +412,74 @@
411412
{"model_name": "gpt-4-0613", "support_finetune": True, "type": "LLM"},
412413
],
413414
},
415+
"SiliconFlow": {
416+
"llm_list": [
417+
{"model_name": "Qwen/QwQ-32B", "support_finetune": False, "type": "LLM"},
418+
{"model_name": "Qwen/Qwen3-32B", "support_finetune": False, "type": "LLM"},
419+
{"model_name": "Qwen/Qwen3-14B", "support_finetune": False, "type": "LLM"},
420+
{"model_name": "Qwen/Qwen3-30B-A3B", "support_finetune": False, "type": "LLM"},
421+
{"model_name": "Qwen/Qwen3-235B-A22B", "support_finetune": False, "type": "LLM"},
422+
{"model_name": "Qwen/Qwen2.5-72B-Instruct", "support_finetune": False, "type": "LLM"},
423+
{"model_name": "Qwen/Qwen2.5-72B-Instruct-128K", "support_finetune": False, "type": "LLM"},
424+
{"model_name": "Qwen/Qwen2.5-32B-Instruct", "support_finetune": False, "type": "LLM"},
425+
{"model_name": "Qwen/Qwen2.5-14B-Instruct", "support_finetune": False, "type": "LLM"},
426+
{"model_name": "Qwen/Qwen2.5-7B-Instruct", "support_finetune": False, "type": "LLM"},
427+
{"model_name": "Qwen/Qwen2.5-Coder-32B-Instruct", "support_finetune": False, "type": "LLM"},
428+
{"model_name": "Qwen/Qwen2.5-Coder-7B-Instruct", "support_finetune": False, "type": "LLM"},
429+
{"model_name": "deepseek-ai/DeepSeek-V3", "support_finetune": False, "type": "LLM"},
430+
{"model_name": "deepseek-ai/DeepSeek-V2.5", "support_finetune": False, "type": "LLM"},
431+
{"model_name": "deepseek-ai/DeepSeek-R1", "support_finetune": False, "type": "LLM"},
432+
{"model_name": "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B", "support_finetune": False, "type": "LLM"},
433+
{"model_name": "deepseek-ai/DeepSeek-R1-Distill-Qwen-14B", "support_finetune": False, "type": "LLM"},
434+
{"model_name": "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B", "support_finetune": False, "type": "LLM"},
435+
{"model_name": "THUDM/GLM-4.1V-9B-Thinking", "support_finetune": False, "type": "LLM"},
436+
{"model_name": "zai-org/GLM-4.6", "support_finetune": False, "type": "LLM"},
437+
{"model_name": "zai-org/GLM-4.5", "support_finetune": False, "type": "LLM"},
438+
{"model_name": "zai-org/GLM-4.5-Air", "support_finetune": False, "type": "LLM"},
439+
{"model_name": "moonshotai/Kimi-K2-Instruct-0905", "support_finetune": False, "type": "LLM"},
440+
{"model_name": "moonshotai/Kimi-Dev-72B", "support_finetune": False, "type": "LLM"},
441+
{"model_name": "MiniMaxAI/MiniMax-M2", "support_finetune": False, "type": "LLM"},
442+
{"model_name": "MiniMaxAI/MiniMax-M1-80k", "support_finetune": False, "type": "LLM"},
443+
],
444+
"embedding_list": [
445+
{"model_name": "BAAI/bge-m3", "support_finetune": False, "type": "embedding"},
446+
{"model_name": "BAAI/bge-large-zh-v1.5", "support_finetune": False, "type": "embedding"},
447+
{"model_name": "Qwen/Qwen3-Embedding-8B", "support_finetune": False, "type": "embedding"},
448+
{"model_name": "Qwen/Qwen3-Embedding-4B", "support_finetune": False, "type": "embedding"},
449+
{"model_name": "Qwen/Qwen3-Embedding-0.6B", "support_finetune": False, "type": "embedding"},
450+
{"model_name": "netease-youdao/bce-embedding-base_v1", "support_finetune": False, "type": "embedding"},
451+
],
452+
"reranker_list": [
453+
{"model_name": "BAAI/bge-reranker-v2-m3", "support_finetune": False, "type": "rerank"},
454+
{"model_name": "Qwen/Qwen3-Reranker-8B", "support_finetune": False, "type": "rerank"},
455+
{"model_name": "Qwen/Qwen3-Reranker-4B", "support_finetune": False, "type": "rerank"},
456+
{"model_name": "Qwen/Qwen3-Reranker-0.6B", "support_finetune": False, "type": "rerank"},
457+
{"model_name": "netease-youdao/bce-reranker-base_v1", "support_finetune": False, "type": "rerank"},
458+
],
459+
"vqa_list": [
460+
{"model_name": "Qwen/Qwen3-VL-32B-Instruct", "support_finetune": False, "type": "VQA"},
461+
{"model_name": "Qwen/Qwen3-VL-8B-Instruct", "support_finetune": False, "type": "VQA"},
462+
{"model_name": "Qwen/Qwen2.5-VL-72B-Instruct", "support_finetune": False, "type": "VQA"},
463+
{"model_name": "Qwen/Qwen2.5-VL-32B-Instruct", "support_finetune": False, "type": "VQA"},
464+
{"model_name": "Qwen/Qwen2-VL-72B-Instruct", "support_finetune": False, "type": "VQA"},
465+
{"model_name": "deepseek-ai/deepseek-vl2", "support_finetune": False, "type": "VQA"},
466+
{"model_name": "zai-org/GLM-4.5V", "support_finetune": False, "type": "VQA"},
467+
],
468+
"sd_list": [
469+
{"model_name": "Qwen/Qwen-Image", "support_finetune": False, "type": "SD"},
470+
{"model_name": "Qwen/Qwen-Image-Edit", "support_finetune": False, "type": "SD"},
471+
{"model_name": "Kwai-Kolors/Kolors", "support_finetune": False, "type": "SD"},
472+
],
473+
"tts_list": [
474+
{"model_name": "fnlp/MOSS-TTSD-v0.5", "support_finetune": False, "type": "TTS"},
475+
{"model_name": "FunAudioLLM/CosyVoice2-0.5B", "support_finetune": False, "type": "TTS"},
476+
{"model_name": "IndexTeam/IndexTTS-2", "support_finetune": False, "type": "TTS"},
477+
],
478+
"stt_list": [
479+
{"model_name": "FunAudioLLM/SenseVoiceSmall", "support_finetune": False, "type": "STT"},
480+
{"model_name": "TeleAI/TeleSpeechASR", "support_finetune": False, "type": "STT"},
481+
],
482+
},
414483
}
415484

416485
local_model_list = {

0 commit comments

Comments
 (0)