Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
rayrayraykk committed Jan 12, 2024
1 parent d3bdf90 commit 26f20f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ repos:
--disable-error-code=import-untyped,
--disable-error-code=truthy-function,
--follow-imports=skip,
--disable-error-code=override,
]
# - repo: https://github.com/numpy/numpydoc
# rev: v1.6.0
Expand Down
2 changes: 1 addition & 1 deletion src/agentscope/agents/learnable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def learn_from_chat(self) -> None:
to decide whether to store the message information into the
knowledge base.
"""
if len(self.memory) > 0:
if self.memory.size() > 0:
for msg in self.memory:
# Ignore msg from itselves to avoid duplication
if msg.get("name") != self.name:
Expand Down
17 changes: 9 additions & 8 deletions src/agentscope/memory/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"""

from abc import ABC, abstractmethod
from typing import Iterable
from typing import Optional
from typing import Union
from typing import Callable
from typing import Iterable, Optional, Union, Callable, Any


class MemoryBase(ABC):
Expand All @@ -21,6 +18,7 @@ class MemoryBase(ABC):
def __init__(
self,
config: Optional[dict] = None,
**kwargs: Any,
) -> None:
"""MemoryBase is a base class for memory of agents.
Expand All @@ -29,6 +27,7 @@ def __init__(
Configuration of this memory.
"""
self.config = {} if config is None else config
self.kwargs = kwargs

def update_config(self, config: dict) -> None:
"""
Expand All @@ -48,13 +47,13 @@ def get_memory(
"""

@abstractmethod
def add(self, memories: Union[list[dict], dict]) -> None:
def add(self, memories: Union[list[dict], dict], **kwargs: Any) -> None:
"""
Adding new memory fragment, depending on how the memory are stored
"""

@abstractmethod
def delete(self, index: Union[Iterable, int]) -> None:
def delete(self, index: Union[Iterable, int], **kwargs: Any) -> None:
"""
Delete memory fragment, depending on how the memory are stored
and matched
Expand All @@ -65,6 +64,7 @@ def load(
self,
memories: Union[str, dict, list],
overwrite: bool = False,
**kwargs: Any,
) -> None:
"""
Load memory, depending on how the memory are passed, design to load
Expand All @@ -76,14 +76,15 @@ def export(
self,
to_mem: bool = False,
file_path: Optional[str] = None,
**kwargs: Any,
) -> Optional[list]:
"""Export memory, depending on how the memory are stored"""

@abstractmethod
def clear(self) -> None:
def clear(self, **kwargs: Any) -> None:
"""Clean memory, depending on how the memory are stored"""

@abstractmethod
def size(self) -> int:
def size(self, **kwargs: Any) -> int:
"""Returns the number of memory segments in memory."""
raise NotImplementedError

0 comments on commit 26f20f0

Please sign in to comment.