embedding-usage.test.mjs
18 lines 820 B
Raw
sha256:94ec65bd2b200240ac785a97cf14c5db066832bd608a24d6a9c151f17b918b02 feat(calendar): hosted bridge/gateway route parity and time… Human minor ⚠ breaking 34 days ago
1 import { describe, it } from 'node:test';
2 import assert from 'node:assert';
3 import { estimateEmbeddingInputTokens, embedWithUsage } from '../lib/embedding.mjs';
4
5 describe('embedding usage helpers', () => {
6 it('estimateEmbeddingInputTokens is ~4 chars per token', () => {
7 assert.strictEqual(estimateEmbeddingInputTokens(['']), 0);
8 assert.strictEqual(estimateEmbeddingInputTokens(['abcd']), 1);
9 assert.strictEqual(estimateEmbeddingInputTokens(['abc']), 1);
10 assert.strictEqual(estimateEmbeddingInputTokens(['x'.repeat(8)]), 2);
11 });
12
13 it('embedWithUsage returns zero tokens for empty input', async () => {
14 const r = await embedWithUsage([], { provider: 'ollama', model: 'nomic-embed-text' });
15 assert.deepStrictEqual(r.vectors, []);
16 assert.strictEqual(r.embedding_input_tokens, 0);
17 });
18 });
File History 1 commit
sha256:94ec65bd2b200240ac785a97cf14c5db066832bd608a24d6a9c151f17b918b02 feat(calendar): hosted bridge/gateway route parity and time… Human minor 34 days ago