[PR #275] [MERGED] Make validate_credentials max_tokens configurable (preserve stream default 10) #279

Closed
opened 2026-02-15 21:16:33 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-sdks/pull/275
Author: @Yeuoly
Created: 12/27/2025
Status: Merged
Merged: 12/29/2025
Merged by: @Yeuoly

Base: mainHead: codex/make-max_tokens-configurable-s3iofr


📝 Commits (1)

📊 Changes

1 file changed (+9 additions, -2 deletions)

View changed files

📝 python/dify_plugin/interfaces/model/openai_compatible/llm.py (+9 -2)

📄 Description

Motivation

  • Providers differ in behavior for validation pings, so the max_tokens used during credentials validation must be configurable.
  • Streaming validation historically relied on max_tokens=10 to ensure a token chunk is emitted, so that behavior should be preserved by default.
  • Allow explicit credential overrides for both non-stream and stream validation to support edge cases where the default is unsuitable.
  • Undo the earlier pyproject.toml version bump as requested to avoid changing the published SDK version.

Description

  • Read validate_credentials_max_tokens from credentials and use it as the ping max_tokens for non-stream validation in python/dify_plugin/interfaces/model/openai_compatible/llm.py with a default fallback of 5.
  • For stream-mode validation, keep the historical default max_tokens=10 but allow override when validate_credentials_max_tokens is explicitly provided in credentials, and add an inline comment explaining the rationale.
  • Add small code adjustments in llm.py to apply the configurable values in both validation flows.
  • Reverted the SDK version change in python/pyproject.toml as requested (the lockfile changes were not reverted here).

Testing

  • No automated tests were executed for this change.
  • All modifications were limited to python/dify_plugin/interfaces/model/openai_compatible/llm.py and python/pyproject.toml (revert).
  • Basic repository operations (git commit) were used to record the change and no runtime validation was performed.
  • Manual code inspection was done during the change process.

Codex Task


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-plugin-sdks/pull/275 **Author:** [@Yeuoly](https://github.com/Yeuoly) **Created:** 12/27/2025 **Status:** ✅ Merged **Merged:** 12/29/2025 **Merged by:** [@Yeuoly](https://github.com/Yeuoly) **Base:** `main` ← **Head:** `codex/make-max_tokens-configurable-s3iofr` --- ### 📝 Commits (1) - [`13eac2d`](https://github.com/langgenius/dify-plugin-sdks/commit/13eac2dccffa616d55e850f5eafd8276914edc3f) Revert SDK version bump ### 📊 Changes **1 file changed** (+9 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `python/dify_plugin/interfaces/model/openai_compatible/llm.py` (+9 -2) </details> ### 📄 Description ### Motivation - Providers differ in behavior for validation pings, so the `max_tokens` used during credentials validation must be configurable. - Streaming validation historically relied on `max_tokens=10` to ensure a token chunk is emitted, so that behavior should be preserved by default. - Allow explicit credential overrides for both non-stream and stream validation to support edge cases where the default is unsuitable. - Undo the earlier `pyproject.toml` version bump as requested to avoid changing the published SDK version. ### Description - Read `validate_credentials_max_tokens` from `credentials` and use it as the ping `max_tokens` for non-stream validation in `python/dify_plugin/interfaces/model/openai_compatible/llm.py` with a default fallback of `5`. - For stream-mode validation, keep the historical default `max_tokens=10` but allow override when `validate_credentials_max_tokens` is explicitly provided in `credentials`, and add an inline comment explaining the rationale. - Add small code adjustments in `llm.py` to apply the configurable values in both validation flows. - Reverted the SDK version change in `python/pyproject.toml` as requested (the lockfile changes were not reverted here). ### Testing - No automated tests were executed for this change. - All modifications were limited to `python/dify_plugin/interfaces/model/openai_compatible/llm.py` and `python/pyproject.toml` (revert). - Basic repository operations (`git commit`) were used to record the change and no runtime validation was performed. - Manual code inspection was done during the change process. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_b_69491f6bf5648326a7880f45f886800d) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 21:16:33 -05:00
yindo closed this issue 2026-02-15 21:16:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-sdks#279