anthropic-adaptive-thinking-models.test.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. import { describe, expect, it } from "vitest";
  2. import { getModels, getProviders } from "../src/models.ts";
  3. import type { Api, Model } from "../src/types.ts";
  4. const EXPECTED_CURRENT_ADAPTIVE_THINKING_MODELS = [
  5. "anthropic/claude-fable-5",
  6. "anthropic/claude-opus-4-8",
  7. "cloudflare-ai-gateway/claude-fable-5",
  8. "opencode/claude-fable-5",
  9. "opencode/claude-opus-4-8",
  10. "vercel-ai-gateway/anthropic/claude-fable-5",
  11. "vercel-ai-gateway/anthropic/claude-opus-4.8",
  12. ];
  13. function getAllModels(): Model<Api>[] {
  14. return getProviders().flatMap((provider) => getModels(provider) as Model<Api>[]);
  15. }
  16. describe("Anthropic adaptive thinking model metadata", () => {
  17. it("marks built-in Anthropic Messages models that use adaptive thinking", () => {
  18. const flaggedModels = getAllModels()
  19. .filter((model): model is Model<"anthropic-messages"> => model.api === "anthropic-messages")
  20. .filter((model) => model.compat?.forceAdaptiveThinking === true)
  21. .map((model) => `${model.provider}/${model.id}`)
  22. .sort();
  23. expect(flaggedModels).toEqual(expect.arrayContaining([...EXPECTED_CURRENT_ADAPTIVE_THINKING_MODELS].sort()));
  24. expect(flaggedModels).toEqual(
  25. flaggedModels.filter((modelId) => /(fable[-.]5|opus[-.]4[-.][678]|sonnet[-.]4[-.]6)/.test(modelId)),
  26. );
  27. });
  28. });