79b110afd0
后端: - 新增 POST /admin/kb/search:管理端跨租户检索,支持 mode 指定单路 (vector/fulltext/graph/hybrid),不走 scopedKB(否则会被强制锁到调用者 自己的 space,跨租户排障就没法做了) - KB 清单补 space_id(检索键是 <space_id>/<name>,缺它前端拼不出 key) 前端: - 数据源&RAG 页补「检索试验台」:同一 query 并排跑生产链路 + 四路诊断, 召回不准时能直接定位是向量/分词/图谱哪一环挂了 - 支付拆成「配置 / 订单与对账」两个子页,挂到运维 > 支付 下; 导航支持二级菜单(NavParent 命中子路由自动展开) - SettingsPage → ModelConfigPage「模型配置」,模型参数与计费规则合一 - 概览 → 仪表盘:并入计费与用量(UsagePage → UsageSection), 去掉系统健康拓扑(与服务状态页重复,同一份 /admin/status 数据) - 全局隐藏滚动条(保留滚动) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
1.7 KiB
Go
40 lines
1.7 KiB
Go
package store
|
|
|
|
import "context"
|
|
|
|
// 数据源清单查询(admin「数据源 & RAG」页做实用;此前该页图谱与权重全 mock)。
|
|
// 全平台口径 → WithoutTenant。Doc.KB 存的是 KB 名字(非 id),故按 (space_id, name) 关联。
|
|
|
|
// DatasourceKB 是一条知识库的清单行(含文档数与总字数、租户名)。
|
|
type DatasourceKB struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
// SpaceID 是检索作用域键的前半段:向量/全文/图谱三库里的库名是 "<space_id>/<name>"
|
|
// (见 handler.scopedKB)。admin 检索试验台要按这个完整键定位库,故必须带出来。
|
|
SpaceID string `json:"space_id"`
|
|
Kind string `json:"kind"`
|
|
TenantID string `json:"tenant_id"`
|
|
TenantName string `json:"tenant_name"`
|
|
Owner string `json:"owner"`
|
|
DocCount int64 `json:"doc_count"`
|
|
TotalWords int64 `json:"total_words"`
|
|
}
|
|
|
|
// AllDatasources 列出全平台知识库 + 各库文档数/总字数(admin 数据源清单)。
|
|
func (p *Postgres) AllDatasources(ctx context.Context) []DatasourceKB {
|
|
if p.db == nil {
|
|
return nil
|
|
}
|
|
var out []DatasourceKB
|
|
p.db.WithContext(WithoutTenant(ctx)).Table("sundynix_kb k").
|
|
Select("k.id, k.name, k.space_id, k.kind, k.tenant_id, coalesce(t.name,'') as tenant_name, k.owner, "+
|
|
"count(d.id) as doc_count, coalesce(sum(d.size),0) as total_words").
|
|
Joins("left join sundynix_doc d on d.kb = k.name and d.space_id = k.space_id and d.deleted_at is null").
|
|
Joins("left join sundynix_tenant t on t.id = k.tenant_id").
|
|
Where("k.deleted_at is null").
|
|
Group("k.id, k.name, k.space_id, k.kind, k.tenant_id, t.name, k.owner").
|
|
Order("doc_count desc, k.created_at desc").
|
|
Scan(&out)
|
|
return out
|
|
}
|