mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 19:27:23 +08:00
Add "type" field to PipelineRecommendedPlugin model; Add query param "type" to recommended-plugins api.
This commit is contained in:
parent
f8b10c2272
commit
bcd33be22a
@ -1004,6 +1004,11 @@ class RagPipelineRecommendedPluginApi(Resource):
|
|||||||
@login_required
|
@login_required
|
||||||
@account_initialization_required
|
@account_initialization_required
|
||||||
def get(self):
|
def get(self):
|
||||||
|
parser = reqparse.RequestParser()
|
||||||
|
parser.add_argument('type', type=str, location='args', required=False, default='all')
|
||||||
|
args = parser.parse_args()
|
||||||
|
plugin_type = args["type"]
|
||||||
|
|
||||||
rag_pipeline_service = RagPipelineService()
|
rag_pipeline_service = RagPipelineService()
|
||||||
recommended_plugins = rag_pipeline_service.get_recommended_plugins()
|
recommended_plugins = rag_pipeline_service.get_recommended_plugins(plugin_type)
|
||||||
return recommended_plugins
|
return recommended_plugins
|
||||||
|
|||||||
@ -0,0 +1,65 @@
|
|||||||
|
"""Alter table pipeline_recommended_plugins add column type
|
||||||
|
|
||||||
|
Revision ID: 6bb0832495f0
|
||||||
|
Revises: 7bb281b7a422
|
||||||
|
Create Date: 2025-12-15 16:14:38.482072
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import models as models
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '6bb0832495f0'
|
||||||
|
down_revision = '7bb281b7a422'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('app_triggers', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('provider_name',
|
||||||
|
existing_type=sa.VARCHAR(length=255),
|
||||||
|
nullable=False,
|
||||||
|
existing_server_default=sa.text("''::character varying"))
|
||||||
|
|
||||||
|
with op.batch_alter_table('operation_logs', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('content',
|
||||||
|
existing_type=postgresql.JSON(astext_type=sa.Text()),
|
||||||
|
nullable=False)
|
||||||
|
|
||||||
|
with op.batch_alter_table('pipeline_recommended_plugins', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('type', sa.String(length=50), nullable=True))
|
||||||
|
|
||||||
|
with op.batch_alter_table('providers', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('quota_used',
|
||||||
|
existing_type=sa.BIGINT(),
|
||||||
|
nullable=False)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
# “推荐插件”model添加type字段;查询推荐列表接口添加type参数
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('providers', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('quota_used',
|
||||||
|
existing_type=sa.BIGINT(),
|
||||||
|
nullable=True)
|
||||||
|
|
||||||
|
with op.batch_alter_table('pipeline_recommended_plugins', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('type')
|
||||||
|
|
||||||
|
with op.batch_alter_table('operation_logs', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('content',
|
||||||
|
existing_type=postgresql.JSON(astext_type=sa.Text()),
|
||||||
|
nullable=True)
|
||||||
|
|
||||||
|
with op.batch_alter_table('app_triggers', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('provider_name',
|
||||||
|
existing_type=sa.VARCHAR(length=255),
|
||||||
|
nullable=True,
|
||||||
|
existing_server_default=sa.text("''::character varying"))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
@ -1458,6 +1458,7 @@ class PipelineRecommendedPlugin(TypeBase):
|
|||||||
)
|
)
|
||||||
plugin_id: Mapped[str] = mapped_column(LongText, nullable=False)
|
plugin_id: Mapped[str] = mapped_column(LongText, nullable=False)
|
||||||
provider_name: 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=True)
|
||||||
position: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=0)
|
position: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=0)
|
||||||
active: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=True)
|
active: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=True)
|
||||||
created_at: Mapped[datetime] = mapped_column(
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
|||||||
@ -1248,12 +1248,14 @@ class RagPipelineService:
|
|||||||
session.commit()
|
session.commit()
|
||||||
return workflow_node_execution_db_model
|
return workflow_node_execution_db_model
|
||||||
|
|
||||||
def get_recommended_plugins(self) -> dict:
|
def get_recommended_plugins(self, type) -> dict:
|
||||||
# Query active recommended plugins
|
# Query active recommended plugins
|
||||||
|
query = db.session.query(PipelineRecommendedPlugin).where(PipelineRecommendedPlugin.active == True)
|
||||||
|
if type and type != "all":
|
||||||
|
query = query.where(PipelineRecommendedPlugin.type == type)
|
||||||
|
|
||||||
pipeline_recommended_plugins = (
|
pipeline_recommended_plugins = (
|
||||||
db.session.query(PipelineRecommendedPlugin)
|
query.order_by(PipelineRecommendedPlugin.position.asc())
|
||||||
.where(PipelineRecommendedPlugin.active == True)
|
|
||||||
.order_by(PipelineRecommendedPlugin.position.asc())
|
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user