Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: update load balancing configurations with new credential IDs and… (#26900)

Xiyuan Chenbd01af64150d
diff --git a/api/core/entities/provider_configuration.py b/api/core/entities/provider_configuration.py
index b0699558367..c4be4292192 100644
--- a/api/core/entities/provider_configuration.py
+++ b/api/core/entities/provider_configuration.py
@@ -1148,6 +1148,15 @@ class ProviderConfiguration(BaseModel):
raise ValueError("Can't add same credential")
provider_model_record.credential_id = credential_record.id
provider_model_record.updated_at = naive_utc_now()
+
+ # clear cache
+ provider_model_credentials_cache = ProviderCredentialsCache(
+ tenant_id=self.tenant_id,
+ identity_id=provider_model_record.id,
+ cache_type=ProviderCredentialsCacheType.MODEL,
+ )
+ provider_model_credentials_cache.delete()
+
session.add(provider_model_record)
session.commit()
@@ -1181,6 +1190,14 @@ class ProviderConfiguration(BaseModel):
session.add(provider_model_record)
session.commit()
+ # clear cache
+ provider_model_credentials_cache = ProviderCredentialsCache(
+ tenant_id=self.tenant_id,
+ identity_id=provider_model_record.id,
+ cache_type=ProviderCredentialsCacheType.MODEL,
+ )
+ provider_model_credentials_cache.delete()
+
def delete_custom_model(self, model_type: ModelType, model: str):
"""
Delete custom model.