Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -58,6 +58,18 @@ def predict(message, system_prompt='', temperature=0.7, max_new_tokens=4096,Topp
|
|
58 |
st.title(TITLE)
|
59 |
st.write(DESCRIPTION)
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
textinput = st.chat_input("Ask LLama-2-70b anything...")
|
62 |
wav_audio_data = st_audiorec()
|
63 |
|
@@ -66,23 +78,13 @@ if wav_audio_data != None:
|
|
66 |
with open("audio.wav", "wb") as f:
|
67 |
f.write(wav_audio_data)
|
68 |
# transcribe audio
|
69 |
-
response = transcribe("audio.wav")
|
70 |
-
|
71 |
with st.chat_message("assistant", avatar='π¦'):
|
72 |
st.markdown(response)
|
73 |
# Add assistant response to chat history
|
74 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
if "messages" not in st.session_state:
|
79 |
-
st.session_state.messages = []
|
80 |
-
|
81 |
-
# Display chat messages from history on app rerun
|
82 |
-
for message in st.session_state.messages:
|
83 |
-
with st.chat_message(message["role"], avatar=("π§βπ»" if message["role"] == 'human' else 'π¦')):
|
84 |
-
st.markdown(message["content"])
|
85 |
-
|
86 |
# React to user input
|
87 |
if prompt := textinput:
|
88 |
# Display user message in chat message container
|
@@ -95,4 +97,8 @@ if prompt := textinput:
|
|
95 |
with st.chat_message("assistant", avatar='π¦'):
|
96 |
st.markdown(response)
|
97 |
# Add assistant response to chat history
|
98 |
-
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
|
|
|
|
|
|
|
|
58 |
st.title(TITLE)
|
59 |
st.write(DESCRIPTION)
|
60 |
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
if "messages" not in st.session_state:
|
66 |
+
st.session_state.messages = []
|
67 |
+
|
68 |
+
# Display chat messages from history on app rerun
|
69 |
+
for message in st.session_state.messages:
|
70 |
+
with st.chat_message(message["role"], avatar=("π§βπ»" if message["role"] == 'human' else 'π¦')):
|
71 |
+
st.markdown(message["content"])
|
72 |
+
|
73 |
textinput = st.chat_input("Ask LLama-2-70b anything...")
|
74 |
wav_audio_data = st_audiorec()
|
75 |
|
|
|
78 |
with open("audio.wav", "wb") as f:
|
79 |
f.write(wav_audio_data)
|
80 |
# transcribe audio
|
81 |
+
response = predict(message=transcribe("audio.wav"))
|
82 |
+
|
83 |
with st.chat_message("assistant", avatar='π¦'):
|
84 |
st.markdown(response)
|
85 |
# Add assistant response to chat history
|
86 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
# React to user input
|
89 |
if prompt := textinput:
|
90 |
# Display user message in chat message container
|
|
|
97 |
with st.chat_message("assistant", avatar='π¦'):
|
98 |
st.markdown(response)
|
99 |
# Add assistant response to chat history
|
100 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
101 |
+
|
102 |
+
|
103 |
+
|
104 |
+
|