| 1 | import { describe, expect, test } from "vitest"; |
| 2 | import { ModelDescription } from "../index.d"; |
| 3 | import { shouldAutoEnableSystemMessageTools } from "./shouldAutoEnableSystemMessageTools"; |
| 4 | |
| 5 | describe("shouldAutoEnableSystemMessageTools", () => { |
| 6 | const createModel = (provider: string, model: string): ModelDescription => ({ |
| 7 | title: "Test Model", |
| 8 | provider, |
| 9 | underlyingProviderName: provider, |
| 10 | model, |
| 11 | }); |
| 12 | |
| 13 | test("should return true for OpenRouter models that don't contain 'claude'", () => { |
| 14 | expect( |
| 15 | shouldAutoEnableSystemMessageTools(createModel("openrouter", "gpt-4o")), |
| 16 | ).toBe(true); |
| 17 | expect( |
| 18 | shouldAutoEnableSystemMessageTools( |
| 19 | createModel("openrouter", "llama-3.3-70b-instruct"), |
| 20 | ), |
| 21 | ).toBe(true); |
| 22 | expect( |
| 23 | shouldAutoEnableSystemMessageTools( |
| 24 | createModel("openrouter", "qwen/qwen-2.5-72b-instruct"), |
| 25 | ), |
| 26 | ).toBe(true); |
| 27 | }); |
| 28 | |
| 29 | test("should return false for OpenRouter Claude models", () => { |
| 30 | expect( |
| 31 | shouldAutoEnableSystemMessageTools( |
| 32 | createModel("openrouter", "anthropic/claude-3-sonnet"), |
| 33 | ), |
| 34 | ).toBe(false); |
| 35 | expect( |
| 36 | shouldAutoEnableSystemMessageTools( |
| 37 | createModel("openrouter", "anthropic/claude-3.5-sonnet"), |
| 38 | ), |
| 39 | ).toBe(false); |
| 40 | expect( |
| 41 | shouldAutoEnableSystemMessageTools( |
| 42 | createModel("openrouter", "claude-3-haiku"), |
| 43 | ), |
| 44 | ).toBe(false); |
| 45 | }); |
| 46 | |
| 47 | test("should return undefined for all other providers", () => { |
| 48 | expect( |
| 49 | shouldAutoEnableSystemMessageTools(createModel("openai", "gpt-4o")), |
| 50 | ).toBe(undefined); |
| 51 | expect( |
| 52 | shouldAutoEnableSystemMessageTools( |
| 53 | createModel("anthropic", "claude-3.5-sonnet"), |
| 54 | ), |
| 55 | ).toBe(undefined); |
| 56 | expect( |
| 57 | shouldAutoEnableSystemMessageTools( |
| 58 | createModel("groq", "llama-3.3-70b-versatile"), |
| 59 | ), |
| 60 | ).toBe(undefined); |
| 61 | expect( |
| 62 | shouldAutoEnableSystemMessageTools( |
| 63 | createModel("together", "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"), |
| 64 | ), |
| 65 | ).toBe(undefined); |
| 66 | }); |
| 67 | |
| 68 | test("should be case insensitive for 'claude' detection", () => { |
| 69 | expect( |
| 70 | shouldAutoEnableSystemMessageTools( |
| 71 | createModel("openrouter", "CLAUDE-models"), |
| 72 | ), |
| 73 | ).toBe(false); |
| 74 | expect( |
| 75 | shouldAutoEnableSystemMessageTools( |
| 76 | createModel("openrouter", "Claude-3.5"), |
| 77 | ), |
| 78 | ).toBe(false); |
| 79 | expect( |
| 80 | shouldAutoEnableSystemMessageTools( |
| 81 | createModel("openrouter", "some-model-Claude"), |
| 82 | ), |
| 83 | ).toBe(false); |
| 84 | }); |
| 85 | }); |