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.

feat: Add "type" field to PipelineRecommendedPlugin model; Add query param "type" to recommended-plugins api. (#29736)

FFXNa93eecaeeee5
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 debe8eed977..46d67f0581e 100644
--- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py
+++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py
@@ -4,7 +4,7 @@ from typing import Any, Literal, cast
from uuid import UUID
from flask import abort, request
-from flask_restx import Resource, marshal_with # type: ignore
+from flask_restx import Resource, marshal_with, reqparse # type: ignore
from pydantic import BaseModel, Field
from sqlalchemy.orm import Session
from werkzeug.exceptions import Forbidden, InternalServerError, NotFound
@@ -975,6 +975,11 @@ class RagPipelineRecommendedPluginApi(Resource):
@login_required
@account_initialization_required
def get(self):
+ parser = reqparse.RequestParser()
+ parser.add_argument("type", type=str, location="args", required=False, default="all")
+ args = parser.parse_args()
+ type = args["type"]
+
rag_pipeline_service = RagPipelineService()
- recommended_plugins = rag_pipeline_service.get_recommended_plugins()
+ recommended_plugins = rag_pipeline_service.get_recommended_plugins(type)
return recommended_plugins
diff --git a/api/migrations/versions/2025_12_16_1817-03ea244985ce_add_type_column_not_null_default_tool.py b/api/migrations/versions/2025_12_16_1817-03ea244985ce_add_type_column_not_null_default_tool.py
new file mode 100644
index 00000000000..2bdd430e815
--- /dev/null
+++ b/api/migrations/versions/2025_12_16_1817-03ea244985ce_add_type_column_not_null_default_tool.py
@@ -0,0 +1,31 @@
+"""add type column not null default tool
+
+Revision ID: 03ea244985ce
+Revises: d57accd375ae
+Create Date: 2025-12-16 18:17:12.193877
+
+"""
+from alembic import op
+import models as models
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+
+# revision identifiers, used by Alembic.
+revision = '03ea244985ce'
+down_revision = 'd57accd375ae'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('pipeline_recommended_plugins', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('type', sa.String(length=50), server_default=sa.text("'tool'"), nullable=False))
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ with op.batch_alter_table('pipeline_recommended_plugins', schema=None) as batch_op:
+ batch_op.drop_column('type')
+ # ### end Alembic commands ###
diff --git a/api/models/dataset.py b/api/models/dataset.py
index ba2eaf6749f..445ac6086fc 100644
--- a/api/models/dataset.py
+++ b/api/models/dataset.py
@@ -1532,6 +1532,7 @@ class PipelineRecommendedPlugin(TypeBase):
)
plugin_id: Mapped[str] = mapped_column(LongText, nullable=False)
provider_name: Mapped[str] = mapped_column(LongText, nullable=False)
+ type: Mapped[str] = mapped_column(sa.String(50), nullable=False, server_default=sa.text("'tool'"))
position: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=0)
active: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=True)
created_at: Mapped[datetime] = mapped_column(
diff --git a/api/services/rag_pipeline/rag_pipeline.py b/api/services/rag_pipeline/rag_pipeline.py
index 097d16e2a76..f53448e7fe6 100644
--- a/api/services/rag_pipeline/rag_pipeline.py
+++ b/api/services/rag_pipeline/rag_pipeline.py
@@ -1248,14 +1248,13 @@ class RagPipelineService:
session.commit()
return workflow_node_execution_db_model
- def get_recommended_plugins(self) -> dict:
+ def get_recommended_plugins(self, type: str) -> dict:
# Query active recommended plugins
- pipeline_recommended_plugins = (
- db.session.query(PipelineRecommendedPlugin)
- .where(PipelineRecommendedPlugin.active == True)
- .order_by(PipelineRecommendedPlugin.position.asc())
- .all()
- )
+ query = db.session.query(PipelineRecommendedPlugin).where(PipelineRecommendedPlugin.active == True)
+ if type and type != "all":
+ query = query.where(PipelineRecommendedPlugin.type == type)
+
+ pipeline_recommended_plugins = query.order_by(PipelineRecommendedPlugin.position.asc()).all()
if not pipeline_recommended_plugins:
return {