mirror of
https://github.com/TencentCloud/TencentDB-Agent-Memory
synced 2026-07-27 12:44:31 +00:00
feat(gateway): add Offload V2 result ref recovery (#577)
* feat(gateway): add offload result ref recovery Signed-off-by: junevanlong <junevanlong@tencent.com> * fix(gateway): align offload recovery wording Signed-off-by: junevanlong <junevanlong@tencent.com> --------- Signed-off-by: junevanlong <junevanlong@tencent.com>
This commit is contained in:
@@ -255,7 +255,7 @@ class MemoryClient:
|
||||
"""``POST /core/write``"""
|
||||
return self._stub.post(f"{_V2}/core/write", {"content": content})
|
||||
|
||||
# -- Offload (Ingest + Compact + Query-MMD) ----------------------------
|
||||
# -- Offload (Ingest + Compact + Read-Ref + Query-MMD) -----------------
|
||||
|
||||
def offload_ingest(
|
||||
self,
|
||||
@@ -336,6 +336,46 @@ class MemoryClient:
|
||||
}),
|
||||
)
|
||||
|
||||
def offload_read_ref(
|
||||
self,
|
||||
session_id: str,
|
||||
result_ref: str,
|
||||
*,
|
||||
query: Optional[str] = None,
|
||||
start_line: Optional[int] = None,
|
||||
end_line: Optional[int] = None,
|
||||
max_tokens: Optional[int] = None,
|
||||
) -> Dict[str, Any]:
|
||||
"""``POST /v2/offload/read-ref`` — 读取已归档的原始工具结果。
|
||||
|
||||
服务端会验证 ``result_ref`` 是否属于 ``session_id``,并限制返回内容长度。
|
||||
``query`` 与行范围参数不能同时使用。
|
||||
|
||||
Parameters
|
||||
----------
|
||||
session_id : str
|
||||
归档结果所属的会话 ID。
|
||||
result_ref : str
|
||||
Offload V2 压缩结果中返回的引用。
|
||||
query : str, optional
|
||||
用于定位片段的子串,匹配时不区分大小写。
|
||||
start_line, end_line : int, optional
|
||||
从 1 开始且包含首尾的行范围。
|
||||
max_tokens : int, optional
|
||||
返回内容的最大 token 数,服务端另有硬上限。
|
||||
"""
|
||||
return self._stub.post(
|
||||
f"{_V2}/offload/read-ref",
|
||||
_strip_none({
|
||||
"session_id": session_id,
|
||||
"result_ref": result_ref,
|
||||
"query": query,
|
||||
"start_line": start_line,
|
||||
"end_line": end_line,
|
||||
"max_tokens": max_tokens,
|
||||
}),
|
||||
)
|
||||
|
||||
def offload_query_mmd(
|
||||
self,
|
||||
session_id: str,
|
||||
@@ -542,7 +582,7 @@ class AsyncMemoryClient:
|
||||
async def write_core(self, content: str) -> Dict[str, Any]:
|
||||
return await self._stub.post(f"{_V2}/core/write", {"content": content})
|
||||
|
||||
# -- Offload (Ingest + Compact + Query-MMD) ----------------------------
|
||||
# -- Offload (Ingest + Compact + Read-Ref + Query-MMD) -----------------
|
||||
|
||||
async def offload_ingest(
|
||||
self,
|
||||
@@ -586,6 +626,29 @@ class AsyncMemoryClient:
|
||||
}),
|
||||
)
|
||||
|
||||
async def offload_read_ref(
|
||||
self,
|
||||
session_id: str,
|
||||
result_ref: str,
|
||||
*,
|
||||
query: Optional[str] = None,
|
||||
start_line: Optional[int] = None,
|
||||
end_line: Optional[int] = None,
|
||||
max_tokens: Optional[int] = None,
|
||||
) -> Dict[str, Any]:
|
||||
"""``POST /v2/offload/read-ref``(异步)"""
|
||||
return await self._stub.post(
|
||||
f"{_V2}/offload/read-ref",
|
||||
_strip_none({
|
||||
"session_id": session_id,
|
||||
"result_ref": result_ref,
|
||||
"query": query,
|
||||
"start_line": start_line,
|
||||
"end_line": end_line,
|
||||
"max_tokens": max_tokens,
|
||||
}),
|
||||
)
|
||||
|
||||
async def offload_query_mmd(
|
||||
self,
|
||||
session_id: str,
|
||||
|
||||
Reference in New Issue
Block a user