feat(knowledge): add short-term ask memory
This commit is contained in:
@@ -135,7 +135,14 @@ where a.id is null and o.ext1 in ('aihr-knowledge','aihr-knowledge-staging');
|
||||
|
||||
## 6. 查询、日志与限流观察
|
||||
|
||||
内部统一入口为 `POST /api/knowledge/query`,外部入口为 `POST /api/open/knowledge/query`。外部请求使用 `Authorization: Bearer <API_TOKEN>`。查询日志只保存问题哈希、有效空间、来源类型、状态、耗时和提示版本,不保存完整问题或令牌。
|
||||
内部统一入口为 `POST /api/knowledge/query`,内部移动端可带 `conversationId/contextVersion` 启用最近 6 轮、30 分钟不活跃过期的短期会话;外部入口 `POST /api/open/knowledge/query` 始终无状态。内部原文件/视频通过 `GET /api/knowledge/resources/{attachmentId}/content` 在下载时重新鉴权。外部请求使用 `Authorization: Bearer <API_TOKEN>`。查询日志只保存问题哈希、有效空间、来源类型、状态、耗时和提示版本,不保存完整问题或令牌。
|
||||
|
||||
`aihr_knowledge_conversation` 只保存脱敏截断后的短期上下文,过期记录由查询流量每 5 分钟惰性清理最多 500 条。可只读观察积压:
|
||||
|
||||
```sql
|
||||
select count(*) total, sum(expires_time <= now()) expired, min(expires_time) oldest_expiry
|
||||
from aihr_knowledge_conversation;
|
||||
```
|
||||
|
||||
```sql
|
||||
select tenant_id, app_id, status, source_types, count(*) calls,
|
||||
@@ -154,6 +161,13 @@ order by last_time desc;
|
||||
```bash
|
||||
bash scripts/tests/provision-knowledge-platform.test.sh
|
||||
node --test scripts/tests/knowledge-platform-security.test.mjs
|
||||
npm --prefix mobile-uni run test:unit
|
||||
```
|
||||
|
||||
本地手机号登录、多轮改写、原文件下载、视频空结果和旧版本冲突可执行:
|
||||
|
||||
```bash
|
||||
AIHR_BASE_URL='http://127.0.0.1:8080' node scripts/verify-ask-memory-local.mjs
|
||||
```
|
||||
|
||||
真实环境验证器从环境变量读取令牌,绝不写入命令脚本或仓库:
|
||||
|
||||
Reference in New Issue
Block a user