fix: bad xinference error (#2384)

This commit is contained in:
Yeuoly 2024-02-05 10:52:14 +08:00 committed by GitHub
parent b814f0b7e3
commit 56c25bfb78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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]]]: