mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 09:19:23 +01:00
Add support for loading multiple URLs into superbig
This commit is contained in:
parent
04eca9b65b
commit
befa307c42
@ -92,8 +92,13 @@ def feed_file_into_collector(file, chunk_len, chunk_count):
|
||||
yield i
|
||||
|
||||
|
||||
def feed_url_into_collector(url, chunk_len, chunk_count):
|
||||
yield 'Loading the URL...'
|
||||
def feed_url_into_collector(urls, chunk_len, chunk_count):
|
||||
urls = urls.strip().split('\n')
|
||||
all_text = ''
|
||||
cumulative = ''
|
||||
for url in urls:
|
||||
cumulative += f'Loading {url}...\n\n'
|
||||
yield cumulative
|
||||
html = urlopen(url).read()
|
||||
soup = BeautifulSoup(html, features="html.parser")
|
||||
for script in soup(["script", "style"]):
|
||||
@ -103,7 +108,9 @@ def feed_url_into_collector(url, chunk_len, chunk_count):
|
||||
lines = (line.strip() for line in text.splitlines())
|
||||
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
|
||||
text = '\n\n'.join(chunk for chunk in chunks if chunk)
|
||||
for i in feed_data_into_collector(text, chunk_len, chunk_count):
|
||||
all_text += text
|
||||
|
||||
for i in feed_data_into_collector(all_text, chunk_len, chunk_count):
|
||||
yield i
|
||||
|
||||
|
||||
@ -173,7 +180,7 @@ def ui():
|
||||
update_data = gr.Button('Apply')
|
||||
|
||||
with gr.Tab("URL input"):
|
||||
url_input = gr.Textbox(lines=1, label='Input URL')
|
||||
url_input = gr.Textbox(lines=10, label='Input URL', info='Enter one or more URLs separated by newline characters')
|
||||
update_url = gr.Button('Apply')
|
||||
|
||||
with gr.Tab("File input"):
|
||||
|
Loading…
Reference in New Issue
Block a user