Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
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 |
-
|
| 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.
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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")
|