方法介绍
delete_prompts 用于批量删除 Memory Prompt。功能说明如下:批量操作:支持一次删除多个 Prompt,数量限制 [1, 100]。
级联清除:删除时会同步清除所有引用该 Prompt 的实例级、团队级和 Agent 级设置。
自动去重:重复 ID 会被服务端自动去重处理。
清除统计:返回结果包含级联清除的设置数量统计。
导入
from tencentdb_agent_memory.v3 import AsyncMemoryPromptClient
方法签名
async def delete(self,memory_prompt_ids: Iterable[str],) -> Dict[str, Any]
使用示例
from tencentdb_agent_memory.v3 import AsyncMemoryPromptClientclient = AsyncMemoryPromptClient(endpoint="https://memory.tdai.tencentyun.com",api_key="sk-xxxxxxxxxxxxxxxx",service_id="tdai-mem-xxxxxxxx")result = await client.delete(memory_prompt_ids=[ # 必填,待删除 Prompt ID 列表,1-100 条"mp-550e8400-e29b-41d4-a716-446655440000","mp-660f9511-f30c-52e5-b827-557766551111"])print(result)
请求参数
参数名 | 类型 | 必填 | 描述说明 |
memory_prompt_ids | List[str] | 是 | 待删除的 Prompt ID 列表。数量限制:[1, 100]。重复 ID 会被服务端自动去重 |
响应示例
{"deleted_prompt_ids": ["mp-550e8400-e29b-41d4-a716-446655440000","mp-660f9511-f30c-52e5-b827-557766551111"],"cleared_settings": {"instance": 1,"team": 2,"agent": 5}}
响应参数说明
参数名 | 类型 | 参数含义 |
deleted_prompt_ids | List[str] | 本次实际删除的 Prompt ID 列表 |
cleared_settings | Dict | 本次删除操作级联清除的 Prompt 引用数量统计 |
cleared_settings.instance | int | 级联清除的实例级 Prompt 引用数量 |
cleared_settings.team | int | 级联清除的团队级 Prompt 引用数量 |
cleared_settings.agent | int | 级联清除的 Agent 级 Prompt 引用数量 |
错误码
错误码 | 触发场景 | 处理建议 |
400 | memory_prompt_ids 为空或数量超过 100 | 检查列表长度是否在 [1, 100] 范围内 |
401 | API Key 缺失或格式不正确 | 检查 Bearer Token 配置 |
503 | Prompt 存储服务暂时不可用 | 稍后重试 |