mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 20:17:29 +08:00
r2
This commit is contained in:
parent
2972a06f16
commit
874e1bc41d
@ -0,0 +1,43 @@
|
|||||||
|
"""add_pipeline_info_6
|
||||||
|
|
||||||
|
Revision ID: 224fba149d48
|
||||||
|
Revises: d466c551816f
|
||||||
|
Create Date: 2025-06-11 11:55:01.179201
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import models as models
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '224fba149d48'
|
||||||
|
down_revision = 'd466c551816f'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('pipeline_built_in_templates', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('created_by', models.types.StringUUID(), nullable=False))
|
||||||
|
batch_op.add_column(sa.Column('updated_by', models.types.StringUUID(), nullable=True))
|
||||||
|
|
||||||
|
with op.batch_alter_table('pipeline_customized_templates', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('created_by', models.types.StringUUID(), nullable=False))
|
||||||
|
batch_op.add_column(sa.Column('updated_by', models.types.StringUUID(), nullable=True))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('pipeline_customized_templates', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('updated_by')
|
||||||
|
batch_op.drop_column('created_by')
|
||||||
|
|
||||||
|
with op.batch_alter_table('pipeline_built_in_templates', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('updated_by')
|
||||||
|
batch_op.drop_column('created_by')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
@ -1189,6 +1189,15 @@ class PipelineBuiltInTemplate(Base): # type: ignore[name-defined]
|
|||||||
language = db.Column(db.String(255), nullable=False)
|
language = db.Column(db.String(255), nullable=False)
|
||||||
created_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp())
|
updated_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
|
created_by = db.Column(StringUUID, nullable=False)
|
||||||
|
updated_by = db.Column(StringUUID, nullable=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_user_name(self):
|
||||||
|
account = db.session.query(Account).filter(Account.id == self.created_by).first()
|
||||||
|
if account:
|
||||||
|
return account.name
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class PipelineCustomizedTemplate(Base): # type: ignore[name-defined]
|
class PipelineCustomizedTemplate(Base): # type: ignore[name-defined]
|
||||||
@ -1208,9 +1217,18 @@ class PipelineCustomizedTemplate(Base): # type: ignore[name-defined]
|
|||||||
yaml_content = db.Column(db.Text, nullable=False)
|
yaml_content = db.Column(db.Text, nullable=False)
|
||||||
install_count = db.Column(db.Integer, nullable=False, default=0)
|
install_count = db.Column(db.Integer, nullable=False, default=0)
|
||||||
language = db.Column(db.String(255), nullable=False)
|
language = db.Column(db.String(255), nullable=False)
|
||||||
|
created_by = db.Column(StringUUID, nullable=False)
|
||||||
|
updated_by = db.Column(StringUUID, nullable=True)
|
||||||
created_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp())
|
updated_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_user_name(self):
|
||||||
|
account = db.session.query(Account).filter(Account.id == self.created_by).first()
|
||||||
|
if account:
|
||||||
|
return account.name
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class Pipeline(Base): # type: ignore[name-defined]
|
class Pipeline(Base): # type: ignore[name-defined]
|
||||||
__tablename__ = "pipelines"
|
__tablename__ = "pipelines"
|
||||||
|
|||||||
@ -70,6 +70,9 @@ class CustomizedPipelineTemplateRetrieval(PipelineTemplateRetrievalBase):
|
|||||||
return {
|
return {
|
||||||
"id": pipeline_template.id,
|
"id": pipeline_template.id,
|
||||||
"name": pipeline_template.name,
|
"name": pipeline_template.name,
|
||||||
"icon": pipeline_template.icon,
|
"icon_info": pipeline_template.icon,
|
||||||
|
"description": pipeline_template.description,
|
||||||
|
"chunk_structure": pipeline_template.chunk_structure,
|
||||||
"export_data": yaml.safe_load(pipeline_template.yaml_content),
|
"export_data": yaml.safe_load(pipeline_template.yaml_content),
|
||||||
|
"created_by": pipeline_template.created_user_name,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,9 @@ class DatabasePipelineTemplateRetrieval(PipelineTemplateRetrievalBase):
|
|||||||
return {
|
return {
|
||||||
"id": pipeline_template.id,
|
"id": pipeline_template.id,
|
||||||
"name": pipeline_template.name,
|
"name": pipeline_template.name,
|
||||||
"icon": pipeline_template.icon,
|
"icon_info": pipeline_template.icon,
|
||||||
"chunk_structure": pipeline_template.chunk_structure,
|
"chunk_structure": pipeline_template.chunk_structure,
|
||||||
"export_data": yaml.safe_load(pipeline_template.yaml_content),
|
"export_data": yaml.safe_load(pipeline_template.yaml_content),
|
||||||
|
"created_by": pipeline_template.created_user_name,
|
||||||
|
"description": pipeline_template.description,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,6 +116,7 @@ class RagPipelineService:
|
|||||||
customized_template.name = template_info.name
|
customized_template.name = template_info.name
|
||||||
customized_template.description = template_info.description
|
customized_template.description = template_info.description
|
||||||
customized_template.icon = template_info.icon_info.model_dump()
|
customized_template.icon = template_info.icon_info.model_dump()
|
||||||
|
customized_template.updated_by = current_user.id
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return customized_template
|
return customized_template
|
||||||
|
|
||||||
@ -694,7 +695,6 @@ class RagPipelineService:
|
|||||||
db.session.add(document)
|
db.session.add(document)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
return workflow_node_execution
|
return workflow_node_execution
|
||||||
|
|
||||||
def update_workflow(
|
def update_workflow(
|
||||||
@ -969,6 +969,7 @@ class RagPipelineService:
|
|||||||
position=max_position + 1 if max_position else 1,
|
position=max_position + 1 if max_position else 1,
|
||||||
chunk_structure=dataset.chunk_structure,
|
chunk_structure=dataset.chunk_structure,
|
||||||
language="en-US",
|
language="en-US",
|
||||||
|
created_by=current_user.id,
|
||||||
)
|
)
|
||||||
db.session.add(pipeline_customized_template)
|
db.session.add(pipeline_customized_template)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user