rag/wwwroot/api/kb_delete.dspy
ymq 00262a6d2a feat(rag-api): 对外B2B API+内部tools包装
- wwwroot/api/ 六个对外端点(Bearer Key 鉴权,路由授 any、业务鉴权在 api_core):
  kb_create/kb_delete/doc_upload/doc_delete/tag_create/doc_set_tags/search
- rag/api_core.py: verify_api_key + make_api_env(org注入) + 六个业务核心
  (复用 init.py 底层检索/入库能力,杜绝双实现分叉)
- 统一返回格式 {"status":"ok"|"error","data":...}
- rag/ingest.py: 入库管线从 upload_file.dspy 抽出共享(UI/API同一引擎)
- rag/tools.py: RAG_TOOL_SCHEMAS + exec_rag_tool(与API同构,供内部助手调用)
- rag_api_keys 表 model(key 只存 SHA256);管理端 api_key_create/list/revoke
- load_path.py 注册 7 个 API 端点(any) + 3 个管理端点(logined)
2026-09-03 15:51:19 +08:00

13 lines
489 B
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.

# 对外 API删除知识库全量级联清理
# POST /rag/api/kb_delete.dspy Authorization: Bearer <api-key>
# body/query: {kb_id}
from rag import api_core as C
_ctx, _e = await C.verify_api_key(request)
if _e:
return C._err(_e, code="unauthorized")
_ns = await C.read_json_body(request, params_kw)
if not C.require_scope(_ctx, "kb.delete"):
return C._err("api key lacks scope: kb.delete", code="forbidden")
env = C.make_api_env(_ctx)
return await C.kb_delete(env, _ns)