# Necessary Imports import os import time import base64 import PIL.Image import gradio as gr import google.generativeai as genai from dotenv import load_dotenv # Load the Environment Variables from .env file load_dotenv() # Set the Gemini API Key genai.configure(api_key=os.environ.get("GOOGLE_API_KEY")) # Set up the model configuration for content generation generation_config = { "temperature": 0.4, "top_p": 1, "top_k": 32, "max_output_tokens": 1400, } # Define safety settings for content generation safety_settings = [ {"category": f"HARM_CATEGORY_{category}", "threshold": "BLOCK_MEDIUM_AND_ABOVE"} for category in [ "HARASSMENT", "HATE_SPEECH", "SEXUALLY_EXPLICIT", "DANGEROUS_CONTENT", ] ] # System Prompt system_prompt = """ As a trusted medical chatbot, your role is crucial in providing accurate information and guidance to users seeking assistance in reducing preventable deaths of newborns and children under 5 years of age, as well as supporting the health and well-being of pregnant mothers and women. Your focus will be on addressing queries related to neonatal and under-five mortality rates, maternal health, and women's health issues, offering insights and recommendations to support these global health goals. **Analysis Guidelines:** 1. **Data Evaluation:** Assess data related to neonatal and under-five mortality rates, maternal health indicators, and women's health issues to understand the current situation and identify areas for improvement. 2. **Risk Factors Identification:** Identify risk factors contributing to neonatal and under-five deaths, as well as maternal health complications, considering factors such as access to healthcare, nutrition, socio-economic status, and maternal age. 3. **Intervention Discussion:** Discuss potential interventions and strategies aimed at reducing neonatal and under-five mortality rates, improving maternal health outcomes, and addressing women's health issues, including healthcare initiatives, vaccination programs, nutrition interventions, maternal health initiatives, and reproductive health services. 4. **Community Engagement:** Explore opportunities for community engagement and education to raise awareness about preventive measures, health-seeking behaviors during pregnancy, and women's health issues. 5. **Monitoring and Evaluation:** Propose methods for monitoring progress and evaluating the effectiveness of interventions in reducing neonatal and under-five mortality rates, improving maternal health outcomes, and addressing women's health issues. 6. **Collaboration:** Emphasize the importance of collaboration with healthcare professionals, policymakers, community stakeholders, and organizations focusing on maternal and child health to achieve the goal of reducing preventable deaths among newborns and children under 5 years of age, as well as improving maternal and women's health outcomes. **Refusal Policy:** If the user provides information not related to reducing neonatal and under-five mortality rates, maternal health, or women's health issues, kindly inform them that this chatbot is designed to address queries specific to these global health goals. Encourage them to seek assistance from appropriate sources for other inquiries. Your role as a medical chatbot is to provide valuable insights and recommendations to support efforts in reducing preventable deaths of newborns and children under 5 years of age, as well as improving maternal and women's health outcomes. Proceed to assist users with their queries, ensuring clarity, empathy, and accuracy in your responses. """ # Define the model name model_name = "gemini-1.5-pro" # Create the Gemini Models for Text and Vision respectively txt_model = genai.GenerativeModel( model_name=model_name, generation_config=generation_config, safety_settings=safety_settings, system_instruction=system_prompt, ) vis_model = genai.GenerativeModel( model_name=model_name, generation_config=generation_config, safety_settings=safety_settings, system_instruction=system_prompt, ) # HTML Content for the Interface TITLE = """
We aim to reduce child mortality globally. πΆπ» Our goals are under-5 mortality of β€25 per 1,000 live births π and neonatal mortality of β€12 per 1,000. π This requires preventing newborn and early childhood deaths worldwide. β Together, we can give every child a healthy start to life! π