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
6da5e541
Unverified
Commit
6da5e541
authored
May 23, 2023
by
John Wang
Committed by
GitHub
May 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat/open azure validate (#163)
parent
1c5f63de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
providers.py
api/controllers/console/workspace/providers.py
+1
-1
azure_provider.py
api/core/llm/provider/azure_provider.py
+25
-7
No files found.
api/controllers/console/workspace/providers.py
View file @
6da5e541
...
...
@@ -157,7 +157,7 @@ class ProviderTokenValidateApi(Resource):
args
=
parser
.
parse_args
()
# todo: remove this when the provider is supported
if
provider
in
[
ProviderName
.
ANTHROPIC
.
value
,
ProviderName
.
AZURE_OPENAI
.
value
,
ProviderName
.
COHERE
.
value
,
if
provider
in
[
ProviderName
.
ANTHROPIC
.
value
,
ProviderName
.
COHERE
.
value
,
ProviderName
.
HUGGINGFACEHUB
.
value
]:
return
{
'result'
:
'success'
,
'warning'
:
'MOCK: This provider is not supported yet.'
}
...
...
api/core/llm/provider/azure_provider.py
View file @
6da5e541
...
...
@@ -78,7 +78,7 @@ class AzureProvider(BaseProvider):
def
get_token_type
(
self
):
# TODO: change to dict when implemented
return
lambda
value
:
value
return
dict
def
config_validate
(
self
,
config
:
Union
[
dict
|
str
]):
"""
...
...
@@ -91,16 +91,34 @@ class AzureProvider(BaseProvider):
if
'openai_api_version'
not
in
config
:
config
[
'openai_api_version'
]
=
'2023-03-15-preview'
self
.
get_models
(
credentials
=
config
)
models
=
self
.
get_models
(
credentials
=
config
)
if
not
models
:
raise
ValidateFailedError
(
"Please add deployments for 'text-davinci-003', "
"'gpt-3.5-turbo', 'text-embedding-ada-002'."
)
fixed_model_ids
=
[
'text-davinci-003'
,
'gpt-35-turbo'
,
'text-embedding-ada-002'
]
current_model_ids
=
[
model
[
'id'
]
for
model
in
models
]
missing_model_ids
=
[
fixed_model_id
for
fixed_model_id
in
fixed_model_ids
if
fixed_model_id
not
in
current_model_ids
]
if
missing_model_ids
:
raise
ValidateFailedError
(
"Please add deployments for '{}'."
.
format
(
", "
.
join
(
missing_model_ids
)))
except
AzureAuthenticationError
:
raise
ValidateFailedError
(
'
Azure OpenAI Credentials v
alidation failed, please check your API Key.'
)
except
requests
.
ConnectionError
:
raise
ValidateFailedError
(
'
Azure OpenAI Credentials v
alidation failed, please check your API Base Endpoint.'
)
raise
ValidateFailedError
(
'
V
alidation failed, please check your API Key.'
)
except
(
requests
.
ConnectionError
,
requests
.
RequestException
)
:
raise
ValidateFailedError
(
'
V
alidation failed, please check your API Base Endpoint.'
)
except
AzureRequestFailedError
as
ex
:
raise
ValidateFailedError
(
'
Azure OpenAI Credentials v
alidation failed, error: {}.'
.
format
(
str
(
ex
)))
raise
ValidateFailedError
(
'
V
alidation failed, error: {}.'
.
format
(
str
(
ex
)))
except
Exception
as
ex
:
logging
.
exception
(
'Azure OpenAI Credentials validation failed'
)
raise
ex
raise
ValidateFailedError
(
'Validation failed, error: {}.'
.
format
(
str
(
ex
)))
def
get_encrypted_token
(
self
,
config
:
Union
[
dict
|
str
]):
"""
...
...
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