用于更新已写入记忆库的事件记忆。
URL | /api/memory/event/update | 统一资源标识符 |
|---|---|---|
请求方法 | POST | 客户端对记忆库服务器请求的操作类型 |
请求头 | Content-Type: application/json | 请求消息类型 |
Authorization: HMAC-SHA256 *** | 基于AK/SK生成的签名信息 |
参数 | 类型 | 是否必须 | 参数说明 |
|---|---|---|---|
collection_name | String | 否 | 目标记忆库的名称。 |
project_name | String | 否 | 记忆库所属项目。 |
resource_id | String | 否 | 记忆库唯一的资源 id。可选择直接传 resource_id,或同时传 collection_name 和 project_name 作为记忆库的唯一标识。 |
event_id | String | 是 | 需要更新的事件记忆id。 |
memory_info | Object | 否 | 事件记忆的内容。对于内置事件sys_event_v1,只有summary;对于内置事件sys_profile_collect_v1,只有user_profile;对于自定义事件,按照自定义的属性字段展示。
{
{ |
user_id | Array of String | 否 | 事件关联的user_id。 |
assistant_id | Array of String | 否 | 事件关联的assitant_id。 |
参数 | 类型 | 参数说明 |
|---|---|---|
code | Integer | 状态码,0表示成功,其他表示错误。 |
message | String | 返回信息,成功时通常为 "success"。失败则返回原因。 |
data | Object | 返回的详细数据,成功添加消息时此字段通常为空。 |
request_id | String | 标识每个请求的唯一ID。 |
import os import json import requests API_KEY = os.environ.get("MEMORY_API_KEY") url = "https://api-knowledgebase.mlp.cn-beijing.volces.com/api/memory/event/update" headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } data = { "collection_name": "my_first_memory_collection", "event_id": "6879e9d0f2b275b6a4ae2960_0", # 替换成你的事件ID "memory_info": { "original_messages": ( "周一, 2025-08-18 02:58 下午\n" "user1(user): 我特别喜欢看比赛,明天又有比赛看了!\n" "user1(user): 小A为了跟小B的这场比赛,练了整整半年。\n" "assistant1(assistant): 这么励志!那这次肯定稳了吧?\n" "user1(user): 我也觉得,小B根本就没咋准备\n" "assistant1(assistant): 哈哈,一起期待一下小A的表现" ), "summary": ( "2025年8月18日下午,用户表示特别喜欢看比赛,称8月19日有小A和小B的比赛," "小A为此练了半年,小B没咋准备,助理期待小A表现。" ) } } response = requests.post(url, headers=headers, data=json.dumps(data, ensure_ascii=False)) print("Status Code:", response.status_code) print("Response:", response.text)
{ "code":0, "message":"success", "data": { "resource_id": "kb-8349ef57xxxxxxx" }, "request_id":"0216950295xxxxxxx" }