Skip to content

Commit

Permalink
fix: credentials validate compatible problem (#2170)
Browse files Browse the repository at this point in the history
  • Loading branch information
takatost authored Jan 24, 2024
1 parent 78524a5 commit 784da52
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/core/entities/provider_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,16 @@ def custom_credentials_validate(self, credentials: dict) -> Tuple[Provider, dict

if provider_record:
try:
original_credentials = json.loads(
provider_record.encrypted_config) if provider_record.encrypted_config else {}
# fix origin data
if provider_record.encrypted_config:
if not provider_record.encrypted_config.startswith("{"):
original_credentials = {
"openai_api_key": provider_record.encrypted_config
}
else:
original_credentials = json.loads(provider_record.encrypted_config)
else:
original_credentials = {}
except JSONDecodeError:
original_credentials = {}

Expand Down

0 comments on commit 784da52

Please sign in to comment.