Files
sentclaw/backend/app/models/tool.py
T
2026-04-07 16:05:05 +08:00

30 lines
954 B
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.
from .base import BaseModel
from . import db
class Tool(BaseModel):
__tablename__ = "tools"
name = db.Column(db.String(100), unique=True, nullable=False, comment="工具名称")
type = db.Column(
db.String(50), nullable=False, comment="类型(builtin, mcp, custom"
)
description = db.Column(db.Text, nullable=True, comment="描述")
config = db.Column(db.JSON, nullable=True, comment="配置(JSON")
is_active = db.Column(db.Boolean, default=True, nullable=False, comment="是否激活")
agent_tools = db.relationship(
"AgentTool", backref="tool", lazy=True, cascade="all, delete-orphan"
)
class AgentTool(BaseModel):
__tablename__ = "agent_tools"
agent_id = db.Column(
db.BigInteger, db.ForeignKey("agents.id"), nullable=False, comment="Agent ID"
)
tool_id = db.Column(
db.BigInteger, db.ForeignKey("tools.id"), nullable=False, comment="工具ID"
)