| 1 | import { assert, describe, it } from "@effect/vitest" |
| 2 | import { Schema } from "effect" |
| 3 | import { LanguageModel } from "effect/ai" |
| 4 | |
| 5 | describe("LanguageModel representation v2", () => { |
| 6 | it("projects the encoded side before JSON Schema generation", () => { |
| 7 | assert.strictEqual(LanguageModel.defaultCodecTransformer(Schema.FiniteFromString).jsonSchema.type, "string") |
| 8 | }) |
| 9 | |
| 10 | it("uses custom JSON Schema compiler annotations in the default transformer", () => { |
| 11 | const schema = Schema.String.check(Schema.makeFilter<string>((value) => value.length >= 2, { |
| 12 | representation: { |
| 13 | id: "test/ai/language-model/minTwoCharacters", |
| 14 | payload: null |
| 15 | }, |
| 16 | toJsonSchema: () => ({ minLength: 2 }) |
| 17 | })) |
| 18 | |
| 19 | assert.deepStrictEqual(LanguageModel.defaultCodecTransformer(schema).jsonSchema, { |
| 20 | type: "string", |
| 21 | minLength: 2 |
| 22 | }) |
| 23 | }) |
| 24 | }) |