-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
70 lines (57 loc) · 2.27 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import streamlit as st
from dotenv import load_dotenv
load_dotenv() # Activate the Local Vars...
#from langchain_google_genai import PromptTemplate, LLMChain
import google.generativeai as genai
import os
import pandas as pd
# Configure the api_key
genai.configure(api_key = os.getenv('GOOGLE-API-KEY'))
# Streamlit Page
st.header("👨⚕️ Healthcare :blue[Advisor] ⚕️", divider = "green")
input = st.text_input('''Hi! I am your medical expert 💊.
Ask me information about Health, Diseases & Fitness Only''')
submit = st.button("Submit")
# BMI Calculator
st.sidebar.subheader("BMI Calculator ✍️")
weight = st.sidebar.text_input("Weight (in kgs): ")
height = st.sidebar.text_input("Height (in cms): ")
# Calculate the BMI
weight = pd.to_numeric(weight)
height = pd.to_numeric(height)
height_mts = height/100
bmi = weight/(height_mts**2)
# Scale of the BMI
notes = f'''The BMI value can be interpreted as:
* Underweight: BMI<18.5
* Normal Weight: BMI 18.5 - 24.9
* Overweight: BMI 25 - 29.9
* Obese: BMI > 30'''
if bmi:
st.sidebar.markdown("The BMI is: ")
st.sidebar.write(bmi)
st.sidebar.write(notes)
# Generative AI Application
def get_response(text_input):
model = genai.GenerativeModel("gemini-pro")
if text_input!="":
myprompt = '''I want you to acts as a Dietician and Healthcare Expert
and answer the questions on Health & Related Topics Only. If the User is asking information/
prompting on the topics other than Health, just pass the Message - "I am a Healthcare Chatbot
and can answer questions related to Health , Diseases & Fitness Only". Please note if someone asks for
medicines or medicines name, just pass the message - "Please reach out to your Doctor for Medication."
So, here is the Question...'''
response = model.generate_content(myprompt+text_input)
return(response.text)
else:
st.write("Please Enter the Prompt!!")
if submit:
response = get_response(input)
st.subheader("The :orange[Response] is: ")
st.write(response)
# Disclaimer
st.subheader("Disclaimer: ", divider = True)
notes = f'''
1. This is an AI Advisor and should not be construed as a Medical Advise.
2. Before taking any action, it is recommended to consult a Medical Practitioner.'''
st.markdown(notes)