Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import shutil
|
|
7 |
import subprocess
|
8 |
import os
|
9 |
|
10 |
-
|
11 |
def setup_api_key():
|
12 |
google_api_key = os.getenv("GOOGLE_API_KEY")
|
13 |
genai.configure(api_key=google_api_key)
|
@@ -87,9 +87,9 @@ def add_html_to_word(html_text, doc):
|
|
87 |
doc.add_paragraph(element.get_text()) # For any other tags
|
88 |
|
89 |
def process_pdf(pdf_file, user_questions):
|
90 |
-
file_name = pdf_file.
|
91 |
saved_file_path = f"/tmp/{file_name}"
|
92 |
-
shutil.copyfile(pdf_file
|
93 |
|
94 |
subprocess.run(["apt-get", "update"])
|
95 |
subprocess.run(["apt-get", "install", "-y", "poppler-utils"])
|
@@ -123,14 +123,14 @@ questions_str = "\n".join(questions)
|
|
123 |
iface = gr.Interface(
|
124 |
fn=process_pdf,
|
125 |
inputs=[
|
126 |
-
gr.File(label="Upload PDF", type="
|
127 |
gr.TextArea(label="Enter Questions", placeholder="Type your questions here, one per line.", value=questions_str)
|
128 |
],
|
129 |
outputs=[
|
130 |
gr.HTML(label="HTML Formatted Report"),
|
131 |
gr.File(label="DOCX File Output", type="file")
|
132 |
],
|
133 |
-
title="REPORT GENERATOR: ASK YOUR QUESTIONS TO A PDF FILE @YED",
|
134 |
description="Upload a PDF to ask questions and get the answers."
|
135 |
)
|
136 |
|
|
|
7 |
import subprocess
|
8 |
import os
|
9 |
|
10 |
+
# Setup your API key
|
11 |
def setup_api_key():
|
12 |
google_api_key = os.getenv("GOOGLE_API_KEY")
|
13 |
genai.configure(api_key=google_api_key)
|
|
|
87 |
doc.add_paragraph(element.get_text()) # For any other tags
|
88 |
|
89 |
def process_pdf(pdf_file, user_questions):
|
90 |
+
file_name = pdf_file.split('/')[-1]
|
91 |
saved_file_path = f"/tmp/{file_name}"
|
92 |
+
shutil.copyfile(pdf_file, saved_file_path)
|
93 |
|
94 |
subprocess.run(["apt-get", "update"])
|
95 |
subprocess.run(["apt-get", "install", "-y", "poppler-utils"])
|
|
|
123 |
iface = gr.Interface(
|
124 |
fn=process_pdf,
|
125 |
inputs=[
|
126 |
+
gr.File(label="Upload PDF", type="filepath"),
|
127 |
gr.TextArea(label="Enter Questions", placeholder="Type your questions here, one per line.", value=questions_str)
|
128 |
],
|
129 |
outputs=[
|
130 |
gr.HTML(label="HTML Formatted Report"),
|
131 |
gr.File(label="DOCX File Output", type="file")
|
132 |
],
|
133 |
+
title="REPORT GENERATOR: ASK YOUR QUESTIONS TO A PDF FILE BY @YED",
|
134 |
description="Upload a PDF to ask questions and get the answers."
|
135 |
)
|
136 |
|