rajeshk10 commited on
Commit
74c231e
1 Parent(s): 676b8fd

feat: initial commit for HealthMate-AI

Browse files
Files changed (4) hide show
  1. app.py +63 -0
  2. chat.py +49 -0
  3. checker.py +137 -0
  4. requirements.txt +0 -0
app.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from chat import langchainning
3
+ from checker import checking, health_keywords
4
+
5
+ def user_input(user):
6
+
7
+ ans = langchainning().run(user)
8
+ return ans
9
+
10
+ st.title("HealthMate-AI")
11
+ st.caption("Hi Human, How can I help you today?")
12
+
13
+ if "messages" not in st.session_state:
14
+ st.session_state.messages = []
15
+
16
+
17
+
18
+ q = st.chat_input("Type something here....")
19
+
20
+ def checking(query):
21
+ flag = False
22
+ list_of_words = query.split(" ")
23
+ for i in list_of_words:
24
+ if i.lower() in health_keywords:
25
+ flag = True
26
+ break
27
+ return flag
28
+
29
+
30
+
31
+
32
+
33
+
34
+ #
35
+ if q is not None and len(q.strip()) > 0:
36
+ if checking(q):
37
+ st.session_state.messages.append(("user", q))
38
+ st.session_state.messages.append(("assistant", user_input(q)))
39
+
40
+ for role, message in st.session_state.messages:
41
+ if role == "user":
42
+ st.chat_message("user")
43
+ st.write(message)
44
+ elif role == "assistant":
45
+ st.chat_message("assistant")
46
+ st.write(message)
47
+ else:
48
+ # st.session_state.messages.append(("user", q))
49
+ # st.session_state.messages.append(("assistant", "I'm a medical and health related chatbot. Please ask me about health or medicine."))
50
+ # for role, message in st.session_state.messages:
51
+ # if role == "user":
52
+ # st.chat_message("user")
53
+ # st.write(message)
54
+ # elif role == "assistant":
55
+ # st.chat_message("assistant")
56
+ # # st.write(message)
57
+ st.write("I'm a medical and health related chatbot. Please ask me about health or medicine.")
58
+
59
+
60
+ b = st.button("Clear Chat")
61
+ if b:
62
+ st.session_state.messages = []
63
+
chat.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from langchain_community.llms import HuggingFaceEndpoint
4
+ from langchain.chains import LLMChain
5
+ from langchain_core.prompts import PromptTemplate
6
+ from dotenv import load_dotenv
7
+
8
+ load_dotenv()
9
+
10
+
11
+
12
+ # setting the Api
13
+ model_Api = os.getenv("MY_API_KEY")
14
+ os.environ["HUGGINGFACEHUB_API_TOKEN"] = model_Api
15
+
16
+ repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
17
+
18
+ def QueryBuilding():
19
+
20
+ Query_template = """Consider yourself as a personalized professional medical assistant for the user {query},
21
+
22
+ Answer: provide guidance and support to the user in a more detailed, simple and straightforward manner. """
23
+ return Query_template
24
+
25
+ def PromptEngineering():
26
+ Prompt = PromptTemplate.from_template(QueryBuilding())
27
+ return Prompt
28
+
29
+
30
+
31
+ def LLM_building():
32
+ llm_model = HuggingFaceEndpoint(
33
+ repo_id=repo_id,
34
+ max_length = 128, # Set the maximum input length
35
+ token = model_Api # Set the API token
36
+
37
+ )
38
+ return llm_model
39
+
40
+ def langchainning():
41
+ llm_chain = LLMChain(prompt=PromptEngineering(), llm=LLM_building())
42
+ return llm_chain
43
+
44
+ # def user_input(user):
45
+ # # user = input()
46
+ # ans = langchainning().run(user)
47
+ # return ans
48
+
49
+
checker.py ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ health_keywords = ["health", "medicine", "doctor", "symptoms", "treatment", "prescription", "wellness", "medical advice",
2
+ "disease", "illness", "condition", "ailment", "infection", "fever", "cough", "headache",
3
+ "nausea", "vomiting", "diarrhea", "fatigue", "remedy", "cure", "prevention",
4
+ "diagnosis", "prognosis", "consultation", "medical history", "immunization", "vaccine",
5
+ "pharmacy", "pharmaceuticals", "side effects", "dosage", "medicine cabinet",
6
+ "healthcare provider", "general practitioner", "specialist", "nurse", "physician assistant",
7
+ "hospital", "clinic", "emergency room", "operating room", "ICU", "intensive care unit",
8
+ "primary care", "secondary care", "tertiary care", "quarantine", "isolation",
9
+ "health insurance", "coverage", "premium", "policy", "benefits", "claim",
10
+ "medical record", "electronic health record", "HIPAA", "patient confidentiality",
11
+ "medical research", "clinical trial", "medical journal", "peer-reviewed",
12
+ "public health", "epidemiology", "outbreak", "pandemic", "contagious", "transmission",
13
+ "immunity", "herd immunity", "hygiene", "sanitation", "nutrition", "diet", "exercise",
14
+ "fitness", "mental health", "stress", "anxiety", "depression", "therapy", "counseling",
15
+ "substance abuse", "addiction", "rehabilitation", "well-being", "holistic health",
16
+ "alternative medicine", "integrative medicine", "complementary medicine",
17
+ "traditional medicine", "naturopathy", "acupuncture", "homeopathy", "chiropractic",
18
+ "osteopathy", "massage therapy", "aromatherapy", "herbal medicine", "supplements",
19
+ "vitamins", "minerals", "nutritional supplements", "dietary supplements",
20
+ "nutraceuticals", "functional foods", "superfoods", "organic foods",
21
+ "genetic predisposition", "hereditary", "genetic testing", "DNA", "genomics",
22
+ "genome sequencing", "gene therapy", "stem cells", "regenerative medicine",
23
+ "precision medicine", "personalized medicine", "telemedicine", "virtual care",
24
+ "wearable technology", "health monitoring", "health tracking", "fitness tracker",
25
+ "smartwatch", "mobile health apps", "mHealth", "telehealth", "remote patient monitoring",
26
+ "anemia", "asthma", "arthritis", "diabetes", "hypertension", "hyperthyroidism",
27
+ "hypothyroidism", "migraine", "osteoporosis", "pneumonia", "stroke", "tuberculosis",
28
+ "coronary artery disease", "fibromyalgia", "chronic obstructive pulmonary disease",
29
+ "endometriosis", "gastroesophageal reflux disease", "irritable bowel syndrome",
30
+ "multiple sclerosis", "Parkinson's disease", "Alzheimer's disease", "schizophrenia",
31
+ "bipolar disorder", "post-traumatic stress disorder", "cancer", "leukemia", "lymphoma",
32
+ "melanoma", "breast cancer", "colon cancer", "lung cancer", "prostate cancer",
33
+ "skin cancer", "heart attack", "cardiac arrest", "arrhythmia", "congestive heart failure",
34
+ "kidney stones", "urinary tract infection", "gastroenteritis", "appendicitis",
35
+ "concussion", "fracture", "sprain", "strain", "pneumothorax", "hypoglycemia",
36
+ "hyperglycemia", "anaphylaxis", "sepsis", "hypotension", "hypertension",
37
+ "pulmonary embolism", "deep vein thrombosis", "cirrhosis", "hepatitis", "pancreatitis",
38
+ "diverticulitis", "gastritis", "peptic ulcer disease", "celiac disease", "Crohn's disease",
39
+ "ulcerative colitis", "gout", "rheumatoid arthritis", "lupus", "psoriasis",
40
+ "eczema", "acne", "rosacea", "warts", "genital herpes", "gonorrhea", "syphilis",
41
+ "chlamydia", "HIV", "AIDS", "influenza", "common cold", "bronchitis", "sinusitis",
42
+ "tonsillitis", "pharyngitis", "otitis media", "conjunctivitis", "glaucoma",
43
+ "cataracts", "macular degeneration", "amblyopia", "strabismus", "myopia", "hyperopia",
44
+ "astigmatism", "presbyopia", "cataract surgery", "LASIK", "contact lenses",
45
+ "orthokeratology", "retinal detachment", "retinopathy", "macular edema",
46
+ "keratoconus", "uveitis", "iritis", "keratitis", "corneal ulcer", "conjunctival hemorrhage",
47
+ "corneal abrasion", "retinal vein occlusion", "retinal artery occlusion",
48
+ "central retinal vein occlusion", "central retinal artery occlusion", "retinal tear",
49
+ "retinal detachment", "macular hole", "macular pucker", "epiretinal membrane",
50
+ "diabetic retinopathy", "hypertensive retinopathy", "retinal degeneration",
51
+ "retinal detachment", "retinitis pigmentosa", "macular degeneration",
52
+ "optic neuritis", "optic neuropathy", "glaucoma", "uveitis", "iritis", "retinal detachment",
53
+ "keratoconus", "corneal dystrophy", "corneal ulcer", "conjunctivitis", "blepharitis",
54
+ "chalazion", "stye", "papilledema", "conjunctival cyst", "conjunctival tumor",
55
+ "corneal abrasion", "corneal foreign body", "corneal perforation", "corneal ulcer",
56
+ "eye pain", "blurry vision", "double vision", "flashes of light", "floaters",
57
+ "redness", "itchiness", "tearing", "burning sensation", "foreign body sensation",
58
+ "sensitivity to light", "bulging eye", "sunken eye", "abnormal eye movement",
59
+ "watery eye", "dry eye", "swelling", "lump or mass", "discharge", "crusting",
60
+ "drooping eyelid", "crossed eyes", "lazy eye", "loss of vision", "changes in vision",
61
+ "glaucoma", "cataracts", "macular degeneration", "diabetic retinopathy",
62
+ "retinal detachment", "eye injury", "trauma to the eye", "blow to the eye",
63
+ "foreign object in the eye", "chemical burn to the eye", "eye infection",
64
+ "conjunctivitis", "corneal ulcer", "keratitis", "uveitis", "iritis", "endophthalmitis",
65
+ "retinal vein occlusion", "retinal artery occlusion", "optic neuritis", "optic neuropathy",
66
+ "papilledema", "papillitis", "optic nerve atrophy", "optic nerve compression",
67
+ "optic nerve tumor", "optic glioma", "orbital cellulitis", "orbital tumor",
68
+ "orbital fracture", "eyelid laceration", "eye tumor", "eye cancer", "eye melanoma",
69
+ "eye lymphoma", "choroidal melanoma", "retinoblastoma", "eye stroke", "visual snow",
70
+ "ocular migraine", "ocular histoplasmosis", "ocular toxoplasmosis", "ocular syphilis",
71
+ "ocular tuberculosis", "ocular sarcoidosis", "ocular herpes", "ocular shingles",
72
+ "ocular pemphigoid", "ocular cicatricial pemphigoid", "ocular graft-versus-host disease",
73
+ "ocular surface disease", "ocular rosacea", "ocular allergies", "ocular surface tumor",
74
+ "ocular surface cancer", "ocular surface melanoma", "ocular surface lymphoma",
75
+ "ocular surface squamous neoplasia", "ocular surface carcinoma", "uveitis",
76
+ "anterior uveitis", "posterior uveitis", "intermediate uveitis", "panuveitis",
77
+ "scleritis", "episcleritis", "iridocyclitis", "iriditis", "choroiditis", "chorioretinitis",
78
+ "pars planitis", "vogt-koyanagi-harada syndrome", "sympathetic ophthalmia",
79
+ "birdshot chorioretinopathy", "retinitis", "retinal vasculitis", "serpiginous choroiditis",
80
+ "necrotizing retinitis", "herpetic retinitis", "cytomegalovirus retinitis", "toxoplasma retinitis",
81
+ "acute retinal necrosis", "fungal retinitis", "parasitic retinitis", "interstitial keratitis",
82
+ "neuroretinitis", "retinal artery occlusion", "central retinal artery occlusion",
83
+ "branch retinal artery occlusion", "retinal vein occlusion", "central retinal vein occlusion",
84
+ "branch retinal vein occlusion", "macular edema", "macular hole", "macular pucker",
85
+ "epiretinal membrane", "macular degeneration", "wet macular degeneration", "dry macular degeneration",
86
+ "geographic atrophy", "macular ischemia", "central serous chorioretinopathy", "submacular hemorrhage",
87
+ "subretinal hemorrhage", "choroidal neovascularization", "angioid streaks",
88
+ "drusen", "retinal pigment epithelial detachment", "choroidal detachment", "vitreous hemorrhage",
89
+ "vitreous detachment", "vitreomacular traction", "retinoschisis", "retinal detachment",
90
+ "rhegmatogenous retinal detachment", "tractional retinal detachment", "exudative retinal detachment",
91
+ "familial exudative vitreoretinopathy", "retinal tear", "retinal break", "macular tear",
92
+ "retinal dialysis", "retinal hole", "retinal avulsion", "retinal detachment with giant tear",
93
+ "posterior vitreous detachment", "posterior vitreous detachment with retinal tear",
94
+ "retinal detachment with proliferative vitreoretinopathy", "macular retinoschisis",
95
+ "vitreous hemorrhage", "subretinal hemorrhage", "intraretinal hemorrhage",
96
+ "retinal hemorrhage", "choroidal hemorrhage", "hyphema", "vitreal hemorrhage",
97
+ "vitreous floaters", "retinal pigment epithelial detachment", "macular hemorrhage",
98
+ "macular neovascularization", "choroidal neovascularization", "angioid streaks",
99
+ "punctate inner choroidopathy", "multifocal choroiditis", "ocular histoplasmosis syndrome",
100
+ "presumed ocular histoplasmosis syndrome", "myopic choroidal neovascularization",
101
+ "pathologic myopia", "malignant myopia", "posterior staphyloma", "macular hole",
102
+ "macular pseudohole", "macular lamellar hole", "full-thickness macular hole",
103
+ "lamellar macular hole", "myopic macular hole", "idiopathic macular hole",
104
+ "secondary macular hole", "traumatic macular hole", "macular cyst", "macular edema",
105
+ "cystoid macular edema", "diffuse macular edema", "macular cystoid edema",
106
+ "cystoid macular edema", "macular telangiectasia", "macular retinal telangiectasia",
107
+ "macular capillary telangiectasia", "juxtafoveal telangiectasia", "paramacular telangiectasia",
108
+ "perifoveal telangiectasia", "perifoveal telangiectasia", "perifoveal retinal telangiectasia",
109
+ "perifoveal capillary telangiectasia", "retinal telangiectasia", "retinal capillary telangiectasia",
110
+ "macular pucker", "macular epiretinal membrane", "idiopathic macular pucker",
111
+ "secondary macular pucker", "traumatic macular pucker", "epiretinal membrane",
112
+ "macular cyst", "macular pseudocyst", "macular schisis", "macular schisis with detachment",
113
+ "myopic macular schisis", "idiopathic macular schisis", "secondary macular schisis",
114
+ "traumatic macular schisis", "familial exudative vitreoretinopathy", "Coats' disease",
115
+ "retinopathy of prematurity", "retinal dystrophy", "retinitis pigmentosa",
116
+ "Leber's congenital amaurosis", "Stargardt disease", "choroideremia", "gyrate atrophy",
117
+ "achromatopsia", "cone dystrophy", "cone-rod dystrophy", "cone-rod retinal dystrophy",
118
+ "rod-cone dystrophy", "rod-cone retinal dystrophy", "night blindness",
119
+ "nyctalopia", "tunnel vision", "peripheral vision loss", "color vision deficiency",
120
+ "color blindness", "red-green color blindness", "blue-yellow color", "headache", "cancer" ]
121
+
122
+
123
+ def checking(query):
124
+ flag = False
125
+ list_of_words = query.split(" ")
126
+ for i in list_of_words:
127
+ if i.lower() in health_keywords:
128
+ flag = True
129
+ break
130
+ return flag
131
+
132
+
133
+ # if checking("i have an headache"):
134
+ # print("sucess")
135
+ # else:
136
+ # print("failed")
137
+
requirements.txt ADDED
Binary file (2.66 kB). View file