Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,15 +5,6 @@ from helpers import text_to_speech, autoplay_audio, speech_to_text, get_api_key
|
|
5 |
from generate_answer import base_model_chatbot, with_pdf_chatbot
|
6 |
from audio_recorder_streamlit import audio_recorder
|
7 |
from streamlit_float import *
|
8 |
-
import streamlit.components.v1 as components
|
9 |
-
|
10 |
-
# Load Custom CSS
|
11 |
-
def load_css(file_path):
|
12 |
-
with open(file_path) as f:
|
13 |
-
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
14 |
-
|
15 |
-
# Load your CSS file
|
16 |
-
load_css("style.css")
|
17 |
|
18 |
def main(answer_mode: str):
|
19 |
# Float feature initialization
|
@@ -41,9 +32,8 @@ def main(answer_mode: str):
|
|
41 |
audio_bytes = audio_recorder()
|
42 |
|
43 |
for message in st.session_state.messages:
|
44 |
-
role_class = "assistant" if message["role"] == "assistant" else "user"
|
45 |
with st.chat_message(message["role"]):
|
46 |
-
st.
|
47 |
|
48 |
if audio_bytes:
|
49 |
# Write the audio bytes to a file
|
@@ -78,9 +68,9 @@ def main(answer_mode: str):
|
|
78 |
st.session_state.messages.append({"role": "assistant", "content": final_response})
|
79 |
os.remove(audio_file)
|
80 |
|
|
|
81 |
# Float the footer container and provide CSS to target it with
|
82 |
footer_container.float("bottom: 0rem;")
|
83 |
-
footer_container.markdown('<div class="footer"><p class="footer-text">Powered by OpenAI API | Streamlit</p></div>', unsafe_allow_html=True)
|
84 |
|
85 |
if __name__ == "__main__":
|
86 |
-
main(answer_mode='base_model') # Or: answer_mode='pdf_chat'
|
|
|
5 |
from generate_answer import base_model_chatbot, with_pdf_chatbot
|
6 |
from audio_recorder_streamlit import audio_recorder
|
7 |
from streamlit_float import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def main(answer_mode: str):
|
10 |
# Float feature initialization
|
|
|
32 |
audio_bytes = audio_recorder()
|
33 |
|
34 |
for message in st.session_state.messages:
|
|
|
35 |
with st.chat_message(message["role"]):
|
36 |
+
st.write(message["content"])
|
37 |
|
38 |
if audio_bytes:
|
39 |
# Write the audio bytes to a file
|
|
|
68 |
st.session_state.messages.append({"role": "assistant", "content": final_response})
|
69 |
os.remove(audio_file)
|
70 |
|
71 |
+
|
72 |
# Float the footer container and provide CSS to target it with
|
73 |
footer_container.float("bottom: 0rem;")
|
|
|
74 |
|
75 |
if __name__ == "__main__":
|
76 |
+
main(answer_mode='base_model') # Or: answer_mode='pdf_chat'
|