Skip to content

Commit

Permalink
add toast notification when audio_source is generated; add key to sid…
Browse files Browse the repository at this point in the history
…ebar
  • Loading branch information
nwaughachukwuma committed Nov 11, 2024
1 parent 9a7f6e2 commit 32ba054
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 0 additions & 2 deletions api/src/utils/audiocast_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from src.services.gemini_client import GeminiConfig, generate_content
from src.services.openai_client import get_openai
from src.utils.chat_utils import ContentCategory
from src.utils.make_seed import make_seed
from src.utils.prompt_templates.source_content_prompt import get_content_source_prompt
from src.utils.prompt_templates.streamline_audio import streamline_audio_script_prompt
from src.utils.prompt_templates.tts_prompt import Metadata, TTSPromptMaker
Expand Down Expand Up @@ -35,7 +34,6 @@ def generate_source_content(category: ContentCategory, summary: str):
],
temperature=0.5,
max_tokens=4096,
seed=make_seed({"category": category, "summary": summary}),
)

return response.choices[0].message.content
Expand Down
10 changes: 7 additions & 3 deletions app/src/lib/components/ChatListActionItems.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { getSessionContext } from '@/stores/sessionContext.svelte';
import type { ContentCategory } from '@/utils/types';
import { env } from '@env';
import { toast } from 'svelte-sonner';
export let sessionId: string;
Expand All @@ -24,7 +25,7 @@
if ($fetchingSource$) return;
$fetchingSource$ = true;
const response = await fetch(`${env.API_BASE_URL}/get-audiocast-source`, {
return fetch(`${env.API_BASE_URL}/get-audiocast-source`, {
method: 'POST',
body: JSON.stringify({ sessionId, category, summary }),
headers: { 'Content-Type': 'application/json' }
Expand All @@ -33,9 +34,12 @@
if (res.ok) return res.json();
throw new Error('Failed to get audiocast source');
})
.then((res) => {
$audioSource$ = res;
toast.success('Audiocast source generated successfully');
})
.catch((error) => toast.error(error.message))
.finally(() => ($fetchingSource$ = false));
$audioSource$ = response;
}
</script>

Expand Down
4 changes: 3 additions & 1 deletion app/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

<div class="relative flex h-full w-full gap-x-2">
<span class="hidden md:block">
<SearchSidebar />
{#key sessionId}
<SearchSidebar />
{/key}
</span>

{#if !browser}
Expand Down
4 changes: 3 additions & 1 deletion app/src/routes/chat/[sessionId=sessionId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@
{#if finalResponse}
<ChatListActionItems {sessionId} let:ongenerate let:onreviewSource>
{#if $fetchingSource$}
<Spinner />
<div class="block w-full animate-pulse text-center p-2 text-gray-300">
Fetching Audiocast Source...Please wait
</div>
{:else}
<CheckFinalResponse
content={item.content}
Expand Down

0 comments on commit 32ba054

Please sign in to comment.