browser / src /lib /mock.ts
lrigamai's picture
Group LoRAs by character, add table view and docked detail panel
45fb44a
Raw History Blame Contribute Delete
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] };
}