From bb9584c5f9b83b945f1a5511de0f7dce92635bd7 Mon Sep 17 00:00:00 2001 From: huangzhuang_3rd Date: Wed, 12 Aug 2026 13:30:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20AI=20Worker=20=E5=B9=B3=E5=8F=B0=20MVP?= =?UTF-8?q?=20v1.0.0=20-=20=E5=A4=9A=E7=A7=9F=E6=88=B7/=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86/AI=20Worker/=E4=BB=BB=E5=8A=A1=E7=BC=96?= =?UTF-8?q?=E6=8E=92/HITL=E5=AE=A1=E6=A0=B8/=E6=88=90=E6=9C=AC=E6=B2=BB?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/models/worker.py | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 backend/app/models/worker.py diff --git a/backend/app/models/worker.py b/backend/app/models/worker.py new file mode 100644 index 0000000..0295643 --- /dev/null +++ b/backend/app/models/worker.py @@ -0,0 +1,49 @@ +"""AI Worker model - the 'virtual employee' profile.""" +from sqlalchemy import Column, String, Integer, Text, Boolean, ForeignKey, Float +from app.models.base import Base, TimestampMixin, TenantMixin + + +class AIWorker(Base, TimestampMixin, TenantMixin): + """An AI Worker is a 'virtual employee' profile. + + Combines: model config + system prompt (role) + tool whitelist + cost limits. + + Status: active, idle, busy, offline, cooling + """ + __tablename__ = "ai_workers" + + id = Column(Integer, primary_key=True, autoincrement=True) + + name = Column(String(200), nullable=False) + description = Column(Text, default="") + + # Model configuration + provider = Column(String(100), nullable=False, default="openai") + model_name = Column(String(200), nullable=False, default="gpt-4o-mini") + api_key = Column(String(500), nullable=True) # If empty, uses default + base_url = Column(String(500), nullable=True) + temperature = Column(Float, default=0.7) + + # Role / system prompt + system_prompt = Column(Text, default="You are a helpful AI assistant.") + + # Tool whitelist (JSON array of tool names) + tools = Column(Text, default="[]") + + # Cost limits + max_cost_per_task_cents = Column(Integer, nullable=True) + max_cost_per_month_cents = Column(Integer, nullable=True) + + # Status + status = Column(String(50), default="active") + is_active = Column(Boolean, default=True) + + # Available time window (JSON: {"start": "09:00", "end": "18:00"}) + available_hours = Column(Text, default='{"start": "00:00", "end": "23:59"}') + + # Current load + current_task_count = Column(Integer, default=0) + max_concurrent_tasks = Column(Integer, default=1) + + def __repr__(self): + return f""