Skip to content

Commit

Permalink
override loading message when generating first response with attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Dec 7, 2024
1 parent dbcc7e8 commit cc1141a
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/src/lib/utils/pluralize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function pluralize(count: number, singular: string, plural: string) {
return count === 1 ? singular : plural;
}
15 changes: 13 additions & 2 deletions app/src/routes/chat/[sessionId=sessionId]/+page.svelte
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import AudiocastPageHeader from '@/components/AudiocastPageHeader.svelte';
import { getSummary, isfinalResponse } from '@/utils/session.utils';
import { getAttachmentsContext } from '@/stores/attachmentsContext.svelte.js';
import { pluralize } from '@/utils/pluralize';
export let data;
@@ -121,15 +122,25 @@
</p>

<div class="flex flex-col gap-y-3 h-full">
{#each sessionChats as item (item.id)}
{#each sessionChats as item, ix (item.id)}
{@const finalResponse = isfinalResponse(item)}
{@const firstRequest = ix === 1}
<ChatListItem
type={item.role}
content={item.content}
loading={item.loading}
createdAt={item.createdAt}
on:regenerate={onregenerate}
/>
>
<span class="animate-pulse" slot="loading">
{#if firstRequest && $sessionUploadItems$.length}
{@const count = $sessionUploadItems$.length}
Evaluating {pluralize(count, 'attachment', 'attachments')}...
{:else}
Generating response...
{/if}
</span>
</ChatListItem>

{#if finalResponse}
<ChatListActionItems

0 comments on commit cc1141a

Please sign in to comment.