Skip to content

Commit

Permalink
Memory fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
BillSchumacher committed Apr 9, 2023
1 parent 9e139fb commit a861dec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions scripts/memory/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def add(self, text: str):
Returns: None
"""
if 'Command Error:' in text:
return ""
self.data.texts.append(text)

embedding = get_ada_embedding(text)
Expand All @@ -64,6 +66,7 @@ def add(self, text: str):
option=SAVE_OPTIONS
)
f.write(out)
return text

def clear(self) -> str:
"""
Expand Down
4 changes: 3 additions & 1 deletion scripts/memory/redismem.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def add(self, data: str) -> str:
Returns: Message indicating that the data has been added.
"""
if 'Command Error:' in data:
return ""
vector = get_ada_embedding(data)
vector = np.array(vector).astype(np.float32).tobytes()
data_dict = {
Expand Down Expand Up @@ -132,7 +134,7 @@ def get_relevant(
except Exception as e:
print("Error calling Redis search: ", e)
return None
return list(results.docs)
return [result.data for result in results.docs]

def get_stats(self):
"""
Expand Down

0 comments on commit a861dec

Please sign in to comment.