Spaces:
Running
Running
pratikshahp
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -28,13 +28,11 @@ def generate_summary(text, model="gpt-4o-mini"):
|
|
28 |
# Gradio app layout
|
29 |
with gr.Blocks() as demo:
|
30 |
gr.Markdown("# Content Summarizer")
|
31 |
-
gr.Markdown("###
|
32 |
|
33 |
-
# File upload
|
34 |
-
file_upload = gr.File(label="Upload Text File", type="filepath")
|
35 |
|
36 |
# Text input area
|
37 |
-
text_input = gr.Textbox(label="
|
38 |
|
39 |
# Output area for the summary
|
40 |
summary_output = gr.Textbox(label="Summary", lines=5)
|
@@ -42,12 +40,8 @@ with gr.Blocks() as demo:
|
|
42 |
# Button to generate the summary
|
43 |
generate_button = gr.Button("Generate Summary")
|
44 |
|
45 |
-
# Logic to handle
|
46 |
-
def handle_input(
|
47 |
-
if file is not None:
|
48 |
-
# Read the uploaded file
|
49 |
-
text = file.name.read().decode("utf-8")
|
50 |
-
|
51 |
if text.strip():
|
52 |
# Generate summary
|
53 |
summary = generate_summary(text)
|
@@ -55,7 +49,7 @@ with gr.Blocks() as demo:
|
|
55 |
else:
|
56 |
return "Please enter some text to summarize."
|
57 |
|
58 |
-
generate_button.click(fn=handle_input, inputs=[
|
59 |
|
60 |
# Launch the Gradio app
|
61 |
demo.launch()
|
|
|
28 |
# Gradio app layout
|
29 |
with gr.Blocks() as demo:
|
30 |
gr.Markdown("# Content Summarizer")
|
31 |
+
gr.Markdown("### Paste text, and the app will generate a summary for you.")
|
32 |
|
|
|
|
|
33 |
|
34 |
# Text input area
|
35 |
+
text_input = gr.Textbox(label="Paste Your Text Here", lines=10)
|
36 |
|
37 |
# Output area for the summary
|
38 |
summary_output = gr.Textbox(label="Summary", lines=5)
|
|
|
40 |
# Button to generate the summary
|
41 |
generate_button = gr.Button("Generate Summary")
|
42 |
|
43 |
+
# Logic to handle text input and generate the summary
|
44 |
+
def handle_input(text):
|
|
|
|
|
|
|
|
|
45 |
if text.strip():
|
46 |
# Generate summary
|
47 |
summary = generate_summary(text)
|
|
|
49 |
else:
|
50 |
return "Please enter some text to summarize."
|
51 |
|
52 |
+
generate_button.click(fn=handle_input, inputs=[text_input], outputs=summary_output)
|
53 |
|
54 |
# Launch the Gradio app
|
55 |
demo.launch()
|