bumk766fall2023 commited on
Commit
be92746
·
1 Parent(s): 6132d52

bug fixes

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -104,7 +104,12 @@ with gr.Blocks(theme = theme) as demo:
104
 
105
  # String typed by user
106
  text = history[-1][0]
107
- search_keyword = find_best_keyword_match(keywords, text)
 
 
 
 
 
108
 
109
  if search_keyword == "None":
110
  bot_message = "Sorry, don't know any restaurants at this location..." + " [DEBUG (params: " + url_params + ")]"
@@ -134,11 +139,11 @@ with gr.Blocks(theme = theme) as demo:
134
 
135
  # Events handling
136
 
137
- btn.click(user, [msg, chatbot], [msg, chatbot], queue=True, show_progress=False).then(
138
  bot, [chatbot, url_params], chatbot, concurrency_limit=50
139
  )
140
 
141
- msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True, show_progress=False).then(
142
  bot, [chatbot, url_params], chatbot, concurrency_limit=50
143
  )
144
 
@@ -169,7 +174,7 @@ def levenshtein_distance(s1, s2):
169
 
170
  return previous_row[-1]
171
 
172
- def find_best_keyword_match(keywords, text, max_distance=3):
173
  """Find the best keyword match in the text, allowing for some misspelling."""
174
  text_normalized = normalize(text)
175
  best_match = None
 
104
 
105
  # String typed by user
106
  text = history[-1][0]
107
+ print("User Input:", text)
108
+
109
+ if text != "":
110
+ search_keyword = find_best_keyword_match(keywords, text)
111
+ else:
112
+ search_keyword = "None"
113
 
114
  if search_keyword == "None":
115
  bot_message = "Sorry, don't know any restaurants at this location..." + " [DEBUG (params: " + url_params + ")]"
 
139
 
140
  # Events handling
141
 
142
+ btn.click(user, [msg, chatbot], [msg, chatbot], queue=False, show_progress=False).then(
143
  bot, [chatbot, url_params], chatbot, concurrency_limit=50
144
  )
145
 
146
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False, show_progress=False).then(
147
  bot, [chatbot, url_params], chatbot, concurrency_limit=50
148
  )
149
 
 
174
 
175
  return previous_row[-1]
176
 
177
+ def find_best_keyword_match(keywords, text, max_distance=5):
178
  """Find the best keyword match in the text, allowing for some misspelling."""
179
  text_normalized = normalize(text)
180
  best_match = None