Spaces:
Running
Running
Aniket
commited on
Commit
ยท
2f8dd72
1
Parent(s):
c1a57f5
Made UI changes
Browse files
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 |
-
-
|
| 86 |
-
-
|
| 87 |
-
-
|
| 88 |
-
-
|
| 89 |
-
-
|
| 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('
|
| 99 |
st.markdown("""
|
| 100 |
-
|
|
|
|
| 101 |
""")
|
| 102 |
|
|
|
|
| 103 |
st.markdown("""
|
| 104 |
-
|
|
|
|
| 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
|