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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor: convert ProviderQuotaType if/elif to match/case (#30001) (#34561)
agenthaulk8b992513b86e
diff --git a/api/events/event_handlers/update_provider_when_message_created.py b/api/events/event_handlers/update_provider_when_message_created.pyindex f68cdaadde0..1d615f0f87a 100644--- a/api/events/event_handlers/update_provider_when_message_created.py+++ b/api/events/event_handlers/update_provider_when_message_created.py@@ -135,37 +135,40 @@ def handle(sender: Message, **kwargs):model_name=model_config.model,)if used_quota is not None:- if provider_configuration.system_configuration.current_quota_type == ProviderQuotaType.TRIAL:- from services.credit_pool_service import CreditPoolService+ match provider_configuration.system_configuration.current_quota_type:+ case ProviderQuotaType.TRIAL:+ from services.credit_pool_service import CreditPoolService- CreditPoolService.check_and_deduct_credits(- tenant_id=tenant_id,- credits_required=used_quota,- pool_type="trial",- )- elif provider_configuration.system_configuration.current_quota_type == ProviderQuotaType.PAID:- from services.credit_pool_service import CreditPoolService+ CreditPoolService.check_and_deduct_credits(+ tenant_id=tenant_id,+ credits_required=used_quota,+ pool_type="trial",+ )+ case ProviderQuotaType.PAID:+ from services.credit_pool_service import CreditPoolService- CreditPoolService.check_and_deduct_credits(- tenant_id=tenant_id,- credits_required=used_quota,- pool_type="paid",- )- else:- quota_update = _ProviderUpdateOperation(- filters=_ProviderUpdateFilters(+ CreditPoolService.check_and_deduct_credits(tenant_id=tenant_id,- provider_name=ModelProviderID(model_config.provider).provider_name,- provider_type=ProviderType.SYSTEM.value,- quota_type=provider_configuration.system_configuration.current_quota_type,- ),- values=_ProviderUpdateValues(quota_used=Provider.quota_used + used_quota, last_used=current_time),- additional_filters=_ProviderUpdateAdditionalFilters(- quota_limit_check=True # Provider.quota_limit > Provider.quota_used- ),- description="quota_deduction_update",- )- updates_to_perform.append(quota_update)+ credits_required=used_quota,+ pool_type="paid",+ )+ case ProviderQuotaType.FREE:+ quota_update = _ProviderUpdateOperation(+ filters=_ProviderUpdateFilters(+ tenant_id=tenant_id,+ provider_name=ModelProviderID(model_config.provider).provider_name,+ provider_type=ProviderType.SYSTEM.value,+ quota_type=provider_configuration.system_configuration.current_quota_type,+ ),+ values=_ProviderUpdateValues(+ quota_used=Provider.quota_used + used_quota, last_used=current_time+ ),+ additional_filters=_ProviderUpdateAdditionalFilters(+ quota_limit_check=True # Provider.quota_limit > Provider.quota_used+ ),+ description="quota_deduction_update",+ )+ updates_to_perform.append(quota_update)# Execute all updatesstart_time = time_module.perf_counter()