Download apps/core/api/schema_utils.py from jun2024/fachuan: direct link, hf CLI and curl.
- Browser
- Download file 458 Bytes
-
https://huggingface.co/spaces/jun2024/fachuan/resolve/main/apps/core/api/schema_utils.py
- Command line
-
hf download hf://spaces/jun2024/fachuan/apps/core/api/schema_utils.py
-
curl -L -o schema_utils.py https://huggingface.co/spaces/jun2024/fachuan/resolve/main/apps/core/api/schema_utils.py
458 Bytes
| """API endpoints.""" | |
| from __future__ import annotations | |
| from typing import Any, cast | |
| def schema_to_update_dict(schema: Any) -> dict[str, Any]: | |
| if schema is None: | |
| return {} | |
| if isinstance(schema, dict): | |
| return schema | |
| model_dump = getattr(schema, "model_dump", None) | |
| if callable(model_dump): | |
| return cast(dict[str, Any], model_dump(exclude_unset=True)) | |
| return cast(dict[str, Any], schema.dict(exclude_unset=True)) | |