Skip to content

Commit

Permalink
#391 Chat Ordering based upon the order of interaction (#445)
Browse files Browse the repository at this point in the history
Co-authored-by: Blake R <[email protected]>
  • Loading branch information
arjxn-py and blakerosenthal authored Jul 22, 2024
1 parent 9ff6f30 commit 7c5728a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ragna/deploy/_ui/left_sidebar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

import panel as pn
import param

Expand Down Expand Up @@ -59,6 +61,14 @@ def refresh(self):

@pn.depends("refresh_counter", "chats", "current_chat_id", on_init=True)
def __panel__(self):
epoch = datetime(1970, 1, 1)
self.chats.sort(
key=lambda chat: (
epoch if not chat["messages"] else chat["messages"][-1]["timestamp"]
),
reverse=True,
)

self.chat_buttons = []
for chat in self.chats:
button = pn.widgets.Button(
Expand Down

0 comments on commit 7c5728a

Please sign in to comment.