mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-15 00:16:46 +00:00
fix: error type fixes and docling parsing improvements
This commit is contained in:
1 parent
fcef3e68e5
commit
0ecb421954
15 files changed
+938
-59
No files matched your search
@@ -14,7 +14,7 @@ import zipfile
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from application.parser.file.base_parser import BaseParser
|
||||
from application.parser.file.base_parser import BaseParser, DocumentParseError
|
||||
from application.utils import truncate_to_line_boundary
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -346,9 +346,14 @@ class DoclingParser(BaseParser):
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error parsing file with docling: {e}", exc_info=True)
|
||||
if errors == "ignore":
|
||||
return f"[Error parsing file with docling: {str(e)}]"
|
||||
raise
|
||||
# ``errors`` governs *decoding* leniency, not whether a total
|
||||
# conversion failure may be substituted for the document. Returning
|
||||
# the message here (the old ``errors == "ignore"`` branch) made the
|
||||
# caller store the traceback as the file's text and report the
|
||||
# upload successful — the model then read the error as the document.
|
||||
raise DocumentParseError(
|
||||
f"Failed to parse {Path(file).name} with docling: {e}"
|
||||
) from e
|
||||
|
||||
|
||||
class DoclingPDFParser(DoclingParser):
|
||||
|
||||
Reference in new issue
Block a user