diff --git a/core/cat/looking_glass/recall_settings.py b/core/cat/looking_glass/recall_settings.py new file mode 100644 index 000000000..7c95c36a5 --- /dev/null +++ b/core/cat/looking_glass/recall_settings.py @@ -0,0 +1,30 @@ +"""Module for retrieving default configurations for episodic, declarative and procedural memories""" + +from typing import Any +from cat.utils import BaseModelDict + + +class RecallSettingsMetadata(BaseModelDict): + """Settigs's metadata for default configurations + + Variables: + source (str): the source of the recall query + """ + + source: str + + +class RecallSettings(BaseModelDict): + """Class for retrieving default configurations for episodic, declarative and procedural memories + + Variables: + embedding (Any): the embedding of the recall query - default None + k (int): the number of memories to return - default 3 + threshold (float): the threshold - default 0.5 + metadata (RecallSettingsMetadata): metadata - default None + """ + + embedding: Any + k: int = 3 + threshold: float = 0.5 + metadata: RecallSettingsMetadata = None diff --git a/core/cat/looking_glass/stray_cat.py b/core/cat/looking_glass/stray_cat.py index bd9802a23..9e9d042f0 100644 --- a/core/cat/looking_glass/stray_cat.py +++ b/core/cat/looking_glass/stray_cat.py @@ -15,6 +15,7 @@ from cat.log import log from cat.looking_glass.cheshire_cat import CheshireCat from cat.looking_glass.callbacks import NewTokenHandler, ModelInteractionHandler +from cat.looking_glass.recall_settings import RecallSettingsMetadata, RecallSettings from cat.memory.working_memory import WorkingMemory from cat.convo.messages import CatMessage, UserMessage, MessageWhy, Role, EmbedderModelInteraction from cat.agents import AgentOutput @@ -232,27 +233,18 @@ def recall_relevant_memories_to_working_memory(self, query=None): self.mad_hatter.execute_hook("before_cat_recalls_memories", cat=self) # Setting default recall configs for each memory - # TODO: can these data structures become instances of a RecallSettings class? - default_episodic_recall_config = { - "embedding": recall_query_embedding, - "k": 3, - "threshold": 0.7, - "metadata": {"source": self.user_id}, - } - - default_declarative_recall_config = { - "embedding": recall_query_embedding, - "k": 3, - "threshold": 0.7, - "metadata": None, - } - - default_procedural_recall_config = { - "embedding": recall_query_embedding, - "k": 3, - "threshold": 0.7, - "metadata": None, - } + default_episodic_recall_config = RecallSettings( + embedding=recall_query_embedding, + metadata=RecallSettingsMetadata(source=self.user_id), + ) + + default_declarative_recall_config = RecallSettings( + embedding=recall_query_embedding + ) + + default_procedural_recall_config = RecallSettings( + embedding=recall_query_embedding + ) # hooks to change recall configs for each memory recall_configs = [