Skip to content

Commit

Permalink
feat: add time indicator and make the ui match websearch
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin committed Nov 30, 2024
1 parent 295a038 commit 3a19eb2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
34 changes: 26 additions & 8 deletions src/lib/components/chat/OpenReasoningResults.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,27 @@
<div
class="relative grid aspect-square place-content-center overflow-hidden rounded-lg bg-gray-100 dark:bg-gray-800"
>
<IconThought class="text-lg {loading ? 'animate-spin-slow' : ''}" />
<svg
class="absolute inset-0 text-gray-300 transition-opacity dark:text-gray-700 {loading
? 'opacity-100'
: 'opacity-0'}"
width="40"
height="40"
viewBox="0 0 38 38"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
class="loading-path"
d="M8 2.5H30C30 2.5 35.5 2.5 35.5 8V30C35.5 30 35.5 35.5 30 35.5H8C8 35.5 2.5 35.5 2.5 30V8C2.5 8 2.5 2.5 8 2.5Z"
stroke="currentColor"
stroke-width="1"
stroke-linecap="round"
id="shape"
/>
</svg>

<IconThought class="text-[1rem]" />
</div>
<dl class="leading-4">
<dd class="text-sm">Reasoning</dd>
Expand All @@ -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;
}
}
</style>
5 changes: 3 additions & 2 deletions src/lib/server/textGeneration/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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.`,
};
}

Expand Down Expand Up @@ -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.`,
};
}
}
Expand Down

0 comments on commit 3a19eb2

Please sign in to comment.