Add initial VibeGuard browser extension
This commit is contained in:
parent
f251f0f8ce
commit
9c65a61ebb
43 changed files with 125275 additions and 2 deletions
28
tests/model-metadata.test.ts
Normal file
28
tests/model-metadata.test.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { validateManifest } from "../src/inference/model-metadata";
|
||||
import { resolveOutputIndex } from "../src/inference/classifier";
|
||||
|
||||
const manifest = {
|
||||
source: "wagesj45/toxic-comment-classifier",
|
||||
revision: "abc123",
|
||||
architecture: "DistilBertForSequenceClassification",
|
||||
labels: { toxic: 1, nonToxic: 0, names: { toxic: 1, non_toxic: 0 } },
|
||||
maxLength: 512,
|
||||
quantization: "int8-dynamic",
|
||||
runtime: "onnxruntime-web-wasm"
|
||||
};
|
||||
|
||||
describe("model contract", () => {
|
||||
it("accepts a binary manifest and resolves common output labels", () => {
|
||||
expect(validateManifest(manifest)).toEqual(manifest);
|
||||
expect(resolveOutputIndex("LABEL_1", manifest)).toBe(1);
|
||||
expect(resolveOutputIndex("not-toxic", manifest)).toBe(0);
|
||||
expect(resolveOutputIndex("toxic", manifest)).toBe(1);
|
||||
});
|
||||
|
||||
it("rejects incomplete metadata", () => {
|
||||
expect(() => validateManifest({ ...manifest, labels: { toxic: 1, nonToxic: 1, names: {} } })).toThrow();
|
||||
expect(() => validateManifest({ ...manifest, maxLength: 0 })).toThrow();
|
||||
expect(() => validateManifest({ ...manifest, labels: undefined as unknown as typeof manifest.labels })).toThrow();
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue