mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-21 18:05:30 -04:00
[PR #235] [MERGED] feat: Configurable Ping Max Tokens #246
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-plugin-sdks/pull/235
Author: @Bytechoreographer
Created: 11/4/2025
Status: ✅ Merged
Merged: 12/8/2025
Merged by: @Mairuis
Base:
main← Head:feat/increase_ping_max_tokens📝 Commits (1)
a5c44cefix: increase max_tokens from 5 to 16 for some specific models like gpt-5-codex in ping test, add PING_MAX_TOKENS configuration for model validation ping requests📊 Changes
2 files changed (+12 additions, -2 deletions)
View changed files
📝
python/dify_plugin/config/config.py(+5 -0)📝
python/dify_plugin/interfaces/model/openai_compatible/llm.py(+7 -2)📄 Description
Feature: Configurable Ping Max Tokens
Overview
Changed the
max_tokensparameter in OpenAI-compatible model validation (ping) requests from a hard-coded value to an environment variable-based configuration, improving flexibility and meeting different provider requirements.Background
Some OpenAI-compatible model providers—such as OpenRouter (when wrapping other vendors or offering models like gpt-5-codex)—either require the max_tokens parameter in validation requests to be at least 16 (resulting in validation failure if not met) or enforce a minimum output token limit overall (returning a 400 error for very small values like 5). However, the previous implementation hard-coded this max_tokens value as 5, which lacked flexibility.

Fixes #225
Changes
1. Configuration File Changes
File:
python/dify_plugin/config/config.pyAdded a new environment variable configuration in the
DifyPluginEnvclass:Notes:
.envfile2. Implementation Code Changes
File:
python/dify_plugin/interfaces/model/openai_compatible/llm.py2.1 Import Configuration Class
Added at the beginning of the file:
2.2 Modified validate_credentials Method
In the
validate_credentialsmethod:Usage
1. Using Default Value (Recommended)
No configuration needed. The system will use the default value of 16.
2. Custom Configuration
Add to the
.envfile in the project root directory:Or set other values based on actual needs, for example:
Compatibility Notes
Related Files
python/dify_plugin/config/config.py- Configuration definitionpython/dify_plugin/interfaces/model/openai_compatible/llm.py- Implementation codeModification Date
2025-01-06
Pull Request Checklist
Thank you for your contribution! Before submitting your PR, please make sure you have completed the following checks:
Compatibility Check
README.mdREADME.mdREADME.mdREADME.mdAvailable Checks
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.