embedding-usage.test.mjs
sha256:fbe982a22c05c6fe2e93876f250deecdb43d883f648b4e1810c7546caa9f17db
docs: activate KNOWTATION- board identity and preserve livi…
Human
minor
⚠ breaking
2 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:fbe982a22c05c6fe2e93876f250deecdb43d883f648b4e1810c7546caa9f17db
docs: activate KNOWTATION- board identity and preserve livi…
Human
minor
⚠
2 days ago