Spaces:
Runtime error
Runtime error
wrote response to foreground
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
|
| 4 |
#---------------------------------#
|
| 5 |
import pandas as pd
|
|
@@ -63,18 +63,17 @@ def mh_assistant(openai_key,query):
|
|
| 63 |
st.title('Mental Health Assistant :broken_heart:')
|
| 64 |
|
| 65 |
# Create a text input box for the OpenAI key
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
query = st.text_input('Enter your query', type='default')
|
| 71 |
-
if query:
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
# st.error('Please enter your OpenAI key',icon="🚨")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from mental_health_raqa import mh_assistant
|
| 3 |
|
| 4 |
#---------------------------------#
|
| 5 |
import pandas as pd
|
|
|
|
| 63 |
st.title('Mental Health Assistant :broken_heart:')
|
| 64 |
|
| 65 |
# Create a text input box for the OpenAI key
|
| 66 |
+
openai_key = st.text_input('Enter your OpenAI Key', type='password')
|
| 67 |
+
key_submit = st.button('Submit')
|
| 68 |
+
# Display the key when the user presses the 'Submit' button
|
| 69 |
+
if key_submit and openai_key:
|
| 70 |
+
query = st.text_input('Enter your query', type='default')
|
| 71 |
+
if query:
|
| 72 |
+
try:
|
| 73 |
+
with st.spinner('Processing your query...'):
|
| 74 |
+
response = mh_assistant(openai_key,query)
|
| 75 |
+
st.write(response)
|
| 76 |
+
except Exception as e:
|
| 77 |
+
st.error(f'An error occurred: {e}',icon=':no_entry_sign:')
|
| 78 |
+
elif key_submit and not openai_key:
|
| 79 |
+
st.error('Please enter your OpenAI key',icon="🚨")
|
|
|