Spaces:
Sleeping
Sleeping
Create schemas.py
Browse files- app/schemas.py +59 -0
app/schemas.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
from pydantic import BaseModel, Field
|
| 3 |
+
from typing import List, Optional, Dict, Any
|
| 4 |
+
|
| 5 |
+
class CampaingCreate(BaseModel):
|
| 6 |
+
campaing_id: str
|
| 7 |
+
strbrand: str
|
| 8 |
+
product: str
|
| 9 |
+
target_audience: str
|
| 10 |
+
tone: str ="信頼感・エビデンス重視"
|
| 11 |
+
language: str = "ja"
|
| 12 |
+
contraints: Optional[Dict[str, Any]] = None
|
| 13 |
+
k_variant: int = 5
|
| 14 |
+
value_per_conversion: float = 1.0
|
| 15 |
+
|
| 16 |
+
class AdVariant(BaseModel):
|
| 17 |
+
variant_id: str
|
| 18 |
+
text: str
|
| 19 |
+
status: str
|
| 20 |
+
rejection_reason: Optional[str] = None
|
| 21 |
+
|
| 22 |
+
class GenerateAdsRequest(CampaingCreate):
|
| 23 |
+
pass
|
| 24 |
+
|
| 25 |
+
class GenerateAdsResponse(BaseModel):
|
| 26 |
+
campaing_id: str
|
| 27 |
+
variants: List[AdVariant]
|
| 28 |
+
|
| 29 |
+
class ServerRequest(BaseModel):
|
| 30 |
+
campaing_id: str
|
| 31 |
+
context: Optional[Dict[str, Any]] = None
|
| 32 |
+
|
| 33 |
+
class ServeResponse(BaseModel):
|
| 34 |
+
campaing_id: str
|
| 35 |
+
variant_id: str
|
| 36 |
+
text: str
|
| 37 |
+
|
| 38 |
+
class FeedbackEvent(BaseModel):
|
| 39 |
+
campaing_id: str
|
| 40 |
+
variant_id: str
|
| 41 |
+
event_type: str
|
| 42 |
+
ts: Optional[str] = None
|
| 43 |
+
value: Optional[float] = None
|
| 44 |
+
|
| 45 |
+
class ReportRequest(BaseModel):
|
| 46 |
+
campaing_id: str
|
| 47 |
+
|
| 48 |
+
class VariantReport(BaseModel):
|
| 49 |
+
variant_id: str
|
| 50 |
+
impressions: int
|
| 51 |
+
clicks: int
|
| 52 |
+
conversions: int
|
| 53 |
+
ctr: float
|
| 54 |
+
cvr: float
|
| 55 |
+
expected_value: float
|
| 56 |
+
|
| 57 |
+
class ReportResponse(BaseModel):
|
| 58 |
+
campaing_id:str
|
| 59 |
+
variant:List[VariantReport]
|