The ranges of values for presence_penalty and frequency_penalty in the OpenAI models plugin do not match those in the official OpenAI API. #183

Closed
opened 2026-02-16 10:18:22 -05:00 by yindo · 1 comment
Owner

Originally created by @natsu12 on GitHub (Apr 9, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues Dify issues & Dify Official Plugins, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.0.1

Plugin version

OpenAI 0.0.14

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

The presence_penalty and frequency_penalty in parameter_rules in all yaml files in the openai plugin use the default template:

parameter_rules:
  - name: temperature
    use_template: temperature
  - name: top_p
    use_template: top_p
  - name: presence_penalty
    use_template: presence_penalty
  - name: frequency_penalty
    use_template: frequency_penalty

While in the default template in dify-plugin-sdks, the range of the value of requency_penalty and presence_penalty is 0 to 1:

DefaultParameterName.PRESENCE_PENALTY: {
    "label": {
        "en_US": "Presence Penalty",
        "zh_Hans": "存在惩罚",
    },
    "type": "float",
    "help": {
        "en_US": "Applies a penalty to the log-probability of tokens already in the text.",
        "zh_Hans": "对文本中已有的标记的对数概率施加惩罚。",
    },
    "required": False,
    "default": 0.0,
    "min": 0.0,
    "max": 1.0,
    "precision": 2,
},
DefaultParameterName.FREQUENCY_PENALTY: {
    "label": {
        "en_US": "Frequency Penalty",
        "zh_Hans": "频率惩罚",
    },
    "type": "float",
    "help": {
        "en_US": "Applies a penalty to the log-probability of tokens that appear in the text.",
        "zh_Hans": "对文本中出现的标记的对数概率施加惩罚。",
    },
    "required": False,
    "default": 0.0,
    "min": 0.0,
    "max": 1.0,
    "precision": 2,
},

However, the value range of OpenAI official API should be -2 to 2, right?

Image

Image

✔️ Error log

No response

Originally created by @natsu12 on GitHub (Apr 9, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.0.1 ### Plugin version OpenAI 0.0.14 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce The `presence_penalty` and `frequency_penalty` in parameter_rules in all yaml files in the [openai plugin](https://github.com/langgenius/dify-official-plugins/blob/main/models/openai/models/llm/gpt-3.5-turbo-0125.yaml) use the default template: ``` parameter_rules: - name: temperature use_template: temperature - name: top_p use_template: top_p - name: presence_penalty use_template: presence_penalty - name: frequency_penalty use_template: frequency_penalty ``` While in the default template in [dify-plugin-sdks](https://github.com/langgenius/dify-plugin-sdks/blob/main/python/dify_plugin/entities/model/__init__.py), the range of the value of `requency_penalty` and `presence_penalty` is 0 to 1: ``` DefaultParameterName.PRESENCE_PENALTY: { "label": { "en_US": "Presence Penalty", "zh_Hans": "存在惩罚", }, "type": "float", "help": { "en_US": "Applies a penalty to the log-probability of tokens already in the text.", "zh_Hans": "对文本中已有的标记的对数概率施加惩罚。", }, "required": False, "default": 0.0, "min": 0.0, "max": 1.0, "precision": 2, }, DefaultParameterName.FREQUENCY_PENALTY: { "label": { "en_US": "Frequency Penalty", "zh_Hans": "频率惩罚", }, "type": "float", "help": { "en_US": "Applies a penalty to the log-probability of tokens that appear in the text.", "zh_Hans": "对文本中出现的标记的对数概率施加惩罚。", }, "required": False, "default": 0.0, "min": 0.0, "max": 1.0, "precision": 2, }, ``` However, the value range of [OpenAI official API](https://platform.openai.com/docs/api-reference/responses/create) should be -2 to 2, right? ![Image](https://github.com/user-attachments/assets/3657a1c6-2311-4445-ae2b-40f7fd15d70f) ![Image](https://github.com/user-attachments/assets/0c160e73-e3f7-4389-888a-9aeaeb6dbf31) ### ✔️ Error log _No response_
yindo added the bug label 2026-02-16 10:18:22 -05:00
yindo closed this issue 2026-02-16 10:18:22 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 16, 2025):

Hi, @natsu12. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a mismatch between the OpenAI models plugin YAML files and the dify-plugin-sdks default templates regarding presence_penalty and frequency_penalty parameter ranges.
  • The plugin YAML files do not specify ranges, while the SDK enforces a 0 to 1 range for these parameters.
  • This was observed on Dify version 1.0.1 with OpenAI plugin 0.0.14 in a self-hosted Docker setup.
  • No further updates or comments have been provided since your initial report.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here to keep the discussion open.
  • If I do not hear back within 5 days, this issue will be automatically closed.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 16, 2025): Hi, @natsu12. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a mismatch between the OpenAI models plugin YAML files and the dify-plugin-sdks default templates regarding presence_penalty and frequency_penalty parameter ranges. - The plugin YAML files do not specify ranges, while the SDK enforces a 0 to 1 range for these parameters. - This was observed on Dify version 1.0.1 with OpenAI plugin 0.0.14 in a self-hosted Docker setup. - No further updates or comments have been provided since your initial report. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here to keep the discussion open. - If I do not hear back within 5 days, this issue will be automatically closed. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#183