| 
184 | 184 | )  | 
185 | 185 | from inference.core.interfaces.http.middlewares.cors import PathAwareCORSMiddleware  | 
186 | 186 | from inference.core.interfaces.http.middlewares.gzip import gzip_response_if_requested  | 
187 |  | -from inference.core.interfaces.http.orjson_utils import orjson_response  | 
 | 187 | +from inference.core.interfaces.http.orjson_utils import (  | 
 | 188 | +    orjson_response,  | 
 | 189 | +    orjson_response_keeping_parent_id,  | 
 | 190 | +)  | 
188 | 191 | from inference.core.interfaces.stream_manager.api.entities import (  | 
189 | 192 |     CommandResponse,  | 
190 | 193 |     ConsumePipelineResponse,  | 
@@ -1994,7 +1997,9 @@ def yolo_world_infer(  | 
1994 | 1997 | 
 
  | 
1995 | 1998 |                 @app.post(  | 
1996 | 1999 |                     "/doctr/ocr",  | 
1997 |  | -                    response_model=OCRInferenceResponse | List[OCRInferenceResponse],  | 
 | 2000 | +                    response_model=Union[  | 
 | 2001 | +                        OCRInferenceResponse, List[OCRInferenceResponse]  | 
 | 2002 | +                    ],  | 
1998 | 2003 |                     summary="DocTR OCR response",  | 
1999 | 2004 |                     description="Run the DocTR OCR model to retrieve text in an image.",  | 
2000 | 2005 |                 )  | 
@@ -2036,13 +2041,15 @@ def doctr_retrieve_text(  | 
2036 | 2041 |                             "authorizer"  | 
2037 | 2042 |                         ]["lambda"]["actor"]  | 
2038 | 2043 |                         trackUsage(doctr_model_id, actor)  | 
2039 |  | -                    return orjson_response(response)  | 
 | 2044 | +                    return orjson_response_keeping_parent_id(response)  | 
2040 | 2045 | 
 
  | 
2041 | 2046 |             if CORE_MODEL_EASYOCR_ENABLED:  | 
2042 | 2047 | 
 
  | 
2043 | 2048 |                 @app.post(  | 
2044 | 2049 |                     "/easy_ocr/ocr",  | 
2045 |  | -                    response_model=OCRInferenceResponse | List[OCRInferenceResponse],  | 
 | 2050 | +                    response_model=Union[  | 
 | 2051 | +                        OCRInferenceResponse, List[OCRInferenceResponse]  | 
 | 2052 | +                    ],  | 
2046 | 2053 |                     summary="EasyOCR OCR response",  | 
2047 | 2054 |                     description="Run the EasyOCR model to retrieve text in an image.",  | 
2048 | 2055 |                 )  | 
@@ -2084,7 +2091,7 @@ def easy_ocr_retrieve_text(  | 
2084 | 2091 |                             "authorizer"  | 
2085 | 2092 |                         ]["lambda"]["actor"]  | 
2086 | 2093 |                         trackUsage(easy_ocr_model_id, actor)  | 
2087 |  | -                    return orjson_response(response)  | 
 | 2094 | +                    return orjson_response_keeping_parent_id(response)  | 
2088 | 2095 | 
 
  | 
2089 | 2096 |             if CORE_MODEL_SAM_ENABLED:  | 
2090 | 2097 | 
 
  | 
@@ -2472,7 +2479,7 @@ def trocr_retrieve_text(  | 
2472 | 2479 |                             "authorizer"  | 
2473 | 2480 |                         ]["lambda"]["actor"]  | 
2474 | 2481 |                         trackUsage(trocr_model_id, actor)  | 
2475 |  | -                    return orjson_response(response)  | 
 | 2482 | +                    return orjson_response_keeping_parent_id(response)  | 
2476 | 2483 | 
 
  | 
2477 | 2484 |         if not (LAMBDA or GCP_SERVERLESS):  | 
2478 | 2485 | 
 
  | 
 | 
0 commit comments