embedding-usage.test.mjs
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
11 hours 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:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d
docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge
Human
11 hours ago