| 1 | import { jest } from "@jest/globals"; |
| 2 | import Anthropic from "../Anthropic.js"; |
| 3 | import Deepseek from "../Deepseek.js"; |
| 4 | import FunctionNetwork from "../FunctionNetwork.js"; |
| 5 | import Mistral from "../Mistral.js"; |
| 6 | import OpenAI from "../OpenAI.js"; |
| 7 | import ContinueProxy from "../stubs/ContinueProxy.js"; |
| 8 | import Vllm from "../Vllm.js"; |
| 9 | |
| 10 | // Mock the parseProxyModelName function |
| 11 | const mockParseProxyModelName = jest.fn(); |
| 12 | jest.mock("@continuedev/config-yaml", () => ({ |
| 13 | parseProxyModelName: mockParseProxyModelName, |
| 14 | decodeSecretLocation: jest.fn(), |
| 15 | SecretType: { NotFound: "not-found" }, |
| 16 | })); |
| 17 | |
| 18 | // Test cases: [LLM class, model, expected supportsFim result, description] |
| 19 | const testCases: [any, string, boolean, string][] = [ |
| 20 | [ContinueProxy, "owner/package/vllm/some-model", false, "vllm provider"], |
| 21 | [ContinueProxy, "owner/package/openai/gpt-4", true, "openai provider"], |
| 22 | [ |
| 23 | ContinueProxy, |
| 24 | "owner/package/anthropic/claude-3", |
| 25 | true, |
| 26 | "anthropic provider", |
| 27 | ], |
| 28 | [ContinueProxy, "owner/package/cohere/command-r", true, "cohere provider"], |
| 29 | [ |
| 30 | ContinueProxy, |
| 31 | "owner/package/unknown-provider/some-model", |
| 32 | true, |
| 33 | "unknown provider", |
| 34 | ], |
| 35 | [ContinueProxy, "owner/package/groq/llama-model", true, "groq provider"], |
| 36 | [Vllm, "any-model", false, "Vllm"], |
| 37 | [Anthropic, "claude-3-5-sonnet-latest", false, "Anthropic"], |
| 38 | [FunctionNetwork, "any-model", false, "FunctionNetwork"], |
| 39 | [OpenAI, "codestral", false, "OpenAI"], |
| 40 | [Mistral, "codestral", true, "Mistral"], |
| 41 | [Deepseek, "deepseek-chat", true, "Deepseek"], |
| 42 | ]; |
| 43 | |
| 44 | testCases.forEach(([LLMClass, model, expectedResult, description]) => { |
| 45 | test(`supportsFim returns ${expectedResult} for ${description}`, () => { |
| 46 | const llm = new LLMClass({ |
| 47 | model, |
| 48 | apiKey: "test-key", |
| 49 | }); |
| 50 | |
| 51 | const result = llm.supportsFim(); |
| 52 | |
| 53 | expect(result).toBe(expectedResult); |
| 54 | }); |
| 55 | }); |