[DataProcessor] add strict#7307
Conversation
|
Thanks for your contribution! |
| name: str | ||
| description: Optional[str] = None | ||
| parameters: Optional[dict[str, Any]] = None | ||
| strict: bool = False |
There was a problem hiding this comment.
这里把 strict 设为 bool = False 会导致在 model_dump()(未设置 exclude_defaults)时,总是把 strict: false 序列化并透传到 engine/request(见 fastdeploy/engine/request.py:293),从而改变未显式指定 strict 的请求负载。为保持与现有行为/文档示例一致(未提供则不发送),建议将其改为 Optional[bool] = None,并在序列化时保持 exclude_none=True 或沿用现有的 value is not None 过滤逻辑。
| strict: bool = False | |
| strict: Optional[bool] = None |
| name: str | ||
| description: Optional[str] = None | ||
| parameters: Optional[dict[str, Any]] = None | ||
| strict: bool = False |
There was a problem hiding this comment.
PR 描述目前仍是模板内容,缺少最基本的 Motivation / Modifications(为什么要加 strict、解决了什么问题、是否影响兼容性/用法)。建议补充这些信息,并在需要时同步更新相关文档/使用示例说明。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7307 +/- ##
==========================================
Coverage ? 74.55%
==========================================
Files ? 383
Lines ? 53589
Branches ? 8405
==========================================
Hits ? 39951
Misses ? 10915
Partials ? 2723
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:
|
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-13
📋 Review 摘要
PR 概述:为 FunctionDefinition 类添加 strict 字段,支持 OpenAI API 的严格模式功能调用。
变更范围:fastdeploy/entrypoints/openai/protocol.py
影响面 Tag:[DataProcessor]
📝 PR 规范检查
PR 标题包含有效标签 [DataProcessor],但 PR 描述不完整。Motivation 和 Modifications 部分均为空,未说明变更背景和实现细节。
标题建议(可直接复制):
- 当前:
[DataProcessor] add strict(已符合规范)
描述模板(可直接复制):
## Motivation
支持 OpenAI API 中 Function Calling 的严格模式(strict mode),确保模型生成的 JSON 输出严格遵循参数定义的 JSON Schema。参考:https://platform.openai.com/docs/guides/function-calling
## Modifications
在 `FunctionDefinition` 类中添加 `strict: Optional[bool] = None` 字段,与 `JsonSchemaResponseFormat` 的字段定义保持一致。
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | protocol.py:232 |
缺少针对 strict 字段的单元测试 |
总体评价
代码变更正确且无破坏性风险,strict 字段与 JsonSchemaResponseFormat 保持一致,符合 OpenAI API 规范。建议补充单元测试以验证新字段的序列化/反序列化行为。
| name: str | ||
| description: Optional[str] = None | ||
| parameters: Optional[dict[str, Any]] = None | ||
| strict: Optional[bool] = None |
There was a problem hiding this comment.
🟡 建议 虽然变更简单且向后兼容,但建议添加单元测试验证 strict 字段的序列化/反序列化行为,确保与 JsonSchemaResponseFormat.strict 行为一致。
示例测试(可添加到 tests/entrypoints/test_chat.py):
def test_function_strict_field(self):
"""Test strict field in FunctionDefinition"""
tool = ChatCompletionToolsParam(
type="function",
function={
"name": "get_weather",
"description": "Get weather info",
"parameters": {"type": "object", "properties": {}},
"strict": True,
}
)
self.assertTrue(tool.function.strict)
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.