|
1 | 1 | import { describe, expect, test } from "bun:test" |
2 | | -import { parse } from "../../src/util/model" |
| 2 | +import { parse, contextLimit } from "../../src/util/model" |
3 | 3 |
|
4 | 4 | describe("util.model", () => { |
5 | 5 | test("splits provider from a nested model identifier", () => { |
6 | 6 | expect(parse("provider/org/model")).toEqual({ providerID: "provider", modelID: "org/model" }) |
7 | 7 | expect(parse("invalid")).toEqual({ providerID: "invalid", modelID: "" }) |
8 | 8 | }) |
| 9 | + |
| 10 | + test("contextLimit returns input limit when available", () => { |
| 11 | + const model = { limit: { context: 400_000, input: 272_000, output: 128_000 } } |
| 12 | + expect(contextLimit(model)).toBe(272_000) |
| 13 | + }) |
| 14 | + |
| 15 | + test("contextLimit falls back to context limit when input is 0", () => { |
| 16 | + const model = { limit: { context: 200_000, input: 0, output: 32_000 } } |
| 17 | + expect(contextLimit(model)).toBe(200_000) |
| 18 | + }) |
| 19 | + |
| 20 | + test("contextLimit falls back to context limit when input is undefined", () => { |
| 21 | + const model = { limit: { context: 1_000_000, output: 128_000 } } |
| 22 | + expect(contextLimit(model)).toBe(1_000_000) |
| 23 | + }) |
| 24 | + |
| 25 | + test("contextLimit returns undefined for undefined model", () => { |
| 26 | + expect(contextLimit(undefined)).toBeUndefined() |
| 27 | + }) |
| 28 | + |
| 29 | + test("contextLimit returns undefined when both limits are 0", () => { |
| 30 | + const model = { limit: { context: 0, output: 0 } } |
| 31 | + expect(contextLimit(model)).toBeUndefined() |
| 32 | + }) |
9 | 33 | }) |
0 commit comments