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.

fix: bad xinference error (#2384)

Yeuoly56c25bfb783d
diff --git a/api/core/model_runtime/model_providers/xinference/llm/llm.py b/api/core/model_runtime/model_providers/xinference/llm/llm.py
index 58801229d2b..841e1978732 100644
--- a/api/core/model_runtime/model_providers/xinference/llm/llm.py
+++ b/api/core/model_runtime/model_providers/xinference/llm/llm.py
@@ -70,7 +70,7 @@ class XinferenceAILargeLanguageModel(LargeLanguageModel):
elif 'generate' in extra_param.model_ability:
credentials['completion_type'] = 'completion'
else:
- raise ValueError(f'xinference model ability {extra_param.model_ability} is not supported')
+ raise ValueError(f'xinference model ability {extra_param.model_ability} is not supported, check if you have the right model type')
if extra_param.support_function_call:
credentials['support_function_call'] = True
diff --git a/api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.py
index 02541e310f9..bfc77db494d 100644
--- a/api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.py
+++ b/api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.py
@@ -114,8 +114,10 @@ class XinferenceTextEmbeddingModel(TextEmbeddingModel):
credentials['max_tokens'] = extra_args.max_tokens
self._invoke(model=model, credentials=credentials, texts=['ping'])
- except (InvokeAuthorizationError, RuntimeError):
- raise CredentialsValidateFailedError('Invalid api key')
+ except InvokeAuthorizationError as e:
+ raise CredentialsValidateFailedError(f'Failed to validate credentials for model {model}: {e}')
+ except RuntimeError as e:
+ raise CredentialsValidateFailedError(e)
@property
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: