Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from main import extract_entities_from_file
|
|
|
|
| 3 |
|
| 4 |
def process(file):
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
iface = gr.Interface(
|
| 11 |
fn=process,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from main import extract_entities_from_file
|
| 3 |
+
from starlette.requests import ClientDisconnect
|
| 4 |
|
| 5 |
def process(file):
|
| 6 |
+
try:
|
| 7 |
+
results = extract_entities_from_file(file)
|
| 8 |
+
if not results:
|
| 9 |
+
return "No entities found."
|
| 10 |
+
return "\n".join([f"{text} -> {label}" for text, label in results])
|
| 11 |
+
except ClientDisconnect:
|
| 12 |
+
print("Client disconnected during processing.")
|
| 13 |
+
return "Client disconnected before processing could complete."
|
| 14 |
+
except Exception as e:
|
| 15 |
+
print(f"Unhandled error: {e}")
|
| 16 |
+
return "An error occurred during processing."
|
| 17 |
|
| 18 |
iface = gr.Interface(
|
| 19 |
fn=process,
|