@@ -256,29 +256,23 @@ def ai_parse_document(stage_location: StageLocation, path: str) -> Dict[str, Any
256256 full_path = resolved_path or path
257257
258258 # Keep metadata first for predictable JSON ordering.
259- payload : Dict [str , Any ] = OrderedDict (
260- [
261- (
262- "metadata" ,
263- {
264- "chunk_count" : chunk_count ,
265- "chunk_size" : DEFAULT_CHUNK_SIZE ,
266- "duration_ms" : duration_ms ,
267- "file_size" : file_size if file_size is not None else 0 ,
268- "filename" : Path (path ).name ,
269- "path" : full_path or path ,
270- "timings_ms" : {
271- "convert" : (t_convert_end_ns - t_convert_start_ns )
272- / 1_000_000.0 ,
273- "chunk" : (t_chunk_end_ns - t_convert_end_ns ) / 1_000_000.0 ,
274- "total" : duration_ms ,
275- },
276- "version" : 1 ,
277- },
278- ),
279- ("chunks" , pages ),
280- ]
281- )
259+ payload : Dict [str , Any ] = {
260+ "metadata" : {
261+ "chunk_count" : chunk_count ,
262+ "chunk_size" : DEFAULT_CHUNK_SIZE ,
263+ "duration_ms" : duration_ms ,
264+ "file_size" : file_size if file_size is not None else 0 ,
265+ "filename" : Path (path ).name ,
266+ "path" : full_path or path ,
267+ "timings_ms" : {
268+ "convert" : (t_convert_end_ns - t_convert_start_ns ) / 1_000_000.0 ,
269+ "chunk" : (t_chunk_end_ns - t_convert_end_ns ) / 1_000_000.0 ,
270+ "total" : duration_ms ,
271+ },
272+ "version" : 1 ,
273+ },
274+ "chunks" : pages ,
275+ }
282276 if fallback :
283277 payload ["error_information" ] = [
284278 {
@@ -296,19 +290,11 @@ def ai_parse_document(stage_location: StageLocation, path: str) -> Dict[str, Any
296290 )
297291 return payload
298292 except Exception as exc : # pragma: no cover - defensive for unexpected docling errors
299- return OrderedDict (
300- [
301- (
302- "metadata" ,
303- {
304- "path" : path ,
305- "filename" : Path (path ).name ,
306- },
307- ),
308- ("chunks" , []),
309- (
310- "error_information" ,
311- [{"message" : str (exc ), "type" : exc .__class__ .__name__ }],
312- ),
313- ]
314- )
293+ return {
294+ "metadata" : {
295+ "path" : path ,
296+ "filename" : Path (path ).name ,
297+ },
298+ "chunks" : [],
299+ "error_information" : [{"message" : str (exc ), "type" : exc .__class__ .__name__ }],
300+ }
0 commit comments