-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RecallSettings now extends cat.utils.BaseModelDict
- Loading branch information
Showing
2 changed files
with
38 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
"""Module for retrieving default configurations for episodic, declarative and procedural memories""" | ||
|
||
from typing import Any | ||
from cat.utils import BaseModelDict | ||
|
||
class RecallSettings: | ||
"""Class for retrieving default configurations for episodic, declarative and procedural memories""" | ||
|
||
DEFAULT_K = 3 | ||
DEFAULT_TRESHOLD = 0.5 | ||
|
||
def _build_settings( | ||
self, | ||
recall_query_embedding, | ||
user_id=None, | ||
k=DEFAULT_K, | ||
treshold=DEFAULT_TRESHOLD, | ||
): | ||
return { | ||
"embedding": recall_query_embedding, | ||
"k": k, | ||
"threshold": treshold, | ||
"metadata": {"source": user_id} if user_id else None, | ||
} | ||
|
||
def default_episodic_config(self, recall_query_embedding, user_id): | ||
return self._build_settings(recall_query_embedding, user_id) | ||
|
||
def default_declarative_config(self, recall_query_embedding): | ||
return self._build_settings(recall_query_embedding) | ||
|
||
def default_procedural_config(self, recall_query_embedding): | ||
return self._build_settings(recall_query_embedding) | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters