From d47815c87b8d26db5e9ce9e5b979159fb8151adb Mon Sep 17 00:00:00 2001 From: ZhaoyangLiu-Leo Date: Tue, 23 Jul 2024 16:20:09 +0800 Subject: [PATCH 1/2] [docstring] update the readme --- README.md | 32 ++++++++++++++++++++++++++++++-- README_ZH.md | 27 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e8c0fb7..2b0745d3 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ English | [**中文**](./README_ZH.md) # MemoryScope -# Installation +# 🚀 Installation ## (1) Docker-Compose (Recommanded) 1. Clone the project and edit the config. @@ -48,4 +48,32 @@ English | [**中文**](./README_ZH.md) 4. Launch the built image with command: ``` sudo docker run -it --rm --net=host memoryscope - ``` \ No newline at end of file + ``` + +# 💡 Contribute + +Contributions are always encouraged! + +We highly recommend install pre-commit hooks in this repo before committing pull requests. +These hooks are small house-keeping scripts executed every time you make a git commit, +which will take care of the formatting and linting automatically. +```shell +poetry install --with dev +pre-commit install +``` + + + +# 📖 Citation + +Reference to cite if you use MemoryScope in a paper: + +``` +@software{MemoryScope, +author = {}, +month = {08}, +title = {{MemoryScope}}, +url = {https://github.com/modelscope/MemoryScope}, +year = {2024} +} +``` \ No newline at end of file diff --git a/README_ZH.md b/README_ZH.md index 4ae08bf3..bdaebc95 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -12,3 +12,30 @@ - worker: 框架中的基本工作模块 + +# 💡 代码贡献 + +欢迎社区的代码贡献。 + +我们非常推荐每一个贡献者在代码提交前,安装`pre-commit`钩子工具, +能够帮助在每一次git提交的时候,进行自动化的代码格式校验。 +```shell +poetry install --with dev +pre-commit install +``` + + + +# 📖 引用 + +如果您在论文中有使用该项目,请添加以下引用: + +``` +@software{MemoryScope, +author = {}, +month = {08}, +title = {{MemoryScope}}, +url = {https://github.com/modelscope/MemoryScope}, +year = {2024} +} +``` \ No newline at end of file From a7b0fe614f4ec2c93c52bb69767984621f8b1349 Mon Sep 17 00:00:00 2001 From: ZhaoyangLiu-Leo Date: Tue, 23 Jul 2024 16:50:45 +0800 Subject: [PATCH 2/2] [docstring] update the docstring of memory base worker --- .../memory/worker/memory_base_worker.py | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/memory_scope/memory/worker/memory_base_worker.py b/memory_scope/memory/worker/memory_base_worker.py index 4c3be5e0..aee86d52 100644 --- a/memory_scope/memory/worker/memory_base_worker.py +++ b/memory_scope/memory/worker/memory_base_worker.py @@ -26,7 +26,8 @@ class MemoryBaseWorker(BaseWorker, metaclass=ABCMeta): Args: embedding_model (str): Identifier or instance of the embedding model used for transforming text. generation_model (str): Identifier or instance of the text generation model. - rank_model (str): Identifier or instance of the ranking model for sorting or prioritizing data. + rank_model (str): Identifier or instance of the ranking model for sorting the retrieved memories + wrt. the semantic similarities. **kwargs: Additional keyword arguments passed to the parent class initializer. The constructor also initializes key attributes related to memory store, monitoring, @@ -47,10 +48,20 @@ class MemoryBaseWorker(BaseWorker, metaclass=ABCMeta): @property def chat_messages(self) -> List[Message]: + """ + Property to get the chat messages. + + Returns: + List[Message]: List of chat messages. + """ return self.get_context(CHAT_MESSAGES) @chat_messages.setter def chat_messages(self, value): + """ + Set the chat messages with the new value. + """ + self.set_context(CHAT_MESSAGES, value) @property @@ -101,7 +112,7 @@ class MemoryBaseWorker(BaseWorker, metaclass=ABCMeta): from the global context's model dictionary before returning it. Returns: - BaseModel: The rank model instance used for ranking tasks within the conversation management system. + BaseModel: The rank model instance used for ranking tasks. """ if isinstance(self._rank_model, str): self._rank_model = G_CONTEXT.model_dict[self._rank_model] # Fetch model instance if string reference @@ -109,6 +120,13 @@ class MemoryBaseWorker(BaseWorker, metaclass=ABCMeta): @property def memory_store(self) -> BaseMemoryStore: + """ + Property to access the memory vector store. If not initialized, it fetches + the global memory store. + + Returns: + BaseMemoryStore: The memory store instance used for inserting, updating, retrieving and deleting operations. + """ if self._memory_store is None: self._memory_store = G_CONTEXT.memory_store return self._memory_store @@ -133,7 +151,7 @@ class MemoryBaseWorker(BaseWorker, metaclass=ABCMeta): If not set initially, it retrieves the 'assistant_name' as the username. Returns: - str: The name of the user. + str: The name of the assistant. """ if self._user_name is None: self._user_name = G_CONTEXT.meta_data["assistant_name"] @@ -145,7 +163,7 @@ class MemoryBaseWorker(BaseWorker, metaclass=ABCMeta): Retrieves the target name, initializing it from meta_data if not set. Returns: - str: The human-readable name of the target. + str: The readable name of the human. """ if self._target_name is None: self._target_name = G_CONTEXT.meta_data["human_name"] @@ -165,6 +183,12 @@ class MemoryBaseWorker(BaseWorker, metaclass=ABCMeta): @property def memory_handler(self) -> MemoryHandler: + """ + Lazily initializes and returns the MemoryHandler instance. + + Returns: + MemoryHandler: An instance of MemoryHandler. + """ if not self.has_content(MEMORY_HANDLER): self.set_context(MEMORY_HANDLER, MemoryHandler()) # Initialize the memory handler if not present return self.get_context(MEMORY_HANDLER)