Browse Source

fix: inference embedding validate (#1187)

tags/0.3.23
takatost 2 years ago
parent
commit
c8bd76cd66
No account linked to committer's email address
2 changed files with 17 additions and 8 deletions
  1. 15
    6
      api/core/model_providers/providers/xinference_provider.py
  2. 2
    2
      api/requirements.txt

+ 15
- 6
api/core/model_providers/providers/xinference_provider.py View File

from typing import Type from typing import Type


import requests import requests
from langchain.embeddings import XinferenceEmbeddings


from core.helper import encrypter from core.helper import encrypter
from core.model_providers.models.embedding.xinference_embedding import XinferenceEmbedding from core.model_providers.models.embedding.xinference_embedding import XinferenceEmbedding
'model_uid': credentials['model_uid'], 'model_uid': credentials['model_uid'],
} }


llm = XinferenceLLM(
**credential_kwargs
)
if model_type == ModelType.TEXT_GENERATION:
llm = XinferenceLLM(
**credential_kwargs
)

llm("ping")
elif model_type == ModelType.EMBEDDINGS:
embedding = XinferenceEmbeddings(
**credential_kwargs
)


llm("ping")
embedding.embed_query("ping")
except Exception as ex: except Exception as ex:
raise CredentialsValidateFailedError(str(ex)) raise CredentialsValidateFailedError(str(ex))


:param credentials: :param credentials:
:return: :return:
""" """
extra_credentials = cls._get_extra_credentials(credentials)
credentials.update(extra_credentials)
if model_type == ModelType.TEXT_GENERATION:
extra_credentials = cls._get_extra_credentials(credentials)
credentials.update(extra_credentials)


credentials['server_url'] = encrypter.encrypt_token(tenant_id, credentials['server_url']) credentials['server_url'] = encrypter.encrypt_token(tenant_id, credentials['server_url'])



+ 2
- 2
api/requirements.txt View File

pytest-mock~=3.11.1 pytest-mock~=3.11.1
tiktoken==0.3.3 tiktoken==0.3.3
Authlib==1.2.0 Authlib==1.2.0
boto3~=1.26.123
boto3==1.28.17
tenacity==8.2.2 tenacity==8.2.2
cachetools~=5.3.0 cachetools~=5.3.0
weaviate-client~=3.21.0 weaviate-client~=3.21.0
transformers~=4.31.0 transformers~=4.31.0
stripe~=5.5.0 stripe~=5.5.0
pandas==1.5.3 pandas==1.5.3
xinference==0.2.1
xinference==0.4.2
safetensors==0.3.2 safetensors==0.3.2

Loading…
Cancel
Save