Full-stack implementation of the KB Accelerator feature that converts static MSP knowledge base articles into interactive troubleshooting and procedural flows using AI. Backend: - Migrations 054/055: kb_imports, kb_import_nodes tables + plan_limits KB columns - SQLAlchemy models with relationships and self-referential node hierarchy - Text extraction service (txt, paste, docx with structural metadata) - AI conversion service with MSP-specialist prompts for both flow types - 8 API endpoints: upload, get, list, convert, edit node, commit, delete, quota - Tier-gated access via plan_limits (free: 3 lifetime, pro/team: unlimited) - 8 integration tests covering upload, get/list, quota, commit, delete Frontend: - TypeScript types and API client for all KB Accelerator endpoints - Multi-step wizard page: upload → processing → review → success - Upload screen with paste/file tabs, drag-drop, target type selector - Two-panel review screen with source highlighting and node cards - Per-node actions: approve, edit, regenerate, insert, delete - Confidence color indicators (green/amber/red) - Sidebar navigation with Sparkles icon - Code-split lazy-loaded route at /kb-accelerator Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
2.0 KiB
Python
31 lines
2.0 KiB
Python
from sqlalchemy import String, Integer, Boolean, text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from app.core.database import Base
|
|
|
|
|
|
class PlanLimits(Base):
|
|
__tablename__ = "plan_limits"
|
|
|
|
plan: Mapped[str] = mapped_column(String(50), primary_key=True)
|
|
max_trees: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
max_sessions_per_month: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
max_users: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
custom_branding: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
priority_support: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
export_formats: Mapped[list] = mapped_column(JSONB, nullable=False, default=lambda: ["markdown", "text"])
|
|
|
|
# AI Flow Builder limits
|
|
max_ai_builds_per_month: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
max_ai_builds_per_24h: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
|
|
# KB Accelerator limits
|
|
kb_accelerator_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("false"))
|
|
kb_max_lifetime_conversions: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
kb_batch_max_size: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
kb_allowed_formats: Mapped[list] = mapped_column(JSONB, nullable=False, default=lambda: ["txt", "paste"], server_default=text("'[\"txt\",\"paste\"]'::jsonb"))
|
|
kb_detailed_analysis: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("false"))
|
|
kb_conversational_refinement: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("false"))
|
|
kb_step_library_matching: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("false"))
|
|
kb_history_limit: Mapped[int | None] = mapped_column(Integer, nullable=True)
|