@@ -260,6 +260,62 @@ def test_process_response(self):
260260 self .assertTrue ("multimodal_outputs" in processed .__dict__ )
261261 self .assertEqual (processed .multimodal_outputs ["images" ].shape , response .multimodal_outputs ["images" ].shape )
262262
263+ def test_process_response_dict (self ):
264+ """
265+ Test processing of a response dictionary through the processor.
266+
267+ Ensures:
268+ 1. The returned dict contains expected keys
269+ 2. Multimodal outputs are preserved
270+ 3. Text output matches expected decoded tokens
271+ """
272+ # Mock output from model
273+ response_dict = {
274+ "request_id" : "12345" ,
275+ "responses" : [{"text" : "This is a test response." }],
276+ "multimodal_outputs" : {"images" : np .random .randint (0 , 256 , (1 , 3 , 224 , 224 ))},
277+ }
278+
279+ # Patch processor's ids2tokens to return expected text
280+ with patch .object (
281+ self .processor .processor , "ids2tokens" , return_value = ["This" , "is" , "a" , "test" , "response" , "." ]
282+ ):
283+ processed = self .processor .process_response_dict (response_dict )
284+
285+ # Assertions
286+ self .assertIn ("request_id" , processed )
287+ self .assertIn ("responses" , processed )
288+ self .assertIn ("multimodal_outputs" , processed )
289+ self .assertEqual (processed ["responses" ][0 ]["text" ], "This is a test response." )
290+
291+ def test_process_response (self ):
292+ """
293+ Test processing of a Response object through the processor.
294+
295+ Ensures:
296+ 1. Returns a Request object
297+ 2. Response text is correctly decoded
298+ 3. Multimodal outputs are preserved
299+ """
300+ from fastdeploy .engine .response import Response
301+
302+ # Mock a Response object
303+ response = Response (
304+ request_id = "12345" ,
305+ responses = [{"text" : "Another test response" }],
306+ multimodal_outputs = {"images" : np .random .randint (0 , 256 , (1 , 3 , 224 , 224 ))},
307+ )
308+
309+ # Patch ids2tokens
310+ with patch .object (self .processor .processor , "ids2tokens" , return_value = ["Another" , "test" , "response" ]):
311+ processed = self .processor .process_response (response )
312+
313+ # Assertions
314+ self .assertIsInstance (processed , Request )
315+ self .assertEqual (processed .responses [0 ]["text" ], "Another test response" )
316+ self .assertTrue ("multimodal_outputs" in processed .__dict__ )
317+ self .assertEqual (processed .multimodal_outputs ["images" ].shape , response .multimodal_outputs ["images" ].shape )
318+
263319 def test_prompt (self ):
264320 """
265321 Test processing of prompt with image and video placeholders
0 commit comments