Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,13 +53,14 @@ def get_wiki_article(topic):
|
|
| 53 |
choices = [x for x in e.options if ('disambiguation' not in x) and ('All pages' not in x) and (x!=topic)]
|
| 54 |
s = random.choice(choices)
|
| 55 |
p = wikipedia.page(s)
|
| 56 |
-
saved = AIMemory(p,
|
| 57 |
return p.content, p.url
|
| 58 |
|
| 59 |
def get_answer(topic, question):
|
| 60 |
w_art, w_url=get_wiki_article(topic)
|
| 61 |
qa = {'question': question, 'context': w_art}
|
| 62 |
res = nlp(qa)
|
|
|
|
| 63 |
return res['answer'], w_url, {'confidence':res['score']}
|
| 64 |
|
| 65 |
|
|
|
|
| 53 |
choices = [x for x in e.options if ('disambiguation' not in x) and ('All pages' not in x) and (x!=topic)]
|
| 54 |
s = random.choice(choices)
|
| 55 |
p = wikipedia.page(s)
|
| 56 |
+
saved = AIMemory(p.content, p.url)
|
| 57 |
return p.content, p.url
|
| 58 |
|
| 59 |
def get_answer(topic, question):
|
| 60 |
w_art, w_url=get_wiki_article(topic)
|
| 61 |
qa = {'question': question, 'context': w_art}
|
| 62 |
res = nlp(qa)
|
| 63 |
+
saved = AIMemory(res['answer'], w_url)
|
| 64 |
return res['answer'], w_url, {'confidence':res['score']}
|
| 65 |
|
| 66 |
|