Skip to content

Conversation

@xiaolei373
Copy link
Collaborator

@xiaolei373 xiaolei373 commented Sep 9, 2025

本次改动主要包括以下两点:

  1. 请求参数超参数校验前置

    • 将请求参数的超参数校验逻辑前置到 ChatCompletionRequest / CompletionRequest 类中。
    • 校验逻辑保持不变,仅调整校验位置,确保参数在进入业务逻辑前即被验证。
  2. 错误信息格式全局统一

    • 错误响应格式与 OpenAI 对齐,统一为以下结构:

      {
        "error": {
          "message": "错误的详细描述(不为 null)",
          "type": "错误类别(可为 null)",
          "param": "具体出错的参数(可为 null)",
          "code": "细分错误类别(可为 null)"
        }
      }
    • 具体约定:

      • 请求参数异常

        • messageparam 提供准确错误信息与参数名。

        • type 固定为 "invalid_request_error"

        • code 根据不同场景设置具体枚举值(如 "invalid_value")。

        • 示例:

          {
            "error": {
              "message": "Input should be a valid integer, got a number with a fractional part",
              "type": "invalid_request_error",
              "param": "max_tokens",
              "code": "invalid_value"
            }
          }
      • 引擎或底层推理错误

        • 错误信息统一封装在 message 字段中。
        • type 固定为 "internal_error"
        • 其他字段使用默认值。

@paddle-bot
Copy link

paddle-bot bot commented Sep 9, 2025

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Sep 9, 2025
@xiaolei373 xiaolei373 force-pushed the valid_para_format_error_info branch 10 times, most recently from 6976e04 to 5270dd5 Compare September 12, 2025 06:22
@xiaolei373 xiaolei373 changed the title Valid para format error info 【Format】Valid para format error info Sep 12, 2025
@xiaolei373 xiaolei373 changed the title 【Format】Valid para format error info [format] Valid para format error info Sep 12, 2025
@xiaolei373 xiaolei373 force-pushed the valid_para_format_error_info branch from 5270dd5 to 3f3c012 Compare September 12, 2025 08:30
@Jiang-Jia-Jun Jiang-Jia-Jun merged commit 9ac5394 into PaddlePaddle:develop Sep 12, 2025
14 of 17 checks passed
@xiaolei373 xiaolei373 mentioned this pull request Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants