mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-04-23 06:09:43 +08:00
11 lines
305 B
Python
11 lines
305 B
Python
import pydantic
|
|
from pydantic import BaseModel
|
|
|
|
|
|
def dump_model(model: BaseModel) -> dict:
|
|
if hasattr(pydantic, "model_dump"):
|
|
# FIXME mypy error, try to fix it instead of using type: ignore
|
|
return pydantic.model_dump(model) # type: ignore
|
|
else:
|
|
return model.model_dump()
|