feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持

This commit is contained in:
hugo committed 2026-07-07 11:10:32 +08:00
1 parent ac4262cd75
commit c8ce77199e
183 files changed
+11690 -2300

No files matched your search

@@ -0,0 +1,84 @@
"""add agent registry columns
Revision ID: b3c4d5e6f7a8
Revises: a1b2c3d4e610
Create Date: 2026-07-06 22:45:00.000000
"""
from alembic import op
import sqlalchemy as sa
revision = 'b3c4d5e6f7a8'
down_revision = 'a1b2c3d4e610'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('agents', schema=None) as batch_op:
batch_op.add_column(
sa.Column('agent_code', sa.String(length=64), nullable=False, server_default='generic'),
)
batch_op.add_column(
sa.Column('runtime_provider', sa.String(length=32), nullable=False, server_default='dify'),
)
batch_op.add_column(
sa.Column('conversation_mode', sa.String(length=32), nullable=False, server_default='chat'),
)
batch_op.add_column(
sa.Column('dify_app_type', sa.String(length=20), nullable=False, server_default='chatflow'),
)
batch_op.add_column(sa.Column('iframe_url', sa.String(length=500), nullable=True))
batch_op.add_column(sa.Column('category', sa.String(length=64), nullable=True))
batch_op.add_column(sa.Column('sub_category', sa.String(length=64), nullable=True))
batch_op.add_column(
sa.Column('sort_order', sa.Integer(), nullable=False, server_default='0'),
)
batch_op.add_column(sa.Column('welcome_message', sa.Text(), nullable=True))
batch_op.add_column(
sa.Column('suggested_questions_style', sa.String(length=20), nullable=False, server_default='plain'),
)
batch_op.add_column(sa.Column('suggested_questions', sa.JSON(), nullable=True))
batch_op.add_column(sa.Column('capabilities', sa.JSON(), nullable=True))
batch_op.add_column(sa.Column('file_upload_policy', sa.JSON(), nullable=True))
batch_op.add_column(sa.Column('bound_schedule_task_id', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('handler_config', sa.JSON(), nullable=True))
batch_op.add_column(
sa.Column('updated_at', sa.DateTime(), nullable=False, server_default=sa.text('CURRENT_TIMESTAMP')),
)
batch_op.create_foreign_key(
'fk_agents_bound_schedule_task_id',
'schedule_tasks',
['bound_schedule_task_id'],
['id'],
)
op.alter_column('agents', 'agent_code', server_default=None)
op.alter_column('agents', 'runtime_provider', server_default=None)
op.alter_column('agents', 'conversation_mode', server_default=None)
op.alter_column('agents', 'dify_app_type', server_default=None)
op.alter_column('agents', 'sort_order', server_default=None)
op.alter_column('agents', 'suggested_questions_style', server_default=None)
op.alter_column('agents', 'updated_at', server_default=None)
def downgrade():
with op.batch_alter_table('agents', schema=None) as batch_op:
batch_op.drop_constraint('fk_agents_bound_schedule_task_id', type_='foreignkey')
batch_op.drop_column('updated_at')
batch_op.drop_column('handler_config')
batch_op.drop_column('bound_schedule_task_id')
batch_op.drop_column('file_upload_policy')
batch_op.drop_column('capabilities')
batch_op.drop_column('suggested_questions')
batch_op.drop_column('suggested_questions_style')
batch_op.drop_column('welcome_message')
batch_op.drop_column('sort_order')
batch_op.drop_column('sub_category')
batch_op.drop_column('category')
batch_op.drop_column('iframe_url')
batch_op.drop_column('dify_app_type')
batch_op.drop_column('conversation_mode')
batch_op.drop_column('runtime_provider')
batch_op.drop_column('agent_code')