Quellcode durchsuchen

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

takatost vor 1 Jahr
Ursprung
Commit
ae975b10e9
1 geänderte Dateien mit 8 neuen und 1 gelöschten Zeilen
  1. 8 1
      api/core/provider_manager.py

+ 8 - 1
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 = {}