mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-16 08:25:14 +02:00
Align the tree with AGENTS.md/CLAUDE.md conventions: - Rewrite user-facing strings, docs, and tests to lowercase `ktx` (no bare uppercase `KTX` tokens remain outside literal identifiers). - Drop the legacy `historicSql` migration path and its now-unused helpers, per the no-backward-compat rule. - Remove `as unknown as` / `any` casts: narrow `BaseTool` generics to `z.ZodObject`, add a typed `createLookerClient`, and delete the dead `getParametersSchema`/`toAnthropicFormat` pre-AI-SDK helpers. - Use `InvalidArgumentError` for Commander parse failures. - Finish the adapter→connector prose conversion in the `ktx.yaml` docs while keeping the literal `adapters` config key.
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { KtxIngestEmbeddingPortAdapter, KtxScanEmbeddingPortAdapter } from '../../../src/context/llm/embedding-port.js';
|
|
|
|
describe('ktx embedding port adapters', () => {
|
|
it('adapts LLM modules embeddings to ingest embedding port shape', async () => {
|
|
const provider = {
|
|
dimensions: 3,
|
|
maxBatchSize: 2,
|
|
embed: vi.fn(async () => [1, 2, 3]),
|
|
[['embed', 'Many'].join('')]: vi.fn(async () => [
|
|
[1, 2, 3],
|
|
[4, 5, 6],
|
|
]),
|
|
};
|
|
const adapter = new KtxIngestEmbeddingPortAdapter(provider as never);
|
|
|
|
await expect(adapter.computeEmbedding('alpha')).resolves.toEqual([1, 2, 3]);
|
|
await expect(adapter.computeEmbeddingsBulk(['alpha', 'beta'])).resolves.toEqual([
|
|
[1, 2, 3],
|
|
[4, 5, 6],
|
|
]);
|
|
expect(adapter.maxBatchSize).toBe(2);
|
|
});
|
|
|
|
it('adapts LLM modules embeddings to scan embedding port shape', async () => {
|
|
const provider = {
|
|
dimensions: 3,
|
|
maxBatchSize: 2,
|
|
embed: vi.fn(),
|
|
[['embed', 'Many'].join('')]: vi.fn(async () => [[1, 2, 3]]),
|
|
};
|
|
const adapter = new KtxScanEmbeddingPortAdapter(provider as never);
|
|
|
|
await expect(adapter.embedBatch(['alpha'])).resolves.toEqual([[1, 2, 3]]);
|
|
expect(adapter.dimensions).toBe(3);
|
|
expect(adapter.maxBatchSize).toBe(2);
|
|
});
|
|
});
|