From 14896304f3c31eec0ea9f5cd7698fbd455f78a3f Mon Sep 17 00:00:00 2001 From: Piero Savastano Date: Mon, 4 Sep 2023 16:58:38 +0200 Subject: [PATCH] remove hooks from vector memory --- .../mad_hatter/core_plugin/hooks/memory.py | 41 ------------------- core/cat/memory/vector_memory.py | 3 -- 2 files changed, 44 deletions(-) delete mode 100644 core/cat/mad_hatter/core_plugin/hooks/memory.py diff --git a/core/cat/mad_hatter/core_plugin/hooks/memory.py b/core/cat/mad_hatter/core_plugin/hooks/memory.py deleted file mode 100644 index dff2deee..00000000 --- a/core/cat/mad_hatter/core_plugin/hooks/memory.py +++ /dev/null @@ -1,41 +0,0 @@ -"""Hooks to modify the Cat's memory collections. - -Here is a collection of methods to hook the insertion of memories in the vector databases. - -""" - -from langchain.docstore.document import Document -from cat.memory.vector_memory import VectorMemoryCollection -from cat.mad_hatter.decorators import hook - - -# Hook called before a memory collection has been created. -# This happens at first launch and whenever the collection is deleted and recreated. -@hook(priority=0) -def before_collection_created(vector_memory_collection: VectorMemoryCollection, cat): - """Do something before a new collection is created in vectorDB - - Parameters - ---------- - vector_memory_collection : VectorMemoryCollection - Instance of `VectorMemoryCollection` wrapping the actual db collection. - cat : CheshireCat - Cheshire Car instance. - """ - pass - - -# Hook called after a memory collection has been created. -# This happens at first launch and whenever the collection is deleted and recreated. -@hook(priority=0) -def after_collection_created(vector_memory_collection: VectorMemoryCollection, cat): - """Do something after a new collection is created in vectorDB - - Parameters - ---------- - vector_memory_collection : VectorMemoryCollection - Instance of `VectorMemoryCollection` wrapping the actual db collection. - cat : CheshireCat - Cheshire Car instance. - """ - pass \ No newline at end of file diff --git a/core/cat/memory/vector_memory.py b/core/cat/memory/vector_memory.py index 8d3e11a0..a5eace6f 100644 --- a/core/cat/memory/vector_memory.py +++ b/core/cat/memory/vector_memory.py @@ -146,8 +146,6 @@ def create_collection_if_not_exists(self): # create collection def create_collection(self): - self.cat.mad_hatter.execute_hook('before_collection_created', self) - log(f"Creating collection {self.collection_name} ...", "WARNING") self.client.recreate_collection( collection_name=self.collection_name, @@ -174,7 +172,6 @@ def create_collection(self): ) ] ) - self.cat.mad_hatter.execute_hook('after_collection_created', self) # retrieve similar memories from text def recall_memories_from_text(self, text, metadata=None, k=5, threshold=None):