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
a7cdb745
Unverified
Commit
a7cdb745
authored
Sep 01, 2023
by
takatost
Committed by
GitHub
Sep 01, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support spark v2 validate (#1086)
parent
73c86ee6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
spark_provider.py
api/core/model_providers/providers/spark_provider.py
+28
-7
No files found.
api/core/model_providers/providers/spark_provider.py
View file @
a7cdb745
...
...
@@ -83,14 +83,15 @@ class SparkProvider(BaseModelProvider):
if
'api_secret'
not
in
credentials
:
raise
CredentialsValidateFailedError
(
'Spark api_secret must be provided.'
)
try
:
credential_kwargs
=
{
'app_id'
:
credentials
[
'app_id'
],
'api_key'
:
credentials
[
'api_key'
],
'api_secret'
:
credentials
[
'api_secret'
],
}
credential_kwargs
=
{
'app_id'
:
credentials
[
'app_id'
],
'api_key'
:
credentials
[
'api_key'
],
'api_secret'
:
credentials
[
'api_secret'
],
}
try
:
chat_llm
=
ChatSpark
(
model_name
=
'spark-v2'
,
max_tokens
=
10
,
temperature
=
0.01
,
**
credential_kwargs
...
...
@@ -104,7 +105,27 @@ class SparkProvider(BaseModelProvider):
chat_llm
(
messages
)
except
SparkError
as
ex
:
raise
CredentialsValidateFailedError
(
str
(
ex
))
# try spark v1.5 if v2.1 failed
try
:
chat_llm
=
ChatSpark
(
model_name
=
'spark'
,
max_tokens
=
10
,
temperature
=
0.01
,
**
credential_kwargs
)
messages
=
[
HumanMessage
(
content
=
"ping"
)
]
chat_llm
(
messages
)
except
SparkError
as
ex
:
raise
CredentialsValidateFailedError
(
str
(
ex
))
except
Exception
as
ex
:
logging
.
exception
(
'Spark config validation failed'
)
raise
ex
except
Exception
as
ex
:
logging
.
exception
(
'Spark config validation failed'
)
raise
ex
...
...
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