mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
Sort by most recent chatIDs (#9946)
When we `lazy_load` iMessage chats, return chats w/ most recent msg first (matches what is visualized in app).
This commit is contained in:
parent
cf5a50469f
commit
387813bfb2
@ -108,8 +108,13 @@ class IMessageChatLoader(chat_loaders.BaseChatLoader):
|
||||
) from e
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Fetch the list of chat IDs
|
||||
cursor.execute("SELECT ROWID FROM chat")
|
||||
# Fetch the list of chat IDs sorted by time (most recent first)
|
||||
query = """SELECT chat_id
|
||||
FROM message
|
||||
JOIN chat_message_join ON message.ROWID = chat_message_join.message_id
|
||||
GROUP BY chat_id
|
||||
ORDER BY MAX(date) DESC;"""
|
||||
cursor.execute(query)
|
||||
chat_ids = [row[0] for row in cursor.fetchall()]
|
||||
|
||||
for chat_id in chat_ids:
|
||||
|
Loading…
Reference in New Issue
Block a user