|
import streamlit as st |
|
import pandas as pd |
|
from model import create_agent |
|
|
|
|
|
st.set_page_config(page_title="Appointment Booking Bot", page_icon="π₯") |
|
|
|
@st.cache_data |
|
def load_doctor_data(): |
|
return pd.read_csv('doctor_specialization_dummy_data.csv') |
|
|
|
doctor_df = load_doctor_data() |
|
API_KEY = "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" |
|
|
|
|
|
general_prompt_template = """ |
|
You are a healthcare assistant AI. Your primary responsibilities are: |
|
|
|
- Keep the conversation friendly and provide required details too. |
|
- Suggesting a doctor based on the user's symptoms. |
|
- Managing doctor-related appointments (book, reschedule, delete), adhering to specific rules. |
|
- Provide general assistance, such as greetings, if the user starts with a hello or introduction. |
|
|
|
Appointment Rules: |
|
- Appointments can only be scheduled/reschedule from Monday to Friday, between 10 AM and 7 PM. |
|
- Appointments must be booked/reschedule within the next 7 days. |
|
- Book/Reschedule the appointment for 60 minutes/1 hr. |
|
- You are not allowed to handle appointments outside these constraints. |
|
|
|
If the user says something like "hello," "hi," "hey," or a similar greeting, respond appropriately. |
|
If the user provides symptoms, suggest a doctor based on those symptoms. |
|
If user asks details of doctor or book appointment slots without specifying symptoms, ask the user what symptoms they have. |
|
""" |
|
|
|
|
|
@st.cache_resource |
|
def get_agent(): |
|
return create_agent(general_prompt_template) |
|
|
|
agent = get_agent() |
|
|
|
|
|
st.title("Appointment Booking Bot") |
|
|
|
|
|
if "messages" not in st.session_state: |
|
st.session_state.messages = [] |
|
|
|
|
|
for message in st.session_state.messages: |
|
with st.chat_message(message["role"]): |
|
st.markdown(message["content"]) |
|
|
|
|
|
if prompt := st.chat_input("What is your query?"): |
|
|
|
st.chat_message("user").markdown(prompt) |
|
|
|
st.session_state.messages.append({"role": "user", "content": prompt}) |
|
|
|
response = agent({"input": prompt})['output'] |
|
|
|
|
|
with st.chat_message("assistant"): |
|
st.markdown(response) |
|
|
|
st.session_state.messages.append({"role": "assistant", "content": response}) |
|
|
|
|
|
def main(): |
|
st.sidebar.title("About") |
|
st.sidebar.info(""" |
|
π₯ **Appointment Booking Bot** |
|
|
|
π©Ί Virtual Doctors Appointment Managing |
|
|
|
π **Key Features:** |
|
- Symptom analysis and health advice |
|
- Medical information lookup |
|
- Appointment management: |
|
π
Book appointments |
|
π Reschedule appointments |
|
ποΈ Delete appointments |
|
|
|
β° **Appointment Availability:** |
|
- Monday to Friday |
|
- 10 AM to 7 PM |
|
- Book up to 7 days in advance |
|
|
|
β οΈ **Important Note:** |
|
This app is for informational purposes only and does not replace professional medical advice. Always consult with a qualified healthcare provider for medical concerns. |
|
|
|
π‘ Start by describing your symptoms or managing your appointments! |
|
""") |
|
|
|
col1, col2 = st.sidebar.columns([2, 1]) |
|
|
|
|
|
with col1: |
|
st.markdown("π€ **SIMRAN**") |
|
|
|
|
|
with col2: |
|
logout_button = st.button("Logout", key="logout", help="Click to logout", use_container_width=True) |
|
|
|
if __name__ == "__main__": |
|
main() |