agent-Specialization/api_doc/prompts_personalization.md

59 lines
1.6 KiB
Markdown
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.

# Prompt 与个性化Personalization管理 API
## Prompt主提示词存储位置
- 路径:`api/users/<user>/data/prompts/<name>.txt`
- 内容格式:纯文本
## 个性化存储位置
- 路径:`api/users/<user>/data/personalization/<name>.json`
- 内容格式JSON对应原有 personalization 配置结构
## 接口
### 列出 Prompt
`GET /api/v1/prompts`
响应:
```json
{ "success": true, "items": [ { "name": "default", "size": 123, "updated_at": 1769182550.59 } ] }
```
### 获取 Prompt 内容
`GET /api/v1/prompts/{name}`
响应:
```json
{ "success": true, "name": "custom_a", "content": "你的主系统提示..." }
```
### 创建/覆盖 Prompt
`POST /api/v1/prompts`
```json
{ "name": "custom_a", "content": "你的主系统提示内容" }
```
成功返回 `{ "success": true, "name": "custom_a" }`
---
### 列出个性化
`GET /api/v1/personalizations`
### 获取个性化内容
`GET /api/v1/personalizations/{name}`
### 创建/覆盖个性化
`POST /api/v1/personalizations`
```json
{ "name": "biz_mobile", "content": { ... personalization json ... } }
```
---
## 在对话/消息中使用
- `POST /api/v1/conversations` 可选参数:`prompt_name`、`personalization_name`,会写入对话元数据并在后续消息中应用。
- `POST /api/v1/messages` 可选参数:`prompt_name`、`personalization_name`,立即应用并写入元数据。
- 元数据字段:`custom_prompt_name`、`personalization_name`;对话加载时会自动套用对应文件(若不存在则忽略)。
优先级:调用时传入 > 对话元数据 > 默认主 prompt / 默认个性化配置。