Merge pull request #1114 from Sathvik-1007/fix/list-drawers-pagination-total
fix: add total count to tool_list_drawers pagination response
This commit is contained in:
@@ -1013,6 +1013,13 @@ def tool_list_drawers(wing: str = None, room: str = None, limit: int = 20, offse
|
|||||||
kwargs["where"] = where
|
kwargs["where"] = where
|
||||||
result = col.get(**kwargs)
|
result = col.get(**kwargs)
|
||||||
|
|
||||||
|
# Compute total matching drawers for pagination.
|
||||||
|
if where:
|
||||||
|
total_result = col.get(where=where, include=[])
|
||||||
|
total = len(total_result["ids"])
|
||||||
|
else:
|
||||||
|
total = col.count()
|
||||||
|
|
||||||
drawers = []
|
drawers = []
|
||||||
for i, did in enumerate(result["ids"]):
|
for i, did in enumerate(result["ids"]):
|
||||||
meta = result["metadatas"][i]
|
meta = result["metadatas"][i]
|
||||||
@@ -1027,6 +1034,7 @@ def tool_list_drawers(wing: str = None, room: str = None, limit: int = 20, offse
|
|||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
"drawers": drawers,
|
"drawers": drawers,
|
||||||
|
"total": total,
|
||||||
"count": len(drawers),
|
"count": len(drawers),
|
||||||
"offset": offset,
|
"offset": offset,
|
||||||
"limit": limit,
|
"limit": limit,
|
||||||
@@ -1817,7 +1825,7 @@ TOOLS = {
|
|||||||
"handler": tool_get_drawer,
|
"handler": tool_get_drawer,
|
||||||
},
|
},
|
||||||
"mempalace_list_drawers": {
|
"mempalace_list_drawers": {
|
||||||
"description": "List drawers with pagination. Optional wing/room filter. Returns IDs, wings, rooms, and content previews.",
|
"description": "List drawers with pagination. Optional wing/room filter. Returns IDs, wings, rooms, content previews, and total matching count for pagination.",
|
||||||
"input_schema": {
|
"input_schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
Reference in New Issue
Block a user