From 8f7fdb7c60d31ae688a471b8a8f8d21b3e0ab65d Mon Sep 17 00:00:00 2001 From: "fuqingxu.fqx" Date: Mon, 19 Aug 2024 17:19:26 +0800 Subject: [PATCH] feat: Update MemoryScope context initialization and Elasticsearch sync operations --- memoryscope/core/memoryscope.py | 4 ++-- memoryscope/core/storage/llama_index_sync_elasticsearch.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/memoryscope/core/memoryscope.py b/memoryscope/core/memoryscope.py index 26a8bcde..818bfe12 100644 --- a/memoryscope/core/memoryscope.py +++ b/memoryscope/core/memoryscope.py @@ -33,10 +33,10 @@ class MemoryScope(ConfigManager): self.logger.warning("If a semantic ranking model is not available, MemoryScope will use cosine similarity " "scoring as a substitute. However, the ranking effectiveness will be somewhat " "compromised.") - self.context.memory_scope_uuid = datetime.now().strftime(global_conf["logger_name_time_suffix"]) + self._context.memory_scope_uuid = datetime.now().strftime(global_conf["logger_name_time_suffix"]) # set context_initialized - self.context.context_initialized = True + self._context.context_initialized = True # init memory_chat memory_chat_conf_dict = self.config["memory_chat"] diff --git a/memoryscope/core/storage/llama_index_sync_elasticsearch.py b/memoryscope/core/storage/llama_index_sync_elasticsearch.py index ed468416..41881a69 100644 --- a/memoryscope/core/storage/llama_index_sync_elasticsearch.py +++ b/memoryscope/core/storage/llama_index_sync_elasticsearch.py @@ -619,6 +619,13 @@ class SyncElasticsearchStore(BasePydanticVectorStore): }) return self.sync_query(query, custom_query, es_filter, **kwargs) + def sync_delete_all(self): + self._store.client.delete_by_query(index=[self.index_name], body={"query": {"match_all": {}}}) + + def sync_search_all(self): + search_res = self._store.client.search(index=[self.index_name], body={"query": {"match_all": {}}}) + raise search_res + def sync_query( self, query: VectorStoreQuery,