wiwide commited on
Commit
83db81e
1 Parent(s): d6d9f3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,6 +1,7 @@
1
  from transformers import pipeline
2
  from bs4 import BeautifulSoup
3
  import requests
 
4
 
5
  def extract_text_from_url(url):
6
  response = requests.get(url)
@@ -13,10 +14,12 @@ def answer_question(context, question):
13
  'context': context,
14
  'question': question
15
  })
16
- return answer
17
 
18
- # Replace 'https://www.example.com' with the URL of the webpage you're interested in
19
- webpage_text = extract_text_from_url('https://www.example.com')
 
 
20
 
21
- # Replace 'Your question here' with the question you want to ask
22
- print(answer_question(webpage_text, 'Your question here'))
 
1
  from transformers import pipeline
2
  from bs4 import BeautifulSoup
3
  import requests
4
+ import gradio as gr
5
 
6
  def extract_text_from_url(url):
7
  response = requests.get(url)
 
14
  'context': context,
15
  'question': question
16
  })
17
+ return answer['answer']
18
 
19
+ def app(url, question):
20
+ webpage_text = extract_text_from_url(url)
21
+ answer = answer_question(webpage_text, question)
22
+ return answer
23
 
24
+ iface = gr.Interface(fn=app, inputs=["text", "text"], outputs="text")
25
+ iface.launch()