Instructions to use dizyann/crivo-web with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use dizyann/crivo-web with Transformers.js:
// ⚠️ Unknown pipeline tag
Download tests/cli.test.ts from dizyann/crivo-web: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/dizyann/crivo-web/resolve/main/tests/cli.test.ts
- Command line
-
hf download hf://dizyann/crivo-web/tests/cli.test.ts
-
curl -L -o cli.test.ts https://huggingface.co/dizyann/crivo-web/resolve/main/tests/cli.test.ts
1.89 kB
| import { expect, test } from 'bun:test' | |
| const cli = new URL('../src/cli.ts', import.meta.url).pathname | |
| async function run(args: string[], stdin = '') { | |
| const child = Bun.spawn([process.execPath, cli, ...args], { | |
| stdin: new Blob([stdin]), | |
| stdout: 'pipe', | |
| stderr: 'pipe' | |
| }) | |
| const [code, stdout, stderr] = await Promise.all([ | |
| child.exited, | |
| new Response(child.stdout).text(), | |
| new Response(child.stderr).text() | |
| ]) | |
| return { code, stdout, stderr } | |
| } | |
| test('CLI help documents file and stdin input without loading a model', async () => { | |
| const result = await run(['--help']) | |
| expect(result.code).toBe(0) | |
| expect(result.stdout).toContain('JSON file path') | |
| expect(result.stdout).toContain('--device') | |
| expect(result.stderr).toBe('') | |
| }) | |
| test.each([[], ['-', '--device', 'unknown'], ['-', '--dtype', 'unknown'], ['--unknown']])( | |
| 'CLI rejects invalid arguments %j', | |
| async (...args) => { | |
| const result = await run(args) | |
| expect(result.code).toBe(1) | |
| expect(result.stdout).toBe('') | |
| expect(result.stderr).toContain('error:') | |
| } | |
| ) | |
| test('CLI reports malformed stdin as JSON on stderr', async () => { | |
| const result = await run(['-'], '{') | |
| expect(result.code).toBe(1) | |
| expect(result.stdout).toBe('') | |
| expect(JSON.parse(result.stderr).error.type).toBe('invalid-json') | |
| }) | |
| test('CLI validates metadata from stdin before inference', async () => { | |
| const result = await run(['-'], JSON.stringify({ state: null, decisions: [] })) | |
| expect(result.code).toBe(1) | |
| expect(result.stdout).toBe('') | |
| expect(JSON.parse(result.stderr).error).toMatchObject({ | |
| type: 'invalid-input', | |
| path: 'decisions' | |
| }) | |
| }) | |
| test('CLI reports unreadable files', async () => { | |
| const result = await run([`${cli}/missing.json`]) | |
| expect(result.code).toBe(1) | |
| expect(result.stdout).toBe('') | |
| expect(JSON.parse(result.stderr).error.type).toBe('input-read-error') | |
| }) | |