Aniket commited on
Commit
2f8dd72
ยท
1 Parent(s): c1a57f5

Made UI changes

Browse files
Files changed (1) hide show
  1. app.py +37 -31
app.py CHANGED
@@ -29,6 +29,7 @@ st.set_page_config(page_title= "Medical chatbot", page_icon=":bot:")
29
  if "chat_history" not in st.session_state:
30
  st.session_state.chat_history = []
31
 
 
32
  PINECONE_API_KEY = "1bae0d8e-019e-4e87-8080-ecf523e5f25f"
33
  def get_response(user_query):
34
  # Initilize the prompt
@@ -64,14 +65,7 @@ def get_response(user_query):
64
  # answer = vector_store.similarity_search(user_query, k=3)
65
  # return answer.stream().get("answer")
66
 
67
- # Function to simulate typing effect
68
- def type_effect(text):
69
- for char in text:
70
- st.write(char)
71
- time.sleep(0.05)
72
- st.write("")
73
 
74
- import streamlit as st
75
 
76
  # Sidebar content
77
  with st.sidebar:
@@ -79,14 +73,18 @@ with st.sidebar:
79
  st.markdown("""
80
  Welcome to our Medical Chatbot project, an AI-powered application designed to assist users with their medical queries through intelligent interactions.
81
  """)
 
 
 
 
82
 
83
  st.header('๐Ÿ”‘ Key Features:')
84
  st.markdown("""
85
- - **Custom LLM Model**: Utilizes a custom Large Language Model hosted on Hugging Face for tailored medical responses.
86
- - **Hugging Face Integration**: Secure access using Hugging Face credentials for model authentication.
87
- - **Streamlit Interface**: User-friendly and intuitive interface built with Streamlit.
88
- - **LangChain for Prompt Management**: Ensures precise and contextually appropriate responses by managing prompts and chat history.
89
- - **Pinecone for Vector Storage**: Efficient vector storage and retrieval for quick access to relevant information.
90
  """)
91
 
92
  st.header('๐Ÿš€ Future Enhancements:')
@@ -95,20 +93,35 @@ with st.sidebar:
95
  - **Enhanced Medical Knowledge Base**: Continuous updates to keep the model current with the latest medical information.
96
  """)
97
 
98
- st.header('โš ๏ธ Disclaimer:')
99
  st.markdown("""
100
- **Please Note**: This chatbot is designed to provide general medical information and is not a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your physician or other qualified health providers with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read on this application.
 
101
  """)
102
 
 
103
  st.markdown("""
104
- This project aims to provide a reliable, accessible, and user-friendly platform for preliminary medical consultations. Explore the features and provide feedback to help us improve. Thank you for being a part of our journey to revolutionize medical assistance with AI!
 
105
  """)
106
 
107
 
108
- st.title("Medical chatbot")
109
 
110
  st.write("Welcome to the medical chatbot. Please enter your symptoms below and I will try to help you.")
111
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  if "chat_history" in st.session_state:
113
  for message in st.session_state.chat_history:
114
  if "user" in message:
@@ -118,6 +131,8 @@ if "chat_history" in st.session_state:
118
  with st.chat_message("AI"):
119
  st.markdown(message["bot"])
120
 
 
 
121
  user_query = st.chat_input("Enter your symptoms here")
122
  if user_query is not None and user_query != "":
123
 
@@ -127,22 +142,13 @@ if user_query is not None and user_query != "":
127
  st.session_state.chat_history.append({"user": user_query})
128
 
129
  with st.chat_message("AI"):
130
- # =""
131
- # for message in st.session_state.chat_history:
132
- # if "user" in message:
133
- # += f"User: {message['user']}\n"
134
- # elif "bot" in message:
135
- # += f"Bot: {message['bot']}\n"
136
-
137
- ai_response = get_response(user_query)
138
- # st.write(type(ai_response))
139
- result = ai_response["result"]
140
- # type_effect(result)
141
- st.markdown(result)
142
-
143
- # Get the response from backend and present it here
144
- st.session_state.chat_history.append({"bot": result})
145
 
 
 
 
 
 
 
146
 
147
 
148
  # import os
 
29
  if "chat_history" not in st.session_state:
30
  st.session_state.chat_history = []
31
 
32
+
33
  PINECONE_API_KEY = "1bae0d8e-019e-4e87-8080-ecf523e5f25f"
34
  def get_response(user_query):
35
  # Initilize the prompt
 
65
  # answer = vector_store.similarity_search(user_query, k=3)
66
  # return answer.stream().get("answer")
67
 
 
 
 
 
 
 
68
 
 
69
 
70
  # Sidebar content
71
  with st.sidebar:
 
73
  st.markdown("""
74
  Welcome to our Medical Chatbot project, an AI-powered application designed to assist users with their medical queries through intelligent interactions.
75
  """)
76
+ st.header('โš ๏ธ Disclaimer:')
77
+ st.markdown("""
78
+ **Note**: This chatbot provides general medical info and is not a substitute for professional medical advice. Always consult your doctor for any health concerns. Do not delay seeking medical advice because of information from this app.
79
+ """)
80
 
81
  st.header('๐Ÿ”‘ Key Features:')
82
  st.markdown("""
83
+ - ๐Ÿ‘‰**Custom LLM Model**: Utilizes a custom Large Language Model hosted on Hugging Face for tailored medical responses.
84
+ - ๐Ÿ‘‰**Hugging Face Integration**: Secure access using Hugging Face credentials for model authentication.
85
+ - ๐Ÿ‘‰**Streamlit Interface**: User-friendly and intuitive interface built with Streamlit.
86
+ - ๐Ÿ‘‰**LangChain for Prompt Management**: Ensures precise and contextually appropriate responses by managing prompts and chat history.
87
+ - ๐Ÿ‘‰**Pinecone for Vector Storage**: Efficient vector storage and retrieval for quick access to relevant information.
88
  """)
89
 
90
  st.header('๐Ÿš€ Future Enhancements:')
 
93
  - **Enhanced Medical Knowledge Base**: Continuous updates to keep the model current with the latest medical information.
94
  """)
95
 
96
+ st.header(':building_construction: View Other projects')
97
  st.markdown("""
98
+ - ๐Ÿ‘‰Github: https://github.com/Aniket2021448/
99
+ - ๐Ÿ‘‰Portfolio: https://aniket2021448.github.io/My-portfolio/
100
  """)
101
 
102
+ st.header('๐Ÿค—๐Ÿ’ฌ Contact the developer')
103
  st.markdown("""
104
+ - ๐Ÿ‘‰Email: https://github.com/Aniket2021448/
105
+ - ๐Ÿ‘‰Portfolio: https://aniket2021448.github.io/My-portfolio/
106
  """)
107
 
108
 
109
+ st.title("Medical chatbot ๐Ÿค–")
110
 
111
  st.write("Welcome to the medical chatbot. Please enter your symptoms below and I will try to help you.")
112
 
113
+ if "messages" not in st.session_state.keys():
114
+ st.session_state.chat_history.append({"bot": "How may I help you?"})
115
+
116
+ if "chat_history" in st.session_state:
117
+ for message in st.session_state.chat_history:
118
+ if "bot" in message:
119
+ with st.chat_message("AI"):
120
+ st.markdown(message["bot"])
121
+
122
+
123
+ st.session_state.chat_history = []
124
+
125
  if "chat_history" in st.session_state:
126
  for message in st.session_state.chat_history:
127
  if "user" in message:
 
131
  with st.chat_message("AI"):
132
  st.markdown(message["bot"])
133
 
134
+
135
+
136
  user_query = st.chat_input("Enter your symptoms here")
137
  if user_query is not None and user_query != "":
138
 
 
142
  st.session_state.chat_history.append({"user": user_query})
143
 
144
  with st.chat_message("AI"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
+ with st.spinner("Thinking..."):
147
+ ai_response = get_response(user_query)
148
+ result = ai_response["result"]
149
+
150
+ st.markdown(result)
151
+ st.session_state.chat_history.append({"bot": result})
152
 
153
 
154
  # import os