From f4064c05d1a5166f95ec86c44a9050911b605920 Mon Sep 17 00:00:00 2001 From: huayaoyue6 Date: Sun, 7 Dec 2025 16:41:59 +0800 Subject: [PATCH] fix: use configurable max_tokens in credential validation instead of hardcoded value The `validate_credentials` method in `OAICompatLargeLanguageModel` uses a hardcoded `max_tokens: 5` value when testing model connectivity. This can cause credential validation failures for models that have minimum token requirements higher than 5, even when the credentials are correct. --- python/dify_plugin/interfaces/model/openai_compatible/llm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/dify_plugin/interfaces/model/openai_compatible/llm.py b/python/dify_plugin/interfaces/model/openai_compatible/llm.py index dcff5ffd..8f5b7ba7 100644 --- a/python/dify_plugin/interfaces/model/openai_compatible/llm.py +++ b/python/dify_plugin/interfaces/model/openai_compatible/llm.py @@ -183,7 +183,8 @@ def validate_credentials(self, model: str, credentials: dict) -> None: endpoint_url += "/" # prepare the payload for a simple ping to the model - data = {"model": credentials.get("endpoint_model_name", model), "max_tokens": 5} + data = {"model": credentials.get("endpoint_model_name", model), + "max_tokens": int(credentials.get("max_tokens_to_sample", 20))} completion_type = LLMMode.value_of(credentials["mode"])