2024-01-02 23:42:00 +08:00
|
|
|
import pydantic
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
def dump_model(model: BaseModel) -> dict:
|
2024-09-10 17:00:20 +08:00
|
|
|
if hasattr(pydantic, "model_dump"):
|
2024-12-24 18:38:51 +08:00
|
|
|
# FIXME mypy error, try to fix it instead of using type: ignore
|
|
|
|
return pydantic.model_dump(model) # type: ignore
|
2024-01-02 23:42:00 +08:00
|
|
|
else:
|
2024-06-14 01:05:37 +08:00
|
|
|
return model.model_dump()
|