Spaces:
Sleeping
Sleeping
juniorjukeko
commited on
Commit
•
1c3a79b
1
Parent(s):
35b36a4
Update app.py
Browse files
app.py
CHANGED
@@ -87,7 +87,10 @@ def preprocess_pdf_text(pdf_file): #(list_of_text):
|
|
87 |
return doc_sections
|
88 |
|
89 |
def dummy1(pdf_file):
|
90 |
-
|
|
|
|
|
|
|
91 |
|
92 |
def summarize_pdf(pdf_file, api_key,
|
93 |
model_name, temperature, llm_max_tokens,
|
@@ -150,7 +153,7 @@ def main():
|
|
150 |
pdf_doc = gr.File(label="Uploaded PDF:", file_types=['.pdf'])
|
151 |
API_KEY = gr.Textbox(label="OpenAI API Key:", lines=1, type="password")
|
152 |
ingest_pdf = gr.State()
|
153 |
-
|
154 |
summarize_button = gr.Button(value="Summarize!")
|
155 |
summarized_text = gr.Textbox(label="Summary", lines=10, show_copy_button=True)
|
156 |
|
@@ -182,7 +185,7 @@ def main():
|
|
182 |
|
183 |
# summarize_click = summarize_button.click(preprocess_pdf_text, inputs=[pdf_doc], outputs=[ingest_pdf]).\
|
184 |
# then(summarize_pdf, inputs=list_inputs, outputs=[summarized_text])
|
185 |
-
|
186 |
demo.queue(concurrency_count=1).launch(share=True)
|
187 |
|
188 |
if __name__ == "__main__":
|
|
|
87 |
return doc_sections
|
88 |
|
89 |
def dummy1(pdf_file):
|
90 |
+
loader = PyPDFLoader(pdf_file.name)
|
91 |
+
pdf_docs = loader.load_and_split(text_splitter)
|
92 |
+
|
93 |
+
return "FINISH"+pdf_docs[0].page_content
|
94 |
|
95 |
def summarize_pdf(pdf_file, api_key,
|
96 |
model_name, temperature, llm_max_tokens,
|
|
|
153 |
pdf_doc = gr.File(label="Uploaded PDF:", file_types=['.pdf'])
|
154 |
API_KEY = gr.Textbox(label="OpenAI API Key:", lines=1, type="password")
|
155 |
ingest_pdf = gr.State()
|
156 |
+
submit_button = gr.Button(value="Upload!")
|
157 |
summarize_button = gr.Button(value="Summarize!")
|
158 |
summarized_text = gr.Textbox(label="Summary", lines=10, show_copy_button=True)
|
159 |
|
|
|
185 |
|
186 |
# summarize_click = summarize_button.click(preprocess_pdf_text, inputs=[pdf_doc], outputs=[ingest_pdf]).\
|
187 |
# then(summarize_pdf, inputs=list_inputs, outputs=[summarized_text])
|
188 |
+
submit_button.click(dummy1, inputs=[pdf_doc], outputs=[summarized_text])
|
189 |
demo.queue(concurrency_count=1).launch(share=True)
|
190 |
|
191 |
if __name__ == "__main__":
|