Skip to content

Commit 88a3d44

Browse files
fix(zai): try catch extract schema transform (botpress#14714)
1 parent b219b0d commit 88a3d44

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/zai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@botpress/zai",
33
"description": "Zui AI (zai) – An LLM utility library written on top of Zui and the Botpress API",
4-
"version": "2.5.5",
4+
"version": "2.5.6",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
77
"exports": {

packages/zai/src/operations/extract.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ const extract = async <S extends OfType<AnyObjectOrArray>>(
125125
): Promise<S['_output']> => {
126126
ctx.controller.signal.throwIfAborted()
127127

128-
let schema = transforms.fromJSONSchema(transforms.toJSONSchema(_schema as any as z.ZodType))
128+
let schema: z.ZodType
129+
try {
130+
schema = transforms.fromJSONSchema(transforms.toJSONSchema(_schema as any as z.ZodType))
131+
} catch {
132+
// The above transformers arent the legacy once. They are very strict and might fail on some schema types.
133+
schema = _schema as any as z.ZodType
134+
}
129135

130136
const options = Options.parse(_options ?? {})
131137
const tokenizer = await getTokenizer()

0 commit comments

Comments
 (0)