Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the legacy document format to move to docling v2 output #485

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/instructlab/sdg/utils/chunkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ def chunk_documents(self) -> List:
docling_json_paths = list(docling_artifacts_path.glob("*.json"))
chunks = []
for json_fp in docling_json_paths:
chunks.extend(self._process_parsed_docling_json(json_fp))
with json_fp.open("r", encoding="utf-8") as file:
data = json.load(file)
chunks.extend(self._process_parsed_docling_json(data))

return chunks

Expand Down Expand Up @@ -522,11 +524,11 @@ def export_documents(self, converted_docs: Iterable[ConversionResult]):

# Export Deep Search document JSON format:
with (docling_artifacts_path / f"{doc_filename}.json").open("w") as fp:
fp.write(json.dumps(doc.legacy_document.export_to_dict()))
fp.write(json.dumps(doc.document.export_to_dict()))

# Export Markdown format:
with (docling_artifacts_path / f"{doc_filename}.md").open("w") as fp:
fp.write(doc.legacy_document.export_to_markdown())
fp.write(doc.document.export_to_markdown())
else:
logger.info(f"Document {doc.input.file} failed to convert.")
failure_count += 1
Expand Down
Loading