@botpress/zai 2.5.4 → 2.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,7 +22,12 @@ const NO_MORE = "\u25A0NO_MORE_ELEMENT\u25A0";
22
22
  const ZERO_ELEMENTS = "\u25A0ZERO_ELEMENTS\u25A0";
23
23
  const extract = async (input, _schema, _options, ctx) => {
24
24
  ctx.controller.signal.throwIfAborted();
25
- let schema = transforms.fromJSONSchema(transforms.toJSONSchema(_schema));
25
+ let schema;
26
+ try {
27
+ schema = transforms.fromJSONSchema(transforms.toJSONSchema(_schema));
28
+ } catch {
29
+ schema = _schema;
30
+ }
26
31
  const options = Options.parse(_options ?? {});
27
32
  const tokenizer = await getTokenizer();
28
33
  const model = await ctx.getModel();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@botpress/zai",
3
3
  "description": "Zui AI (zai) – An LLM utility library written on top of Zui and the Botpress API",
4
- "version": "2.5.4",
4
+ "version": "2.5.6",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
@@ -32,7 +32,7 @@
32
32
  "author": "",
33
33
  "license": "ISC",
34
34
  "dependencies": {
35
- "@botpress/cognitive": "0.3.2",
35
+ "@botpress/cognitive": "0.3.3",
36
36
  "json5": "^2.2.3",
37
37
  "jsonrepair": "^3.10.0",
38
38
  "lodash-es": "^4.17.21",
@@ -125,7 +125,13 @@ const extract = async <S extends OfType<AnyObjectOrArray>>(
125
125
  ): Promise<S['_output']> => {
126
126
  ctx.controller.signal.throwIfAborted()
127
127
 
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
+ }
129
135
 
130
136
  const options = Options.parse(_options ?? {})
131
137
  const tokenizer = await getTokenizer()