Spaces:
Running
Running
Commit
•
a27b6f6
1
Parent(s):
0adc481
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,29 @@
|
|
1 |
import streamlit as st
|
2 |
from ai_assistant import ai_doctor
|
3 |
|
4 |
-
# Create layout with two
|
5 |
-
|
6 |
|
7 |
-
# Display image in the left
|
8 |
-
|
|
|
9 |
|
10 |
-
# Display title in the right
|
11 |
-
|
|
|
12 |
|
13 |
-
# Create a text input box for the OpenAI key
|
14 |
-
openai_key =
|
15 |
|
16 |
-
query =
|
17 |
-
submit =
|
18 |
-
if submit:
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
1 |
import streamlit as st
|
2 |
from ai_assistant import ai_doctor
|
3 |
|
4 |
+
# Create layout with two containers
|
5 |
+
left_container, right_container = st.columns([1, 3])
|
6 |
|
7 |
+
# Display image in the left container
|
8 |
+
with left_container:
|
9 |
+
st.image("ai_doctor_img.jpg", caption="Your AI Doctor Image", width=200)
|
10 |
|
11 |
+
# Display title in the right container
|
12 |
+
with right_container:
|
13 |
+
st.markdown("<h1 style='text-align: center;'>Your AI Doctor 🤖</h1>", unsafe_allow_html=True)
|
14 |
|
15 |
+
# Create a text input box for the OpenAI key
|
16 |
+
openai_key = st.text_input('Enter your OpenAI Key', type='password')
|
17 |
|
18 |
+
query = st.text_input('Enter your query', type='default')
|
19 |
+
submit = st.button('Submit')
|
20 |
+
if submit:
|
21 |
+
if query and openai_key:
|
22 |
+
try:
|
23 |
+
with st.spinner('Processing your query...'):
|
24 |
+
response = mh_assistant(openai_key, query)
|
25 |
+
st.write(response)
|
26 |
+
except Exception as e:
|
27 |
+
st.error(f'An error occurred: {e}', icon=':no_entry_sign:')
|
28 |
+
else:
|
29 |
+
st.error('Please enter your OpenAI key and Query both!', icon="🚨")
|