MCPcopy Index your code
hub / github.com/PaddlePaddle/FastDeploy / process_response

Method process_response

fastdeploy/input/text_processor.py:392–423  ·  view source on GitHub ↗

Preprocess the response Args: response_dict (Dict): response for engine, contain ids fields Returns: Dict: response contain text fields

(self, response_dict, **kwargs)

Source from the content-addressed store, hash-verified

390 return full_text
391
392 def process_response(self, response_dict, **kwargs):
393 """
394 Preprocess the response
395
396 Args:
397 response_dict (Dict): response for engine, contain ids fields
398
399 Returns:
400 Dict: response contain text fields
401 """
402 req_id = response_dict.request_id
403 token_ids = response_dict.outputs.token_ids
404 if token_ids[-1] == self.tokenizer.eos_token_id:
405 token_ids = token_ids[:-1]
406 full_text = self.tokenizer.decode(token_ids)
407 response_dict.outputs.text = full_text
408 if self.reasoning_parser:
409 reasoning_content, text = self.reasoning_parser.extract_reasoning_content(
410 full_text, response_dict, self.model_status_dict[req_id]
411 )
412 response_dict.outputs.text = text
413 response_dict.outputs.reasoning_content = reasoning_content
414 if self.tool_parser_obj:
415 tool_parser = self.tool_parser_obj(self.tokenizer)
416 tool_call_info = tool_parser.extract_tool_calls(full_text, response_dict)
417 if tool_call_info.tools_called:
418 response_dict.outputs.tool_calls = tool_call_info.tool_calls
419 if req_id in self.model_status_dict:
420 del self.model_status_dict[req_id]
421 data_processor_logger.info(f"req_id:{req_id}, token_ids: {token_ids}")
422
423 return response_dict
424
425 def process_response_dict_normal(self, response_dict, **kwargs):
426 """

Callers 2

generateMethod · 0.45
_run_engineMethod · 0.45

Calls 4

decodeMethod · 0.45
extract_tool_callsMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected