-
Notifications
You must be signed in to change notification settings - Fork 105
feat: Configurable Ping Max Tokens #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Configurable Ping Max Tokens #235
Conversation
Summary of ChangesHello @Bytechoreographer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request increases the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly increases the max_tokens for credential validation to support providers with minimum token limits. My review includes suggestions to replace the hardcoded value 32 with a named constant. This will improve the code's readability and make it easier to maintain in the future.
63f55f0 to
4dc76a8
Compare
…pt-5-codex in ping test, add PING_MAX_TOKENS configuration for model validation ping requests
4dc76a8 to
a5c44ce
Compare

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.

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:
# Some special providers may require larger values PING_MAX_TOKENS=64Compatibility 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