mirror of
https://github.com/langgenius/dify.git
synced 2026-09-24 23:22:26 +08:00
fix(api): enforce document creation limits in pipeline generator (#37586)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
autofix-ci[bot]
parent
1065fe519c
commit
ad5bade45f
@@ -2032,14 +2032,7 @@ class DocumentService:
|
||||
website_info = knowledge_config.data_source.info_list.website_info_list
|
||||
assert website_info
|
||||
count = len(website_info.urls)
|
||||
batch_upload_limit = int(dify_config.BATCH_UPLOAD_LIMIT)
|
||||
|
||||
if features.billing.subscription.plan == CloudPlan.SANDBOX and count > 1:
|
||||
raise ValueError("Your current plan does not support batch upload, please upgrade your plan.")
|
||||
if count > batch_upload_limit:
|
||||
raise ValueError(f"You have reached the batch upload limit of {batch_upload_limit}.")
|
||||
|
||||
DocumentService.check_documents_upload_quota(count, features)
|
||||
DocumentService.check_document_creation_limits(count, features)
|
||||
|
||||
# if dataset is empty, update dataset data_source_type
|
||||
if not dataset.data_source_type and knowledge_config.data_source:
|
||||
@@ -2603,6 +2596,21 @@ class DocumentService:
|
||||
f"You have reached the limit of your subscription. Only {can_upload_size} documents can be uploaded."
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def check_document_creation_limits(count: int, features: FeatureModel):
|
||||
"""Validate billing-backed document creation limits before document rows are created."""
|
||||
if not features.billing.enabled:
|
||||
return
|
||||
|
||||
if features.billing.subscription.plan == CloudPlan.SANDBOX and count > 1:
|
||||
raise ValueError("Your current plan does not support batch upload, please upgrade your plan.")
|
||||
|
||||
batch_upload_limit = int(dify_config.BATCH_UPLOAD_LIMIT)
|
||||
if count > batch_upload_limit:
|
||||
raise ValueError(f"You have reached the batch upload limit of {batch_upload_limit}.")
|
||||
|
||||
DocumentService.check_documents_upload_quota(count, features)
|
||||
|
||||
@staticmethod
|
||||
def build_document(
|
||||
dataset: Dataset,
|
||||
@@ -2824,13 +2832,7 @@ class DocumentService:
|
||||
website_info = knowledge_config.data_source.info_list.website_info_list
|
||||
if website_info:
|
||||
count = len(website_info.urls)
|
||||
if features.billing.subscription.plan == CloudPlan.SANDBOX and count > 1:
|
||||
raise ValueError("Your current plan does not support batch upload, please upgrade your plan.")
|
||||
batch_upload_limit = int(dify_config.BATCH_UPLOAD_LIMIT)
|
||||
if count > batch_upload_limit:
|
||||
raise ValueError(f"You have reached the batch upload limit of {batch_upload_limit}.")
|
||||
|
||||
DocumentService.check_documents_upload_quota(count, features)
|
||||
DocumentService.check_document_creation_limits(count, features)
|
||||
|
||||
dataset_collection_binding_id = None
|
||||
retrieval_model = None
|
||||
|
||||
Reference in New Issue
Block a user