chore: optimize memory messages fetch count limit (#6021)

This commit is contained in:
takatost 2024-07-06 03:25:38 +08:00 committed by GitHub
parent 79df8825c8
commit 23dc6edb99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,9 +36,11 @@ class TokenBufferMemory:
).order_by(Message.created_at.desc()) ).order_by(Message.created_at.desc())
if message_limit and message_limit > 0: if message_limit and message_limit > 0:
messages = query.limit(message_limit).all() message_limit = message_limit if message_limit <= 500 else 500
else: else:
messages = query.all() message_limit = 500
messages = query.limit(message_limit).all()
messages = list(reversed(messages)) messages = list(reversed(messages))
message_file_parser = MessageFileParser( message_file_parser = MessageFileParser(