Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") | |
| def analyze_text(text): | |
| summary = summarizer(text, max_length=150, min_length=40, do_sample=False)[0]["summary_text"] | |
| follow_ups = [ | |
| "What assumptions are made?", | |
| "What are potential counterarguments?", | |
| "What are possible next research questions?" | |
| ] | |
| return summary, "\n".join(follow_ups) | |
| with gr.Blocks() as demo: | |
| gr.Markdown("### 🧠 Clarity Agent\nPaste text or upload a file to get a summary and follow-up ideas.") | |
| with gr.Row(): | |
| input_text = gr.Textbox(label="Paste text", lines=12) | |
| file_upload = gr.File(label="...or upload .txt/.md", file_types=[".txt", ".md"]) | |
| submit = gr.Button("Analyze") | |
| output_summary = gr.Textbox(label="Summary") | |
| output_questions = gr.Textbox(label="Follow-up Questions") | |
| def load_and_analyze(paste, file): | |
| content = paste or (file.read().decode() if file else "") | |
| return analyze_text(content) if content.strip() else ("No input provided", "") | |
| submit.click(load_and_analyze, inputs=[input_text, file_upload], outputs=[output_summary, output_questions]) | |
| demo.launch() | |