@botpress/zai 2.5.5 → 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
|
|
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
|
@@ -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
|
|
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()
|