Memory fixes.

This commit is contained in:
BillSchumacher
2023-04-08 23:33:18 -05:00
parent 9e139fb314
commit a861dec676
2 changed files with 6 additions and 1 deletions

View File

@@ -44,6 +44,8 @@ class LocalCache(MemoryProviderSingleton):
Returns: None Returns: None
""" """
if 'Command Error:' in text:
return ""
self.data.texts.append(text) self.data.texts.append(text)
embedding = get_ada_embedding(text) embedding = get_ada_embedding(text)
@@ -64,6 +66,7 @@ class LocalCache(MemoryProviderSingleton):
option=SAVE_OPTIONS option=SAVE_OPTIONS
) )
f.write(out) f.write(out)
return text
def clear(self) -> str: def clear(self) -> str:
""" """

View File

@@ -69,6 +69,8 @@ class RedisMemory(MemoryProviderSingleton):
Returns: Message indicating that the data has been added. Returns: Message indicating that the data has been added.
""" """
if 'Command Error:' in data:
return ""
vector = get_ada_embedding(data) vector = get_ada_embedding(data)
vector = np.array(vector).astype(np.float32).tobytes() vector = np.array(vector).astype(np.float32).tobytes()
data_dict = { data_dict = {
@@ -132,7 +134,7 @@ class RedisMemory(MemoryProviderSingleton):
except Exception as e: except Exception as e:
print("Error calling Redis search: ", e) print("Error calling Redis search: ", e)
return None return None
return list(results.docs) return [result.data for result in results.docs]
def get_stats(self): def get_stats(self):
""" """