|
| 1 | +// npx vitest run api/providers/fetchers/__tests__/requesty.spec.ts |
| 2 | + |
| 3 | +import axios from "axios" |
| 4 | + |
| 5 | +import { getRequestyModels } from "../requesty" |
| 6 | + |
| 7 | +vi.mock("axios") |
| 8 | +const mockAxiosGet = vi.mocked(axios.get) |
| 9 | + |
| 10 | +function makeRawModel(overrides: Record<string, unknown>) { |
| 11 | + return { |
| 12 | + id: "some/model", |
| 13 | + max_output_tokens: 8192, |
| 14 | + context_window: 200000, |
| 15 | + supports_caching: false, |
| 16 | + supports_vision: false, |
| 17 | + supports_reasoning: false, |
| 18 | + input_price: "0.000003", |
| 19 | + output_price: "0.000015", |
| 20 | + description: "Test model", |
| 21 | + caching_price: null, |
| 22 | + cached_price: null, |
| 23 | + ...overrides, |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +describe("getRequestyModels", () => { |
| 28 | + it("applies Fable 5 overrides when parsing anthropic/claude-fable-5", async () => { |
| 29 | + const rawFable5 = makeRawModel({ |
| 30 | + id: "anthropic/claude-fable-5", |
| 31 | + max_output_tokens: 128000, |
| 32 | + context_window: 1000000, |
| 33 | + supports_caching: true, |
| 34 | + supports_vision: true, |
| 35 | + supports_reasoning: true, |
| 36 | + input_price: "0.00001", |
| 37 | + output_price: "0.00005", |
| 38 | + caching_price: "0.0000125", |
| 39 | + cached_price: "0.000001", |
| 40 | + }) |
| 41 | + |
| 42 | + mockAxiosGet.mockResolvedValueOnce({ data: { data: [rawFable5] } }) |
| 43 | + |
| 44 | + const models = await getRequestyModels() |
| 45 | + const fable5 = models["anthropic/claude-fable-5"] |
| 46 | + |
| 47 | + expect(fable5).toBeDefined() |
| 48 | + expect(fable5.supportsReasoningBudget).toBe(true) |
| 49 | + expect(fable5.supportsReasoningBinary).toBe(true) |
| 50 | + expect(fable5.supportsTemperature).toBe(false) |
| 51 | + }) |
| 52 | + |
| 53 | + it("does not apply Fable 5 overrides to other models", async () => { |
| 54 | + const rawSonnet = makeRawModel({ |
| 55 | + id: "anthropic/claude-sonnet-4.6", |
| 56 | + supports_reasoning: true, |
| 57 | + }) |
| 58 | + |
| 59 | + mockAxiosGet.mockResolvedValueOnce({ data: { data: [rawSonnet] } }) |
| 60 | + |
| 61 | + const models = await getRequestyModels() |
| 62 | + const sonnet = models["anthropic/claude-sonnet-4.6"] |
| 63 | + |
| 64 | + expect(sonnet.supportsReasoningBinary).toBeUndefined() |
| 65 | + expect(sonnet.supportsTemperature).toBeUndefined() |
| 66 | + }) |
| 67 | +}) |
0 commit comments