Skip to content

Commit c7fca3d

Browse files
authored
Revert "fix: 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 (#235)" (#263)
This reverts commit ee8ea3d.
1 parent ee8ea3d commit c7fca3d

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

python/dify_plugin/config/config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ class DifyPluginEnv(BaseSettings):
4040

4141
DIFY_PLUGIN_DAEMON_URL: str = Field(default="http://localhost:5002", description="backwards invocation address")
4242

43-
PING_MAX_TOKENS: int = Field(
44-
default=16,
45-
description="Maximum tokens for model validation ping request. Some providers require at least 16 tokens.",
46-
)
47-
4843
model_config = SettingsConfigDict(
4944
# read from dotenv format config file
5045
env_file=".env",

python/dify_plugin/interfaces/model/openai_compatible/llm.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ def validate_credentials(self, model: str, credentials: dict) -> None:
172172
:return:
173173
"""
174174
try:
175-
# Load ping max_tokens configuration from environment variable
176-
config = DifyPluginEnv()
177-
ping_max_tokens = config.PING_MAX_TOKENS
178-
179175
headers = {"Content-Type": "application/json"}
180176

181177
api_key = credentials.get("api_key")
@@ -187,7 +183,7 @@ def validate_credentials(self, model: str, credentials: dict) -> None:
187183
endpoint_url += "/"
188184

189185
# prepare the payload for a simple ping to the model
190-
data = {"model": credentials.get("endpoint_model_name", model), "max_tokens": ping_max_tokens}
186+
data = {"model": credentials.get("endpoint_model_name", model), "max_tokens": 5}
191187

192188
completion_type = LLMMode.value_of(credentials["mode"])
193189

@@ -206,7 +202,7 @@ def validate_credentials(self, model: str, credentials: dict) -> None:
206202
stream_mode_auth = credentials.get("stream_mode_auth", "not_use")
207203
if stream_mode_auth == "use":
208204
data["stream"] = True
209-
data["max_tokens"] = ping_max_tokens
205+
data["max_tokens"] = 10
210206
response = requests.post(endpoint_url, headers=headers, json=data, timeout=(10, 300), stream=True)
211207
if response.status_code != 200:
212208
raise CredentialsValidateFailedError(

0 commit comments

Comments
 (0)