awacke1 commited on
Commit
5c248ad
·
1 Parent(s): dc6bc52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -22
app.py CHANGED
@@ -6,27 +6,25 @@ from datetime import datetime
6
 
7
  gmaps = googlemaps.Client(key='AIzaSyDybq2mxujekZVivmr03Y5-GGHXesn4TLI')
8
 
9
- # Geocoding an address
10
- geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
11
-
12
- # Look up an address with reverse geocoding
13
- reverse_geocode_result = gmaps.reverse_geocode((40.714224, -73.961452))
14
-
15
- # Request directions via public transit
16
- now = datetime.now()
17
- directions_result = gmaps.directions("Sydney Town Hall",
18
- "Parramatta, NSW",
19
- mode="transit",
20
- departure_time=now)
21
-
22
- # Validate an address with address validation
23
- addressvalidation_result = gmaps.addressvalidation(['1600 Amphitheatre Pk'],
24
- regionCode='US',
25
- locality='Mountain View',
26
- enableUspsCass=True)
27
-
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
 
 
 
30
 
31
  from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
32
  import torch
@@ -123,8 +121,8 @@ description = """Chatbot With persistent memory dataset allowing multiagent syst
123
  def get_base(filename):
124
  basedir = os.path.dirname(__file__)
125
  print(basedir)
126
- #loadPath = basedir + "\\" + filename # works on windows
127
- loadPath = basedir + filename # works on ubuntu
128
  print(loadPath)
129
  return loadPath
130
 
@@ -163,6 +161,7 @@ with gr.Blocks() as demo:
163
  with gr.Row():
164
  t1 = gr.Textbox(lines=1, default="", label="Chat Text:")
165
  b1 = gr.Button("Respond and Retrieve Messages")
 
166
 
167
  with gr.Row(): # inputs and buttons
168
  s1 = gr.State([])
@@ -170,7 +169,13 @@ with gr.Blocks() as demo:
170
  with gr.Row(): # inputs and buttons
171
  file = gr.File(label="File")
172
  s2 = gr.Markdown()
173
-
 
 
 
 
 
174
  b1.click(fn=chat, inputs=[t1, s1], outputs=[s1, df1, file])
 
175
 
176
  demo.launch(debug=True, show_error=True)
 
6
 
7
  gmaps = googlemaps.Client(key='AIzaSyDybq2mxujekZVivmr03Y5-GGHXesn4TLI')
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ def GetMapInfo(inputText):
11
+ geocode_result = gmaps.geocode('640 Jackson Street, St. Paul, MN 55101')
12
+ geo_address = geocode_result[0]['formatted_address']
13
+ geo_directions = geocode_result[0]['geometry']['location']
14
+ geo_geocode = geocode_result[0]['geometry']['location_type']
15
+
16
+ lat = geo_directions['lat']
17
+ lng = geo_directions['lng']
18
+
19
+ reverse_geocode_result = gmaps.reverse_geocode((lat, lng))
20
+
21
+ now = datetime.now()
22
+ directions_result = gmaps.directions("Sydney Town Hall","Parramatta, NSW",mode="transit", departure_time=now)
23
+ #addressvalidation_result = gmaps.addressvalidation(['1600 Amphitheatre Pk'], regionCode='US', locality='Mountain View', enableUspsCass=True)
24
 
25
+ #return geocode_result, reverse_geocode_result, directions_result, addressvalidation_result
26
+ #return geo_address, geo_directions, geo_geocode, reverse_geocode_result, directions_result, addressvalidation_result
27
+ return geo_address, geo_directions, geo_geocode
28
 
29
  from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
30
  import torch
 
121
  def get_base(filename):
122
  basedir = os.path.dirname(__file__)
123
  print(basedir)
124
+ loadPath = basedir + "\\" + filename # works on windows
125
+ #loadPath = basedir + filename # works on ubuntu
126
  print(loadPath)
127
  return loadPath
128
 
 
161
  with gr.Row():
162
  t1 = gr.Textbox(lines=1, default="", label="Chat Text:")
163
  b1 = gr.Button("Respond and Retrieve Messages")
164
+ b2 = gr.Button("Get Map Information")
165
 
166
  with gr.Row(): # inputs and buttons
167
  s1 = gr.State([])
 
169
  with gr.Row(): # inputs and buttons
170
  file = gr.File(label="File")
171
  s2 = gr.Markdown()
172
+ with gr.Row():
173
+ df21 = gr.Textbox(lines=4, default="", label="Geocode1:")
174
+ df22 = gr.Textbox(lines=4, default="", label="Geocode2:")
175
+ df23 = gr.Textbox(lines=4, default="", label="Geocode3:")
176
+ df3 = gr.Dataframe(wrap=True, max_rows=1000, overflow_row_behaviour= "paginate")
177
+ df4 = gr.Dataframe(wrap=True, max_rows=1000, overflow_row_behaviour= "paginate")
178
  b1.click(fn=chat, inputs=[t1, s1], outputs=[s1, df1, file])
179
+ b2.click(fn=GetMapInfo, inputs=[t1], outputs=[df21, df22, df23])
180
 
181
  demo.launch(debug=True, show_error=True)