Fix return types for client methods (#1914)

This commit is contained in:
Dev Khant
2024-09-26 22:10:51 +05:30
committed by GitHub
parent 61dd5a5ea4
commit 2d3dda3a4c

View File

@@ -139,14 +139,14 @@ class MemoryClient:
return response.json() return response.json()
@api_error_handler @api_error_handler
def get_all(self, **kwargs) -> Dict[str, Any]: def get_all(self, **kwargs) -> List[Dict[str, Any]]:
"""Retrieve all memories, with optional filtering. """Retrieve all memories, with optional filtering.
Args: Args:
**kwargs: Optional parameters for filtering (user_id, agent_id, app_id, limit). **kwargs: Optional parameters for filtering (user_id, agent_id, app_id, limit).
Returns: Returns:
A dictionary containing the list of memories. A list of dictionaries containing memories.
Raises: Raises:
APIError: If the API request fails. APIError: If the API request fails.
@@ -163,7 +163,7 @@ class MemoryClient:
return response.json() return response.json()
@api_error_handler @api_error_handler
def search(self, query: str, version: str = "v1", **kwargs) -> Dict[str, Any]: def search(self, query: str, version: str = "v1", **kwargs) -> List[Dict[str, Any]]:
"""Search memories based on a query. """Search memories based on a query.
Args: Args:
@@ -172,7 +172,7 @@ class MemoryClient:
**kwargs: Additional parameters such as user_id, agent_id, app_id, limit, filters. **kwargs: Additional parameters such as user_id, agent_id, app_id, limit, filters.
Returns: Returns:
A dictionary containing the search results. A list of dictionaries containing search results.
Raises: Raises:
APIError: If the API request fails. APIError: If the API request fails.
@@ -218,7 +218,7 @@ class MemoryClient:
return response.json() return response.json()
@api_error_handler @api_error_handler
def delete_all(self, **kwargs) -> Dict[str, Any]: def delete_all(self, **kwargs) -> Dict[str, str]:
"""Delete all memories, with optional filtering. """Delete all memories, with optional filtering.
Args: Args:
@@ -238,14 +238,14 @@ class MemoryClient:
return response.json() return response.json()
@api_error_handler @api_error_handler
def history(self, memory_id: str) -> Dict[str, Any]: def history(self, memory_id: str) -> List[Dict[str, Any]]:
"""Retrieve the history of a specific memory. """Retrieve the history of a specific memory.
Args: Args:
memory_id: The ID of the memory to retrieve history for. memory_id: The ID of the memory to retrieve history for.
Returns: Returns:
A dictionary containing the memory history. A list of dictionaries containing the memory history.
Raises: Raises:
APIError: If the API request fails. APIError: If the API request fails.
@@ -256,7 +256,7 @@ class MemoryClient:
return response.json() return response.json()
@api_error_handler @api_error_handler
def users(self): def users(self) -> Dict[str, Any]:
"""Get all users, agents, and sessions for which memories exist.""" """Get all users, agents, and sessions for which memories exist."""
params = {"org_name": self.organization, "project_name": self.project} params = {"org_name": self.organization, "project_name": self.project}
response = self.client.get("/v1/entities/", params=params) response = self.client.get("/v1/entities/", params=params)