Spaces:
Running
Running
hanoch.rahimi@gmail
commited on
Commit
·
56ce28d
1
Parent(s):
5c9ea55
added map with pins
Browse files- app.py +10 -0
- data/countries.csv +246 -0
app.py
CHANGED
@@ -4,6 +4,7 @@ from langchain.chains import RetrievalQA
|
|
4 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
5 |
from langchain.prompts import PromptTemplate
|
6 |
from langchain.vectorstores import Pinecone
|
|
|
7 |
from streamlit.runtime.state import session_state
|
8 |
import openai
|
9 |
import streamlit as st
|
@@ -25,6 +26,8 @@ embed = OpenAIEmbeddings(
|
|
25 |
|
26 |
st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
|
27 |
|
|
|
|
|
28 |
|
29 |
st.session_state.index = utils.init_pinecone()
|
30 |
|
@@ -207,6 +210,7 @@ def run_query(query, report_type, top_k , regions, countries, is_debug, index_na
|
|
207 |
# """
|
208 |
list_html = "<div class='container-fluid'>"
|
209 |
|
|
|
210 |
for r in sorted_results:
|
211 |
company_name = r["name"]
|
212 |
if company_name in names:
|
@@ -222,9 +226,15 @@ def run_query(query, report_type, top_k , regions, countries, is_debug, index_na
|
|
222 |
region = r["metadata"]["region"]
|
223 |
country = r["metadata"]["country"]
|
224 |
company_id = r["metadata"]["company_id"]
|
|
|
|
|
225 |
list_html = list_html + card(company_id, company_name, description, score, data_type, region, country, r['data'], is_debug)
|
226 |
|
227 |
list_html = list_html + '</div>'
|
|
|
|
|
|
|
|
|
228 |
st.markdown(list_html, unsafe_allow_html=True)
|
229 |
|
230 |
|
|
|
4 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
5 |
from langchain.prompts import PromptTemplate
|
6 |
from langchain.vectorstores import Pinecone
|
7 |
+
import pandas as pd
|
8 |
from streamlit.runtime.state import session_state
|
9 |
import openai
|
10 |
import streamlit as st
|
|
|
26 |
|
27 |
st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
|
28 |
|
29 |
+
COUNTRIES_FN="data/countries.csv"
|
30 |
+
country_geo = pd.read_csv(COUNTRIES_FN)
|
31 |
|
32 |
st.session_state.index = utils.init_pinecone()
|
33 |
|
|
|
210 |
# """
|
211 |
list_html = "<div class='container-fluid'>"
|
212 |
|
213 |
+
locations = set()
|
214 |
for r in sorted_results:
|
215 |
company_name = r["name"]
|
216 |
if company_name in names:
|
|
|
226 |
region = r["metadata"]["region"]
|
227 |
country = r["metadata"]["country"]
|
228 |
company_id = r["metadata"]["company_id"]
|
229 |
+
|
230 |
+
locations.add(country)
|
231 |
list_html = list_html + card(company_id, company_name, description, score, data_type, region, country, r['data'], is_debug)
|
232 |
|
233 |
list_html = list_html + '</div>'
|
234 |
+
|
235 |
+
pins = country_geo[country_geo['name'].isin(locations)].loc[:, ['latitude', 'longitude']]
|
236 |
+
|
237 |
+
st.map(pins)
|
238 |
st.markdown(list_html, unsafe_allow_html=True)
|
239 |
|
240 |
|
data/countries.csv
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
country,latitude,longitude,name
|
2 |
+
AD,42.546245,1.601554,Andorra
|
3 |
+
AE,23.424076,53.847818,"United Arab Emirates"
|
4 |
+
AF,33.93911,67.709953,Afghanistan
|
5 |
+
AG,17.060816,-61.796428,"Antigua and Barbuda"
|
6 |
+
AI,18.220554,-63.068615,Anguilla
|
7 |
+
AL,41.153332,20.168331,Albania
|
8 |
+
AM,40.069099,45.038189,Armenia
|
9 |
+
AN,12.226079,-69.060087,"Netherlands Antilles"
|
10 |
+
AO,-11.202692,17.873887,Angola
|
11 |
+
AQ,-75.250973,-0.071389,Antarctica
|
12 |
+
AR,-38.416097,-63.616672,Argentina
|
13 |
+
AS,-14.270972,-170.132217,"American Samoa"
|
14 |
+
AT,47.516231,14.550072,Austria
|
15 |
+
AU,-25.274398,133.775136,Australia
|
16 |
+
AW,12.52111,-69.968338,Aruba
|
17 |
+
AZ,40.143105,47.576927,Azerbaijan
|
18 |
+
BA,43.915886,17.679076,"Bosnia and Herzegovina"
|
19 |
+
BB,13.193887,-59.543198,Barbados
|
20 |
+
BD,23.684994,90.356331,Bangladesh
|
21 |
+
BE,50.503887,4.469936,Belgium
|
22 |
+
BF,12.238333,-1.561593,"Burkina Faso"
|
23 |
+
BG,42.733883,25.48583,Bulgaria
|
24 |
+
BH,25.930414,50.637772,Bahrain
|
25 |
+
BI,-3.373056,29.918886,Burundi
|
26 |
+
BJ,9.30769,2.315834,Benin
|
27 |
+
BM,32.321384,-64.75737,Bermuda
|
28 |
+
BN,4.535277,114.727669,Brunei
|
29 |
+
BO,-16.290154,-63.588653,Bolivia
|
30 |
+
BR,-14.235004,-51.92528,Brazil
|
31 |
+
BS,25.03428,-77.39628,Bahamas
|
32 |
+
BT,27.514162,90.433601,Bhutan
|
33 |
+
BV,-54.423199,3.413194,"Bouvet Island"
|
34 |
+
BW,-22.328474,24.684866,Botswana
|
35 |
+
BY,53.709807,27.953389,Belarus
|
36 |
+
BZ,17.189877,-88.49765,Belize
|
37 |
+
CA,56.130366,-106.346771,Canada
|
38 |
+
CC,-12.164165,96.870956,"Cocos [Keeling] Islands"
|
39 |
+
CD,-4.038333,21.758664,"Congo [DRC]"
|
40 |
+
CF,6.611111,20.939444,"Central African Republic"
|
41 |
+
CG,-0.228021,15.827659,"Congo [Republic]"
|
42 |
+
CH,46.818188,8.227512,Switzerland
|
43 |
+
CI,7.539989,-5.54708,"Côte d'Ivoire"
|
44 |
+
CK,-21.236736,-159.777671,"Cook Islands"
|
45 |
+
CL,-35.675147,-71.542969,Chile
|
46 |
+
CM,7.369722,12.354722,Cameroon
|
47 |
+
CN,35.86166,104.195397,China
|
48 |
+
CO,4.570868,-74.297333,Colombia
|
49 |
+
CR,9.748917,-83.753428,"Costa Rica"
|
50 |
+
CU,21.521757,-77.781167,Cuba
|
51 |
+
CV,16.002082,-24.013197,"Cape Verde"
|
52 |
+
CX,-10.447525,105.690449,"Christmas Island"
|
53 |
+
CY,35.126413,33.429859,Cyprus
|
54 |
+
CZ,49.817492,15.472962,"Czech Republic"
|
55 |
+
DE,51.165691,10.451526,Germany
|
56 |
+
DJ,11.825138,42.590275,Djibouti
|
57 |
+
DK,56.26392,9.501785,Denmark
|
58 |
+
DM,15.414999,-61.370976,Dominica
|
59 |
+
DO,18.735693,-70.162651,"Dominican Republic"
|
60 |
+
DZ,28.033886,1.659626,Algeria
|
61 |
+
EC,-1.831239,-78.183406,Ecuador
|
62 |
+
EE,58.595272,25.013607,Estonia
|
63 |
+
EG,26.820553,30.802498,Egypt
|
64 |
+
EH,24.215527,-12.885834,"Western Sahara"
|
65 |
+
ER,15.179384,39.782334,Eritrea
|
66 |
+
ES,40.463667,-3.74922,Spain
|
67 |
+
ET,9.145,40.489673,Ethiopia
|
68 |
+
FI,61.92411,25.748151,Finland
|
69 |
+
FJ,-16.578193,179.414413,Fiji
|
70 |
+
FK,-51.796253,-59.523613,"Falkland Islands [Islas Malvinas]"
|
71 |
+
FM,7.425554,150.550812,Micronesia
|
72 |
+
FO,61.892635,-6.911806,"Faroe Islands"
|
73 |
+
FR,46.227638,2.213749,France
|
74 |
+
GA,-0.803689,11.609444,Gabon
|
75 |
+
GB,55.378051,-3.435973,"United Kingdom"
|
76 |
+
GD,12.262776,-61.604171,Grenada
|
77 |
+
GE,42.315407,43.356892,Georgia
|
78 |
+
GF,3.933889,-53.125782,"French Guiana"
|
79 |
+
GG,49.465691,-2.585278,Guernsey
|
80 |
+
GH,7.946527,-1.023194,Ghana
|
81 |
+
GI,36.137741,-5.345374,Gibraltar
|
82 |
+
GL,71.706936,-42.604303,Greenland
|
83 |
+
GM,13.443182,-15.310139,Gambia
|
84 |
+
GN,9.945587,-9.696645,Guinea
|
85 |
+
GP,16.995971,-62.067641,Guadeloupe
|
86 |
+
GQ,1.650801,10.267895,"Equatorial Guinea"
|
87 |
+
GR,39.074208,21.824312,Greece
|
88 |
+
GS,-54.429579,-36.587909,"South Georgia and the South Sandwich Islands"
|
89 |
+
GT,15.783471,-90.230759,Guatemala
|
90 |
+
GU,13.444304,144.793731,Guam
|
91 |
+
GW,11.803749,-15.180413,Guinea-Bissau
|
92 |
+
GY,4.860416,-58.93018,Guyana
|
93 |
+
GZ,31.354676,34.308825,"Gaza Strip"
|
94 |
+
HK,22.396428,114.109497,"Hong Kong"
|
95 |
+
HM,-53.08181,73.504158,"Heard Island and McDonald Islands"
|
96 |
+
HN,15.199999,-86.241905,Honduras
|
97 |
+
HR,45.1,15.2,Croatia
|
98 |
+
HT,18.971187,-72.285215,Haiti
|
99 |
+
HU,47.162494,19.503304,Hungary
|
100 |
+
ID,-0.789275,113.921327,Indonesia
|
101 |
+
IE,53.41291,-8.24389,Ireland
|
102 |
+
IL,31.046051,34.851612,Israel
|
103 |
+
IM,54.236107,-4.548056,"Isle of Man"
|
104 |
+
IN,20.593684,78.96288,India
|
105 |
+
IO,-6.343194,71.876519,"British Indian Ocean Territory"
|
106 |
+
IQ,33.223191,43.679291,Iraq
|
107 |
+
IR,32.427908,53.688046,Iran
|
108 |
+
IS,64.963051,-19.020835,Iceland
|
109 |
+
IT,41.87194,12.56738,Italy
|
110 |
+
JE,49.214439,-2.13125,Jersey
|
111 |
+
JM,18.109581,-77.297508,Jamaica
|
112 |
+
JO,30.585164,36.238414,Jordan
|
113 |
+
JP,36.204824,138.252924,Japan
|
114 |
+
KE,-0.023559,37.906193,Kenya
|
115 |
+
KG,41.20438,74.766098,Kyrgyzstan
|
116 |
+
KH,12.565679,104.990963,Cambodia
|
117 |
+
KI,-3.370417,-168.734039,Kiribati
|
118 |
+
KM,-11.875001,43.872219,Comoros
|
119 |
+
KN,17.357822,-62.782998,"Saint Kitts and Nevis"
|
120 |
+
KP,40.339852,127.510093,"North Korea"
|
121 |
+
KR,35.907757,127.766922,"South Korea"
|
122 |
+
KW,29.31166,47.481766,Kuwait
|
123 |
+
KY,19.513469,-80.566956,"Cayman Islands"
|
124 |
+
KZ,48.019573,66.923684,Kazakhstan
|
125 |
+
LA,19.85627,102.495496,Laos
|
126 |
+
LB,33.854721,35.862285,Lebanon
|
127 |
+
LC,13.909444,-60.978893,"Saint Lucia"
|
128 |
+
LI,47.166,9.555373,Liechtenstein
|
129 |
+
LK,7.873054,80.771797,"Sri Lanka"
|
130 |
+
LR,6.428055,-9.429499,Liberia
|
131 |
+
LS,-29.609988,28.233608,Lesotho
|
132 |
+
LT,55.169438,23.881275,Lithuania
|
133 |
+
LU,49.815273,6.129583,Luxembourg
|
134 |
+
LV,56.879635,24.603189,Latvia
|
135 |
+
LY,26.3351,17.228331,Libya
|
136 |
+
MA,31.791702,-7.09262,Morocco
|
137 |
+
MC,43.750298,7.412841,Monaco
|
138 |
+
MD,47.411631,28.369885,Moldova
|
139 |
+
ME,42.708678,19.37439,Montenegro
|
140 |
+
MG,-18.766947,46.869107,Madagascar
|
141 |
+
MH,7.131474,171.184478,"Marshall Islands"
|
142 |
+
MK,41.608635,21.745275,"Macedonia [FYROM]"
|
143 |
+
ML,17.570692,-3.996166,Mali
|
144 |
+
MM,21.913965,95.956223,"Myanmar [Burma]"
|
145 |
+
MN,46.862496,103.846656,Mongolia
|
146 |
+
MO,22.198745,113.543873,Macau
|
147 |
+
MP,17.33083,145.38469,"Northern Mariana Islands"
|
148 |
+
MQ,14.641528,-61.024174,Martinique
|
149 |
+
MR,21.00789,-10.940835,Mauritania
|
150 |
+
MS,16.742498,-62.187366,Montserrat
|
151 |
+
MT,35.937496,14.375416,Malta
|
152 |
+
MU,-20.348404,57.552152,Mauritius
|
153 |
+
MV,3.202778,73.22068,Maldives
|
154 |
+
MW,-13.254308,34.301525,Malawi
|
155 |
+
MX,23.634501,-102.552784,Mexico
|
156 |
+
MY,4.210484,101.975766,Malaysia
|
157 |
+
MZ,-18.665695,35.529562,Mozambique
|
158 |
+
NA,-22.95764,18.49041,Namibia
|
159 |
+
NC,-20.904305,165.618042,"New Caledonia"
|
160 |
+
NE,17.607789,8.081666,Niger
|
161 |
+
NF,-29.040835,167.954712,"Norfolk Island"
|
162 |
+
NG,9.081999,8.675277,Nigeria
|
163 |
+
NI,12.865416,-85.207229,Nicaragua
|
164 |
+
NL,52.132633,5.291266,Netherlands
|
165 |
+
NO,60.472024,8.468946,Norway
|
166 |
+
NP,28.394857,84.124008,Nepal
|
167 |
+
NR,-0.522778,166.931503,Nauru
|
168 |
+
NU,-19.054445,-169.867233,Niue
|
169 |
+
NZ,-40.900557,174.885971,"New Zealand"
|
170 |
+
OM,21.512583,55.923255,Oman
|
171 |
+
PA,8.537981,-80.782127,Panama
|
172 |
+
PE,-9.189967,-75.015152,Peru
|
173 |
+
PF,-17.679742,-149.406843,"French Polynesia"
|
174 |
+
PG,-6.314993,143.95555,"Papua New Guinea"
|
175 |
+
PH,12.879721,121.774017,Philippines
|
176 |
+
PK,30.375321,69.345116,Pakistan
|
177 |
+
PL,51.919438,19.145136,Poland
|
178 |
+
PM,46.941936,-56.27111,"Saint Pierre and Miquelon"
|
179 |
+
PN,-24.703615,-127.439308,"Pitcairn Islands"
|
180 |
+
PR,18.220833,-66.590149,"Puerto Rico"
|
181 |
+
PS,31.952162,35.233154,"Palestinian Territories"
|
182 |
+
PT,39.399872,-8.224454,Portugal
|
183 |
+
PW,7.51498,134.58252,Palau
|
184 |
+
PY,-23.442503,-58.443832,Paraguay
|
185 |
+
QA,25.354826,51.183884,Qatar
|
186 |
+
RE,-21.115141,55.536384,Réunion
|
187 |
+
RO,45.943161,24.96676,Romania
|
188 |
+
RS,44.016521,21.005859,Serbia
|
189 |
+
RU,61.52401,105.318756,Russia
|
190 |
+
RW,-1.940278,29.873888,Rwanda
|
191 |
+
SA,23.885942,45.079162,"Saudi Arabia"
|
192 |
+
SB,-9.64571,160.156194,"Solomon Islands"
|
193 |
+
SC,-4.679574,55.491977,Seychelles
|
194 |
+
SD,12.862807,30.217636,Sudan
|
195 |
+
SE,60.128161,18.643501,Sweden
|
196 |
+
SG,1.352083,103.819836,Singapore
|
197 |
+
SH,-24.143474,-10.030696,"Saint Helena"
|
198 |
+
SI,46.151241,14.995463,Slovenia
|
199 |
+
SJ,77.553604,23.670272,"Svalbard and Jan Mayen"
|
200 |
+
SK,48.669026,19.699024,Slovakia
|
201 |
+
SL,8.460555,-11.779889,"Sierra Leone"
|
202 |
+
SM,43.94236,12.457777,"San Marino"
|
203 |
+
SN,14.497401,-14.452362,Senegal
|
204 |
+
SO,5.152149,46.199616,Somalia
|
205 |
+
SR,3.919305,-56.027783,Suriname
|
206 |
+
ST,0.18636,6.613081,"São Tomé and Príncipe"
|
207 |
+
SV,13.794185,-88.89653,"El Salvador"
|
208 |
+
SY,34.802075,38.996815,Syria
|
209 |
+
SZ,-26.522503,31.465866,Swaziland
|
210 |
+
TC,21.694025,-71.797928,"Turks and Caicos Islands"
|
211 |
+
TD,15.454166,18.732207,Chad
|
212 |
+
TF,-49.280366,69.348557,"French Southern Territories"
|
213 |
+
TG,8.619543,0.824782,Togo
|
214 |
+
TH,15.870032,100.992541,Thailand
|
215 |
+
TJ,38.861034,71.276093,Tajikistan
|
216 |
+
TK,-8.967363,-171.855881,Tokelau
|
217 |
+
TL,-8.874217,125.727539,Timor-Leste
|
218 |
+
TM,38.969719,59.556278,Turkmenistan
|
219 |
+
TN,33.886917,9.537499,Tunisia
|
220 |
+
TO,-21.178986,-175.198242,Tonga
|
221 |
+
TR,38.963745,35.243322,Turkey
|
222 |
+
TT,10.691803,-61.222503,"Trinidad and Tobago"
|
223 |
+
TV,-7.109535,177.64933,Tuvalu
|
224 |
+
TW,23.69781,120.960515,Taiwan
|
225 |
+
TZ,-6.369028,34.888822,Tanzania
|
226 |
+
UA,48.379433,31.16558,Ukraine
|
227 |
+
UG,1.373333,32.290275,Uganda
|
228 |
+
UM,,,"U.S. Minor Outlying Islands"
|
229 |
+
US,37.09024,-95.712891,"United States"
|
230 |
+
UY,-32.522779,-55.765835,Uruguay
|
231 |
+
UZ,41.377491,64.585262,Uzbekistan
|
232 |
+
VA,41.902916,12.453389,"Vatican City"
|
233 |
+
VC,12.984305,-61.287228,"Saint Vincent and the Grenadines"
|
234 |
+
VE,6.42375,-66.58973,Venezuela
|
235 |
+
VG,18.420695,-64.639968,"British Virgin Islands"
|
236 |
+
VI,18.335765,-64.896335,"U.S. Virgin Islands"
|
237 |
+
VN,14.058324,108.277199,Vietnam
|
238 |
+
VU,-15.376706,166.959158,Vanuatu
|
239 |
+
WF,-13.768752,-177.156097,"Wallis and Futuna"
|
240 |
+
WS,-13.759029,-172.104629,Samoa
|
241 |
+
XK,42.602636,20.902977,Kosovo
|
242 |
+
YE,15.552727,48.516388,Yemen
|
243 |
+
YT,-12.8275,45.166244,Mayotte
|
244 |
+
ZA,-30.559482,22.937506,"South Africa"
|
245 |
+
ZM,-13.133897,27.849332,Zambia
|
246 |
+
ZW,-19.015438,29.154857,Zimbabwe
|