Spaces:
Running
Running
import gradio as gr | |
from main import main | |
def rexplore_summarizer(corpus): | |
response = main(corpus) | |
return response, response['summary'], response['mindmap'] | |
def clear_everything(text_corpus, raw_data, summary, mindmap): | |
return None, None, None, None | |
theme = gr.themes.Soft( | |
primary_hue="purple", | |
secondary_hue="cyan", | |
neutral_hue="slate", | |
font=[ | |
gr.themes.GoogleFont('Syne'), | |
gr.themes.GoogleFont('Poppins'), | |
gr.themes.GoogleFont('Poppins'), | |
gr.themes.GoogleFont('Poppins') | |
], | |
) | |
with gr.Blocks(theme=theme, title="ReXplore Summarizer", fill_height=True) as app: | |
gr.HTML( | |
value =''' | |
<h1 style="text-align: center;">ReXplore Summarizer <p style="text-align: center;">Designed and Developed by <a href='https://raannakasturi.eu.org' target="_blank" rel="nofollow noreferrer external">Nayan Kasturi</a></p> </h1> | |
<p style="text-align: center;">This app uses a hybrid approach to summarize PDF documents based on CPU as well as GPU.</p> | |
<p style="text-align: center;">The app uses traditional methodologies such as TextRank, LSA, Luhn algorithms as well as large language model (LLM) to generate summaries as well as mindmaps.</p> | |
<p style="text-align: center;">The summarization process can take some time depending on the size of the text corpus and the complexity of the content.</p> | |
''') | |
with gr.Row(): | |
with gr.Column(): | |
text_corpus = gr.TextArea(label="Text Corpus", placeholder="Paste the text corpus here", lines=5) | |
with gr.Row(): | |
clear_btn = gr.Button(value="Clear", variant='stop') | |
summarize_btn = gr.Button(value="Summarize", variant='primary') | |
raw_data = gr.TextArea(label="Raw Data", placeholder="The generated raw data will be displayed here", lines=7, interactive=False, show_copy_button=True) | |
with gr.Row(): | |
summary = gr.TextArea(label="Summary", placeholder="The generated summary will be displayed here", lines=7, interactive=False, show_copy_button=True) | |
mindmap = gr.TextArea(label="Mindmap", placeholder="The generated mindmap will be displayed here", lines=7, interactive=False, show_copy_button=True) | |
summarize_btn.click( | |
rexplore_summarizer, | |
inputs=[text_corpus], | |
outputs=[raw_data, summary, mindmap], | |
concurrency_limit=1, | |
scroll_to_output=True, | |
show_api=True, | |
api_name="rexplore_summarizer", | |
show_progress="full", | |
) | |
clear_btn.click(clear_everything, inputs=[text_corpus, raw_data, summary, mindmap], outputs=[text_corpus, raw_data, summary, mindmap], show_api=False) | |
app.queue(default_concurrency_limit=1).launch(show_api=True) | |