from transformers import pipeline import gradio as gr import wikipediaapi import nltk nltk.download('punkt') def get_wiki_summary(search): wiki_wiki = wikipediaapi.Wikipedia('MyProjectName (merlin@example.com)', 'en') page = wiki_wiki.page(search) isExist = page.exists() if not isExist: return isExist, "Not found", "Not found", "Not found", "Not found" url = page.fullurl tittle = page.title text = page.text #summary = page.summary[0:300] summary = page.summary #summarizer = pipeline("summarization", model = "BeenaSamuel/t5_small_cnn_multi_news_abstractive_summarizer_v2") #summary = summarizer(text)[0]["summary_text"] return isExist, url, tittle, summary, text wiki_summary = gr.Interface( get_wiki_summary, gr.Text(label="Search Wikipedia"), [ gr.Text(label="Page exists?"), gr.Text(label="URL"), gr.Text(label="Title"), gr.Text(label="Summary", lines=4), gr.Text(label="Text", lines=10) ] ) wiki_summary.launch(share=True)