Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,9 @@ 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']
|
|
@@ -67,7 +69,7 @@ def SaveResult(text, outputfileName):
|
|
| 67 |
f.write('\n')
|
| 68 |
return
|
| 69 |
|
| 70 |
-
|
| 71 |
def store_message(name: str, message: str, outputfileName: str):
|
| 72 |
basedir = os.path.dirname(__file__)
|
| 73 |
savePath = outputfileName
|
|
@@ -75,8 +77,6 @@ def store_message(name: str, message: str, outputfileName: str):
|
|
| 75 |
# if file doesnt exist, create it with labels
|
| 76 |
from os.path import exists
|
| 77 |
file_exists = exists(savePath)
|
| 78 |
-
|
| 79 |
-
|
| 80 |
|
| 81 |
if (file_exists==False):
|
| 82 |
with open(savePath, "w") as f: #write
|
|
@@ -116,9 +116,6 @@ def add_note_to_history(note, note_history):# good example of non async since we
|
|
| 116 |
note_history = '</s> <s>'.join(note_history)
|
| 117 |
return [note_history]
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
title = "💬ChatBack🧠💾"
|
| 123 |
description = """Chatbot With persistent memory dataset allowing multiagent system AI to access a shared dataset as memory pool with stored interactions.
|
| 124 |
Current Best SOTA Chatbot: https://huggingface.co/facebook/blenderbot-400M-distill?text=Hey+my+name+is+ChatBack%21+Are+you+ready+to+rock%3F """
|
|
@@ -126,8 +123,8 @@ description = """Chatbot With persistent memory dataset allowing multiagent syst
|
|
| 126 |
def get_base(filename):
|
| 127 |
basedir = os.path.dirname(__file__)
|
| 128 |
print(basedir)
|
| 129 |
-
|
| 130 |
-
loadPath = basedir + filename # works on ubuntu
|
| 131 |
print(loadPath)
|
| 132 |
return loadPath
|
| 133 |
|
|
@@ -148,17 +145,18 @@ def chat(message, history):
|
|
| 148 |
history.append((list_history[-2], list_history[-1]))
|
| 149 |
|
| 150 |
df=pd.DataFrame()
|
| 151 |
-
|
| 152 |
if UseMemory:
|
| 153 |
#outputfileName = 'ChatbotMemory.csv'
|
| 154 |
outputfileName = 'ChatbotMemory3.csv' # Test first time file create
|
| 155 |
df = store_message(message, response, outputfileName) # Save to dataset
|
| 156 |
basedir = get_base(outputfileName)
|
| 157 |
-
|
| 158 |
-
|
| 159 |
|
| 160 |
return history, df, basedir
|
| 161 |
|
|
|
|
|
|
|
|
|
|
| 162 |
with gr.Blocks() as demo:
|
| 163 |
gr.Markdown("<h1><center>🍰 AI Google Maps Demonstration🎨</center></h1>")
|
| 164 |
|
|
@@ -182,4 +180,4 @@ with gr.Blocks() as demo:
|
|
| 182 |
b1.click(fn=chat, inputs=[t1, s1], outputs=[s1, df1, file])
|
| 183 |
b2.click(fn=GetMapInfo, inputs=[t1], outputs=[df21, df22, df23])
|
| 184 |
|
| 185 |
-
demo.launch(debug=True, show_error=True)
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def GetMapInfo(inputText):
|
| 11 |
+
#geocode_result = gmaps.geocode('640 Jackson Street, St. Paul, MN 55101')
|
| 12 |
+
geocode_result = gmaps.geocode(inputText)
|
| 13 |
+
|
| 14 |
geo_address = geocode_result[0]['formatted_address']
|
| 15 |
geo_directions = geocode_result[0]['geometry']['location']
|
| 16 |
geo_geocode = geocode_result[0]['geometry']['location_type']
|
|
|
|
| 69 |
f.write('\n')
|
| 70 |
return
|
| 71 |
|
| 72 |
+
|
| 73 |
def store_message(name: str, message: str, outputfileName: str):
|
| 74 |
basedir = os.path.dirname(__file__)
|
| 75 |
savePath = outputfileName
|
|
|
|
| 77 |
# if file doesnt exist, create it with labels
|
| 78 |
from os.path import exists
|
| 79 |
file_exists = exists(savePath)
|
|
|
|
|
|
|
| 80 |
|
| 81 |
if (file_exists==False):
|
| 82 |
with open(savePath, "w") as f: #write
|
|
|
|
| 116 |
note_history = '</s> <s>'.join(note_history)
|
| 117 |
return [note_history]
|
| 118 |
|
|
|
|
|
|
|
|
|
|
| 119 |
title = "💬ChatBack🧠💾"
|
| 120 |
description = """Chatbot With persistent memory dataset allowing multiagent system AI to access a shared dataset as memory pool with stored interactions.
|
| 121 |
Current Best SOTA Chatbot: https://huggingface.co/facebook/blenderbot-400M-distill?text=Hey+my+name+is+ChatBack%21+Are+you+ready+to+rock%3F """
|
|
|
|
| 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 |
|
|
|
|
| 145 |
history.append((list_history[-2], list_history[-1]))
|
| 146 |
|
| 147 |
df=pd.DataFrame()
|
| 148 |
+
|
| 149 |
if UseMemory:
|
| 150 |
#outputfileName = 'ChatbotMemory.csv'
|
| 151 |
outputfileName = 'ChatbotMemory3.csv' # Test first time file create
|
| 152 |
df = store_message(message, response, outputfileName) # Save to dataset
|
| 153 |
basedir = get_base(outputfileName)
|
|
|
|
|
|
|
| 154 |
|
| 155 |
return history, df, basedir
|
| 156 |
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
|
| 160 |
with gr.Blocks() as demo:
|
| 161 |
gr.Markdown("<h1><center>🍰 AI Google Maps Demonstration🎨</center></h1>")
|
| 162 |
|
|
|
|
| 180 |
b1.click(fn=chat, inputs=[t1, s1], outputs=[s1, df1, file])
|
| 181 |
b2.click(fn=GetMapInfo, inputs=[t1], outputs=[df21, df22, df23])
|
| 182 |
|
| 183 |
+
demo.launch(debug=True, show_error=True)
|