From 3a19eb2597a95f433cff3fb238b5fe99c9484caa Mon Sep 17 00:00:00 2001 From: Nathan Sarrazin Date: Sat, 30 Nov 2024 21:46:47 +0000 Subject: [PATCH] feat: add time indicator and make the ui match websearch --- .../chat/OpenReasoningResults.svelte | 34 ++++++++++++++----- src/lib/server/textGeneration/generate.ts | 5 +-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/lib/components/chat/OpenReasoningResults.svelte b/src/lib/components/chat/OpenReasoningResults.svelte index b6c28e6b063..7720ec0d10c 100644 --- a/src/lib/components/chat/OpenReasoningResults.svelte +++ b/src/lib/components/chat/OpenReasoningResults.svelte @@ -16,7 +16,27 @@
- + + + + +
Reasoning
@@ -41,16 +61,14 @@ display: none; } - :global(.animate-spin-slow) { - animation: spin 3s linear infinite; + .loading-path { + stroke-dasharray: 61.45; + animation: loading 2s linear infinite; } - @keyframes spin { - from { - transform: rotate(0deg); - } + @keyframes loading { to { - transform: rotate(360deg); + stroke-dashoffset: 122.9; } } diff --git a/src/lib/server/textGeneration/generate.ts b/src/lib/server/textGeneration/generate.ts index af14fe5647c..ece4528dccb 100644 --- a/src/lib/server/textGeneration/generate.ts +++ b/src/lib/server/textGeneration/generate.ts @@ -22,6 +22,7 @@ export async function* generate( let reasoningBuffer = ""; let lastReasoningUpdate = new Date(); let status = ""; + const startTime = new Date(); if ( model.reasoning && (model.reasoning.type === "regex" || model.reasoning.type === "summarize") @@ -90,7 +91,7 @@ Do not use prefixes such as Response: or Answer: when answering to the user.`, yield { type: MessageUpdateType.Reasoning, subtype: MessageReasoningUpdateType.Status, - status: "Done reasoning.", + status: `Done in ${Math.round((new Date().getTime() - startTime.getTime()) / 1000)}s.`, }; } @@ -118,7 +119,7 @@ Do not use prefixes such as Response: or Answer: when answering to the user.`, yield { type: MessageUpdateType.Reasoning, subtype: MessageReasoningUpdateType.Status, - status: "Done reasoning.", + status: `Done in ${Math.round((new Date().getTime() - startTime.getTime()) / 1000)}s.`, }; } }