Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,12 +13,17 @@ def extract_text_from_pdf(pdf_content):
|
|
| 13 |
|
| 14 |
|
| 15 |
def generate_summary(file_content, user_input_text):
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
else:
|
| 20 |
-
# Handle user input text
|
| 21 |
-
input_text = user_input_text
|
| 22 |
|
| 23 |
# Load pre-trained Flan-T5 model
|
| 24 |
text_generator = pipeline("text2text-generation", model="google/flan-t5-base")
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
def generate_summary(file_content, user_input_text):
|
| 16 |
+
# Handle uploaded file
|
| 17 |
+
if file_content:
|
| 18 |
+
if isinstance(file_content, bytes):
|
| 19 |
+
# Handle PDF file
|
| 20 |
+
input_text = extract_text_from_pdf(file_content)
|
| 21 |
+
else:
|
| 22 |
+
# Handle uploaded text file
|
| 23 |
+
input_text = file_content.read().decode("utf-8")
|
| 24 |
else:
|
| 25 |
+
# Handle user input text
|
| 26 |
+
input_text = user_input_text
|
| 27 |
|
| 28 |
# Load pre-trained Flan-T5 model
|
| 29 |
text_generator = pipeline("text2text-generation", model="google/flan-t5-base")
|