merve HF staff commited on
Commit
7ec07f8
β€’
1 Parent(s): 20e4b68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -60,15 +60,17 @@ if input:
60
  if resp.status_code == 200:
61
 
62
  model_answer = data["answer"]
 
63
  for key in link_dict:
64
  if key in model_answer:
 
65
  url = link_dict[key]
66
  response_templates = [f"I think that {model_answer} is the best task for this 🀩 Check out the page πŸ‘‰πŸΌ {url}", f"I think you should use {model_answer} πŸͺ„ Check it out here πŸ‘‰πŸΌ {url}", f"I think {model_answer} should work for you πŸ€“ Check out the page πŸ‘‰πŸΌ {url}"]
67
 
68
  bot_answer = random.choice(response_templates)
69
  message_history.append({"text":bot_answer, "is_user" : False})
70
- else:
71
- fallback_template = ["I didn't get the question 🧐 Could you please ask again? Try 'What should I use for detecting masks in an image?'",
72
  "Hmm, not sure I know the answer, maybe you could ask differently? πŸ€“",
73
  "Sorry, I didn't understand you, maybe you could ask differently? πŸ€“ Try asking 'What should I use to extract name in a document' πŸ€—"]
74
  bot_answer = random.choice(fallback_template)
 
60
  if resp.status_code == 200:
61
 
62
  model_answer = data["answer"]
63
+ key_exists = False
64
  for key in link_dict:
65
  if key in model_answer:
66
+ key_exists = True
67
  url = link_dict[key]
68
  response_templates = [f"I think that {model_answer} is the best task for this 🀩 Check out the page πŸ‘‰πŸΌ {url}", f"I think you should use {model_answer} πŸͺ„ Check it out here πŸ‘‰πŸΌ {url}", f"I think {model_answer} should work for you πŸ€“ Check out the page πŸ‘‰πŸΌ {url}"]
69
 
70
  bot_answer = random.choice(response_templates)
71
  message_history.append({"text":bot_answer, "is_user" : False})
72
+ if key_exists = False:
73
+ fallback_template = ["I didn't get the question 🧐 Could you please ask again? Try 'What should I use for detecting masks in an image?'",
74
  "Hmm, not sure I know the answer, maybe you could ask differently? πŸ€“",
75
  "Sorry, I didn't understand you, maybe you could ask differently? πŸ€“ Try asking 'What should I use to extract name in a document' πŸ€—"]
76
  bot_answer = random.choice(fallback_template)