Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +98 -0
- requirements.txt +7 -0
- symptoms_1.txt +200 -0
app.py
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cohere
|
2 |
+
import streamlit as st
|
3 |
+
from serpapi import GoogleSearch
|
4 |
+
import requests
|
5 |
+
from geopy.geocoders import Nominatim
|
6 |
+
from PIL import Image
|
7 |
+
from io import BytesIO
|
8 |
+
|
9 |
+
st.title("Hi there!👨⚕️🩺")
|
10 |
+
st.title("Welcome to *Virtual Diagnosis*")
|
11 |
+
st.write("> **This app is meant to assist medical professionals ONLY**")
|
12 |
+
|
13 |
+
co = cohere.Client('QV5Gd5mELJPltvQm4kN8EH4ORFycFlun14ulhhSf')
|
14 |
+
prompt = st.text_input('What are the symptoms of your patient? (*Try to keep the symptoms meaningful*)')
|
15 |
+
geolocator = Nominatim(user_agent="geoapiExercises")
|
16 |
+
|
17 |
+
def get_coordinates(location):
|
18 |
+
try:
|
19 |
+
location = geolocator.geocode(location)
|
20 |
+
return (location.latitude, location.longitude)
|
21 |
+
except:
|
22 |
+
return None
|
23 |
+
|
24 |
+
with open(r'C:\Users\vishwebh\Desktop\COHERE HACKATHON\symptoms_1.txt', 'r') as file:
|
25 |
+
symptoms = [line.strip().lower() for line in file]
|
26 |
+
if prompt:
|
27 |
+
if any(symptom in prompt.lower() for symptom in symptoms):
|
28 |
+
response = co.generate(
|
29 |
+
model = 'command-xlarge-nightly', #xlarge #medium #small
|
30 |
+
prompt = f"user: Suggest prescription medications for these symptoms: {prompt}\nTLDR:", #
|
31 |
+
max_tokens=300,
|
32 |
+
temperature=0.9,
|
33 |
+
k=0,
|
34 |
+
p=0.75,
|
35 |
+
frequency_penalty=0,
|
36 |
+
presence_penalty=0,
|
37 |
+
stop_sequences=[],
|
38 |
+
return_likelihoods='NONE'
|
39 |
+
)
|
40 |
+
|
41 |
+
text = format(response.generations[0].text)
|
42 |
+
st.write('Prescription medications: %s' %text)
|
43 |
+
st.download_button('Download example prescriptions', text)
|
44 |
+
print("done!")
|
45 |
+
|
46 |
+
|
47 |
+
params = {
|
48 |
+
"engine": "google_shopping",
|
49 |
+
"google_domain": "google.com",
|
50 |
+
"q": text,
|
51 |
+
"api_key": "5fab2158fd9fa6cb16925fd2ae13dc7d62d369d3b882074a8ab5a1a7225a034c" #"47e0ad25f66753bef13f195a4700f446bde4100454876d5ac6445c3822814b7b"
|
52 |
+
}
|
53 |
+
|
54 |
+
search = GoogleSearch(params)
|
55 |
+
items = search.get_dict()
|
56 |
+
|
57 |
+
|
58 |
+
for key, result in items.items():
|
59 |
+
if "google_shopping_url" in result:
|
60 |
+
st.caption(f'<a href="{result["google_shopping_url"]}">Click here for Google search page', unsafe_allow_html=True)
|
61 |
+
else:
|
62 |
+
pass
|
63 |
+
|
64 |
+
for i in range(10):
|
65 |
+
item = items['shopping_results'][i]
|
66 |
+
response = requests.get(item['thumbnail'])
|
67 |
+
st.image(Image.open(BytesIO(response.content)),
|
68 |
+
caption=item['title'], width=400)
|
69 |
+
st.text(item['source'])
|
70 |
+
st.text(item['price'])
|
71 |
+
st.caption(f'<a href="{item["link"]}">Click to buy</a>', unsafe_allow_html=True)
|
72 |
+
|
73 |
+
|
74 |
+
address = st.text_input("Enter your location to search pharmacies near you: ( For best results, enter location in this *format: Area, City, Country*.)")
|
75 |
+
|
76 |
+
if address:
|
77 |
+
coordinates = get_coordinates(address)
|
78 |
+
params = {
|
79 |
+
"engine": "google_maps",
|
80 |
+
"q": "Pharmacies",
|
81 |
+
"ll": "@" + str(coordinates[0]) + "," + str(coordinates[1]) + ",15.1z",
|
82 |
+
"type": "search",
|
83 |
+
"api_key": "5fab2158fd9fa6cb16925fd2ae13dc7d62d369d3b882074a8ab5a1a7225a034c" #"47e0ad25f66753bef13f195a4700f446bde4100454876d5ac6445c3822814b7b"
|
84 |
+
}
|
85 |
+
|
86 |
+
search = GoogleSearch(params)
|
87 |
+
results = search.get_dict()
|
88 |
+
local_results = results["local_results"]
|
89 |
+
for x in range(5):
|
90 |
+
st.write("Name of pharmacy: ", local_results[x]["title"])
|
91 |
+
st.write("address of pharmacy: ", local_results[x]["address"])
|
92 |
+
|
93 |
+
print(type(local_results))
|
94 |
+
|
95 |
+
st.image()
|
96 |
+
|
97 |
+
else:
|
98 |
+
st.write("Kindly pertain your inputs to possible medical symptoms only. Or try rephrasing.")
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cohere
|
2 |
+
streamlit
|
3 |
+
google-search-results
|
4 |
+
requests
|
5 |
+
geopy
|
6 |
+
Pillow
|
7 |
+
io
|
symptoms_1.txt
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Head
|
2 |
+
Forehead
|
3 |
+
Scalp
|
4 |
+
Face
|
5 |
+
Mouth
|
6 |
+
Throat
|
7 |
+
Nose
|
8 |
+
Ears
|
9 |
+
Eyes
|
10 |
+
Neck
|
11 |
+
Chest
|
12 |
+
Stomach
|
13 |
+
Back
|
14 |
+
Abdomen
|
15 |
+
Torso
|
16 |
+
Shoulders
|
17 |
+
Arms
|
18 |
+
Elbows
|
19 |
+
Wrists
|
20 |
+
Hands
|
21 |
+
Fingers
|
22 |
+
Hips
|
23 |
+
Legs
|
24 |
+
Knees
|
25 |
+
Ankles
|
26 |
+
Feet
|
27 |
+
Toes
|
28 |
+
Ovaries
|
29 |
+
Uterus
|
30 |
+
Fallopian tubes
|
31 |
+
Vagina
|
32 |
+
Testicles
|
33 |
+
Penis
|
34 |
+
Prostate gland
|
35 |
+
Fever
|
36 |
+
Cough
|
37 |
+
Headache
|
38 |
+
Fatigue
|
39 |
+
Muscle aches
|
40 |
+
Shortness of breath
|
41 |
+
Chest pain
|
42 |
+
Nausea
|
43 |
+
Vomiting
|
44 |
+
Diarrhea
|
45 |
+
Sore throat
|
46 |
+
Runny nose
|
47 |
+
Stuffy nose
|
48 |
+
Body aches
|
49 |
+
Rash
|
50 |
+
Joint pain
|
51 |
+
Abdominal pain
|
52 |
+
Loss of appetite
|
53 |
+
Blurred vision
|
54 |
+
Dizziness
|
55 |
+
Insomnia
|
56 |
+
Depression
|
57 |
+
Anxiety
|
58 |
+
Chest tightness
|
59 |
+
Back pain
|
60 |
+
Constipation
|
61 |
+
Heartburn
|
62 |
+
Drowsiness
|
63 |
+
Dry mouth
|
64 |
+
Sweating
|
65 |
+
Tingling or numbness in the limbs
|
66 |
+
Tiredness
|
67 |
+
Confusion
|
68 |
+
Forgetfulness
|
69 |
+
Seizures
|
70 |
+
Muscle weakness
|
71 |
+
Stiff neck
|
72 |
+
Tenderness or swelling in the limbs
|
73 |
+
Trouble breathing
|
74 |
+
Trouble speaking
|
75 |
+
Trouble swallowing
|
76 |
+
Trouble seeing
|
77 |
+
Trouble hearing
|
78 |
+
Tremors
|
79 |
+
Urinary incontinence
|
80 |
+
Urinary frequency
|
81 |
+
Weight gain or loss
|
82 |
+
Blackouts or fainting
|
83 |
+
Bruising easily
|
84 |
+
Changes in skin color
|
85 |
+
Changes in skin texture
|
86 |
+
Changes in skin temperature
|
87 |
+
Chills
|
88 |
+
Dehydration
|
89 |
+
Delirium
|
90 |
+
Delusions
|
91 |
+
Difficulty concentrating
|
92 |
+
Difficulty sleeping
|
93 |
+
Difficulty walking
|
94 |
+
Disorientation
|
95 |
+
Excessive thirst
|
96 |
+
Excessive hunger
|
97 |
+
Excessive urination
|
98 |
+
Eye pain
|
99 |
+
Eye redness
|
100 |
+
Eye swelling
|
101 |
+
Eyelid swelling
|
102 |
+
Fatigue or weakness
|
103 |
+
Feelings of hopelessness
|
104 |
+
Hallucinations
|
105 |
+
Hives
|
106 |
+
Impotence
|
107 |
+
Irregular heartbeat
|
108 |
+
Irritability
|
109 |
+
Itching
|
110 |
+
Lack of coordination
|
111 |
+
Lightheadedness
|
112 |
+
Loss of balance
|
113 |
+
Loss of consciousness
|
114 |
+
Loss of motivation
|
115 |
+
Menstrual changes
|
116 |
+
Mood swings
|
117 |
+
Numbness or tingling
|
118 |
+
Paleness
|
119 |
+
Paranoia
|
120 |
+
Poor concentration
|
121 |
+
Rapid heartbeat
|
122 |
+
Severe headache
|
123 |
+
Skin redness
|
124 |
+
Sleepiness
|
125 |
+
Slow heartbeat
|
126 |
+
Speech changes
|
127 |
+
Swelling in the limbs
|
128 |
+
Unusual thirst
|
129 |
+
Abnormal bleeding
|
130 |
+
Abnormal discharge
|
131 |
+
Abnormal heartbeat
|
132 |
+
Abnormal sweating
|
133 |
+
Abnormal urine color
|
134 |
+
Abnormal urine odor
|
135 |
+
Agitation
|
136 |
+
Air hunger
|
137 |
+
Altered taste
|
138 |
+
Altered vision
|
139 |
+
Amnesia
|
140 |
+
Aphasia
|
141 |
+
Appetite changes
|
142 |
+
Arrhythmia
|
143 |
+
Back pain
|
144 |
+
Blind spots
|
145 |
+
Bloating
|
146 |
+
Blood
|
147 |
+
Blood in urine
|
148 |
+
Blood pressure changes
|
149 |
+
Blue lips or face
|
150 |
+
Body odor
|
151 |
+
Brittle nails
|
152 |
+
Bruising easily
|
153 |
+
Chest pain
|
154 |
+
Chest tightness
|
155 |
+
Choking
|
156 |
+
Clumsiness
|
157 |
+
Coldness in hands and feet
|
158 |
+
Coma
|
159 |
+
Confusion
|
160 |
+
Convulsions
|
161 |
+
Coughing up blood
|
162 |
+
Crying easily
|
163 |
+
Decreased appetite
|
164 |
+
Decreased libido
|
165 |
+
Decreased urine output
|
166 |
+
Delirium
|
167 |
+
Delusions
|
168 |
+
Dementia
|
169 |
+
Depression
|
170 |
+
Derealization
|
171 |
+
Diaphoresis
|
172 |
+
Difficulty breathing
|
173 |
+
Difficulty speaking
|
174 |
+
Difficulty swallowing
|
175 |
+
Difficulty urinating
|
176 |
+
Dilation of pupils
|
177 |
+
Disorientation
|
178 |
+
Dizziness
|
179 |
+
Double vision
|
180 |
+
Pain
|
181 |
+
Fatigue
|
182 |
+
Headache
|
183 |
+
Nausea
|
184 |
+
Loss of appetite
|
185 |
+
Shortness of breath
|
186 |
+
Chest pain or pressure
|
187 |
+
Dizziness or lightheadedness
|
188 |
+
Changes in vision
|
189 |
+
Coughing
|
190 |
+
Muscle weakness
|
191 |
+
Joint pain or swelling
|
192 |
+
Skin rash or discoloration
|
193 |
+
Changes in bowel or bladder function
|
194 |
+
Rapid heartbeat or palpitations
|
195 |
+
Fever or chills
|
196 |
+
Sweating or night sweats
|
197 |
+
Sore throat
|
198 |
+
Difficulty swallowing
|
199 |
+
Changes in speech or hearing
|
200 |
+
cold
|