mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2026-04-23 17:11:21 +08:00
[Optimization]update request in tool parser&reasoning parser (#6858)
* update request in tool parser&reasoning parser
This commit is contained in:
@@ -541,6 +541,7 @@ class DataProcessor(BaseDataProcessor):
|
||||
token_ids = output.token_ids
|
||||
is_end = response_obj.finished
|
||||
req_id = response_obj.request_id
|
||||
request = kwargs.get("request", None)
|
||||
if is_end and len(token_ids) > 0 and not kwargs.get("include_stop_str_in_output"):
|
||||
if token_ids[-1] in self.eos_token_ids:
|
||||
token_ids = token_ids[:-1]
|
||||
@@ -553,7 +554,7 @@ class DataProcessor(BaseDataProcessor):
|
||||
response_obj.outputs.enable_parser = True
|
||||
reasoning_content, text = self.reasoning_parser.extract_reasoning_content(
|
||||
full_text,
|
||||
response_obj,
|
||||
request,
|
||||
self.model_status_dict[req_id],
|
||||
)
|
||||
response_obj.outputs.text = text
|
||||
@@ -563,7 +564,7 @@ class DataProcessor(BaseDataProcessor):
|
||||
if self.tool_parser_obj:
|
||||
response_obj.outputs.enable_parser = True
|
||||
tool_parser = self.tool_parser_obj(self.tokenizer)
|
||||
tool_call_info = tool_parser.extract_tool_calls(full_text, response_obj)
|
||||
tool_call_info = tool_parser.extract_tool_calls(full_text, request)
|
||||
if tool_call_info.tools_called:
|
||||
response_obj.outputs.tool_calls = tool_call_info.tool_calls
|
||||
response_obj.outputs.text = tool_call_info.content
|
||||
@@ -587,6 +588,7 @@ class DataProcessor(BaseDataProcessor):
|
||||
token_ids = output.token_ids
|
||||
is_end = response_obj.finished
|
||||
req_id = response_obj.request_id
|
||||
request = kwargs.get("request", None)
|
||||
|
||||
if is_end and len(token_ids) > 0 and not kwargs.get("include_stop_str_in_output"):
|
||||
if token_ids[-1] in self.eos_token_ids:
|
||||
@@ -620,7 +622,7 @@ class DataProcessor(BaseDataProcessor):
|
||||
previous_token_ids,
|
||||
previous_token_ids + token_ids,
|
||||
token_ids,
|
||||
response_obj,
|
||||
request,
|
||||
)
|
||||
if tool_call is None or tool_call.tool_calls:
|
||||
response_obj.outputs.delta_message = tool_call
|
||||
|
||||
Reference in New Issue
Block a user