Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions python/dify_plugin/interfaces/model/openai_compatible/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ 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}
validate_credentials_max_tokens = credentials.get("validate_credentials_max_tokens", 5) or 5
data = {
"model": credentials.get("endpoint_model_name", model),
"max_tokens": validate_credentials_max_tokens,
}

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

Expand All @@ -201,8 +205,11 @@ def validate_credentials(self, model: str, credentials: dict) -> None:
# ADD stream validate_credentials
stream_mode_auth = credentials.get("stream_mode_auth", "not_use")
if stream_mode_auth == "use":
stream_validate_max_tokens = credentials.get("validate_credentials_max_tokens", None) or 10
data["stream"] = True
data["max_tokens"] = 10
# default 10 (introduced in PR #93) to ensure streaming endpoints emit a token chunk;
# allow overriding via credentials when explicitly provided.
data["max_tokens"] = stream_validate_max_tokens
response = requests.post(endpoint_url, headers=headers, json=data, timeout=(10, 300), stream=True)
if response.status_code != 200:
raise CredentialsValidateFailedError(
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "dify_plugin"
version = "0.7.0"
version = "0.7.1"
description = "Dify Plugin SDK"
authors = [{ name = "langgenius", email = "[email protected]" }]
dependencies = [
Expand Down
Loading