| 1 | import { assert, describe, it } from "@effect/vitest"; |
| 2 | |
| 3 | import { thinkingCapabilitiesForPiModel } from "./thinkingCapabilities.ts"; |
| 4 | |
| 5 | describe("thinkingCapabilitiesForPiModel", () => { |
| 6 | it("gives every choice its real level id and tags Pi's default", () => { |
| 7 | const capabilities = thinkingCapabilitiesForPiModel( |
| 8 | { |
| 9 | reasoning: true, |
| 10 | thinkingLevelMap: { off: null, xhigh: "extra_high", max: null }, |
| 11 | }, |
| 12 | "xhigh", |
| 13 | ); |
| 14 | const descriptors = capabilities.optionDescriptors ?? []; |
| 15 | const thinking = descriptors[0]; |
| 16 | assert.equal(thinking?.id, "thinking"); |
| 17 | assert.equal(thinking?.type, "select"); |
| 18 | if (thinking?.type !== "select") return; |
| 19 | assert.deepEqual( |
| 20 | thinking.options.map((option) => [option.id, option.label, option.isDefault === true]), |
| 21 | [ |
| 22 | ["minimal", "Minimal", false], |
| 23 | ["low", "Low", false], |
| 24 | ["medium", "Medium", false], |
| 25 | ["high", "High", false], |
| 26 | ["xhigh", "Extra High", true], |
| 27 | ], |
| 28 | ); |
| 29 | }); |
| 30 | |
| 31 | it("clamps Pi's default to each model's supported levels", () => { |
| 32 | const capabilities = thinkingCapabilitiesForPiModel( |
| 33 | { |
| 34 | reasoning: true, |
| 35 | thinkingLevelMap: { xhigh: "extra_high", max: null }, |
| 36 | }, |
| 37 | "max", |
| 38 | ); |
| 39 | const thinking = capabilities.optionDescriptors?.[0]; |
| 40 | assert.equal(thinking?.type, "select"); |
| 41 | if (thinking?.type !== "select") return; |
| 42 | assert.deepInclude(thinking.options, { |
| 43 | id: "xhigh", |
| 44 | label: "Extra High", |
| 45 | isDefault: true, |
| 46 | }); |
| 47 | assert.notInclude( |
| 48 | thinking.options.map((option) => option.id), |
| 49 | "max", |
| 50 | ); |
| 51 | }); |
| 52 | }); |