chore: fix archival memories (#1366)

Co-authored-by: Shubham Naik <shub@memgpt.ai>
This commit is contained in:
Shubham Naik
2025-03-21 16:26:06 -08:00
committed by GitHub
parent a221e30557
commit 48f2da9453
2 changed files with 12 additions and 3 deletions

View File

@@ -437,9 +437,13 @@ def detach_block(
def list_passages(
agent_id: str,
server: "SyncServer" = Depends(get_letta_server),
after: Optional[int] = Query(None, description="Unique ID of the memory to start the query range at."),
before: Optional[int] = Query(None, description="Unique ID of the memory to end the query range at."),
after: Optional[str] = Query(None, description="Unique ID of the memory to start the query range at."),
before: Optional[str] = Query(None, description="Unique ID of the memory to end the query range at."),
limit: Optional[int] = Query(None, description="How many results to include in the response."),
search: Optional[str] = Query(None, description="Search passages by text"),
ascending: Optional[bool] = Query(
True, description="Whether to sort passages oldest to newest (True, default) or newest to oldest (False)"
),
actor_id: Optional[str] = Header(None, alias="user_id"), # Extract user_id from header, default to None if not present
):
"""
@@ -452,7 +456,9 @@ def list_passages(
agent_id=agent_id,
after=after,
before=before,
query_text=search,
limit=limit,
ascending=ascending,
)

View File

@@ -784,6 +784,8 @@ class SyncServer(Server):
limit: Optional[int] = 100,
order_by: Optional[str] = "created_at",
reverse: Optional[bool] = False,
query_text: Optional[str] = None,
ascending: Optional[bool] = True,
) -> List[Passage]:
# TODO: Thread actor directly through this function, since the top level caller most likely already retrieved the user
actor = self.user_manager.get_user_or_default(user_id=user_id)
@@ -793,9 +795,10 @@ class SyncServer(Server):
actor=actor,
agent_id=agent_id,
after=after,
query_text=query_text,
before=before,
ascending=ascending,
limit=limit,
ascending=not reverse,
)
return records