merve HF staff commited on
Commit
6009075
β€’
1 Parent(s): 1093800

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
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
- if resp.status_code == 200:
 
 
 
 
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]