From 971914621030d54f3f119a7da66b251b4cf9c7a8 Mon Sep 17 00:00:00 2001 From: LUIS NOVO Date: Sat, 26 Oct 2024 18:55:07 -0300 Subject: [PATCH] prevent podcast without context --- stream_app/chat.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/stream_app/chat.py b/stream_app/chat.py index 3ab3c89..44936da 100644 --- a/stream_app/chat.py +++ b/stream_app/chat.py @@ -77,14 +77,19 @@ def chat_sidebar(session_id): instructions = st.text_area( "Instructions", value=selected_template.user_instructions ) - if st.button("Generate"): - with st.spinner("Go grab a coffee, almost there..."): - selected_template.generate_episode( - episode_name=episode_name, - text=context, - instructions=instructions, - ) - st.success("Episode generated successfully") + if len(context.get("note", [])) + len(context.get("source", [])) == 0: + st.warning( + "No notes or sources found in context. You don't want a boring podcast, right? So, add some context first." + ) + else: + if st.button("Generate"): + with st.spinner("Go grab a coffee, almost there..."): + selected_template.generate_episode( + episode_name=episode_name, + text=context, + instructions=instructions, + ) + st.success("Episode generated successfully") st.page_link("pages/5_🎙️_Podcasts.py", label="🎙️ Go to Podcasts") with chat_tab: with st.container(border=True):