Skip to content

Commit

Permalink
0.4.4 - fixes clustering tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Aug 11, 2023
1 parent 77a0b1b commit b32d41d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions agentmemory/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def cluster(epsilon, min_samples, category, filter_metadata=None, novel=False):
cluster_id = 0
for memory in memories:
memory_id = memory["id"]
print("Memory ID: ", memory_id)
if visited[memory_id]:
continue
visited[memory_id] = True
Expand Down
3 changes: 2 additions & 1 deletion agentmemory/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ def update_memory(category, id, text=None, metadata=None, embedding=None):
documents = [text] if text is not None else None
metadatas = [metadata] if metadata is not None else None
embeddings = [embedding] if embedding is not None else None

print('********************** UPDATE')
print(id, documents, metadatas, embeddings)
# Update the memory with the new text and/or metadata
memories.update(
ids=[str(id)], documents=documents, metadatas=metadatas, embeddings=embeddings
Expand Down
5 changes: 5 additions & 0 deletions agentmemory/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ def query(
return self.client.query(self.category, query_texts, n_results)

def update(self, ids, documents=None, metadatas=None, embeddings=None):
self.client.ensure_table_exists(self.category)
# if embeddings is not None
if embeddings is None:
if documents is None:
documents = [None] * len(ids)
for id_, document, metadata in zip(ids, documents, metadatas):
print("updating")
print(id_, document, metadata)
self.client.update(self.category, id_, document, metadata)
else:
for id_, document, metadata, emb in zip(
Expand Down
2 changes: 1 addition & 1 deletion agentmemory/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from .main import *
from .persistence import *
from .events import *
# from .clustering import *
from .clustering import *
from .check_model import *
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name='agentmemory',
version='0.4.3',
version='0.4.4',
description='Easy-to-use memory for agents, document search, knowledge graphing and more.',
long_description=long_description, # added this line
long_description_content_type="text/markdown", # and this line
Expand Down

0 comments on commit b32d41d

Please sign in to comment.