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
62d3eeb4
Commit
62d3eeb4
authored
Jul 15, 2023
by
John Wang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/claude-api-support' into deploy/dev
parents
c66db061
05493c35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
31 deletions
+21
-31
providers.py
api/controllers/console/workspace/providers.py
+1
-1
provider_service.py
api/services/provider_service.py
+20
-30
No files found.
api/controllers/console/workspace/providers.py
View file @
62d3eeb4
...
...
@@ -35,7 +35,7 @@ class ProviderListApi(Resource):
plaintext, the rest is replaced by * and the last two bits are displayed in plaintext
"""
ProviderService
.
init_supported_provider
(
current_user
.
current_tenant
,
"cloud"
)
ProviderService
.
init_supported_provider
(
current_user
.
current_tenant
)
providers
=
Provider
.
query
.
filter_by
(
tenant_id
=
tenant_id
)
.
all
()
provider_list
=
[
...
...
api/services/provider_service.py
View file @
62d3eeb4
...
...
@@ -10,44 +10,34 @@ from models.provider import *
class
ProviderService
:
@
staticmethod
def
init_supported_provider
(
tenant
,
edition
):
def
init_supported_provider
(
tenant
):
"""Initialize the model provider, check whether the supported provider has a record"""
providers
=
Provider
.
query
.
filter_by
(
tenant_id
=
tenant
.
id
)
.
all
()
need_init_provider_names
=
[
ProviderName
.
OPENAI
.
value
,
ProviderName
.
AZURE_OPENAI
.
value
,
ProviderName
.
ANTHROPIC
.
value
]
openai_provider_exists
=
False
azure_openai_provider_exists
=
False
# TODO: The cloud version needs to construct the data of the SYSTEM type
providers
=
db
.
session
.
query
(
Provider
)
.
filter
(
Provider
.
tenant_id
==
tenant
.
id
,
Provider
.
provider_type
==
ProviderType
.
CUSTOM
.
value
,
Provider
.
provider_name
.
in_
(
need_init_provider_names
)
)
.
all
()
exists_provider_names
=
[]
for
provider
in
providers
:
if
provider
.
provider_name
==
ProviderName
.
OPENAI
.
value
and
provider
.
provider_type
==
ProviderType
.
CUSTOM
.
value
:
openai_provider_exists
=
True
if
provider
.
provider_name
==
ProviderName
.
AZURE_OPENAI
.
value
and
provider
.
provider_type
==
ProviderType
.
CUSTOM
.
value
:
azure_openai_provider_exists
=
True
exists_provider_names
.
append
(
provider
.
provider_name
)
# Initialize the model provider, check whether the supported provider has a record
not_exists_provider_names
=
list
(
set
(
need_init_provider_names
)
-
set
(
exists_provider_names
))
# Create default providers if they don't exist
if
not
openai_provider_exists
:
openai_provider
=
Provider
(
tenant_id
=
tenant
.
id
,
provider_name
=
ProviderName
.
OPENAI
.
value
,
provider_type
=
ProviderType
.
CUSTOM
.
value
,
is_valid
=
False
)
db
.
session
.
add
(
openai_provider
)
if
not
azure_openai_provider_exists
:
azure_openai_provider
=
Provider
(
tenant_id
=
tenant
.
id
,
provider_name
=
ProviderName
.
AZURE_OPENAI
.
value
,
provider_type
=
ProviderType
.
CUSTOM
.
value
,
is_valid
=
False
)
db
.
session
.
add
(
azure_openai_provider
)
if
not_exists_provider_names
:
# Initialize the model provider, check whether the supported provider has a record
for
provider_name
in
not_exists_provider_names
:
provider
=
Provider
(
tenant_id
=
tenant
.
id
,
provider_name
=
provider_name
,
provider_type
=
ProviderType
.
CUSTOM
.
value
,
is_valid
=
False
)
db
.
session
.
add
(
provider
)
if
not
openai_provider_exists
or
not
azure_openai_provider_exists
:
db
.
session
.
commit
()
@
staticmethod
...
...
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