init
This commit is contained in:
5
app/schemas/__init__.py
Normal file
5
app/schemas/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
from .form import Form, FormCreate, FormUpdate
|
||||
from .result import Result, ResultCreate, ResultUpdate
|
||||
from .bench import Bench
|
||||
10
app/schemas/bench.py
Normal file
10
app/schemas/bench.py
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas import Form, Result
|
||||
|
||||
|
||||
class Bench(BaseModel):
|
||||
form: Form
|
||||
results: list[Result]
|
||||
44
app/schemas/form.py
Normal file
44
app/schemas/form.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic.v1 import validator
|
||||
|
||||
|
||||
class FormBase(BaseModel):
|
||||
base_prompt: str | None = None
|
||||
prompt: str | None = None
|
||||
p_choice: str | None = None
|
||||
role: str | None = None
|
||||
name: str | None = None
|
||||
uuid: str | None = None
|
||||
desc: str | None = None
|
||||
price: float | None = None
|
||||
favorable: str | None = None
|
||||
remark: str | None = None
|
||||
otherPrompt: str | None = None
|
||||
lang: str | None = None
|
||||
type: str | None = None
|
||||
|
||||
|
||||
class Form(FormBase):
|
||||
id: int
|
||||
created_at: datetime = datetime.now()
|
||||
updated_at: datetime = datetime.now()
|
||||
# custom input conversion for that field
|
||||
_normalize_datetimes = validator(
|
||||
"created_at", "updated_at",
|
||||
allow_reuse=True)(lambda v: v.timestamp())
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class FormCreate(FormBase):
|
||||
...
|
||||
|
||||
|
||||
class FormUpdate(FormBase):
|
||||
...
|
||||
34
app/schemas/result.py
Normal file
34
app/schemas/result.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic.v1 import validator
|
||||
|
||||
|
||||
class ResultBase(BaseModel):
|
||||
prompt: str | None = None
|
||||
name: str | None = None
|
||||
uuid: str | None = None
|
||||
value: str | None = None
|
||||
lang: str | None = None
|
||||
|
||||
|
||||
class Result(ResultBase):
|
||||
id: int
|
||||
created_at: datetime = datetime.now()
|
||||
updated_at: datetime = datetime.now()
|
||||
_normalize_datetimes = validator(
|
||||
"created_at", "updated_at",
|
||||
allow_reuse=True)(lambda v: v.timestamp())
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class ResultCreate(ResultBase):
|
||||
...
|
||||
|
||||
|
||||
class ResultUpdate(ResultBase):
|
||||
...
|
||||
Reference in New Issue
Block a user