Update app.py
Browse files
app.py
CHANGED
@@ -168,6 +168,10 @@ from transformers import MBartForConditionalGeneration, MBart50Tokenizer
|
|
168 |
#model = MBartForConditionalGeneration.from_pretrained(model_name)
|
169 |
#tokenizer = MBart50Tokenizer.from_pretrained(model_name)
|
170 |
|
|
|
|
|
|
|
|
|
171 |
def get_response(input_text):
|
172 |
#model_inputs = tokenizer(input_text, return_tensors="pt")
|
173 |
#generated_tokens = model.generate(**model_inputs,forced_bos_token_id=tokenizer.lang_code_to_id["en_XX"])
|
@@ -191,7 +195,15 @@ def get_response(input_text):
|
|
191 |
if tag == intent["tag"]:
|
192 |
return random.choice(intent['responses'])
|
193 |
else:
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
title = "WeASK: ChatBOT"
|
197 |
description = "Ask your query here"
|
|
|
168 |
#model = MBartForConditionalGeneration.from_pretrained(model_name)
|
169 |
#tokenizer = MBart50Tokenizer.from_pretrained(model_name)
|
170 |
|
171 |
+
import re, string, unicodedata
|
172 |
+
import wikipedia as wk #pip install wikipedia
|
173 |
+
from collections import defaultdict
|
174 |
+
|
175 |
def get_response(input_text):
|
176 |
#model_inputs = tokenizer(input_text, return_tensors="pt")
|
177 |
#generated_tokens = model.generate(**model_inputs,forced_bos_token_id=tokenizer.lang_code_to_id["en_XX"])
|
|
|
195 |
if tag == intent["tag"]:
|
196 |
return random.choice(intent['responses'])
|
197 |
else:
|
198 |
+
reg_ex = re.search('from wikipedia (.*)', input)#tell me about
|
199 |
+
try:
|
200 |
+
if reg_ex:
|
201 |
+
topic = reg_ex.group(1)
|
202 |
+
wiki = wk.summary(topic, sentences = 3)
|
203 |
+
return wiki
|
204 |
+
except Exception as e:
|
205 |
+
#print("No content has been found")
|
206 |
+
return "I do not understand...Please rephrase"
|
207 |
|
208 |
title = "WeASK: ChatBOT"
|
209 |
description = "Ask your query here"
|