Spaces:
Running
Running
Download src/lib/mock.ts from lrigamai/browser: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/lrigamai/browser/resolve/main/src/lib/mock.ts
- Command line
-
hf download hf://spaces/lrigamai/browser/src/lib/mock.ts
-
curl -L -o mock.ts https://huggingface.co/spaces/lrigamai/browser/resolve/main/src/lib/mock.ts
1.09 kB
| import type { BaseModel, Lora } from "../types"; | |
| // Dev-only (`pnpm dev:mock`): adds a fake second base model so multi-model layouts can be tried | |
| // before real files exist. Most characters get a variant, some reuse their real preview images, | |
| // one exists only on the fake model. Never reaches a production build. | |
| const MODEL = "Krea2"; | |
| const DAY = 86_400_000; | |
| export function withMockModel(models: BaseModel[], loras: Lora[]): { models: BaseModel[]; loras: Lora[] } { | |
| const base = loras.filter((l) => l.model === models[0]?.id); | |
| const fake = (name: string, i: number, from?: Lora): Lora => ({ | |
| id: `${MODEL}/${MODEL}_${name}.safetensors`, | |
| name, | |
| file: `${MODEL}_${name}.safetensors`, | |
| model: MODEL, | |
| size: 312_000_000 + i * 7_000_000, | |
| sha256: `mock${i}`.padEnd(64, "0"), | |
| updated: new Date(Date.now() - i * DAY).toISOString(), | |
| previews: from && i % 2 === 0 ? from.previews : [], | |
| }); | |
| const mock = [...base.slice(0, 4).map((l, i) => fake(l.name, i, l)), fake("vesper", 5)]; | |
| return { models: [...models, { id: MODEL, count: mock.length }], loras: [...loras, ...mock] }; | |
| } | |