Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -97,25 +97,21 @@ if input:
|
|
| 97 |
|
| 98 |
model_answer = find_sentences("How can I extract information from invoices?")
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
|
| 104 |
-
key_exists = False
|
| 105 |
-
for key in link_dict:
|
| 106 |
-
if key in model_answer:
|
| 107 |
-
key_exists = True
|
| 108 |
-
url = link_dict[key]
|
| 109 |
-
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}"]
|
| 110 |
-
|
| 111 |
-
bot_answer = random.choice(response_templates)
|
| 112 |
-
message_history.append({"text":bot_answer, "is_user" : False})
|
| 113 |
-
if key_exists == False:
|
| 114 |
-
fallback_template = ["I didn't get the question π§ Could you please ask again? Try 'What should I use for detecting masks in an image?'",
|
| 115 |
-
"Hmm, not sure I know the answer, maybe you could ask differently? π€",
|
| 116 |
-
"Sorry, I didn't understand you, maybe you could ask differently? π€ Try asking 'What should I use to extract name in a document' π€"]
|
| 117 |
-
bot_answer = random.choice(fallback_template)
|
| 118 |
message_history.append({"text":bot_answer, "is_user" : False})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
with placeholder.container():
|
| 121 |
last_message = message_history[-1]
|
|
|
|
| 97 |
|
| 98 |
model_answer = find_sentences("How can I extract information from invoices?")
|
| 99 |
|
| 100 |
+
key_exists = False
|
| 101 |
+
for key in link_dict:
|
| 102 |
+
if key in model_answer:
|
| 103 |
+
key_exists = True
|
| 104 |
+
url = link_dict[key]
|
| 105 |
+
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}"]
|
| 106 |
|
| 107 |
+
bot_answer = random.choice(response_templates)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
message_history.append({"text":bot_answer, "is_user" : False})
|
| 109 |
+
if key_exists == False:
|
| 110 |
+
fallback_template = ["I didn't get the question π§ Could you please ask again? Try 'What should I use for detecting masks in an image?'",
|
| 111 |
+
"Hmm, not sure I know the answer, maybe you could ask differently? π€",
|
| 112 |
+
"Sorry, I didn't understand you, maybe you could ask differently? π€ Try asking 'What should I use to extract name in a document' π€"]
|
| 113 |
+
bot_answer = random.choice(fallback_template)
|
| 114 |
+
message_history.append({"text":bot_answer, "is_user" : False})
|
| 115 |
|
| 116 |
with placeholder.container():
|
| 117 |
last_message = message_history[-1]
|