HEHEBOIOG commited on
Commit
e9f54bc
·
verified ·
1 Parent(s): 6b75565

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -21
app.py CHANGED
@@ -10,21 +10,6 @@ import gdown
10
  import os
11
  import pandas as pd
12
 
13
- # # Download the file
14
- # file_id = '1P3Nz6f3KG0m0kO_2pEfnVIhgP8Bvkl4v'
15
- # url = f'https://drive.google.com/uc?id={file_id}'
16
- # excel_file_path = os.path.join(os.path.expanduser("~"), 'medical_data.csv')
17
-
18
- # gdown.download(url, excel_file_path, quiet=False)
19
-
20
- # # Read the CSV file into a DataFrame using 'latin1' encoding
21
- # try:
22
- # medical_df = pd.read_csv(excel_file_path, encoding='utf-8')
23
- # except UnicodeDecodeError:
24
- # medical_df = pd.read_csv(excel_file_path, encoding='latin1')
25
-
26
- # Read the CSV file into a DataFrame using 'latin1' encoding
27
-
28
  excel_file_path = 'medical_data.csv'
29
 
30
  try:
@@ -71,11 +56,51 @@ def get_medical_response(question, vectorizer, X_tfidf, model, tokenizer, sbert_
71
  else:
72
  return lm_generated_response
73
 
74
- # Streamlit app
75
- st.title("DiBot")
76
-
77
- user_input = st.text_input("You:")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  if user_input.lower() == "exit":
79
  st.stop()
80
- response = get_medical_response(user_input, vectorizer, X_tfidf, model, tokenizer, sbert_model, medical_df)
81
- st.text_area("Bot's Response:", response)
 
 
 
 
10
  import os
11
  import pandas as pd
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  excel_file_path = 'medical_data.csv'
14
 
15
  try:
 
56
  else:
57
  return lm_generated_response
58
 
59
+ # Custom CSS to enhance the UI
60
+ st.markdown("""
61
+ <style>
62
+ .main {
63
+ background-color: #f5f5f5;
64
+ padding: 2rem;
65
+ border-radius: 10px;
66
+ }
67
+ .stTextInput > div > div > input {
68
+ border: 2px solid #ccc;
69
+ border-radius: 10px;
70
+ padding: 10px;
71
+ width: 100%;
72
+ }
73
+ .stButton > button {
74
+ background-color: #4CAF50;
75
+ color: white;
76
+ border: none;
77
+ border-radius: 10px;
78
+ padding: 10px 20px;
79
+ cursor: pointer;
80
+ }
81
+ .stButton > button:hover {
82
+ background-color: #45a049;
83
+ }
84
+ .stTextArea > div > div > textarea {
85
+ border: 2px solid #ccc;
86
+ border-radius: 10px;
87
+ padding: 10px;
88
+ width: 100%;
89
+ }
90
+ </style>
91
+ """, unsafe_allow_html=True)
92
+
93
+ # Streamlit app layout
94
+ st.title("🤖 DiBot - Your Medical Query Assistant")
95
+ st.write("Ask me any medical question, and I'll do my best to provide an accurate response.")
96
+
97
+ st.subheader("Enter your question below:")
98
+
99
+ user_input = st.text_input("Your question:", "")
100
  if user_input.lower() == "exit":
101
  st.stop()
102
+
103
+ if user_input:
104
+ response = get_medical_response(user_input, vectorizer, X_tfidf, model, tokenizer, sbert_model, medical_df)
105
+ st.subheader("Bot's Response:")
106
+ st.text_area("", response, height=200)