import streamlit as st import pandas as pd from model import create_agent # Set page config at the very beginning st.set_page_config(page_title="Appointment Booking Bot", page_icon="🏥") # Load doctor data @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 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. """ # Initialize the agent @st.cache_resource def get_agent(): return create_agent(general_prompt_template) agent = get_agent() # Streamlit app st.title("Appointment Booking Bot") # Initialize chat history if "messages" not in st.session_state: st.session_state.messages = [] # Display chat messages from history on app rerun for message in st.session_state.messages: with st.chat_message(message["role"]): st.markdown(message["content"]) # React to user input if prompt := st.chat_input("What is your query?"): # Display user message in chat message container st.chat_message("user").markdown(prompt) # Add user message to chat history st.session_state.messages.append({"role": "user", "content": prompt}) response = agent({"input": prompt})['output'] # Display assistant response in chat message container with st.chat_message("assistant"): st.markdown(response) # Add assistant response to chat history st.session_state.messages.append({"role": "assistant", "content": response}) # Main function to run the app 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. 💡 Start by describing your symptoms or managing your appointments! """) # Display a horizontal line, emoji, and the name "SIMRAN" col1, col2 = st.sidebar.columns([2, 1]) # Display emoji and name in the first column with col1: st.markdown("👤 **SIMRAN**") # Profile emoji next to the name # Display red logout button in the second column with col2: logout_button = st.button("Logout", key="logout", help="Click to logout", use_container_width=True) if __name__ == "__main__": main()