Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,10 +8,10 @@ from bs4 import BeautifulSoup
|
|
8 |
import re
|
9 |
|
10 |
benefits = [
|
11 |
-
{"benefitName": "Universal Credit", "coreName": "
|
12 |
-
{"benefitName": "Universal Credit", "coreName": "
|
13 |
-
{"benefitName": "Universal Credit", "coreName": "how much can I get
|
14 |
-
{"benefitName": "Universal Credit", "coreName": "
|
15 |
]
|
16 |
|
17 |
|
@@ -93,7 +93,21 @@ core4Classes = list(set(list(map(lambda x: x['coreName'], benefits))))
|
|
93 |
# contexts
|
94 |
benefitsClasses, core4Classes
|
95 |
|
96 |
-
|
97 |
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
iface.launch()
|
|
|
8 |
import re
|
9 |
|
10 |
benefits = [
|
11 |
+
{"benefitName": "Universal Credit", "coreName": "what is this benefit", "link": "https://www.gov.uk/universal-credit/"},
|
12 |
+
{"benefitName": "Universal Credit", "coreName": "who can apply", "link": "https://www.gov.uk/universal-credit/eligibility"},
|
13 |
+
{"benefitName": "Universal Credit", "coreName": "how much can I get", "link": "https://www.gov.uk/universal-credit/what-youll-get,https://www.gov.uk/universal-credit/how-youre-paid"},
|
14 |
+
{"benefitName": "Universal Credit", "coreName": "How to apply", "link": "https://www.gov.uk/universal-credit/how-to-claim"}
|
15 |
]
|
16 |
|
17 |
|
|
|
93 |
# contexts
|
94 |
benefitsClasses, core4Classes
|
95 |
|
96 |
+
question_answerer = pipeline("question-answering")
|
97 |
|
98 |
+
|
99 |
+
coreName = 'how much can I get'
|
100 |
+
def testQA(question):
|
101 |
+
|
102 |
+
predictedBenefit = "Universal Credit"
|
103 |
+
predictedCore = coreName
|
104 |
+
|
105 |
+
time = datetime.now()
|
106 |
+
context = list(filter(lambda x: x['benefitName']==predictedBenefit and x['coreName']==predictedCore, benefits))[0]
|
107 |
+
answer = question_answerer(question = question, context = context['context'])
|
108 |
+
time3 = (datetime.now() - time).total_seconds()
|
109 |
+
|
110 |
+
return answer
|
111 |
+
|
112 |
+
iface = gr.Interface(fn=testQA, inputs="text", outputs="text")
|
113 |
iface.launch()
|