- Gradio 5.50.0 ChatInterface with type='messages' streaming - LangGraph create_react_agent with InMemorySaver checkpointer - 4 @tool functions: search_dashboards, get_health_summary, list_environments, get_task_status - Structured ChatMessage metadata (7 discriminator types: stream_token, tool_start/end/error, confirm_required, confirm_resolved, error) - HITL resume via second submit() with interrupt_before/Command - Dual-identity RBAC: service JWT + user JWT for tool calls - File upload (10 MB limit, pdfplumber/xlsx/JSON parser) - Conversation persistence via POST /api/agent/conversations/save - REST API: list, history, archive conversations; multi-tab gate; LLM config - LLM provider selection via Admin -> LLM Settings (assistant_planner_provider) - Svelte 5 AgentChatModel with stream event queue, dedup, stream_status watcher - MarkdownRenderer using svelte-markdown with semantic Tailwind tokens - ToolCallCard (3 states: executing/completed/failed) - ConversationList with search, date grouping, infinite scroll - ConnectionIndicator with Gradio health status - /agent route with two-column layout - Vite proxy /api/agent/gradio -> Gradio SSE - Fixed: not_() SQLAlchemy operator, route collision with _admin_routes - Fixed: conversation_id -> id normalization, .pyc cache staleness - Fixed: event.data array parsing (Gradio returns [jsonStr, null]) - Requirements pinned: gradio==5.50.0, pydantic>=2.7,<=2.12.3
76 lines
2.7 KiB
Python
76 lines
2.7 KiB
Python
# #region Alembic.AddAgentConversations [C:2] [TYPE Function] [SEMANTICS alembic,migration,agent]
|
|
# @BRIEF Add agent_conversations and agent_messages tables for Gradio Agent Chat.
|
|
# @RELATION DEPENDS_ON -> [Models.Agent]
|
|
"""add agent conversations
|
|
|
|
Revision ID: f2b3c4d5e6f7
|
|
Revises: f0e9d8c7b6a5
|
|
Create Date: 2026-06-09 13:30:00.000000
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "f2b3c4d5e6f7"
|
|
down_revision: Union[str, None] = "f0e9d8c7b6a5"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"agent_conversations",
|
|
sa.Column("id", sa.String(), nullable=False),
|
|
sa.Column("user_id", sa.String(), nullable=False),
|
|
sa.Column("title", sa.String(256), nullable=False, server_default="New Conversation"),
|
|
sa.Column("is_archived", sa.Boolean(), nullable=False, server_default=sa.text("false")),
|
|
sa.Column("created_at", sa.DateTime(), server_default=sa.func.now()),
|
|
sa.Column("updated_at", sa.DateTime(), server_default=sa.func.now()),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_agent_conversations_user_id"),
|
|
"agent_conversations",
|
|
["user_id"],
|
|
unique=False,
|
|
)
|
|
|
|
op.create_table(
|
|
"agent_messages",
|
|
sa.Column("id", sa.String(), nullable=False),
|
|
sa.Column(
|
|
"conversation_id",
|
|
sa.String(),
|
|
sa.ForeignKey("agent_conversations.id"),
|
|
nullable=False,
|
|
),
|
|
sa.Column("role", sa.String(16), nullable=False),
|
|
sa.Column("text", sa.Text(), nullable=True),
|
|
sa.Column("state", sa.String(32), nullable=True),
|
|
sa.Column("tool_calls", sa.JSON(), nullable=True),
|
|
sa.Column("attachments", sa.JSON(), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(), server_default=sa.func.now()),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_agent_messages_conversation_id"),
|
|
"agent_messages",
|
|
["conversation_id"],
|
|
unique=False,
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f("ix_agent_messages_conversation_id"), table_name="agent_messages")
|
|
op.drop_table("agent_messages")
|
|
op.drop_index(op.f("ix_agent_conversations_user_id"), table_name="agent_conversations")
|
|
op.drop_table("agent_conversations")
|
|
# ### end Alembic commands ###
|
|
# #endregion Alembic.AddAgentConversations
|