simran0608's picture
Update app.py
eb889b0 verified
import streamlit as st
import os
import pandas as pd
from model import create_agent
from dotenv import load_dotenv
from config import PROMPT
# Set page config at the very beginning
st.set_page_config(page_title="Appointment Booking Bot", page_icon="πŸ₯")
# Load doctor data
load_dotenv()
API_KEY = os.environ["API_KEY"]
# General prompt template
general_prompt_template=PROMPT
# 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")
st.write("**NOTE:** Currently the slots are getting booked/reshedule/delete in Google Calender in the specific account whose credentials are provided.")
# 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})
# agent=create_agent(general_prompt_template)
response = agent.invoke({"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 Appointment Managing
πŸ”‘ **Key Features:**
- 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 managing your appointment using google Calender!
""")
# 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()