Spaces:
Running on Zero
Running on Zero
Download tests/model-utils.test.js from fffiloni/cabin-local: direct link, hf CLI and curl.
- Browser
- Download file 945 Bytes
-
https://huggingface.co/spaces/fffiloni/cabin-local/resolve/main/tests/model-utils.test.js
- Command line
-
hf download hf://spaces/fffiloni/cabin-local/tests/model-utils.test.js
-
curl -L -o model-utils.test.js https://huggingface.co/spaces/fffiloni/cabin-local/resolve/main/tests/model-utils.test.js
945 Bytes
| import test from 'node:test'; | |
| import assert from 'node:assert/strict'; | |
| import { assertModel, recentMessages } from '../src/model-utils.js'; | |
| test('rejects truncated and modified weights before native loading',()=>{ | |
| const model={bytes:123,sha256:'expected'}; | |
| assert.throws(()=>assertModel(model,122,'expected'),/incomplete/); | |
| assert.throws(()=>assertModel(model,123,'altered'),/SHA-256/); | |
| assert.doesNotThrow(()=>assertModel(model,123,'expected')); | |
| }); | |
| test('conversation budget preserves complete recent exchanges',()=>{ | |
| const pair=n=>[{role:'user',content:String(n).repeat(200)},{role:'assistant',content:String(n).repeat(500)}]; | |
| const result=recentMessages([...pair(1),...pair(2),...pair(3)],'next'); | |
| assert.deepEqual(result.slice(1,-1),[...pair(2),...pair(3)]); | |
| assert.equal(result[0].role,'system');assert.equal(result.at(-1).content,'next'); | |
| assert.equal(recentMessages([], 'x'.repeat(600)).at(-1).content.length,500); | |
| }); | |