mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-15 17:25:26 -04:00
fix: fixed minor consistency issues within MemoryManager (#1353)
This commit is contained in:
@@ -12,7 +12,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def tokenize(text: str) -> List[str]:
|
def tokenize(text: str) -> List[str]:
|
||||||
"""Simple tokenizer that splits on whitespace and removes punctuation."""
|
"""Simple tokenizer that splits on whitespace and removes punctuation."""
|
||||||
return [word.strip('.,!?";') for word in text.split()]
|
return [cleaned for word in text.split() if (cleaned := word.strip('.,!?";'))]
|
||||||
|
|
||||||
def get_text_similarity(text1: str, text2: str) -> float:
|
def get_text_similarity(text1: str, text2: str) -> float:
|
||||||
"""Calculate Jaccard similarity between two texts."""
|
"""Calculate Jaccard similarity between two texts."""
|
||||||
@@ -70,7 +70,7 @@ class MemoryManager:
|
|||||||
if text:
|
if text:
|
||||||
memories.append({
|
memories.append({
|
||||||
"text": text,
|
"text": text,
|
||||||
"timestamp": int(datetime.now().timestamp()),
|
"timestamp": int(time.time()),
|
||||||
"session_id": session_id
|
"session_id": session_id
|
||||||
})
|
})
|
||||||
# If we see a heading that suggests memories
|
# If we see a heading that suggests memories
|
||||||
@@ -105,6 +105,7 @@ class MemoryManager:
|
|||||||
def ensure_file_exists(self):
|
def ensure_file_exists(self):
|
||||||
"""Create memory file if it doesn't exist."""
|
"""Create memory file if it doesn't exist."""
|
||||||
if not os.path.exists(self.memory_file):
|
if not os.path.exists(self.memory_file):
|
||||||
|
os.makedirs(os.path.dirname(self.memory_file), exist_ok=True)
|
||||||
with open(self.memory_file, 'w', encoding='utf-8') as f:
|
with open(self.memory_file, 'w', encoding='utf-8') as f:
|
||||||
json.dump([], f, ensure_ascii=False, indent=2)
|
json.dump([], f, ensure_ascii=False, indent=2)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user