|
| 1 | +import { describe, expect, test } from "bun:test" |
| 2 | +import { Schema } from "effect" |
| 3 | +import { ConfigProvider } from "@/config/provider" |
| 4 | +import { CatalogModelStatus, ModelStatus } from "@/provider/model-status" |
| 5 | +import { ModelsDev } from "@/provider/models" |
| 6 | +import { Provider } from "@/provider/provider" |
| 7 | + |
| 8 | +describe("provider model status schemas", () => { |
| 9 | + test("keeps catalog status separate from normalized provider status", () => { |
| 10 | + expect(Schema.decodeUnknownSync(CatalogModelStatus)("deprecated")).toBe("deprecated") |
| 11 | + expect(() => Schema.decodeUnknownSync(CatalogModelStatus)("active")).toThrow() |
| 12 | + expect(Schema.decodeUnknownSync(ModelStatus)("active")).toBe("active") |
| 13 | + }) |
| 14 | + |
| 15 | + test("accepts active status across public provider schemas", () => { |
| 16 | + expect(Schema.decodeUnknownSync(ConfigProvider.Model)({ status: "active" }).status).toBe("active") |
| 17 | + expect( |
| 18 | + Schema.decodeUnknownSync(ModelsDev.Model)({ |
| 19 | + id: "test-model", |
| 20 | + name: "Test Model", |
| 21 | + release_date: "2026-01-01", |
| 22 | + attachment: false, |
| 23 | + reasoning: false, |
| 24 | + temperature: true, |
| 25 | + tool_call: true, |
| 26 | + limit: { context: 128000, output: 8192 }, |
| 27 | + }).status, |
| 28 | + ).toBeUndefined() |
| 29 | + expect( |
| 30 | + Schema.decodeUnknownSync(Provider.Model)({ |
| 31 | + id: "test-model", |
| 32 | + providerID: "test-provider", |
| 33 | + api: { |
| 34 | + id: "test-model", |
| 35 | + url: "", |
| 36 | + npm: "@ai-sdk/openai-compatible", |
| 37 | + }, |
| 38 | + name: "Test Model", |
| 39 | + capabilities: { |
| 40 | + temperature: true, |
| 41 | + reasoning: false, |
| 42 | + attachment: false, |
| 43 | + toolcall: true, |
| 44 | + input: { text: true, audio: false, image: false, video: false, pdf: false }, |
| 45 | + output: { text: true, audio: false, image: false, video: false, pdf: false }, |
| 46 | + interleaved: false, |
| 47 | + }, |
| 48 | + cost: { |
| 49 | + input: 0, |
| 50 | + output: 0, |
| 51 | + cache: { read: 0, write: 0 }, |
| 52 | + }, |
| 53 | + limit: { context: 128000, output: 8192 }, |
| 54 | + status: "active", |
| 55 | + options: {}, |
| 56 | + headers: {}, |
| 57 | + release_date: "2026-01-01", |
| 58 | + }).status, |
| 59 | + ).toBe("active") |
| 60 | + }) |
| 61 | +}) |
0 commit comments