mirror of
https://github.com/tcsenpai/easy-web-summarizer.git
synced 2025-06-06 10:35:20 +00:00
Update web UI for document summarization and translation
This commit is contained in:
parent
ad30aeb2b7
commit
c5f9eb4ebc
@ -7,7 +7,7 @@ A Python script designed to summarize webpages from specified URLs using the Lan
|
||||
[ollama](https://ollama.com/) must be installed and served
|
||||
|
||||
```bash
|
||||
ollama run llama2
|
||||
ollama run llama3
|
||||
```
|
||||
|
||||
```bash
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 181 KiB |
BIN
assets/gradio_old.png
Normal file
BIN
assets/gradio_old.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 84 KiB |
50
webui.py
50
webui.py
@ -1,21 +1,55 @@
|
||||
import gradio as gr
|
||||
|
||||
from summarizer import load_document, setup_summarization_chain
|
||||
from translator import setup_translator_chain
|
||||
|
||||
|
||||
def summarize(url):
|
||||
docs = load_document(url)
|
||||
llm_chain = setup_summarization_chain()
|
||||
result = llm_chain.run(docs)
|
||||
|
||||
return [result, gr.Button("🇹🇷 Translate ", visible=True)]
|
||||
|
||||
|
||||
def translate(text):
|
||||
llm_chain = setup_translator_chain()
|
||||
result = llm_chain.run(text)
|
||||
return result
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
fn=summarize,
|
||||
inputs="text",
|
||||
outputs="text",
|
||||
title="Summarizer",
|
||||
description="Enter a URL to get a summary of the document.",
|
||||
)
|
||||
with gr.Blocks() as demo:
|
||||
gr.Markdown(
|
||||
"""# Cobanov Web Summarizer
|
||||
Easily summarize any web page with a single click."""
|
||||
)
|
||||
|
||||
iface.launch()
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
url = gr.Text(label="URL", placeholder="Enter URL here")
|
||||
btn_generate = gr.Button("Generate")
|
||||
|
||||
summary = gr.Markdown(label="Summary")
|
||||
btn_translate = gr.Button(visible=False)
|
||||
|
||||
gr.Examples(
|
||||
[
|
||||
"https://cobanov.dev/haftalik-bulten/hafta-13",
|
||||
"https://bawolf.substack.com/p/embeddings-are-a-good-starting-point",
|
||||
],
|
||||
inputs=[url],
|
||||
)
|
||||
gr.Markdown(
|
||||
"""
|
||||
```
|
||||
Model: llama3-8b
|
||||
Author: Mert Cobanov
|
||||
Contact: mertcobanov@gmail.com
|
||||
Repo: github.com/mertcobanov/easy-web-summarizer
|
||||
```"""
|
||||
)
|
||||
btn_generate.click(summarize, inputs=[url], outputs=[summary, btn_translate])
|
||||
btn_translate.click(translate, inputs=[summary], outputs=[summary])
|
||||
|
||||
|
||||
demo.launch()
|
||||
|
55
webui2.py
55
webui2.py
@ -1,55 +0,0 @@
|
||||
import gradio as gr
|
||||
|
||||
from summarizer import load_document, setup_summarization_chain
|
||||
from translator import setup_translator_chain
|
||||
|
||||
|
||||
def summarize(url):
|
||||
docs = load_document(url)
|
||||
llm_chain = setup_summarization_chain()
|
||||
result = llm_chain.run(docs)
|
||||
|
||||
return [result, gr.Button("🇹🇷 Translate ", visible=True)]
|
||||
|
||||
|
||||
def translate(text):
|
||||
llm_chain = setup_translator_chain()
|
||||
result = llm_chain.run(text)
|
||||
return result
|
||||
|
||||
|
||||
with gr.Blocks() as demo:
|
||||
gr.Markdown(
|
||||
"""# Cobanov Web Summarizer
|
||||
Easily summarize any web page with a single click."""
|
||||
)
|
||||
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
url = gr.Text(label="URL", placeholder="Enter URL here")
|
||||
btn_generate = gr.Button("Generate")
|
||||
|
||||
summary = gr.Markdown(label="Summary")
|
||||
btn_translate = gr.Button(visible=False)
|
||||
|
||||
gr.Examples(
|
||||
[
|
||||
"https://cobanov.dev/haftalik-bulten/hafta-13",
|
||||
"https://bawolf.substack.com/p/embeddings-are-a-good-starting-point",
|
||||
],
|
||||
inputs=[url],
|
||||
)
|
||||
gr.Markdown(
|
||||
"""
|
||||
```
|
||||
Model: llama3-8b
|
||||
Author: Mert Cobanov
|
||||
Contact: mertcobanov@gmail.com
|
||||
Repo: github.com/mertcobanov/easy-web-summarizer
|
||||
```"""
|
||||
)
|
||||
btn_generate.click(summarize, inputs=[url], outputs=[summary, btn_translate])
|
||||
btn_translate.click(translate, inputs=[summary], outputs=[summary])
|
||||
|
||||
|
||||
demo.launch()
|
21
webui_old.py
Normal file
21
webui_old.py
Normal file
@ -0,0 +1,21 @@
|
||||
import gradio as gr
|
||||
|
||||
from summarizer import load_document, setup_summarization_chain
|
||||
|
||||
|
||||
def summarize(url):
|
||||
docs = load_document(url)
|
||||
llm_chain = setup_summarization_chain()
|
||||
result = llm_chain.run(docs)
|
||||
return result
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
fn=summarize,
|
||||
inputs="text",
|
||||
outputs="text",
|
||||
title="Summarizer",
|
||||
description="Enter a URL to get a summary of the document.",
|
||||
)
|
||||
|
||||
iface.launch()
|
Loading…
x
Reference in New Issue
Block a user