(path: Path)
| 985 | |
| 986 | @functools.lru_cache(maxsize=None) |
| 987 | def lazy_load_file(path: Path) -> ModelPlus: |
| 988 | fp = open(path, 'rb') |
| 989 | first8 = fp.read(8) |
| 990 | fp.seek(0) |
| 991 | if struct.unpack('<Q', first8)[0] < 16 * 1024 * 1024: |
| 992 | # Safetensors format |
| 993 | return lazy_load_safetensors_file(fp, path) |
| 994 | else: |
| 995 | raise ValueError(f"unknown format: {path}. Only safetensors format is supported.") |
| 996 | |
| 997 | |
| 998 | In = TypeVar('In') |
no test coverage detected