@@ -36,8 +36,22 @@ def process(self, process_request: ProcessRequest) -> RecognitionResponse:
36
36
37
37
def deserialize_to_recognition_response (self , content : Union [bytes , bytearray , str ]) -> RecognitionResponse :
38
38
response = self .__to_response_object (content )
39
- response = self .api_client .deserialize (response , ProcessResponse )
40
- return RecognitionResponse (response )
39
+
40
+ if hasattr (response , 'to_str' ):
41
+ response_text = response .to_str ()
42
+ elif hasattr (response , 'data' ):
43
+ data = response .data
44
+ if isinstance (data , (bytes , bytearray )):
45
+ response_text = data .decode ('utf-8' )
46
+ else :
47
+ response_text = str (data )
48
+ else :
49
+ response_text = str (content ) if not isinstance (content , str ) else content
50
+
51
+ content_type = "application/json"
52
+ process_response = self .api_client .deserialize (response_text , "ProcessResponse" , content_type )
53
+
54
+ return RecognitionResponse (process_response )
41
55
42
56
@staticmethod
43
57
def __to_response_object (content : Union [bytes , bytearray , str ]):
0 commit comments