Browse Source

fix: bad xinference error (#2384)

tags/0.5.4
Yeuoly 1 year ago
parent
commit
56c25bfb78
No account linked to committer's email address

+ 1
- 1
api/core/model_runtime/model_providers/xinference/llm/llm.py 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

+ 4
- 2
api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.py 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]]]:

Loading…
Cancel
Save