ymq 1054dbb3a9 feat(embedding): 知识库支持文本(bge-m3 /txte)/多媒体(CLIP /mme)双向量引擎
- create_kb/new_kb_form 加向量引擎选择(文本 bge-m3 / 多媒体 clip-vith14)
- upload_file/batch_ingest/search_result/init.py 按 embedding_engine 路由到 /txte 或 /mme
- 文本知识库上传媒体文件友好拒绝(不再崩溃报错)
2026-08-25 13:15:11 +08:00

23 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

ns = params_kw.copy()
db = DBPools()
dbname = get_module_dbname('rag')
async with db.sqlorContext(dbname) as sor:
env = request._run_ns
userorgid = await env.get_userorgid()
kb_id = uuid()
name = ns.get("name", "")
desc = ns.get("description", "")
# 向量引擎clip-vith14=多媒体(CLIP)bge-m3=文本(bge-m3)。默认 clip-vith14 兼容旧数据
emb_type = ns.get("embedding_type", "") or ns.get("embedding_engine", "")
if emb_type not in ("bge-m3", "clip-vith14"):
emb_type = "clip-vith14"
await sor.sqlExe(
"INSERT INTO knowledge_bases (id, name, description, org_id, embedding_engine, vdb_collection, doc_count, total_size, chunk_count, status, created_at) "
"VALUES (${id}$, ${name}$, ${desc}$, ${org_id}$, ${emb}$, 'rag_collection', 0, 0, 0, 'active', NOW())",
{"id": kb_id, "name": name, "desc": desc, "org_id": userorgid, "emb": emb_type})
return {
"widgettype": "urlwidget",
"options": {"url": entire_url('/rag/knowledge_bases_list/index.ui')}
}
return {"error": "failed"}