fix: openai origin credential not start with { (#1874)

This commit is contained in:
takatost 2024-01-03 12:10:43 +08:00 committed by GitHub
parent b43f1441a9
commit ae975b10e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -446,7 +446,14 @@ class ProviderManager:
custom_provider_configuration = None
if custom_provider_record:
try:
provider_credentials = json.loads(custom_provider_record.encrypted_config)
# fix origin data
if (custom_provider_record.encrypted_config
and not custom_provider_record.encrypted_config.startswith("{")):
provider_credentials = {
"openai_api_key": custom_provider_record.encrypted_config
}
else:
provider_credentials = json.loads(custom_provider_record.encrypted_config)
except JSONDecodeError:
provider_credentials = {}