CobaltZvc commited on
Commit
5bf91a7
·
1 Parent(s): dd0e1bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -1
app.py CHANGED
@@ -12,6 +12,7 @@ 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):
@@ -91,4 +92,33 @@ if prompt:
91
  st.write("address of pharmacy: ", local_results[x]["address"])
92
 
93
  else:
94
- st.write("Kindly pertain your inputs to possible medical symptoms only. Or try rephrasing.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ prompt_med = st.text_input('Search a medicine here: (*Enter the correct spelling of the medicine*)')
16
  geolocator = Nominatim(user_agent="geoapiExercises")
17
 
18
  def get_coordinates(location):
 
92
  st.write("address of pharmacy: ", local_results[x]["address"])
93
 
94
  else:
95
+ st.write("Kindly pertain your inputs to possible medical symptoms only. Or try rephrasing.")
96
+
97
+ if prompt_med:
98
+ params = {
99
+ "engine": "google_shopping",
100
+ "google_domain": "google.com",
101
+ "q": f"{prompt_med} medicine",
102
+ "hl": "en",
103
+ # "gl": "in",
104
+ "api_key": "5fab2158fd9fa6cb16925fd2ae13dc7d62d369d3b882074a8ab5a1a7225a034c" #"47e0ad25f66753bef13f195a4700f446bde4100454876d5ac6445c3822814b7b"
105
+ }
106
+
107
+ search = GoogleSearch(params)
108
+ items = search.get_dict()
109
+
110
+
111
+ for key, result in items.items():
112
+ if "google_shopping_url" in result:
113
+ st.caption(f'<a href="{result["google_shopping_url"]}">Click here for Google search page', unsafe_allow_html=True)
114
+ else:
115
+ pass
116
+
117
+ for i in range(10):
118
+ item = items['shopping_results'][i]
119
+ response = requests.get(item['thumbnail'])
120
+ st.image(Image.open(BytesIO(response.content)),
121
+ caption=item['title'], width=400)
122
+ st.text(item['source'])
123
+ st.text(item['price'])
124
+ st.caption(f'<a href="{item["link"]}">Click to buy</a>', unsafe_allow_html=True)