rag/wwwroot/api/search.dspy
ymq 282845bbf1 refactor(rag-api): 鉴权收敛 RBAC 会话,API 端点改授 logined
- 端点权限 any -> logined(用户纠偏:路由至少 logined)
- 认证统一由 RBAC 中间件把关:cookie 会话 或 Bearer <dapi key>
 (dapi.bearer_auth 注册在 registered_auth_methods,认证后建立会话),
  未认证到不了 dspy,删除 verify_api_key 自查
- dspy 用 C.session_env(request) 取真实请求 env(org 走会话),
  与 UI 通道同一身份机制
- make_api_env 保留给内部 tools 通道(宿主注入可信 org,无 HTTP 会话)
2026-09-03 16:11:27 +08:00

8 lines
423 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知识库检索向量召回 + 重排kb_id 缺省=本机构全部知识库)
# POST /rag/api/search.dspy 认证cookie 会话或 Authorization: Bearer <dapi key>RBAC logined 把关
# body/query: {query, kb_id?, top_k?(默认10), recall_k?(默认top_k*3)}
from rag import api_core as C
_ns = await C.read_json_body(request, params_kw)
env = C.session_env(request)
return await C.search(env, _ns)