[Cherry-Pick]Allows tools and content to coexist.(#6656)#6996
[Cherry-Pick]Allows tools and content to coexist.(#6656)#6996Jiang-Jia-Jun merged 2 commits intoPaddlePaddle:release/2.4from
Conversation
|
Thanks for your contribution! |
There was a problem hiding this comment.
Pull request overview
该 PR 旨在调整文本后处理逻辑:当解析到 tool_calls 时,不再用工具解析结果覆盖原有 text 字段,以便在同一次回复中同时返回自然语言内容与工具调用信息(更贴近 OpenAI “content + tool_calls 可共存”的语义)。
Changes:
- 在
process_response()中,检测到tool_calls时不再覆盖response_dict.outputs.text。 - 在
process_response_dict_normal()中,检测到tool_calls时不再覆盖response_dict["outputs"]["text"]。
| if self.tool_parser_obj: | ||
| tool_parser = self.tool_parser_obj(self.tokenizer) | ||
| tool_call_info = tool_parser.extract_tool_calls(full_text, response_dict) | ||
| if tool_call_info.tools_called: | ||
| response_dict.outputs.tool_calls = tool_call_info.tool_calls |
There was a problem hiding this comment.
当前 DataProcessor 在检测到 tool_calls 时不再用 tool_call_info.content 覆盖 text;但 fastdeploy/input/ernie4_5_processor.py 仍会覆盖 text(会导致 tool_calls + 文本共存行为在不同 processor 间不一致)。如果这是一个全局语义变更,建议同步修改 Ernie4_5Processor,或在此处说明仅适用于 text_processor 的原因。
| tool_call_info = tool_parser.extract_tool_calls(full_text, response_dict) | ||
| if tool_call_info.tools_called: | ||
| response_dict.outputs.tool_calls = tool_call_info.tool_calls |
| tool_parser = self.tool_parser_obj(self.tokenizer) | ||
| tool_call_info = tool_parser.extract_tool_calls(full_text, response_dict) | ||
| if tool_call_info.tools_called: | ||
| response_dict["outputs"]["tool_calls"] = tool_call_info.tool_calls |
There was a problem hiding this comment.
PR 描述目前仍是模板占位(Motivation/Modifications/Usage/Tests 未填写)。建议补充:为何需要允许 tool_calls 与 content 共存、影响哪些模型/接口、以及是否做过回归或对齐 OpenAI tool_calls 行为的测试。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/2.4 #6996 +/- ##
==============================================
Coverage ? 56.03%
==============================================
Files ? 333
Lines ? 42570
Branches ? 6483
==============================================
Hits ? 23855
Misses ? 16831
Partials ? 1884
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f35f0c1
into
PaddlePaddle:release/2.4
Motivation
Modifications
Usage or Command
Accuracy Tests
Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.