Files
hunjing/backend/app/models/skills.py
T
2026-08-21 16:00:13 +08:00

34 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""百工 Skill 能力包模型(skills-design §4.1;契约字典 §10.5 skill_ 前缀)。
Skill 是显式注册的能力包:触发时注入 prompt_fragment 到对话 contract,
tool_bindings 仅作为 prompt 提示(不改变 ToolRuntime 注册集)。
"""
from datetime import datetime
from sqlalchemy import DateTime, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.core.ids import new_skill_id
from app.core.time import utc_now
from app.db.base import Base
class Skill(Base):
"""Skill 能力包。"""
__tablename__ = "skills"
id: Mapped[str] = mapped_column(String(80), primary_key=True, default=new_skill_id)
name: Mapped[str] = mapped_column(String(120), nullable=False, unique=True)
description: Mapped[str] = mapped_column(Text, nullable=False, default="")
trigger: Mapped[str] = mapped_column(Text, nullable=False, default="")
prompt_fragment: Mapped[str] = mapped_column(Text, nullable=False, default="")
tool_bindings_json: Mapped[str] = mapped_column(Text, nullable=False, default="[]")
risk_level: Mapped[str] = mapped_column(String(8), nullable=False, default="L1")
status: Mapped[str] = mapped_column(String(40), nullable=False, default="enabled", index=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utc_now)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), default=utc_now, onupdate=utc_now
)