Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
71 |
-
|
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)
|