mirror of
https://github.com/cpacker/MemGPT.git
synced 2025-06-03 04:30:22 +00:00
Fix bug with supporting paginated search for recall memory
This commit is contained in:
parent
f71c855dce
commit
89b51a12cc
@ -280,23 +280,12 @@ class SQLStorageConnector(StorageConnector):
|
|||||||
# todo: make fuzz https://stackoverflow.com/questions/42388956/create-a-full-text-search-index-with-sqlalchemy-on-postgresql/42390204#42390204
|
# todo: make fuzz https://stackoverflow.com/questions/42388956/create-a-full-text-search-index-with-sqlalchemy-on-postgresql/42390204#42390204
|
||||||
session = self.Session()
|
session = self.Session()
|
||||||
filters = self.get_filters({})
|
filters = self.get_filters({})
|
||||||
|
query = (
|
||||||
|
session.query(self.db_model).filter(*filters).filter(func.lower(self.db_model.text).contains(func.lower(query))).offset(offset)
|
||||||
|
)
|
||||||
if limit:
|
if limit:
|
||||||
results = (
|
query = query.limit(limit)
|
||||||
session.query(self.db_model)
|
results = query.all()
|
||||||
.filter(*filters)
|
|
||||||
.filter(func.lower(self.db_model.text).contains(func.lower(query)))
|
|
||||||
.offset(offset)
|
|
||||||
.all()
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
results = (
|
|
||||||
session.query(self.db_model)
|
|
||||||
.filter(*filters)
|
|
||||||
.filter(func.lower(self.db_model.text).contains(func.lower(query)))
|
|
||||||
.offset(offset)
|
|
||||||
.limit(limit)
|
|
||||||
.all()
|
|
||||||
)
|
|
||||||
# return [self.type(**vars(result)) for result in results]
|
# return [self.type(**vars(result)) for result in results]
|
||||||
return [result.to_record() for result in results]
|
return [result.to_record() for result in results]
|
||||||
|
|
||||||
|
@ -310,10 +310,12 @@ class BaseRecallMemory(RecallMemory):
|
|||||||
self.cache = {}
|
self.cache = {}
|
||||||
|
|
||||||
def text_search(self, query_string, count=None, start=None):
|
def text_search(self, query_string, count=None, start=None):
|
||||||
self.storage.query_text(query_string, count, start)
|
results = self.storage.query_text(query_string, count, start)
|
||||||
|
return results, len(results)
|
||||||
|
|
||||||
def date_search(self, start_date, end_date, count=None, start=None):
|
def date_search(self, start_date, end_date, count=None, start=None):
|
||||||
self.storage.query_date(start_date, end_date, count, start)
|
results = self.storage.query_date(start_date, end_date, count, start)
|
||||||
|
return results, len(results)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
total = self.storage.size()
|
total = self.storage.size()
|
||||||
|
Loading…
Reference in New Issue
Block a user