@botpress/zai 1.0.1 → 1.1.0
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.
- package/dist/adapters/adapter.js +2 -0
- package/dist/adapters/botpress-table.js +168 -0
- package/dist/adapters/memory.js +12 -0
- package/dist/index.d.ts +99 -98
- package/dist/index.js +9 -1873
- package/dist/models.js +387 -0
- package/dist/operations/check.js +141 -0
- package/dist/operations/constants.js +2 -0
- package/dist/operations/errors.js +15 -0
- package/dist/operations/extract.js +212 -0
- package/dist/operations/filter.js +179 -0
- package/dist/operations/label.js +237 -0
- package/dist/operations/rewrite.js +111 -0
- package/dist/operations/summarize.js +132 -0
- package/dist/operations/text.js +46 -0
- package/dist/utils.js +43 -0
- package/dist/zai.js +140 -0
- package/package.json +21 -19
- package/src/adapters/adapter.ts +35 -0
- package/src/adapters/botpress-table.ts +210 -0
- package/src/adapters/memory.ts +13 -0
- package/src/index.ts +11 -0
- package/src/models.ts +394 -0
- package/src/operations/__tests/botpress_docs.txt +26040 -0
- package/src/operations/__tests/cache.jsonl +101 -0
- package/src/operations/__tests/index.ts +87 -0
- package/src/operations/check.ts +187 -0
- package/src/operations/constants.ts +2 -0
- package/src/operations/errors.ts +9 -0
- package/src/operations/extract.ts +291 -0
- package/src/operations/filter.ts +231 -0
- package/src/operations/label.ts +332 -0
- package/src/operations/rewrite.ts +148 -0
- package/src/operations/summarize.ts +193 -0
- package/src/operations/text.ts +63 -0
- package/src/sdk-interfaces/llm/generateContent.ts +127 -0
- package/src/sdk-interfaces/llm/listLanguageModels.ts +19 -0
- package/src/utils.ts +61 -0
- package/src/zai.ts +193 -0
- package/tsconfig.json +2 -2
- package/dist/index.cjs +0 -1903
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -916
- package/dist/index.js.map +0 -1
- package/tsup.config.ts +0 -16
- package/vitest.config.ts +0 -9
- package/vitest.setup.ts +0 -24
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { z } from "@bpinternal/zui";
|
|
2
|
+
import { BotpressClient, GenerationMetadata } from "../utils";
|
|
3
|
+
import { Adapter } from "./adapter";
|
|
4
|
+
const CRITICAL_TAGS = {
|
|
5
|
+
system: "true",
|
|
6
|
+
"schema-purpose": "active-learning",
|
|
7
|
+
"schema-version": "Oct-2024"
|
|
8
|
+
};
|
|
9
|
+
const OPTIONAL_TAGS = {
|
|
10
|
+
"x-studio-title": "Active Learning",
|
|
11
|
+
"x-studio-description": "Table for storing active learning tasks and examples",
|
|
12
|
+
"x-studio-readonly": "true",
|
|
13
|
+
"x-studio-icon": "lucide://atom",
|
|
14
|
+
"x-studio-color": "green"
|
|
15
|
+
};
|
|
16
|
+
const FACTOR = 30;
|
|
17
|
+
const Props = z.object({
|
|
18
|
+
client: BotpressClient,
|
|
19
|
+
tableName: z.string().regex(
|
|
20
|
+
/^[a-zA-Z0-9_]{1,45}Table$/,
|
|
21
|
+
"Table name must be lowercase and contain only letters, numbers and underscores"
|
|
22
|
+
)
|
|
23
|
+
});
|
|
24
|
+
const TableSchema = z.object({
|
|
25
|
+
taskType: z.string().describe("The type of the task (filter, extract, etc.)"),
|
|
26
|
+
taskId: z.string(),
|
|
27
|
+
key: z.string().describe("A unique key for the task (e.g. a hash of the input, taskId, taskType and instructions)"),
|
|
28
|
+
instructions: z.string(),
|
|
29
|
+
input: z.object({}).passthrough().describe("The input to the task"),
|
|
30
|
+
output: z.object({}).passthrough().describe("The expected output"),
|
|
31
|
+
explanation: z.string().nullable(),
|
|
32
|
+
metadata: GenerationMetadata,
|
|
33
|
+
status: z.enum(["pending", "rejected", "approved"]),
|
|
34
|
+
feedback: z.object({
|
|
35
|
+
rating: z.enum(["very-bad", "bad", "good", "very-good"]),
|
|
36
|
+
comment: z.string().nullable()
|
|
37
|
+
}).nullable().default(null)
|
|
38
|
+
});
|
|
39
|
+
const searchableColumns = ["input"];
|
|
40
|
+
const TableJsonSchema = Object.entries(TableSchema.shape).reduce((acc, [key, value]) => {
|
|
41
|
+
acc[key] = value.toJsonSchema();
|
|
42
|
+
acc[key]["x-zui"] ??= {};
|
|
43
|
+
acc[key]["x-zui"].searchable = searchableColumns.includes(key);
|
|
44
|
+
return acc;
|
|
45
|
+
}, {});
|
|
46
|
+
export class TableAdapter extends Adapter {
|
|
47
|
+
client;
|
|
48
|
+
tableName;
|
|
49
|
+
status;
|
|
50
|
+
constructor(props) {
|
|
51
|
+
super();
|
|
52
|
+
props = Props.parse(props);
|
|
53
|
+
this.client = props.client;
|
|
54
|
+
this.tableName = props.tableName;
|
|
55
|
+
this.status = "ready";
|
|
56
|
+
}
|
|
57
|
+
async getExamples({ taskType, taskId, input }) {
|
|
58
|
+
await this.assertTableExists();
|
|
59
|
+
const { rows } = await this.client.findTableRows({
|
|
60
|
+
table: this.tableName,
|
|
61
|
+
search: JSON.stringify({ value: input }).substring(0, 1023),
|
|
62
|
+
// Search is limited to 1024 characters
|
|
63
|
+
limit: 10,
|
|
64
|
+
// TODO
|
|
65
|
+
filter: {
|
|
66
|
+
// Proximity match of approved examples
|
|
67
|
+
taskType,
|
|
68
|
+
taskId,
|
|
69
|
+
status: "approved"
|
|
70
|
+
}
|
|
71
|
+
}).catch((err) => {
|
|
72
|
+
console.error(`Error fetching examples: ${err.message}`);
|
|
73
|
+
return { rows: [] };
|
|
74
|
+
});
|
|
75
|
+
return rows.map((row) => ({
|
|
76
|
+
key: row.key,
|
|
77
|
+
input: row.input.value,
|
|
78
|
+
output: row.output.value,
|
|
79
|
+
explanation: row.explanation,
|
|
80
|
+
similarity: row.similarity ?? 0
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
async saveExample({
|
|
84
|
+
key,
|
|
85
|
+
taskType,
|
|
86
|
+
taskId,
|
|
87
|
+
instructions,
|
|
88
|
+
input,
|
|
89
|
+
output,
|
|
90
|
+
explanation,
|
|
91
|
+
metadata,
|
|
92
|
+
status = "pending"
|
|
93
|
+
}) {
|
|
94
|
+
await this.assertTableExists();
|
|
95
|
+
await this.client.upsertTableRows({
|
|
96
|
+
table: this.tableName,
|
|
97
|
+
keyColumn: "key",
|
|
98
|
+
rows: [
|
|
99
|
+
{
|
|
100
|
+
key,
|
|
101
|
+
taskType,
|
|
102
|
+
taskId,
|
|
103
|
+
instructions,
|
|
104
|
+
input: { value: input },
|
|
105
|
+
output: { value: output },
|
|
106
|
+
explanation: explanation ?? null,
|
|
107
|
+
status,
|
|
108
|
+
metadata
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}).catch(() => {
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async assertTableExists() {
|
|
115
|
+
if (this.status !== "ready") {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const { table, created } = await this.client.getOrCreateTable({
|
|
119
|
+
table: this.tableName,
|
|
120
|
+
factor: FACTOR,
|
|
121
|
+
frozen: true,
|
|
122
|
+
isComputeEnabled: false,
|
|
123
|
+
tags: {
|
|
124
|
+
...CRITICAL_TAGS,
|
|
125
|
+
...OPTIONAL_TAGS
|
|
126
|
+
},
|
|
127
|
+
schema: TableJsonSchema
|
|
128
|
+
}).catch(() => {
|
|
129
|
+
this.status = "error";
|
|
130
|
+
return { table: null, created: false };
|
|
131
|
+
});
|
|
132
|
+
if (!table) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (!created) {
|
|
136
|
+
const issues = [];
|
|
137
|
+
if (table.factor !== FACTOR) {
|
|
138
|
+
issues.push(`Factor is ${table.factor} instead of ${FACTOR}`);
|
|
139
|
+
}
|
|
140
|
+
if (table.frozen !== true) {
|
|
141
|
+
issues.push("Table is not frozen");
|
|
142
|
+
}
|
|
143
|
+
for (const [key, value] of Object.entries(CRITICAL_TAGS)) {
|
|
144
|
+
if (table.tags?.[key] !== value) {
|
|
145
|
+
issues.push(`Tag ${key} is ${table.tags?.[key]} instead of ${value}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
for (const key of Object.keys(TableJsonSchema)) {
|
|
149
|
+
const column = table.schema?.properties[key];
|
|
150
|
+
const expected = TableJsonSchema[key];
|
|
151
|
+
if (!column) {
|
|
152
|
+
issues.push(`Column ${key} is missing`);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (column.type !== expected.type) {
|
|
156
|
+
issues.push(`Column ${key} has type ${column.type} instead of ${expected.type}`);
|
|
157
|
+
}
|
|
158
|
+
if (expected["x-zui"].searchable && !column["x-zui"].searchable) {
|
|
159
|
+
issues.push(`Column ${key} is not searchable but should be`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (issues.length) {
|
|
163
|
+
this.status = "error";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
this.status = "initialized";
|
|
167
|
+
}
|
|
168
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
+
import * as _bpinternal_zui from '@bpinternal/zui';
|
|
2
|
+
import { z } from '@bpinternal/zui';
|
|
1
3
|
import { Client } from '@botpress/client';
|
|
2
|
-
import sdk from '@botpress/sdk';
|
|
3
4
|
import { TextTokenizer } from '@botpress/wasm';
|
|
4
5
|
|
|
5
|
-
type GenerationMetadata =
|
|
6
|
-
declare const GenerationMetadata:
|
|
7
|
-
model:
|
|
8
|
-
cost:
|
|
9
|
-
input:
|
|
10
|
-
output:
|
|
11
|
-
}, "strip",
|
|
6
|
+
type GenerationMetadata = z.input<typeof GenerationMetadata>;
|
|
7
|
+
declare const GenerationMetadata: _bpinternal_zui.ZodObject<{
|
|
8
|
+
model: _bpinternal_zui.ZodString;
|
|
9
|
+
cost: _bpinternal_zui.ZodObject<{
|
|
10
|
+
input: _bpinternal_zui.ZodNumber;
|
|
11
|
+
output: _bpinternal_zui.ZodNumber;
|
|
12
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
12
13
|
input?: number;
|
|
13
14
|
output?: number;
|
|
14
15
|
}, {
|
|
15
16
|
input?: number;
|
|
16
17
|
output?: number;
|
|
17
18
|
}>;
|
|
18
|
-
latency:
|
|
19
|
-
tokens:
|
|
20
|
-
input:
|
|
21
|
-
output:
|
|
22
|
-
}, "strip",
|
|
19
|
+
latency: _bpinternal_zui.ZodNumber;
|
|
20
|
+
tokens: _bpinternal_zui.ZodObject<{
|
|
21
|
+
input: _bpinternal_zui.ZodNumber;
|
|
22
|
+
output: _bpinternal_zui.ZodNumber;
|
|
23
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
23
24
|
input?: number;
|
|
24
25
|
output?: number;
|
|
25
26
|
}, {
|
|
26
27
|
input?: number;
|
|
27
28
|
output?: number;
|
|
28
29
|
}>;
|
|
29
|
-
}, "strip",
|
|
30
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
30
31
|
model?: string;
|
|
31
32
|
cost?: {
|
|
32
33
|
input?: number;
|
|
@@ -558,12 +559,12 @@ declare namespace llm {
|
|
|
558
559
|
}
|
|
559
560
|
}
|
|
560
561
|
|
|
561
|
-
type ActiveLearning =
|
|
562
|
-
declare const ActiveLearning:
|
|
563
|
-
enable:
|
|
564
|
-
tableName:
|
|
565
|
-
taskId:
|
|
566
|
-
}, "strip",
|
|
562
|
+
type ActiveLearning = z.input<typeof ActiveLearning>;
|
|
563
|
+
declare const ActiveLearning: _bpinternal_zui.ZodObject<{
|
|
564
|
+
enable: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodBoolean>;
|
|
565
|
+
tableName: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
|
|
566
|
+
taskId: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
|
|
567
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
567
568
|
tableName?: string;
|
|
568
569
|
taskId?: string;
|
|
569
570
|
enable?: boolean;
|
|
@@ -572,23 +573,23 @@ declare const ActiveLearning: sdk.ZodObject<{
|
|
|
572
573
|
taskId?: string;
|
|
573
574
|
enable?: boolean;
|
|
574
575
|
}>;
|
|
575
|
-
type ZaiConfig =
|
|
576
|
-
declare const ZaiConfig:
|
|
577
|
-
client:
|
|
578
|
-
userId:
|
|
579
|
-
retry:
|
|
580
|
-
maxRetries:
|
|
581
|
-
}, "strip",
|
|
576
|
+
type ZaiConfig = z.input<typeof ZaiConfig>;
|
|
577
|
+
declare const ZaiConfig: _bpinternal_zui.ZodObject<{
|
|
578
|
+
client: z.Schema<any, _bpinternal_zui.ZodTypeDef, any>;
|
|
579
|
+
userId: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
|
|
580
|
+
retry: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodObject<{
|
|
581
|
+
maxRetries: _bpinternal_zui.ZodNumber;
|
|
582
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
582
583
|
maxRetries?: number;
|
|
583
584
|
}, {
|
|
584
585
|
maxRetries?: number;
|
|
585
586
|
}>>;
|
|
586
|
-
modelId:
|
|
587
|
-
activeLearning:
|
|
588
|
-
enable:
|
|
589
|
-
tableName:
|
|
590
|
-
taskId:
|
|
591
|
-
}, "strip",
|
|
587
|
+
modelId: _bpinternal_zui.ZodDefault<z.Schema<string, _bpinternal_zui.ZodTypeDef, string>>;
|
|
588
|
+
activeLearning: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodObject<{
|
|
589
|
+
enable: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodBoolean>;
|
|
590
|
+
tableName: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
|
|
591
|
+
taskId: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
|
|
592
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
592
593
|
tableName?: string;
|
|
593
594
|
taskId?: string;
|
|
594
595
|
enable?: boolean;
|
|
@@ -597,9 +598,9 @@ declare const ZaiConfig: sdk.ZodObject<{
|
|
|
597
598
|
taskId?: string;
|
|
598
599
|
enable?: boolean;
|
|
599
600
|
}>>;
|
|
600
|
-
namespace:
|
|
601
|
-
}, "strip",
|
|
602
|
-
client?:
|
|
601
|
+
namespace: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
|
|
602
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
603
|
+
client?: any;
|
|
603
604
|
userId?: string;
|
|
604
605
|
retry?: {
|
|
605
606
|
maxRetries?: number;
|
|
@@ -612,7 +613,7 @@ declare const ZaiConfig: sdk.ZodObject<{
|
|
|
612
613
|
};
|
|
613
614
|
namespace?: string;
|
|
614
615
|
}, {
|
|
615
|
-
client?:
|
|
616
|
+
client?: any;
|
|
616
617
|
userId?: string;
|
|
617
618
|
retry?: {
|
|
618
619
|
maxRetries?: number;
|
|
@@ -650,10 +651,10 @@ declare class Zai {
|
|
|
650
651
|
learn(taskId: string): Zai;
|
|
651
652
|
}
|
|
652
653
|
|
|
653
|
-
type Options$6 =
|
|
654
|
-
declare const Options$6:
|
|
655
|
-
length:
|
|
656
|
-
}, "strip",
|
|
654
|
+
type Options$6 = z.input<typeof Options$6>;
|
|
655
|
+
declare const Options$6: _bpinternal_zui.ZodObject<{
|
|
656
|
+
length: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>;
|
|
657
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
657
658
|
length?: number;
|
|
658
659
|
}, {
|
|
659
660
|
length?: number;
|
|
@@ -665,20 +666,20 @@ declare module '@botpress/zai' {
|
|
|
665
666
|
}
|
|
666
667
|
}
|
|
667
668
|
|
|
668
|
-
type Options$5 =
|
|
669
|
-
declare const Options$5:
|
|
670
|
-
examples:
|
|
671
|
-
input:
|
|
672
|
-
output:
|
|
673
|
-
}, "strip",
|
|
669
|
+
type Options$5 = z.input<typeof Options$5>;
|
|
670
|
+
declare const Options$5: _bpinternal_zui.ZodObject<{
|
|
671
|
+
examples: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodArray<_bpinternal_zui.ZodObject<{
|
|
672
|
+
input: _bpinternal_zui.ZodString;
|
|
673
|
+
output: _bpinternal_zui.ZodString;
|
|
674
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
674
675
|
input?: string;
|
|
675
676
|
output?: string;
|
|
676
677
|
}, {
|
|
677
678
|
input?: string;
|
|
678
679
|
output?: string;
|
|
679
680
|
}>, "many">>;
|
|
680
|
-
length:
|
|
681
|
-
}, "strip",
|
|
681
|
+
length: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>;
|
|
682
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
682
683
|
length?: number;
|
|
683
684
|
examples?: {
|
|
684
685
|
input?: string;
|
|
@@ -698,24 +699,24 @@ declare module '@botpress/zai' {
|
|
|
698
699
|
}
|
|
699
700
|
}
|
|
700
701
|
|
|
701
|
-
type Options$4 =
|
|
702
|
-
declare const Options$4:
|
|
703
|
-
prompt:
|
|
704
|
-
format:
|
|
705
|
-
length:
|
|
706
|
-
intermediateFactor:
|
|
707
|
-
maxIterations:
|
|
708
|
-
sliding:
|
|
709
|
-
window:
|
|
710
|
-
overlap:
|
|
711
|
-
}, "strip",
|
|
702
|
+
type Options$4 = z.input<typeof Options$4>;
|
|
703
|
+
declare const Options$4: _bpinternal_zui.ZodObject<{
|
|
704
|
+
prompt: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
|
|
705
|
+
format: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
|
|
706
|
+
length: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodNumber>;
|
|
707
|
+
intermediateFactor: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodNumber>;
|
|
708
|
+
maxIterations: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodNumber>;
|
|
709
|
+
sliding: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodObject<{
|
|
710
|
+
window: _bpinternal_zui.ZodNumber;
|
|
711
|
+
overlap: _bpinternal_zui.ZodNumber;
|
|
712
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
712
713
|
window?: number;
|
|
713
714
|
overlap?: number;
|
|
714
715
|
}, {
|
|
715
716
|
window?: number;
|
|
716
717
|
overlap?: number;
|
|
717
718
|
}>>;
|
|
718
|
-
}, "strip",
|
|
719
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
719
720
|
length?: number;
|
|
720
721
|
prompt?: string;
|
|
721
722
|
format?: string;
|
|
@@ -743,13 +744,13 @@ declare module '@botpress/zai' {
|
|
|
743
744
|
}
|
|
744
745
|
}
|
|
745
746
|
|
|
746
|
-
type Options$3 =
|
|
747
|
-
declare const Options$3:
|
|
748
|
-
examples:
|
|
749
|
-
input:
|
|
750
|
-
check:
|
|
751
|
-
reason:
|
|
752
|
-
}, "strip",
|
|
747
|
+
type Options$3 = z.input<typeof Options$3>;
|
|
748
|
+
declare const Options$3: _bpinternal_zui.ZodObject<{
|
|
749
|
+
examples: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodArray<_bpinternal_zui.ZodObject<{
|
|
750
|
+
input: _bpinternal_zui.ZodAny;
|
|
751
|
+
check: _bpinternal_zui.ZodBoolean;
|
|
752
|
+
reason: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
|
|
753
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
753
754
|
input?: any;
|
|
754
755
|
check?: boolean;
|
|
755
756
|
reason?: string;
|
|
@@ -758,7 +759,7 @@ declare const Options$3: sdk.ZodObject<{
|
|
|
758
759
|
check?: boolean;
|
|
759
760
|
reason?: string;
|
|
760
761
|
}>, "many">>;
|
|
761
|
-
}, "strip",
|
|
762
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
762
763
|
examples?: {
|
|
763
764
|
input?: any;
|
|
764
765
|
check?: boolean;
|
|
@@ -778,14 +779,14 @@ declare module '@botpress/zai' {
|
|
|
778
779
|
}
|
|
779
780
|
}
|
|
780
781
|
|
|
781
|
-
type Options$2 =
|
|
782
|
-
declare const Options$2:
|
|
783
|
-
tokensPerItem:
|
|
784
|
-
examples:
|
|
785
|
-
input:
|
|
786
|
-
filter:
|
|
787
|
-
reason:
|
|
788
|
-
}, "strip",
|
|
782
|
+
type Options$2 = z.input<typeof Options$2>;
|
|
783
|
+
declare const Options$2: _bpinternal_zui.ZodObject<{
|
|
784
|
+
tokensPerItem: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>>;
|
|
785
|
+
examples: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodArray<_bpinternal_zui.ZodObject<{
|
|
786
|
+
input: _bpinternal_zui.ZodAny;
|
|
787
|
+
filter: _bpinternal_zui.ZodBoolean;
|
|
788
|
+
reason: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
|
|
789
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
789
790
|
input?: any;
|
|
790
791
|
filter?: boolean;
|
|
791
792
|
reason?: string;
|
|
@@ -794,7 +795,7 @@ declare const Options$2: sdk.ZodObject<{
|
|
|
794
795
|
filter?: boolean;
|
|
795
796
|
reason?: string;
|
|
796
797
|
}>, "many">>;
|
|
797
|
-
}, "strip",
|
|
798
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
798
799
|
examples?: {
|
|
799
800
|
input?: any;
|
|
800
801
|
filter?: boolean;
|
|
@@ -816,11 +817,11 @@ declare module '@botpress/zai' {
|
|
|
816
817
|
}
|
|
817
818
|
}
|
|
818
819
|
|
|
819
|
-
type Options$1 =
|
|
820
|
-
declare const Options$1:
|
|
821
|
-
instructions:
|
|
822
|
-
chunkLength:
|
|
823
|
-
}, "strip",
|
|
820
|
+
type Options$1 = z.input<typeof Options$1>;
|
|
821
|
+
declare const Options$1: _bpinternal_zui.ZodObject<{
|
|
822
|
+
instructions: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
|
|
823
|
+
chunkLength: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>>;
|
|
824
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
824
825
|
instructions?: string;
|
|
825
826
|
chunkLength?: number;
|
|
826
827
|
}, {
|
|
@@ -830,8 +831,8 @@ declare const Options$1: sdk.ZodObject<{
|
|
|
830
831
|
declare module '@botpress/zai' {
|
|
831
832
|
interface Zai {
|
|
832
833
|
/** Extracts one or many elements from an arbitrary input */
|
|
833
|
-
extract<S extends
|
|
834
|
-
extract<S extends
|
|
834
|
+
extract<S extends z.AnyZodObject>(input: unknown, schema: S, options?: Options$1): Promise<z.infer<S>>;
|
|
835
|
+
extract<S extends z.AnyZodObject>(input: unknown, schema: z.ZodArray<S>, options?: Options$1): Promise<Array<z.infer<S>>>;
|
|
835
836
|
}
|
|
836
837
|
}
|
|
837
838
|
|
|
@@ -850,23 +851,23 @@ type Example<T extends string> = {
|
|
|
850
851
|
explanation?: string;
|
|
851
852
|
}>>;
|
|
852
853
|
};
|
|
853
|
-
type Options<T extends string> = Omit<
|
|
854
|
+
type Options<T extends string> = Omit<z.input<typeof Options>, 'examples'> & {
|
|
854
855
|
examples?: Array<Partial<Example<T>>>;
|
|
855
856
|
};
|
|
856
|
-
declare const Options:
|
|
857
|
-
examples:
|
|
858
|
-
input:
|
|
859
|
-
labels:
|
|
860
|
-
label:
|
|
861
|
-
explanation:
|
|
862
|
-
}, "strip",
|
|
857
|
+
declare const Options: _bpinternal_zui.ZodObject<{
|
|
858
|
+
examples: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodArray<_bpinternal_zui.ZodObject<{
|
|
859
|
+
input: _bpinternal_zui.ZodAny;
|
|
860
|
+
labels: _bpinternal_zui.ZodRecord<_bpinternal_zui.ZodString, _bpinternal_zui.ZodObject<{
|
|
861
|
+
label: _bpinternal_zui.ZodEnum<never>;
|
|
862
|
+
explanation: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
|
|
863
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
863
864
|
label: never;
|
|
864
865
|
explanation?: string;
|
|
865
866
|
}, {
|
|
866
867
|
label: never;
|
|
867
868
|
explanation?: string;
|
|
868
869
|
}>>;
|
|
869
|
-
}, "strip",
|
|
870
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
870
871
|
input?: any;
|
|
871
872
|
labels?: Record<string, {
|
|
872
873
|
label: never;
|
|
@@ -879,9 +880,9 @@ declare const Options: sdk.ZodObject<{
|
|
|
879
880
|
explanation?: string;
|
|
880
881
|
}>;
|
|
881
882
|
}>, "many">>;
|
|
882
|
-
instructions:
|
|
883
|
-
chunkLength:
|
|
884
|
-
}, "strip",
|
|
883
|
+
instructions: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
|
|
884
|
+
chunkLength: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>>;
|
|
885
|
+
}, "strip", _bpinternal_zui.ZodTypeAny, {
|
|
885
886
|
instructions?: string;
|
|
886
887
|
examples?: {
|
|
887
888
|
input?: any;
|
|
@@ -903,7 +904,7 @@ declare const Options: sdk.ZodObject<{
|
|
|
903
904
|
chunkLength?: number;
|
|
904
905
|
}>;
|
|
905
906
|
type Labels<T extends string> = Record<T, string>;
|
|
906
|
-
declare const Labels:
|
|
907
|
+
declare const Labels: z.ZodTransformer<_bpinternal_zui.ZodRecord<_bpinternal_zui.ZodString, _bpinternal_zui.ZodString>, Record<string, string>, Record<string, string>>;
|
|
907
908
|
declare module '@botpress/zai' {
|
|
908
909
|
interface Zai {
|
|
909
910
|
/** Tags the provided input with a list of predefined labels */
|