deepkansara-123 commited on
Commit
6d5c992
Β·
verified Β·
1 Parent(s): 02f360a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -11,7 +11,7 @@ from sklearn.metrics.pairwise import cosine_similarity
11
  # Local imports
12
  from database1 import create_db
13
  from first1 import pdf_query
14
- from q_generator1 import QGenerator
15
  from ans_generator1 import AnswerGenerator
16
 
17
  import sqlite3, json
@@ -101,6 +101,20 @@ def generate_qa(filename):
101
  except Exception as e:
102
  return f"❌ Error: {str(e)}"
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  # βœ… Ask question using token (semantic similarity)
105
  def ask_question(token, question):
106
  try:
@@ -173,12 +187,16 @@ with gr.Blocks(theme="default") as demo:
173
  upload_out = gr.Textbox(label="Upload Result", interactive=False)
174
  file.change(fn=upload_pdf, inputs=file, outputs=upload_out)
175
 
176
- with gr.Blocks(title="PDF Q&A Generator") as demo:
177
- with gr.Tab("🧠 2. Generate Questions & Answers"):
178
- gr.Markdown("### πŸ€– Generate Questions and Answers from Uploaded PDF")
179
- fname = gr.Textbox(label="πŸ“„ Enter Uploaded Filename", placeholder="example.pdf")
180
- output_box = gr.Textbox(label="πŸ“ Generated Q&A", lines=15, interactive=False)
181
- gr.Button("πŸš€ Generate Q&A").click(fn=generate_qa, inputs=fname, outputs=output_box)
 
 
 
 
182
 
183
  with gr.Tab("❓ 3. Ask a Question"):
184
  gr.Markdown("### πŸ’¬ Ask a question based on uploaded PDF")
 
11
  # Local imports
12
  from database1 import create_db
13
  from first1 import pdf_query
14
+
15
  from ans_generator1 import AnswerGenerator
16
 
17
  import sqlite3, json
 
101
  except Exception as e:
102
  return f"❌ Error: {str(e)}"
103
 
104
+
105
+
106
+ with gr.Tab("🧠 2. Generate Questions & Answers"):
107
+ gr.Markdown("### πŸ€– Generate Questions and Answers from Uploaded PDF")
108
+
109
+ fname = gr.Textbox(label="πŸ“„ Enter Uploaded Filename", placeholder="example.pdf")
110
+ output_box = gr.Textbox(label="πŸ“ Generated Q&A", lines=15, interactive=False)
111
+
112
+ with gr.Row(): # βœ… Wrap the button so it renders properly
113
+ generate_btn = gr.Button("πŸš€ Generate Q&A")
114
+
115
+ generate_btn.click(fn=generate_qa, inputs=fname, outputs=output_box)
116
+
117
+
118
  # βœ… Ask question using token (semantic similarity)
119
  def ask_question(token, question):
120
  try:
 
187
  upload_out = gr.Textbox(label="Upload Result", interactive=False)
188
  file.change(fn=upload_pdf, inputs=file, outputs=upload_out)
189
 
190
+ with gr.Tab("🧠 2. Generate Questions & Answers"):
191
+ gr.Markdown("### πŸ€– Generate Questions and Answers from Uploaded PDF")
192
+
193
+ fname = gr.Textbox(label="πŸ“„ Enter Uploaded Filename", placeholder="example.pdf")
194
+ output_box = gr.Textbox(label="πŸ“ Generated Q&A", lines=15, interactive=False)
195
+
196
+ with gr.Row(): # βœ… Wrap the button so it renders properly
197
+ generate_btn = gr.Button("πŸš€ Generate Q&A")
198
+
199
+ generate_btn.click(fn=generate_qa, inputs=fname, outputs=output_box)
200
 
201
  with gr.Tab("❓ 3. Ask a Question"):
202
  gr.Markdown("### πŸ’¬ Ask a question based on uploaded PDF")