From 56c25bfb783d064e1b6545d04c3d370a4b3f61f0 Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:52:14 +0800 Subject: [PATCH] fix: bad xinference error (#2384) --- .../model_runtime/model_providers/xinference/llm/llm.py | 2 +- .../xinference/text_embedding/text_embedding.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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 58801229d..841e19787 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 02541e310..bfc77db49 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]]]: