Spaces:
Running
Running
Download core/api/schemas.py from Aynkhn/WorkPilot-AI: direct link, hf CLI and curl.
- Browser
- Download file 2.22 kB
-
https://huggingface.co/spaces/Aynkhn/WorkPilot-AI/resolve/main/core/api/schemas.py
- Command line
-
hf download hf://spaces/Aynkhn/WorkPilot-AI/core/api/schemas.py
-
curl -L -o schemas.py https://huggingface.co/spaces/Aynkhn/WorkPilot-AI/resolve/main/core/api/schemas.py
2.22 kB
| """Request/response models for the HTTP API.""" | |
| from __future__ import annotations | |
| import uuid | |
| from datetime import datetime | |
| from typing import Any, Literal | |
| from pydantic import BaseModel, EmailStr, Field | |
| class SignupIn(BaseModel): | |
| business_name: str = Field(min_length=2, max_length=200) | |
| email: EmailStr | |
| password: str = Field(min_length=10, max_length=200) | |
| class LoginIn(BaseModel): | |
| email: EmailStr | |
| password: str | |
| tenant_id: uuid.UUID | None = None | |
| class TokenPair(BaseModel): | |
| access_token: str | |
| refresh_token: str | |
| tenant_id: uuid.UUID | |
| token_type: str = "bearer" # noqa: S105 | |
| class RefreshIn(BaseModel): | |
| refresh_token: str | |
| class StepUpIn(BaseModel): | |
| code: str = Field(pattern=r"^\d{6}$") | |
| class ChatIn(BaseModel): | |
| message: str = Field(min_length=1, max_length=4000) | |
| class EventIn(BaseModel): | |
| type: str | |
| source: Literal["webhook", "email", "whatsapp", "cron", "manual"] = "manual" | |
| text: str | None = Field(default=None, max_length=20000) | |
| payload: dict[str, Any] = Field(default_factory=dict) | |
| class RunOut(BaseModel): | |
| run_id: uuid.UUID | |
| thread_id: str | |
| status: str | |
| intent: str | None = None | |
| output: str | None = None | |
| error: str | None = None | |
| pending: list[dict[str, Any]] = Field(default_factory=list) | |
| actions: list[dict[str, Any]] = Field(default_factory=list) | |
| class ApprovalOut(BaseModel): | |
| id: uuid.UUID | |
| tool: str | |
| status: str | |
| reason: str | |
| policy_rule: str | None | |
| args: dict[str, Any] | |
| provenance: dict[str, Literal["trusted", "untrusted"]] | |
| preview: dict[str, Any] | |
| required_role: str | |
| requires_stepup: bool | |
| run_id: uuid.UUID | None | |
| created_at: datetime | |
| expires_at: datetime | |
| wait_seconds: int | |
| class DecisionIn(BaseModel): | |
| decision: Literal["approve", "edit", "reject", "respond"] | |
| note: str | None = Field(default=None, max_length=2000) | |
| edited_args: dict[str, Any] | None = None | |
| class KillSwitchIn(BaseModel): | |
| scope: Literal["tenant", "tool"] | |
| target: str | None = None # tool name for scope=tool | |
| enabled: bool | |
| reason: str = "" | |