| 1 | import OpenAI from "../../llm/llms/OpenAI"; |
| 2 | import { DocsCache } from "./DocsCache"; // adjust import path as needed |
| 3 | |
| 4 | describe("DocsCache", () => { |
| 5 | let openAIEmbeddings: OpenAI; |
| 6 | |
| 7 | beforeAll(() => { |
| 8 | openAIEmbeddings = new OpenAI({ |
| 9 | apiKey: "", |
| 10 | model: "text-embedding-ada-002", |
| 11 | }); |
| 12 | }); |
| 13 | |
| 14 | test("normalizeEmbeddingId() produces a valid ID without constructor name", async () => { |
| 15 | // Get the embedding ID from OpenAI embeddings provider |
| 16 | const embeddingId = DocsCache.normalizeEmbeddingId( |
| 17 | openAIEmbeddings.embeddingId, |
| 18 | ); |
| 19 | |
| 20 | // The ID should not contain the constructor name (OpenAI) |
| 21 | expect(embeddingId).toEqual( |
| 22 | `${openAIEmbeddings.model}::${openAIEmbeddings.maxEmbeddingChunkSize}`, |
| 23 | ); |
| 24 | }); |
| 25 | }); |