Michael S. Trusov commited on
Commit
2fdc2fa
·
1 Parent(s): edcbbc9

October 5 commit to Hugging Face

Browse files
Files changed (2) hide show
  1. app.py +17 -6
  2. images/qa_data.txt +2 -2
app.py CHANGED
@@ -62,13 +62,19 @@ def app_inits():
62
  # https://bumk766fall2023-chatbot.hf.space/?dw=0.02&dl=0.0001&ds=0.4
63
 
64
  #print("CALL URL: http://127.0.0.1:7860/?dw=0.02&dl=0.0001&ds=0.4")
65
- print("CALL URL: http://127.0.0.1:7860/?dw=0.2&dl=0.000001&ds=0.000004")
 
66
 
67
  return
68
 
69
  with gr.Blocks(theme = theme) as demo:
70
  #chatbot = gr.Chatbot(value = [[None,'**How can I help you today?**']], elem_id="chatbot", layout = "panel", avatar_images=("images/user.jpg", "images/bot.jpg"),)
71
- chatbot = gr.Chatbot(elem_id="chatbot", layout = "panel", avatar_images=("images/user.jpg", "images/bot.jpg"),)
 
 
 
 
 
72
  # height=800,
73
 
74
  #def get_params(request: gr.Request, param_hiddentextbox):
@@ -168,13 +174,13 @@ with gr.Blocks(theme = theme) as demo:
168
  if search_keyword == "None":
169
  #bot_message = "Sorry, don't know any restaurants at this location..." + " [DEBUG (params: " + url_params + ")]"
170
  bot_message = "Sorry, don't know any restaurants at this location..."
171
- bot_message = "I'm sorry, but I can only provide information about restaurants in Tucson at the moment. Let me know if you'd like recommendations!"
172
  else:
173
  output_text = qs.get(search_keyword, "Keyword identified. No information found.")
174
  bot_message = output_text
175
 
176
  if text == "debug":
177
- bot_message = "[DEBUG (ver. 10/02/2024) params: " + url_params + "\nSentences Delay=" + str(DelayBetweenSentences) + " sec. Words Delay=" + str(DelayBetweenWords) + " sec. Letters Delay=" + str(DelayBetweenLetters) + " sec.) \nKeys:\n" + "\n".join(keywords) + "]"
178
 
179
 
180
  # initialize new entry
@@ -183,9 +189,14 @@ with gr.Blocks(theme = theme) as demo:
183
  # output text letter-by-letter
184
  for character in bot_message:
185
 
186
- if character != "=":
 
 
 
 
 
187
  history[-1][1] += character
188
-
189
  # Delay between words
190
  if character == " ":
191
  time.sleep(DelayBetweenWords)
 
62
  # https://bumk766fall2023-chatbot.hf.space/?dw=0.02&dl=0.0001&ds=0.4
63
 
64
  #print("CALL URL: http://127.0.0.1:7860/?dw=0.02&dl=0.0001&ds=0.4")
65
+ #print("CALL URL: http://127.0.0.1:7860/?dw=0.2&dl=0.000001&ds=0.000004")
66
+ print("CALL URL: http://127.0.0.1:7860/?dw=0.002&dl=0.02&ds=0.000004")
67
 
68
  return
69
 
70
  with gr.Blocks(theme = theme) as demo:
71
  #chatbot = gr.Chatbot(value = [[None,'**How can I help you today?**']], elem_id="chatbot", layout = "panel", avatar_images=("images/user.jpg", "images/bot.jpg"),)
72
+ #chatbot = gr.Chatbot(elem_id="chatbot", layout = "panel", avatar_images=("images/user.jpg", "images/bot.jpg"),)
73
+ #chatbot = gr.Chatbot(elem_id="chatbot", layout = "panel", avatar_images=("images/user.jpg", "images/bot.jpg"),render_markdown=False)
74
+ chatbot = gr.Chatbot(elem_id="chatbot", layout = "panel", avatar_images=("images/user.jpg", "images/bot.jpg"),latex_delimiters=[],)
75
+
76
+
77
+
78
  # height=800,
79
 
80
  #def get_params(request: gr.Request, param_hiddentextbox):
 
174
  if search_keyword == "None":
175
  #bot_message = "Sorry, don't know any restaurants at this location..." + " [DEBUG (params: " + url_params + ")]"
176
  bot_message = "Sorry, don't know any restaurants at this location..."
177
+ bot_message = "I'm sorry, but I can only provide information about Mexican restaurants in Tucson at the moment."
178
  else:
179
  output_text = qs.get(search_keyword, "Keyword identified. No information found.")
180
  bot_message = output_text
181
 
182
  if text == "debug":
183
+ bot_message = "[DEBUG (ver. 10/05/2024) params: " + url_params + "\nSentences Delay=" + str(DelayBetweenSentences) + " sec. Words Delay=" + str(DelayBetweenWords) + " sec. Letters Delay=" + str(DelayBetweenLetters) + " sec.) \nKeys:\n" + "\n".join(keywords) + "]"
184
 
185
 
186
  # initialize new entry
 
189
  # output text letter-by-letter
190
  for character in bot_message:
191
 
192
+ if character == "^":
193
+ history[-1][1] += " "
194
+ elif character == "@":
195
+ history[-1][1] += "<BR>"
196
+
197
+ elif character != "=":
198
  history[-1][1] += character
199
+
200
  # Delay between words
201
  if character == " ":
202
  time.sleep(DelayBetweenWords)
images/qa_data.txt CHANGED
@@ -1,3 +1,3 @@
1
  {
2
- "Tucson": "Here are the top 5 Mexican restaurants in Tucson, AZ, according to various sources:<BR><BR>=\n1. **Guadalajara Original Grill** - Known for its tableside salsa and guacamole preparation, this restaurant offers an authentic dining experience with live music and dishes like chicken fajitas and flavorful Molcajetes.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Rating: 4.6/5`\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Price Range: $$ - $$$$`=\n2. **Mariscos Chihuahua** - A seafood-focused menu featuring dishes such as shrimp ceviche, smoked marlin fish tacos, and fish fillet in creamy green sauce in a simple setting.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Rating: 4.5/5`\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Price Range: $$ - $$$`=\n3. **El Guero Canelo** - Authentic Mexican cuisine venue known for Sonoran hot dogs and Chucho dog, offering generous portions and a condiment bar for personalization.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Rating: 4.5/5`\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Price Range: $$$ - $$$$`=\n4. **Mi Nidito Restaurant, Inc** - Enthusiasts of Mexican cuisine can explore dishes like Sonoran style flat enchiladas, carne seca, and the notable \"Bill Clinton plate\" in an energetic atmosphere with combo plates.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Rating: 4.7/5`\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Price Range: $$ - $$$$`=\n5. **Blanco Cocina + Cantina** - An urban chic eatery providing Mexican-inspired dishes, with a selection of margaritas and a notable tequila bar. Menu highlights include machaca beef short ribs enchiladas and a signature chimichanga.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Rating: 4.6/5`\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Price Range: $$ - $$$$`=\n\nThat is our top 5... Enjoy your culinary adventure!"
3
- }
 
1
  {
2
+ "Tucson": "Here are the top 5 Mexican restaurants in Tucson, AZ, according to various sources:=\n@1. Guadalajara Original Grill - Known for its tableside salsa and guacamole preparation, this restaurant offers an authentic dining experience with live music and dishes like chicken fajitas and flavorful Molcajetes.\n^^^^Rating: 4.6/5\n^^^^Price Range: $$-$$$=\n2. Mariscos Chihuahua - A seafood-focused menu featuring dishes such as shrimp ceviche, smoked marlin fish tacos, and fish fillet in creamy green sauce in a simple setting.\n^^^^Rating: 4.5/5\n^^^^Price Range: $$-$$$=\n3. El Guero Canelo - Authentic Mexican cuisine venue known for Sonoran hot dogs and Chucho dog, offering generous portions and a condiment bar for personalization.\n^^^^Rating: 4.5/5\n^^^^Price Range: $-$$=\n4. Mi Nidito Restaurant, Inc - Enthusiasts of Mexican cuisine can explore dishes like Sonoran style flat enchiladas, carne seca, and the notable \"Bill Clinton plate\" in an energetic atmosphere with combo plates.\n^^^^Rating: 4.7/5\n^^^^Price Range: $$-$$$=\n5. Blanco Cocina + Cantina - An urban chic eatery providing Mexican-inspired dishes, with a selection of margaritas and a notable tequila bar. Menu highlights include machaca beef short ribs enchiladas and a signature chimichanga.\n^^^^Rating: 4.6/5\n^^^^Price Range: $$-$$$=\n@That is our top 5... Enjoy your culinary adventure!"
3
+ }