Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,42 +1,47 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
from ai_assistant import ai_doctor_chat
|
| 3 |
|
| 4 |
-
# Display title
|
| 5 |
st.markdown("<h1 style='text-align: center;'>Your AI Doctor Using Your Custom Knowledge Base 🤖</h1>", unsafe_allow_html=True)
|
| 6 |
|
| 7 |
-
# Create layout with two columns
|
| 8 |
left_column, right_column = st.columns([1, 3])
|
| 9 |
|
| 10 |
-
# Display image in the left column
|
| 11 |
-
left_column.image("ai_doctor_img.jpg", width=200, use_column_width=
|
| 12 |
|
| 13 |
-
# Create a text input box for the OpenAI key
|
| 14 |
openai_key = right_column.text_input('Enter your OpenAI Key', type='password')
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
submit = right_column.button('Submit')
|
|
|
|
| 18 |
if submit:
|
| 19 |
if query and openai_key:
|
| 20 |
try:
|
|
|
|
| 21 |
with st.spinner('Processing your query...'):
|
| 22 |
response = ai_doctor_chat(openai_key, query)
|
| 23 |
-
right_column.
|
| 24 |
except Exception as e:
|
| 25 |
-
right_column.error(f'An error occurred: {e}'
|
| 26 |
else:
|
| 27 |
-
right_column.error('Please enter your OpenAI key and
|
| 28 |
|
|
|
|
| 29 |
st.markdown("---")
|
| 30 |
st.write("Connect with me:")
|
| 31 |
|
|
|
|
| 32 |
kaggle, linkedin, google_scholar, youtube, github = st.columns(5)
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-

|
| 37 |
-
|
| 38 |
-
](https://www.kaggle.com/muhammadimran112233)")
|
| 39 |
linkedin.markdown("[LinkedIn](https://www.linkedin.com/in/muhammad-imran-zaman)")
|
| 40 |
google_scholar.markdown("[Google Scholar](https://scholar.google.com/citations?user=ulVFpy8AAAAJ&hl=en)")
|
| 41 |
youtube.markdown("[YouTube](https://www.youtube.com/@consolioo)")
|
| 42 |
-
github.markdown("[GitHub](https://github.com/Imran-ml)")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Assuming ai_doctor_chat is a custom function you've defined in ai_assistant.py
|
| 4 |
from ai_assistant import ai_doctor_chat
|
| 5 |
|
| 6 |
+
# Display title with centralized HTML styling
|
| 7 |
st.markdown("<h1 style='text-align: center;'>Your AI Doctor Using Your Custom Knowledge Base 🤖</h1>", unsafe_allow_html=True)
|
| 8 |
|
| 9 |
+
# Create layout with two columns, adjusting the ratio for better visual distribution
|
| 10 |
left_column, right_column = st.columns([1, 3])
|
| 11 |
|
| 12 |
+
# Display an image in the left column. Assuming 'ai_doctor_img.jpg' is correctly located in your app's directory.
|
| 13 |
+
left_column.image("ai_doctor_img.jpg", width=200, use_column_width=True)
|
| 14 |
|
| 15 |
+
# Create a text input box for the OpenAI key, ensuring security by masking input
|
| 16 |
openai_key = right_column.text_input('Enter your OpenAI Key', type='password')
|
| 17 |
|
| 18 |
+
# Create a text input for user queries
|
| 19 |
+
query = right_column.text_input('Enter your query')
|
| 20 |
+
# Button to submit the query
|
| 21 |
submit = right_column.button('Submit')
|
| 22 |
+
|
| 23 |
if submit:
|
| 24 |
if query and openai_key:
|
| 25 |
try:
|
| 26 |
+
# Display a spinner while processing the query to improve user experience
|
| 27 |
with st.spinner('Processing your query...'):
|
| 28 |
response = ai_doctor_chat(openai_key, query)
|
| 29 |
+
right_column.success(response)
|
| 30 |
except Exception as e:
|
| 31 |
+
right_column.error(f'An error occurred: {e}')
|
| 32 |
else:
|
| 33 |
+
right_column.error('Please enter both your OpenAI key and your query!', icon="🚨")
|
| 34 |
|
| 35 |
+
# Separator for visual clarity
|
| 36 |
st.markdown("---")
|
| 37 |
st.write("Connect with me:")
|
| 38 |
|
| 39 |
+
# Create a row of columns for social media links
|
| 40 |
kaggle, linkedin, google_scholar, youtube, github = st.columns(5)
|
| 41 |
|
| 42 |
+
# Each column contains a hyperlink to a social profile, wrapped in markdown for formatting
|
| 43 |
+
kaggle.markdown("[Kaggle](https://www.kaggle.com/muhammadimran112233)")
|
|
|
|
|
|
|
|
|
|
| 44 |
linkedin.markdown("[LinkedIn](https://www.linkedin.com/in/muhammad-imran-zaman)")
|
| 45 |
google_scholar.markdown("[Google Scholar](https://scholar.google.com/citations?user=ulVFpy8AAAAJ&hl=en)")
|
| 46 |
youtube.markdown("[YouTube](https://www.youtube.com/@consolioo)")
|
| 47 |
+
github.markdown("[GitHub](https://github.com/Imran-ml)")
|