mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-05 08:06:15 +00:00
[docstring] update the docstring of memory base worker
This commit is contained in:
commit
ac98f10ca5
3 changed files with 85 additions and 6 deletions
32
README.md
32
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
|
||||
```
|
||||
```
|
||||
|
||||
# 💡 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}
|
||||
}
|
||||
```
|
||||
27
README_ZH.md
27
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}
|
||||
}
|
||||
```
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue