From 00d9c028ee141c55d9c9a1413155c9fece3c6557 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Tue, 9 Jul 2024 05:15:15 +0530 Subject: [PATCH 1/7] #391 Chat Ordering from Newest to Oldest --- ragna/deploy/_ui/left_sidebar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ragna/deploy/_ui/left_sidebar.py b/ragna/deploy/_ui/left_sidebar.py index ab8bc1c0..fb806f67 100644 --- a/ragna/deploy/_ui/left_sidebar.py +++ b/ragna/deploy/_ui/left_sidebar.py @@ -60,7 +60,7 @@ def refresh(self): @pn.depends("refresh_counter", "chats", "current_chat_id", on_init=True) def __panel__(self): self.chat_buttons = [] - for chat in self.chats: + for chat in reversed(self.chats): button = pn.widgets.Button( name=chat["metadata"]["name"], css_classes=["chat_button"], From 24f7b3f7fa0bec080fb4457556eff0cd829af90e Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 11 Jul 2024 01:55:43 +0530 Subject: [PATCH 2/7] #391 Sort chat buttons in left sidebar by latest message timestamp --- ragna/deploy/_ui/left_sidebar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ragna/deploy/_ui/left_sidebar.py b/ragna/deploy/_ui/left_sidebar.py index fb806f67..076e310e 100644 --- a/ragna/deploy/_ui/left_sidebar.py +++ b/ragna/deploy/_ui/left_sidebar.py @@ -59,8 +59,10 @@ def refresh(self): @pn.depends("refresh_counter", "chats", "current_chat_id", on_init=True) def __panel__(self): + self.chats.sort(key=lambda chat: chat['messages'][-1]['timestamp'], reverse=True) + self.chat_buttons = [] - for chat in reversed(self.chats): + for chat in self.chats: button = pn.widgets.Button( name=chat["metadata"]["name"], css_classes=["chat_button"], From f4e53a4087175b6d58ea8d76356071955b7bcfa3 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 11 Jul 2024 02:06:30 +0530 Subject: [PATCH 3/7] Fix lint --- ragna/deploy/_ui/left_sidebar.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ragna/deploy/_ui/left_sidebar.py b/ragna/deploy/_ui/left_sidebar.py index 076e310e..b4eaa989 100644 --- a/ragna/deploy/_ui/left_sidebar.py +++ b/ragna/deploy/_ui/left_sidebar.py @@ -59,7 +59,10 @@ def refresh(self): @pn.depends("refresh_counter", "chats", "current_chat_id", on_init=True) def __panel__(self): - self.chats.sort(key=lambda chat: chat['messages'][-1]['timestamp'], reverse=True) + self.chats.sort( + key=lambda chat: chat['messages'][-1]['timestamp'], + reverse=True + ) self.chat_buttons = [] for chat in self.chats: From 9423a583226b9a0ed18c9664c053eccb7d0869f6 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 11 Jul 2024 02:11:31 +0530 Subject: [PATCH 4/7] Fix lint again --- ragna/deploy/_ui/left_sidebar.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ragna/deploy/_ui/left_sidebar.py b/ragna/deploy/_ui/left_sidebar.py index b4eaa989..84515407 100644 --- a/ragna/deploy/_ui/left_sidebar.py +++ b/ragna/deploy/_ui/left_sidebar.py @@ -60,8 +60,7 @@ def refresh(self): @pn.depends("refresh_counter", "chats", "current_chat_id", on_init=True) def __panel__(self): self.chats.sort( - key=lambda chat: chat['messages'][-1]['timestamp'], - reverse=True + key=lambda chat: chat['messages'][-1]['timestamp'], reverse=True ) self.chat_buttons = [] From 9ee52a8b2bc533254f30eb3f585a34d1dd432dad Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 11 Jul 2024 02:15:18 +0530 Subject: [PATCH 5/7] Here we go again --- ragna/deploy/_ui/left_sidebar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ragna/deploy/_ui/left_sidebar.py b/ragna/deploy/_ui/left_sidebar.py index 84515407..f08c49d5 100644 --- a/ragna/deploy/_ui/left_sidebar.py +++ b/ragna/deploy/_ui/left_sidebar.py @@ -60,7 +60,7 @@ def refresh(self): @pn.depends("refresh_counter", "chats", "current_chat_id", on_init=True) def __panel__(self): self.chats.sort( - key=lambda chat: chat['messages'][-1]['timestamp'], reverse=True + key=lambda chat: chat["messages"][-1]["timestamp"], reverse=True ) self.chat_buttons = [] From 0871e378abbfe4baa8fd6b6f18e3587377522fd7 Mon Sep 17 00:00:00 2001 From: Arjun Verma Date: Fri, 12 Jul 2024 04:44:51 +0530 Subject: [PATCH 6/7] Update ragna/deploy/_ui/left_sidebar.py Co-authored-by: Blake R --- ragna/deploy/_ui/left_sidebar.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ragna/deploy/_ui/left_sidebar.py b/ragna/deploy/_ui/left_sidebar.py index f08c49d5..526244d8 100644 --- a/ragna/deploy/_ui/left_sidebar.py +++ b/ragna/deploy/_ui/left_sidebar.py @@ -59,8 +59,13 @@ def refresh(self): @pn.depends("refresh_counter", "chats", "current_chat_id", on_init=True) def __panel__(self): + from datetime import datetime + epoch = datetime(1970, 1, 1) self.chats.sort( - key=lambda chat: chat["messages"][-1]["timestamp"], reverse=True + key=lambda chat: ( + epoch if not chat["messages"] else chat["messages"][-1]["timestamp"] + ), + reverse=True ) self.chat_buttons = [] From 67de21b13787054a1ff834d933558f3ae9488e1b Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Fri, 12 Jul 2024 04:57:52 +0530 Subject: [PATCH 7/7] Linter being linter :sweat_smile: --- ragna/deploy/_ui/left_sidebar.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ragna/deploy/_ui/left_sidebar.py b/ragna/deploy/_ui/left_sidebar.py index 526244d8..379acef5 100644 --- a/ragna/deploy/_ui/left_sidebar.py +++ b/ragna/deploy/_ui/left_sidebar.py @@ -1,3 +1,5 @@ +from datetime import datetime + import panel as pn import param @@ -59,13 +61,12 @@ def refresh(self): @pn.depends("refresh_counter", "chats", "current_chat_id", on_init=True) def __panel__(self): - from datetime import datetime epoch = datetime(1970, 1, 1) self.chats.sort( key=lambda chat: ( epoch if not chat["messages"] else chat["messages"][-1]["timestamp"] ), - reverse=True + reverse=True, ) self.chat_buttons = []