diff --git a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py index 8de32ba7fb..4decf0f627 100644 --- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py +++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py @@ -10,7 +10,6 @@ from controllers.console import api from controllers.console.app.error import ( DraftWorkflowNotExist, ) -from controllers.console.app.wraps import get_app_model from controllers.console.datasets.wraps import get_rag_pipeline from controllers.console.wraps import account_initialization_required, setup_required from controllers.web.error import InvalidArgumentError, NotFoundError @@ -21,12 +20,11 @@ from core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIAB from factories.file_factory import build_from_mapping, build_from_mappings from factories.variable_factory import build_segment_with_type from libs.login import current_user, login_required -from models import App, AppMode, db +from models import db from models.dataset import Pipeline from models.workflow import WorkflowDraftVariable from services.rag_pipeline.rag_pipeline import RagPipelineService from services.workflow_draft_variable_service import WorkflowDraftVariableList, WorkflowDraftVariableService -from services.workflow_service import WorkflowService logger = logging.getLogger(__name__) @@ -399,8 +397,20 @@ api.add_resource( RagPipelineVariableCollectionApi, "/rag/pipelines//workflows/draft/variables", ) -api.add_resource(RagPipelineNodeVariableCollectionApi, "/rag/pipelines//workflows/draft/nodes//variables") -api.add_resource(RagPipelineVariableApi, "/rag/pipelines//workflows/draft/variables/") -api.add_resource(RagPipelineVariableResetApi, "/rag/pipelines//workflows/draft/variables//reset") -api.add_resource(RagPipelineSystemVariableCollectionApi, "/rag/pipelines//workflows/draft/system-variables") -api.add_resource(RagPipelineEnvironmentVariableCollectionApi, "/rag/pipelines//workflows/draft/environment-variables") +api.add_resource( + RagPipelineNodeVariableCollectionApi, + "/rag/pipelines//workflows/draft/nodes//variables", +) +api.add_resource( + RagPipelineVariableApi, "/rag/pipelines//workflows/draft/variables/" +) +api.add_resource( + RagPipelineVariableResetApi, "/rag/pipelines//workflows/draft/variables//reset" +) +api.add_resource( + RagPipelineSystemVariableCollectionApi, "/rag/pipelines//workflows/draft/system-variables" +) +api.add_resource( + RagPipelineEnvironmentVariableCollectionApi, + "/rag/pipelines//workflows/draft/environment-variables", +) diff --git a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py index 16f8f426d9..bb7e27a4bc 100644 --- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py +++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py @@ -960,7 +960,6 @@ class DatasourceListApi(Resource): class RagPipelineWorkflowLastRunApi(Resource): - @setup_required @login_required @account_initialization_required @@ -1093,4 +1092,4 @@ api.add_resource( api.add_resource( RagPipelineWorkflowLastRunApi, "/rag/pipelines//workflows/draft/nodes//last-run", -) \ No newline at end of file +) diff --git a/api/core/app/apps/pipeline/pipeline_generator.py b/api/core/app/apps/pipeline/pipeline_generator.py index 29f9f2360e..2bc89ed99c 100644 --- a/api/core/app/apps/pipeline/pipeline_generator.py +++ b/api/core/app/apps/pipeline/pipeline_generator.py @@ -694,10 +694,12 @@ class PipelineGenerator(BaseAppGenerator): datasource_info, ) else: - all_files.append({ - "key": datasource_info.get("key", ""), - "bucket": datasource_info.get("bucket", None), - }) + all_files.append( + { + "key": datasource_info.get("key", ""), + "bucket": datasource_info.get("bucket", None), + } + ) return all_files else: return datasource_info_list diff --git a/api/services/rag_pipeline/rag_pipeline.py b/api/services/rag_pipeline/rag_pipeline.py index fec2a4b1e1..9d273290bf 100644 --- a/api/services/rag_pipeline/rag_pipeline.py +++ b/api/services/rag_pipeline/rag_pipeline.py @@ -1090,19 +1090,20 @@ class RagPipelineService: db.session.add(pipeline_customized_template) db.session.commit() - def is_workflow_exist(self, pipeline: Pipeline) -> bool: - return ( - db.session.query(Workflow) - .filter( - Workflow.tenant_id == pipeline.tenant_id, - Workflow.app_id == pipeline.id, - Workflow.version == Workflow.VERSION_DRAFT, - ) - .count() - ) > 0 - - def get_node_last_run(self, pipeline: Pipeline, workflow: Workflow, node_id: str) -> WorkflowNodeExecutionModel | None: + return ( + db.session.query(Workflow) + .filter( + Workflow.tenant_id == pipeline.tenant_id, + Workflow.app_id == pipeline.id, + Workflow.version == Workflow.VERSION_DRAFT, + ) + .count() + ) > 0 + + def get_node_last_run( + self, pipeline: Pipeline, workflow: Workflow, node_id: str + ) -> WorkflowNodeExecutionModel | None: # TODO(QuantumGhost): This query is not fully covered by index. criteria = ( WorkflowNodeExecutionModel.tenant_id == pipeline.tenant_id, @@ -1116,4 +1117,4 @@ class RagPipelineService: .order_by(WorkflowNodeExecutionModel.created_at.desc()) .first() ) - return node_exec \ No newline at end of file + return node_exec