文件
mynode/packages/lib/services/ai/OnnxRuntime.test.ts
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

41 行
1.5 KiB
TypeScript

import shim from '../../shim';
// Smoke test confirming onnxruntime-node loads cleanly through the shim. No
// real model is loaded yet — that lands with the LocalEmbeddingProvider. The
// goal of this test is to catch packaging/native-binary breakage early, the
// same way SqliteVec.test does for sqlite-vec.
describe('OnnxRuntime', () => {
it('is reachable via the shim', () => {
const ort = shim.onnxRuntime();
if (!ort) {
// eslint-disable-next-line no-console
console.warn('Skipping onnxruntime test: onnxruntime-node unavailable on this platform');
return;
}
expect(typeof ort.InferenceSession).toBe('function');
expect(typeof ort.Tensor).toBe('function');
});
it('can build a Float32 Tensor with the correct dims', () => {
const ort = shim.onnxRuntime();
if (!ort) return;
const data = new Float32Array([1, 2, 3, 4, 5, 6]);
const t = new ort.Tensor('float32', data, [2, 3]);
expect(t.dims).toEqual([2, 3]);
expect(t.type).toBe('float32');
expect(t.size).toBe(6);
});
it('exposes SessionOptions threading and optimisation flags', () => {
const ort = shim.onnxRuntime();
if (!ort) return;
// We can't instantiate a session without a real model file, but we
// can confirm InferenceSession.create exists — that's the entry
// point LocalEmbeddingProvider will use. The actual model load test
// will land alongside the provider once a real model file is in play.
expect(typeof ort.InferenceSession.create).toBe('function');
});
});