From cfc555d05d8baa91210857dc8f72fd41402030bb Mon Sep 17 00:00:00 2001 From: Yunlu Wen Date: Thu, 7 Aug 2025 10:49:06 +0800 Subject: [PATCH 1/2] feat: add knowledge pipeline creation feature --- .../console/datasets/rag_pipeline/rag_pipeline.py | 2 ++ api/controllers/console/wraps.py | 10 ++++++++++ api/services/feature_service.py | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/api/controllers/console/datasets/rag_pipeline/rag_pipeline.py b/api/controllers/console/datasets/rag_pipeline/rag_pipeline.py index 93976bd6f5..f496149deb 100644 --- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline.py +++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline.py @@ -9,6 +9,7 @@ from controllers.console.wraps import ( account_initialization_required, enterprise_license_required, setup_required, + knowledge_pipeline_publish_enabled, ) from extensions.ext_database import db from libs.login import login_required @@ -116,6 +117,7 @@ class PublishCustomizedPipelineTemplateApi(Resource): @login_required @account_initialization_required @enterprise_license_required + @knowledge_pipeline_publish_enabled def post(self, pipeline_id: str): parser = reqparse.RequestParser() parser.add_argument( diff --git a/api/controllers/console/wraps.py b/api/controllers/console/wraps.py index d862dac373..2df41ba840 100644 --- a/api/controllers/console/wraps.py +++ b/api/controllers/console/wraps.py @@ -261,3 +261,13 @@ def is_allow_transfer_owner(view): abort(403) return decorated + + +def knowledge_pipeline_publish_enabled(view): + @wraps(view) + def decorated(*args, **kwargs): + features = FeatureService.get_features(current_user.current_tenant_id) + if features.knowledge_pipeline.publish_enabled: + return view(*args, **kwargs) + abort(403) + return decorated diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 1441e6ce16..43c8a5fec4 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -87,6 +87,8 @@ class WebAppAuthModel(BaseModel): allow_email_code_login: bool = False allow_email_password_login: bool = False +class KnowledgePipeline(BaseModel): + publish_enabled: bool = False class PluginInstallationScope(StrEnum): NONE = "none" @@ -126,6 +128,7 @@ class FeatureModel(BaseModel): is_allow_transfer_workspace: bool = True # pydantic configs model_config = ConfigDict(protected_namespaces=()) + knowledge_pipeline: KnowledgePipeline = KnowledgePipeline() class KnowledgeRateLimitModel(BaseModel): @@ -265,6 +268,9 @@ class FeatureService: if "knowledge_rate_limit" in billing_info: features.knowledge_rate_limit = billing_info["knowledge_rate_limit"]["limit"] + if "knowledge_pipeline_publish_enabled" in billing_info: + features.knowledge_pipeline.publish_enabled = billing_info["knowledge_pipeline_publish_enabled"] + @classmethod def _fulfill_params_from_enterprise(cls, features: SystemFeatureModel): enterprise_info = EnterpriseService.get_info() From ff76adc88a02ac6699727081d852337238044e05 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 04:17:51 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- api/controllers/console/datasets/rag_pipeline/rag_pipeline.py | 2 +- api/controllers/console/wraps.py | 1 + api/core/app/apps/pipeline/pipeline_runner.py | 1 - api/core/workflow/entities/variable_pool.py | 2 +- api/core/workflow/nodes/datasource/datasource_node.py | 4 ++-- api/services/feature_service.py | 2 ++ 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/controllers/console/datasets/rag_pipeline/rag_pipeline.py b/api/controllers/console/datasets/rag_pipeline/rag_pipeline.py index f496149deb..334c11bddb 100644 --- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline.py +++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline.py @@ -8,8 +8,8 @@ from controllers.console import api from controllers.console.wraps import ( account_initialization_required, enterprise_license_required, - setup_required, knowledge_pipeline_publish_enabled, + setup_required, ) from extensions.ext_database import db from libs.login import login_required diff --git a/api/controllers/console/wraps.py b/api/controllers/console/wraps.py index 2df41ba840..3e1237615a 100644 --- a/api/controllers/console/wraps.py +++ b/api/controllers/console/wraps.py @@ -270,4 +270,5 @@ def knowledge_pipeline_publish_enabled(view): if features.knowledge_pipeline.publish_enabled: return view(*args, **kwargs) abort(403) + return decorated diff --git a/api/core/app/apps/pipeline/pipeline_runner.py b/api/core/app/apps/pipeline/pipeline_runner.py index 89ada53831..9c97b8109f 100644 --- a/api/core/app/apps/pipeline/pipeline_runner.py +++ b/api/core/app/apps/pipeline/pipeline_runner.py @@ -13,7 +13,6 @@ from core.app.entities.app_invoke_entities import ( from core.variables.variables import RAGPipelineVariable, RAGPipelineVariableInput from core.workflow.callbacks import WorkflowCallback, WorkflowLoggingCallback from core.workflow.entities.variable_pool import VariablePool -from core.workflow.enums import SystemVariableKey from core.workflow.graph_engine.entities.event import GraphEngineEvent, GraphRunFailedEvent from core.workflow.graph_engine.entities.graph import Graph from core.workflow.system_variable import SystemVariable diff --git a/api/core/workflow/entities/variable_pool.py b/api/core/workflow/entities/variable_pool.py index d92134db58..f19128b445 100644 --- a/api/core/workflow/entities/variable_pool.py +++ b/api/core/workflow/entities/variable_pool.py @@ -18,6 +18,7 @@ from core.workflow.constants import ( ) from core.workflow.system_variable import SystemVariable from factories import variable_factory + VariableValue = Union[str, int, float, dict, list, File] VARIABLE_PATTERN = re.compile(r"\{\{#([a-zA-Z0-9_]{1,50}(?:\.[a-zA-Z_][a-zA-Z0-9_]{0,29}){1,10})#\}\}") @@ -75,7 +76,6 @@ class VariablePool(BaseModel): for key, value in rag_pipeline_variables_map.items(): self.add((RAG_PIPELINE_VARIABLE_NODE_ID, key), value) - def add(self, selector: Sequence[str], value: Any, /) -> None: """ Add a variable to the variable pool. diff --git a/api/core/workflow/nodes/datasource/datasource_node.py b/api/core/workflow/nodes/datasource/datasource_node.py index 823514de44..fbab9c631d 100644 --- a/api/core/workflow/nodes/datasource/datasource_node.py +++ b/api/core/workflow/nodes/datasource/datasource_node.py @@ -138,7 +138,7 @@ class DatasourceNode(BaseNode): datasource_runtime.get_online_document_page_content( user_id=self.user_id, datasource_parameters=GetOnlineDocumentPageContentRequest( - workspace_id=datasource_info.get("workspace_id"), + workspace_id=datasource_info.get("workspace_id"), page_id=datasource_info.get("page").get("page_id"), type=datasource_info.get("page").get("type"), ), @@ -205,7 +205,7 @@ class DatasourceNode(BaseNode): storage_key=upload_file.key, ) variable_pool.add([self.node_id, "file"], file_info) - #variable_pool.add([self.node_id, "file"], file_info.to_dict()) + # variable_pool.add([self.node_id, "file"], file_info.to_dict()) yield RunCompletedEvent( run_result=NodeRunResult( status=WorkflowNodeExecutionStatus.SUCCEEDED, diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 43c8a5fec4..3bb0fff0a8 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -87,9 +87,11 @@ class WebAppAuthModel(BaseModel): allow_email_code_login: bool = False allow_email_password_login: bool = False + class KnowledgePipeline(BaseModel): publish_enabled: bool = False + class PluginInstallationScope(StrEnum): NONE = "none" OFFICIAL_ONLY = "official_only"