Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
c8bd76cd
Unverified
Commit
c8bd76cd
authored
Sep 15, 2023
by
takatost
Committed by
GitHub
Sep 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: inference embedding validate (#1187)
parent
ec5f585d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
xinference_provider.py
api/core/model_providers/providers/xinference_provider.py
+15
-6
requirements.txt
api/requirements.txt
+2
-2
No files found.
api/core/model_providers/providers/xinference_provider.py
View file @
c8bd76cd
...
...
@@ -2,6 +2,7 @@ import json
from
typing
import
Type
import
requests
from
langchain.embeddings
import
XinferenceEmbeddings
from
core.helper
import
encrypter
from
core.model_providers.models.embedding.xinference_embedding
import
XinferenceEmbedding
...
...
@@ -97,11 +98,18 @@ class XinferenceProvider(BaseModelProvider):
'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
:
raise
CredentialsValidateFailedError
(
str
(
ex
))
...
...
@@ -117,8 +125,9 @@ class XinferenceProvider(BaseModelProvider):
:param credentials:
: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'
])
...
...
api/requirements.txt
View file @
c8bd76cd
...
...
@@ -19,7 +19,7 @@ pytest~=7.3.1
pytest-mock~=3.11.1
tiktoken==0.3.3
Authlib==1.2.0
boto3
~=1.26.123
boto3
==1.28.17
tenacity==8.2.2
cachetools~=5.3.0
weaviate-client~=3.21.0
...
...
@@ -49,5 +49,5 @@ huggingface_hub~=0.16.4
transformers~=4.31.0
stripe~=5.5.0
pandas==1.5.3
xinference==0.
2.1
xinference==0.
4.2
safetensors==0.3.2
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment