-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_models.py
More file actions
128 lines (108 loc) · 3.76 KB
/
Copy pathapi_models.py
File metadata and controls
128 lines (108 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"""
速派 · API Models v1.0
━━━━━━━━━━━━━━━━━━━━
Pydantic models — 唯一真相源(SSOT)。
FastAPI 自动生成 OpenAPI (/docs)
openapi-typescript 自动生成 TypeScript 类型
改一个字段 → 改这里 → 其余自动同步。
"""
from __future__ import annotations
from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
# ═══════════════════════════════════════════
# 请求
# ═══════════════════════════════════════════
class MatchRequest(BaseModel):
scene: str = Field(..., example="AI产品发布会", description="活动场景描述")
budget: int = Field(..., ge=500, le=100000, example=5000, description="预算(元)")
location: str = Field(default="上海", example="上海")
roles: list[str] = Field(
default=["photographer"],
example=["photographer", "editor"],
description="需要的角色"
)
customRoles: list[str] = Field(
default=[],
example=["designer"],
description="客户自备的角色"
)
class ConfirmRequest(BaseModel):
confirmedRoles: list[dict] = Field(
...,
example=[{"role": "photographer", "photographerId": "citizen_018", "source": "platform"}],
description="客户确认的角色列表"
)
note: Optional[str] = Field(default=None, description="客户备注")
# ═══════════════════════════════════════════
# 响应
# ═══════════════════════════════════════════
class PhotographerInfo(BaseModel):
id: str
name: str
tier: str
score: float
skills: list[str]
completedTasks: int
avgRating: float
class TeamSlot(BaseModel):
role: str
status: str = "matched" # matched | confirmed | pending | custom
photographer: Optional[PhotographerInfo] = None
source: str = "platform" # platform | custom
class TeamSlotSummary(BaseModel):
role: str
status: str
assignee: Optional[str] = None
class ProjectCard(BaseModel):
id: str
title: str
status: str
tier: str = "pool"
budget: int = 0
location: str = "上海"
team: list[TeamSlotSummary]
createdAt: datetime
class TimelineEntry(BaseModel):
timestamp: datetime
event: str
by: str
class ProjectDetail(BaseModel):
id: str
title: str
clientName: str = ""
requirement: str = ""
location: str = ""
budget: int = 0
status: str = "matching"
tier: str = "pool"
team: list[TeamSlot] = []
timeline: list[TimelineEntry] = []
class MatchResult(BaseModel):
projectId: str
tier: str
recommendedTeam: list[TeamSlot]
alternativeOptions: dict[str, list[TeamSlot]] = {}
summary: str
class ConfirmResult(BaseModel):
projectId: str
status: str
confirmed: list[str] = []
pending: list[str] = []
nextStep: str = ""
# ═══════════════════════════════════════════
# 列表响应(双通道)
# ═══════════════════════════════════════════
class ProjectListResponse(BaseModel):
human: list[ProjectCard]
agent: list[dict] = []
class ProjectDetailResponse(BaseModel):
human: ProjectDetail
agent: dict = {}
class MatchResponse(BaseModel):
human: MatchResult
agent: dict = {}
class ErrorResponse(BaseModel):
error: str
detail: str = ""
suggestion: str = ""