@@ -29,7 +29,7 @@ class Document(Generic[TypePrediction, TypePage]):
2929 """Result of the base inference"""
3030 id : str
3131 """Id of the document as sent back by the server"""
32- extras : Extras
32+ extras : Optional [ Extras ]
3333 """Potential Extras fields sent back along the prediction"""
3434 ocr : Optional [Ocr ]
3535 """Potential raw text results read by the OCR (limited feature)"""
@@ -45,7 +45,7 @@ def __init__(
4545 self .filename = raw_response .get ("name" , "" )
4646 if "ocr" in raw_response and raw_response ["ocr" ]:
4747 self .ocr = Ocr (raw_response ["ocr" ])
48- if "extras" in raw_response and raw_response ["extras" ]:
48+ if "extras" in raw_response and raw_response ["inference" ][ " extras" ]:
4949 self .extras = Extras (raw_response ["extras" ])
5050 self ._inject_full_text_ocr (raw_response )
5151 self .inference = inference_type (raw_response ["inference" ])
@@ -77,7 +77,7 @@ def _inject_full_text_ocr(self, raw_prediction: StringDict) -> None:
7777
7878 artificial_text_obj = {"content" : full_text_content }
7979
80- if not hasattr (self , "extras" ):
80+ if not hasattr (self , "extras" ) or not self . extras :
8181 self .extras = Extras ({"full_text_ocr" : artificial_text_obj })
8282 else :
8383 self .extras .add_artificial_extra ({"full_text_ocr" : artificial_text_obj })
0 commit comments