API-AI-012:用户 AI 授权设置 API #173

Closed
opened 2026-06-10 21:03:18 +08:00 by wangdl · 1 comment
Owner

目标

提供用户 AI 分析授权、数据使用范围、key 模式、fallback 策略的设置接口。

接口建议

GET /ai/settings
PUT /ai/settings

支持字段

  • allowAiAnalysis
  • allowUseLearningBehavior
  • allowUseUserProfile
  • allowUseDocumentContent
  • allowStoreAiAnalysisHistory
  • apiKeyMode
  • defaultCredentialId
  • fallbackToPlatformKey
  • maxDailyAiJobs
  • maxDailyTokenBudget

校验规则

  1. apiKeyMode = user_deepseek_key 时,defaultCredentialId 必须有效。
  2. 用户只能绑定自己的 credentialId。
  3. allowAiAnalysis = false 时,不应创建新的 AI 分析 job。
  4. allowUseDocumentContent = false 时,Snapshot 不应包含原文片段。

用户关闭 AI 授权时的处理

  1. 禁止创建新的 AI Job。
  2. pending job 自动取消。
  3. running job 标记 cancelRequested。
  4. Runtime heartbeat 或 result submit 时 API 可拒绝已取消 job。

验收标准

  1. 用户可查询自己的 AI 设置。
  2. 用户可更新自己的 AI 设置。
  3. 禁止绑定其他用户的 credential。
  4. 关闭 allowAiAnalysis 后,AI Job 创建接口应拒绝。
  5. 设置变更后 Snapshot Builder 使用新设置。
  6. 提供测试覆盖。
## 目标 提供用户 AI 分析授权、数据使用范围、key 模式、fallback 策略的设置接口。 ## 接口建议 ``` GET /ai/settings PUT /ai/settings ``` ## 支持字段 - allowAiAnalysis - allowUseLearningBehavior - allowUseUserProfile - allowUseDocumentContent - allowStoreAiAnalysisHistory - apiKeyMode - defaultCredentialId - fallbackToPlatformKey - maxDailyAiJobs - maxDailyTokenBudget ## 校验规则 1. apiKeyMode = user_deepseek_key 时,defaultCredentialId 必须有效。 2. 用户只能绑定自己的 credentialId。 3. allowAiAnalysis = false 时,不应创建新的 AI 分析 job。 4. allowUseDocumentContent = false 时,Snapshot 不应包含原文片段。 ## 用户关闭 AI 授权时的处理 1. 禁止创建新的 AI Job。 2. pending job 自动取消。 3. running job 标记 cancelRequested。 4. Runtime heartbeat 或 result submit 时 API 可拒绝已取消 job。 ## 验收标准 1. 用户可查询自己的 AI 设置。 2. 用户可更新自己的 AI 设置。 3. 禁止绑定其他用户的 credential。 4. 关闭 allowAiAnalysis 后,AI Job 创建接口应拒绝。 5. 设置变更后 Snapshot Builder 使用新设置。 6. 提供测试覆盖。
wangdl added this to the M-API-AI-RUNTIME:API AI Runtime 调度与落库 milestone 2026-06-10 21:03:18 +08:00
Author
Owner

完成证据

产物: src/modules/ai-runtime/user-ai.controller.ts + user-ai.service.ts
提交: 4cf2aa9 feat: 用户 AI 设置与 Key 管理 API (API-AI-011~015)

接口:

  • GET /ai/settings — 查询 AI 授权设置(无记录时自动创建默认值)
  • PUT /ai/settings — 更新 AI 授权设置

校验:

  • apiKeyMode=user_deepseek_key 时必须提供有效 defaultCredentialId
  • 禁止绑定其他用户的 credential
  • allowAiAnalysis=false 时后续 Job 创建将被拒绝
  • allowUseDocumentContent=false 时 Snapshot 不包含原文
## 完成证据 **产物**: `src/modules/ai-runtime/user-ai.controller.ts` + `user-ai.service.ts` **提交**: `4cf2aa9` feat: 用户 AI 设置与 Key 管理 API (API-AI-011~015) **接口**: - `GET /ai/settings` — 查询 AI 授权设置(无记录时自动创建默认值) - `PUT /ai/settings` — 更新 AI 授权设置 **校验**: - apiKeyMode=user_deepseek_key 时必须提供有效 defaultCredentialId - 禁止绑定其他用户的 credential - allowAiAnalysis=false 时后续 Job 创建将被拒绝 - allowUseDocumentContent=false 时 Snapshot 不包含原文
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/api-server#173
No description provided.