From a41602eb75bb2c6069d15254c235546d8930afae Mon Sep 17 00:00:00 2001 From: Nathan Sarrazin Date: Tue, 21 Mar 2023 16:57:20 +0100 Subject: [PATCH] Added first question in sidebar for easier parsing of past chats --- api/main.py | 14 ++++++++++++-- web/src/routes/+layout.svelte | 16 +++++++++++----- web/src/routes/+layout.ts | 1 + 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/api/main.py b/api/main.py index 2b69a76..ab0097f 100644 --- a/api/main.py +++ b/api/main.py @@ -146,13 +146,23 @@ async def ask_a_question(chat_id: str, prompt: str): @app.get("/chats", tags=["chats"]) -async def get_all_chats_id(): +async def get_all_chats(): res = [] for i in ( await Chat.find_all().sort((Chat.created, SortDirection.DESCENDING)).to_list() ): await i.fetch_link(Chat.parameters) - res.append({"id": i.id, "created": i.created, "model": i.parameters.model}) + await i.fetch_link(Chat.questions) + + first_q = i.questions[0].question if i.questions else "" + res.append( + { + "id": i.id, + "created": i.created, + "model": i.parameters.model, + "subtitle": first_q, + } + ) return res diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index 88990c7..5e8fa68 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -1,9 +1,6 @@