Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

optimize baichuan invalid key error (#1996)

Yeuolyc9e4147b1135
diff --git a/api/core/model_runtime/model_providers/baichuan/llm/llm.py b/api/core/model_runtime/model_providers/baichuan/llm/llm.py
index 768f527c6ea..8b646cc7657 100644
--- a/api/core/model_runtime/model_providers/baichuan/llm/llm.py
+++ b/api/core/model_runtime/model_providers/baichuan/llm/llm.py
@@ -79,8 +79,10 @@ class BaichuanLarguageModel(LargeLanguageModel):
try:
instance.generate(model=model, stream=False, messages=[
BaichuanMessage(content='ping', role='user')
- ], parameters={}, timeout=10)
- except InvalidAPIKeyError as e:
+ ], parameters={
+ 'max_tokens': 1,
+ }, timeout=60)
+ except (InvalidAPIKeyError, InvalidAuthenticationError) as e:
raise CredentialsValidateFailedError(f"Invalid API key: {e}")
def _generate(self, model: str, credentials: dict, prompt_messages: list[PromptMessage],