-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor chat interface and audiocast generation
- Loading branch information
1 parent
e0c9b19
commit bacce42
Showing
5 changed files
with
74 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import streamlit as st | ||
|
||
from src.utils.chat_thread import ( | ||
use_audiocast_request, | ||
) | ||
from src.utils.render_audiocast import render_audiocast | ||
|
||
|
||
async def audioui(uichat=st.empty()): | ||
""" | ||
Main chat interface | ||
""" | ||
uichat.empty() | ||
|
||
with st.container(): | ||
if not st.session_state.current_audiocast: | ||
st.info("Using your audiocast specifications") | ||
|
||
summary = st.session_state.user_specification | ||
content_category = st.session_state.content_category | ||
await use_audiocast_request(summary, content_category) | ||
else: | ||
st.info("Audiocast generation completed!") | ||
render_audiocast() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import streamlit as st | ||
|
||
from src.utils.chat_thread import ( | ||
evaluate_final_response, | ||
handle_example_prompt, | ||
handle_user_prompt, | ||
) | ||
from src.utils.chat_utils import display_example_cards | ||
from src.utils.render_chat import render_chat_history | ||
|
||
|
||
async def chatui(uichat=st.empty()): | ||
""" | ||
chat interface | ||
""" | ||
st.write( | ||
"Tell me what you'd like to listen to, and I'll create an audiocast for you!" | ||
) | ||
|
||
if st.session_state.messages: | ||
render_chat_history() | ||
elif not st.session_state.example_prompt and not st.session_state.prompt: | ||
display_example_cards() | ||
|
||
if st.session_state.content_category: | ||
content_category = st.session_state.content_category | ||
|
||
if st.session_state.example_prompt: | ||
handle_example_prompt(content_category) | ||
|
||
if st.session_state.prompt: | ||
prompt = st.session_state.prompt | ||
st.session_state.prompt = None | ||
ai_message = handle_user_prompt(prompt, content_category) | ||
|
||
if isinstance(ai_message, str): | ||
await evaluate_final_response(ai_message, content_category) | ||
|
||
# Chat input for custom prompts | ||
if prompt := uichat.chat_input("What would you like to listen to?"): | ||
st.session_state.messages.append({"role": "user", "content": prompt}) | ||
st.session_state.prompt = prompt | ||
st.rerun() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters