Spaces:
Configuration error
Configuration error
Michele Dolfi
commited on
fix(ui): use --port parameter and avoid failing when image is not found (#97)
Browse files- docling_serve/gradio_ui.py +19 -15
docling_serve/gradio_ui.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import importlib
|
2 |
import json
|
3 |
import logging
|
4 |
-
import os
|
5 |
import tempfile
|
6 |
from pathlib import Path
|
7 |
|
@@ -9,6 +8,7 @@ import gradio as gr
|
|
9 |
import requests
|
10 |
|
11 |
from docling_serve.helper_functions import _to_list_of_strings
|
|
|
12 |
|
13 |
logger = logging.getLogger(__name__)
|
14 |
|
@@ -96,7 +96,7 @@ file_output_path = None # Will be set when a new file is generated
|
|
96 |
|
97 |
|
98 |
def health_check():
|
99 |
-
response = requests.get(f"http://localhost:{
|
100 |
if response.status_code == 200:
|
101 |
return "Healthy"
|
102 |
return "Unhealthy"
|
@@ -218,7 +218,7 @@ def process_url(
|
|
218 |
raise gr.Error("No input sources provided.", print_exception=False)
|
219 |
try:
|
220 |
response = requests.post(
|
221 |
-
f"http://localhost:{
|
222 |
json=parameters,
|
223 |
)
|
224 |
except Exception as e:
|
@@ -274,7 +274,7 @@ def process_file(
|
|
274 |
|
275 |
try:
|
276 |
response = requests.post(
|
277 |
-
f"http://localhost:{
|
278 |
files=files_data,
|
279 |
data=parameters,
|
280 |
)
|
@@ -358,17 +358,21 @@ with gr.Blocks(
|
|
358 |
with gr.Row(elem_id="check_health"):
|
359 |
# Logo
|
360 |
with gr.Column(scale=1, min_width=90):
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
|
|
|
|
|
|
|
|
372 |
# Title
|
373 |
with gr.Column(scale=1, min_width=200):
|
374 |
gr.Markdown(
|
|
|
1 |
import importlib
|
2 |
import json
|
3 |
import logging
|
|
|
4 |
import tempfile
|
5 |
from pathlib import Path
|
6 |
|
|
|
8 |
import requests
|
9 |
|
10 |
from docling_serve.helper_functions import _to_list_of_strings
|
11 |
+
from docling_serve.settings import uvicorn_settings
|
12 |
|
13 |
logger = logging.getLogger(__name__)
|
14 |
|
|
|
96 |
|
97 |
|
98 |
def health_check():
|
99 |
+
response = requests.get(f"http://localhost:{uvicorn_settings.port}/health")
|
100 |
if response.status_code == 200:
|
101 |
return "Healthy"
|
102 |
return "Unhealthy"
|
|
|
218 |
raise gr.Error("No input sources provided.", print_exception=False)
|
219 |
try:
|
220 |
response = requests.post(
|
221 |
+
f"http://localhost:{uvicorn_settings.port}/v1alpha/convert/source",
|
222 |
json=parameters,
|
223 |
)
|
224 |
except Exception as e:
|
|
|
274 |
|
275 |
try:
|
276 |
response = requests.post(
|
277 |
+
f"http://localhost:{uvicorn_settings.port}/v1alpha/convert/file",
|
278 |
files=files_data,
|
279 |
data=parameters,
|
280 |
)
|
|
|
358 |
with gr.Row(elem_id="check_health"):
|
359 |
# Logo
|
360 |
with gr.Column(scale=1, min_width=90):
|
361 |
+
try:
|
362 |
+
gr.Image(
|
363 |
+
"https://raw.githubusercontent.com/docling-project/docling/refs/heads/main/docs/assets/logo.svg",
|
364 |
+
height=80,
|
365 |
+
width=80,
|
366 |
+
show_download_button=False,
|
367 |
+
show_label=False,
|
368 |
+
show_fullscreen_button=False,
|
369 |
+
container=False,
|
370 |
+
elem_id="logo",
|
371 |
+
scale=0,
|
372 |
+
)
|
373 |
+
except Exception:
|
374 |
+
logger.warning("Logo not found.")
|
375 |
+
|
376 |
# Title
|
377 |
with gr.Column(scale=1, min_width=200):
|
378 |
gr.Markdown(
|