diff --git a/server/app/routes/convert.py b/server/app/routes/convert.py index 9ad18aac..b1a7c71a 100644 --- a/server/app/routes/convert.py +++ b/server/app/routes/convert.py @@ -4,6 +4,7 @@ import os import aiohttp from pathlib import Path +from urllib.parse import urljoin from azure.ai.documentintelligence.models import AnalyzeDocumentRequest, AnalyzeResult, DocumentContentFormat from azure.ai.documentintelligence import DocumentIntelligenceClient from azure.core.credentials import AzureKeyCredential @@ -55,6 +56,7 @@ async def convert_documents( custom_docling_url: Optional[str] = Header(None) ): use_docetl_server = use_docetl_server.lower() == "true" # TODO: make this a boolean + # If custom Docling URL is provided, forward the request there if custom_docling_url: @@ -78,18 +80,18 @@ async def convert_documents( "output_html": False, "do_ocr": True, "do_table_structure": True, - "include_images": True + "include_images": False } } async with session.post( - f"{custom_docling_url}/convert", + urljoin(custom_docling_url, 'convert'), json=payload, timeout=120 ) as response: if response.status == 200: result = await response.json() - if result["status"] == "success": + if result["status"] in ("success", '4'): results.append({ "filename": file.filename, "markdown": result["document"]["markdown"] diff --git a/website/src/app/api/convertDocuments/route.ts b/website/src/app/api/convertDocuments/route.ts index 954c0d01..e589a022 100644 --- a/website/src/app/api/convertDocuments/route.ts +++ b/website/src/app/api/convertDocuments/route.ts @@ -42,13 +42,14 @@ export async function POST(request: NextRequest) { if (azureEndpoint && azureKey) { targetUrl = `${FASTAPI_URL}/api/azure-convert-documents`; } else if (customDoclingUrl) { - targetUrl = `${customDoclingUrl}/convert`; + targetUrl = `${FASTAPI_URL}/api/convert-documents`; } else { targetUrl = `${FASTAPI_URL}/api/convert-documents${ conversionMethod === "docetl" ? "?use_docetl_server=true" : "" }`; } + // Forward the request to the appropriate backend const response = await fetch(targetUrl, { method: "POST", diff --git a/website/src/components/FileExplorer.tsx b/website/src/components/FileExplorer.tsx index 8b91dfbe..d56aa8d9 100644 --- a/website/src/components/FileExplorer.tsx +++ b/website/src/components/FileExplorer.tsx @@ -691,7 +691,7 @@ export const FileExplorer: React.FC = ({ onValueChange={(value) => setConversionMethod(value as ConversionMethod) } - className="mt-2 grid grid-cols-3 gap-2" + className="mt-2 grid grid-cols-4 gap-2" >
@@ -876,11 +876,11 @@ export const FileExplorer: React.FC = ({
0 - ? "border-border bg-accent/50 p-6" - : "border-border p-8 hover:border-primary" + ? "border-border bg-accent/50 p-3" + : "border-border p-3 hover:border-primary" } `} onDragOver={(e) => { @@ -931,33 +931,30 @@ export const FileExplorer: React.FC = ({ )}
- -
-

- Drag and drop your documents here or -

- -

+ +

+
+ Drag and drop your documents here or + +
+

Supported formats: PDF, DOCX, DOC, TXT, HTML, PPTX, MD

-

- Processing may take up to 2 minutes -