1
- from typing import Optional , Dict , List , Type , TypeVar , Callable
1
+ from typing import Optional , Dict , Type , TypeVar , Callable
2
2
from io import BytesIO
3
3
import base64
4
4
@@ -70,24 +70,10 @@ def get_response_stream_by_id(self, request_id: str) -> Optional[BytesIO]:
70
70
if response_item is None or response_item .body is None :
71
71
return None
72
72
73
+ if isinstance (response_item .body , BytesIO ):
74
+ return response_item .body
73
75
return BytesIO (response_item .body )
74
76
75
- def response (
76
- self ,
77
- request_id : str ,
78
- response_type : Optional [Type [T ]] = None ,
79
- ) -> Optional ['BatchResponseItem' ]:
80
- """
81
- Get a response by its request ID from the collection
82
- :param request_id: The request ID of the response to get
83
- :type request_id: str
84
- :return: The response with the specified request ID as a BatchResponseItem
85
- :rtype: BatchResponseItem
86
- """
87
- if self ._responses is None :
88
- return None
89
- return self ._responses .get (request_id )
90
-
91
77
def response_body (self , request_id : str , type : Type [T ]) -> Optional [T ]:
92
78
"""
93
79
Get the body of a response by its request ID from the collection
@@ -104,7 +90,7 @@ def response_body(self, request_id: str, type: Type[T]) -> Optional[T]:
104
90
if not issubclass (type , Parsable ):
105
91
raise ValueError ("Type passed must implement the Parsable interface" )
106
92
107
- response = self .response (request_id )
93
+ response = self .get_response_by_id (request_id )
108
94
if response is not None :
109
95
content_type = response .content_type
110
96
else :
0 commit comments