Spaces:
Runtime error
Runtime error
うごあいた
Browse files
app.py
CHANGED
|
@@ -10,12 +10,18 @@ import json
|
|
| 10 |
|
| 11 |
def run_workflow(message):
|
| 12 |
try:
|
|
|
|
|
|
|
|
|
|
| 13 |
file = message['files'][0]
|
| 14 |
-
text_message = message['text']
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# PDFファイルをロードしてテキストを抽出
|
| 21 |
loader = UnstructuredPDFLoader(file)
|
|
|
|
| 10 |
|
| 11 |
def run_workflow(message):
|
| 12 |
try:
|
| 13 |
+
if 'files' not in message or not message['files']:
|
| 14 |
+
return "PDFファイルが選択されていません。", ""
|
| 15 |
+
|
| 16 |
file = message['files'][0]
|
|
|
|
| 17 |
|
| 18 |
+
if not file.name.lower().endswith('.pdf'):
|
| 19 |
+
return "選択されたファイルはPDFではありません。", ""
|
| 20 |
+
|
| 21 |
+
if file.size == 0:
|
| 22 |
+
return "選択されたPDFファイルが空です。", ""
|
| 23 |
+
|
| 24 |
+
text_message = message.get('text', '')
|
| 25 |
|
| 26 |
# PDFファイルをロードしてテキストを抽出
|
| 27 |
loader = UnstructuredPDFLoader(file)
|