From ae975b10e94032a07bd8c130fe0be48612bdf951 Mon Sep 17 00:00:00 2001 From: takatost Date: Wed, 3 Jan 2024 12:10:43 +0800 Subject: [PATCH] fix: openai origin credential not start with { (#1874) --- api/core/provider_manager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/core/provider_manager.py b/api/core/provider_manager.py index 4572ff7507..82c149673c 100644 --- a/api/core/provider_manager.py +++ b/api/core/provider_manager.py @@ -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 = {}