Upload 3 files
Browse files- app.py +48 -0
- img/banner.png +0 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import google.generativeai as genai
|
| 3 |
+
import os
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
# Using the GOOGLE_API_KEY environment variable
|
| 9 |
+
genai.configure = os.environ.get('GOOGLE_API_KEY')
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# UI Config and settings
|
| 13 |
+
st.set_page_config(page_title="Marmar-Gemini", page_icon="💊")
|
| 14 |
+
st.image('img/banner.png', use_column_width=True)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def check_drug_interactions(medications, health_history, gender, age, weight, height):
|
| 18 |
+
model = genai.GenerativeModel('gemini-pro')
|
| 19 |
+
prompt = f"Given the health history: {health_history}, provide a detailed explanation of the potential risks and interactions among these medications: {medications}. Only if any. Focus on any increased risks, specific side effects, and the mechanism by which these interactions might occur, also consider the health history. Ensure the explanation is comprehensive & easy to understand, covering the pharmacological aspects and clinical implications for patients. Then, based on gender: {gender}, age: {age}, weight: {weight}, height: {height}, and health history {health_history}, offer tailored advice."
|
| 20 |
+
response = model.generate_content(prompt)
|
| 21 |
+
return response.text
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# Streamlit app interface
|
| 25 |
+
st.title('Empowering you with the knowledge and tools to safely manage your medications.')
|
| 26 |
+
st.write('Welcome to Marmar. Check potential drug interactions and get tailored advice. Please provide the details below to get started.')
|
| 27 |
+
|
| 28 |
+
# Compulsory field for medications and health history
|
| 29 |
+
medications = st.text_area('Enter the names of the medications you are currently taking, separated by commas:',
|
| 30 |
+
help='Please enter the names of the medications you are currently taking, separated by commas.')
|
| 31 |
+
health_history = st.text_area('Enter your health history or describe any ailments:',
|
| 32 |
+
help='Please include any chronic conditions, recent illnesses, or relevant health issues.')
|
| 33 |
+
|
| 34 |
+
# Optional fields for personalized advice
|
| 35 |
+
options = ['Male', 'Female']
|
| 36 |
+
gender = st.selectbox('Choose your gender:', options)
|
| 37 |
+
age = st.text_input('Enter your age (Optional):', '')
|
| 38 |
+
weight = st.text_input('Enter your weight in kg (Optional):', '')
|
| 39 |
+
height = st.text_input('Enter your height in cm (Optional):', '')
|
| 40 |
+
|
| 41 |
+
# Button to check interactions
|
| 42 |
+
if st.button('Check Interactions'):
|
| 43 |
+
if medications and health_history:
|
| 44 |
+
response = check_drug_interactions(
|
| 45 |
+
medications, health_history, gender, age, weight, height)
|
| 46 |
+
st.write('**Response:**', response)
|
| 47 |
+
else:
|
| 48 |
+
st.warning('Please enter the required information to continue.')
|
img/banner.png
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit==1.31.0
|
| 2 |
+
openai==0.28.0
|
| 3 |
+
python-dotenv==1.0.1
|
| 4 |
+
google-generativeai==0.3.2
|
| 5 |
+
python-dotenv
|