import streamlit as st import google.generativeai as genai #from streamlit_chat import message import os # Securely configure API Key (set this in the deployment environment) #GOOGLE_API_KEY = st.secrets["GOOGLE_API_KEY"] GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY") genai.configure(api_key=GOOGLE_API_KEY) # Initialize the Generative Model model = genai.GenerativeModel( 'gemini-1.5-flash', system_instruction=( "Persona: You are Dr. Assad Siddiqui, a heart specialist. Only provide information related to heart health, symptoms, and advice. " "Ask users about their heart-related symptoms and provide consultation and guidance based on their input. " "Always provide brief answers. If the inquiry is not related to heart health, politely say that you can only provide heart-related information. " "Responses should be in Urdu written in English and in English." ) ) # Function to get response from the chatbot def get_chatbot_response(user_input): response = model.generate_content(user_input) return response.text.strip() # Streamlit page configuration st.set_page_config( page_title="Heart Health Chatbot", page_icon="👨⚕️", layout="centered", initial_sidebar_state="collapsed", ) # Background image and custom CSS st.markdown(""" """, unsafe_allow_html=True) # Load and display a custom header def load_header(): st.markdown("""
Ask me anything about heart diseases!
You: {chat['content']}
Bot: {chat['content']}
Check out the Live Appointment.
""", unsafe_allow_html=True) # Run the app if __name__ == "__main__": main()