ritk commited on
Commit
9149d7f
·
verified ·
1 Parent(s): e392081

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+
4
+ def extract_answer(json_file, query):
5
+ try:
6
+ data = json.load(json_file)
7
+ results = []
8
+ for section in data.get("summary", []):
9
+ heading = section.get("heading", "")
10
+ bullets = section.get("bullets", [])
11
+ for bullet in bullets:
12
+ if query.lower() in bullet.lower() or query.lower() in heading.lower():
13
+ results.append(f"{heading} ➜ {bullet}")
14
+ return "\n\n".join(results) if results else "No relevant content found."
15
+ except Exception as e:
16
+ return f"Error reading file: {str(e)}"
17
+
18
+ with gr.Blocks() as demo:
19
+ gr.Markdown("🔍 **Adobe Hackathon - Round 1B Summarizer UI**")
20
+ gr.Markdown("Upload your generated summary JSON and enter a question to view top relevant content from the PDF.")
21
+
22
+ with gr.Row():
23
+ file_input = gr.File(label="Upload Round 1B Summary JSON", file_types=[".json"])
24
+ output_box = gr.Textbox(label="Top Relevant Results", lines=10)
25
+
26
+ query_input = gr.Textbox(label="Enter Persona-Based Query", placeholder="e.g., ER DIAGRAM")
27
+ clear_btn = gr.Button("Clear")
28
+ submit_btn = gr.Button("Submit")
29
+
30
+ def clear_inputs():
31
+ return None, "", ""
32
+
33
+ submit_btn.click(fn=extract_answer, inputs=[file_input, query_input], outputs=output_box)
34
+ clear_btn.click(fn=clear_inputs, inputs=[], outputs=[file_input, query_input, output_box])
35
+
36
+ demo.launch()