@botpress/zai 1.0.0-beta.1

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.
Files changed (126) hide show
  1. package/README.md +57 -0
  2. package/dist/src/adapters/adapter.d.ts +27 -0
  3. package/dist/src/adapters/adapter.js +3 -0
  4. package/dist/src/adapters/adapter.js.map +1 -0
  5. package/dist/src/adapters/botpress-table.d.ts +155 -0
  6. package/dist/src/adapters/botpress-table.js +170 -0
  7. package/dist/src/adapters/botpress-table.js.map +1 -0
  8. package/dist/src/adapters/memory.d.ts +7 -0
  9. package/dist/src/adapters/memory.js +13 -0
  10. package/dist/src/adapters/memory.js.map +1 -0
  11. package/dist/src/env.d.ts +37 -0
  12. package/dist/src/env.js +27 -0
  13. package/dist/src/env.js.map +1 -0
  14. package/dist/src/index.d.ts +9 -0
  15. package/dist/src/index.js +10 -0
  16. package/dist/src/index.js.map +1 -0
  17. package/dist/src/models.d.ts +253 -0
  18. package/dist/src/models.js +348 -0
  19. package/dist/src/models.js.map +1 -0
  20. package/dist/src/operations/__tests/index.d.ts +19 -0
  21. package/dist/src/operations/__tests/index.js +24 -0
  22. package/dist/src/operations/__tests/index.js.map +1 -0
  23. package/dist/src/operations/check.d.ts +36 -0
  24. package/dist/src/operations/check.js +146 -0
  25. package/dist/src/operations/check.js.map +1 -0
  26. package/dist/src/operations/check.test.d.ts +1 -0
  27. package/dist/src/operations/check.test.js +129 -0
  28. package/dist/src/operations/check.test.js.map +1 -0
  29. package/dist/src/operations/constants.d.ts +2 -0
  30. package/dist/src/operations/constants.js +3 -0
  31. package/dist/src/operations/constants.js.map +1 -0
  32. package/dist/src/operations/errors.d.ts +5 -0
  33. package/dist/src/operations/errors.js +11 -0
  34. package/dist/src/operations/errors.js.map +1 -0
  35. package/dist/src/operations/extract.d.ts +20 -0
  36. package/dist/src/operations/extract.js +235 -0
  37. package/dist/src/operations/extract.js.map +1 -0
  38. package/dist/src/operations/extract.test.d.ts +1 -0
  39. package/dist/src/operations/extract.test.js +163 -0
  40. package/dist/src/operations/extract.test.js.map +1 -0
  41. package/dist/src/operations/filter.d.ts +39 -0
  42. package/dist/src/operations/filter.js +184 -0
  43. package/dist/src/operations/filter.js.map +1 -0
  44. package/dist/src/operations/filter.test.d.ts +1 -0
  45. package/dist/src/operations/filter.test.js +151 -0
  46. package/dist/src/operations/filter.test.js.map +1 -0
  47. package/dist/src/operations/label.d.ts +79 -0
  48. package/dist/src/operations/label.js +250 -0
  49. package/dist/src/operations/label.js.map +1 -0
  50. package/dist/src/operations/label.test.d.ts +1 -0
  51. package/dist/src/operations/label.test.js +213 -0
  52. package/dist/src/operations/label.test.js.map +1 -0
  53. package/dist/src/operations/rewrite.d.ts +34 -0
  54. package/dist/src/operations/rewrite.js +106 -0
  55. package/dist/src/operations/rewrite.js.map +1 -0
  56. package/dist/src/operations/rewrite.test.d.ts +1 -0
  57. package/dist/src/operations/rewrite.test.js +96 -0
  58. package/dist/src/operations/rewrite.test.js.map +1 -0
  59. package/dist/src/operations/summarize.d.ts +46 -0
  60. package/dist/src/operations/summarize.js +139 -0
  61. package/dist/src/operations/summarize.js.map +1 -0
  62. package/dist/src/operations/summarize.test.d.ts +1 -0
  63. package/dist/src/operations/summarize.test.js +22 -0
  64. package/dist/src/operations/summarize.test.js.map +1 -0
  65. package/dist/src/operations/text.d.ts +16 -0
  66. package/dist/src/operations/text.js +47 -0
  67. package/dist/src/operations/text.js.map +1 -0
  68. package/dist/src/operations/text.test.d.ts +1 -0
  69. package/dist/src/operations/text.test.js +51 -0
  70. package/dist/src/operations/text.test.js.map +1 -0
  71. package/dist/src/operations/zai-learn.test.d.ts +1 -0
  72. package/dist/src/operations/zai-learn.test.js +71 -0
  73. package/dist/src/operations/zai-learn.test.js.map +1 -0
  74. package/dist/src/operations/zai-retry.test.d.ts +1 -0
  75. package/dist/src/operations/zai-retry.test.js +50 -0
  76. package/dist/src/operations/zai-retry.test.js.map +1 -0
  77. package/dist/src/utils.d.ts +53 -0
  78. package/dist/src/utils.js +49 -0
  79. package/dist/src/utils.js.map +1 -0
  80. package/dist/src/zai.d.ts +97 -0
  81. package/dist/src/zai.js +137 -0
  82. package/dist/src/zai.js.map +1 -0
  83. package/dist/tsconfig.tsbuildinfo +1 -0
  84. package/dist/typings.d.ts +907 -0
  85. package/dist/typings.tsbuildinfo +1 -0
  86. package/dist/vitest.config.d.ts +2 -0
  87. package/dist/vitest.config.js +21 -0
  88. package/dist/vitest.config.js.map +1 -0
  89. package/dist/vitest.setup.d.ts +1 -0
  90. package/dist/vitest.setup.js +22 -0
  91. package/dist/vitest.setup.js.map +1 -0
  92. package/package.json +36 -0
  93. package/src/adapters/adapter.ts +35 -0
  94. package/src/adapters/botpress-table.ts +213 -0
  95. package/src/adapters/memory.ts +13 -0
  96. package/src/env.ts +54 -0
  97. package/src/index.ts +11 -0
  98. package/src/models.ts +347 -0
  99. package/src/operations/__tests/botpress_docs.txt +26040 -0
  100. package/src/operations/__tests/index.ts +30 -0
  101. package/src/operations/check.test.ts +155 -0
  102. package/src/operations/check.ts +187 -0
  103. package/src/operations/constants.ts +2 -0
  104. package/src/operations/errors.ts +9 -0
  105. package/src/operations/extract.test.ts +209 -0
  106. package/src/operations/extract.ts +291 -0
  107. package/src/operations/filter.test.ts +182 -0
  108. package/src/operations/filter.ts +231 -0
  109. package/src/operations/label.test.ts +239 -0
  110. package/src/operations/label.ts +332 -0
  111. package/src/operations/rewrite.test.ts +114 -0
  112. package/src/operations/rewrite.ts +148 -0
  113. package/src/operations/summarize.test.ts +25 -0
  114. package/src/operations/summarize.ts +193 -0
  115. package/src/operations/text.test.ts +60 -0
  116. package/src/operations/text.ts +63 -0
  117. package/src/operations/zai-learn.test.ts +85 -0
  118. package/src/operations/zai-retry.test.ts +64 -0
  119. package/src/scripts/update-models.ts +74 -0
  120. package/src/utils.ts +61 -0
  121. package/src/zai.ts +179 -0
  122. package/tsconfig.json +22 -0
  123. package/tsconfig.types.json +22 -0
  124. package/turbo.json +14 -0
  125. package/vitest.config.ts +23 -0
  126. package/vitest.setup.ts +28 -0
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Zui AI
2
+
3
+ **Zai** (stands for _Zui + AI_) is a lightweight utility library that uses AI to manipulate and generate Zui schemas and objects.
4
+
5
+ It's built on top of Zui and the Botpress client to interface with the different LLMs.
6
+
7
+ ## Usage
8
+
9
+ ```typescript
10
+ import Zai from '@botpress/zai'
11
+
12
+ const zai = new Zai({
13
+ client: new Client({}) // your botpress client here
14
+ })
15
+ ```
16
+
17
+ ## Array
18
+
19
+ ```typescript
20
+ await zai.filter(['cat', 'dog', 'carrot'], 'is an animal')
21
+
22
+ // Not implemented yet
23
+ // await zai.map(filtered, z.object({ animal: z.string(), name: z.string() }))
24
+ // await zai.sort(named, 'from most dangerous to least dangerous')
25
+ // await zai.cluster(named, 'based on color')
26
+ // await zai.append(named, 'another one')
27
+ ```
28
+
29
+ ## String
30
+
31
+ ```typescript
32
+ await zai.text('a story about ....')
33
+ await zai.summarize(book)
34
+ await zai.rewrite('Hello, I am ...', 'make it longer')
35
+
36
+ // Not implemented yet
37
+ // await zai.rate(novel, ['is the novel good?', 'how creative is it?', 'quality of writing', 'is the ending good?'])
38
+ // await zai.label(tweet, [{ label: '' }])
39
+ // await zai.classify(tweet, [])
40
+ ```
41
+
42
+ ## Boolean
43
+
44
+ ```typescript
45
+ await zai.check({ name: 'hey', bio: '...' }, 'contains insults')
46
+ ```
47
+
48
+ ## Object
49
+
50
+ ```typescript
51
+ await zai.extract('My name is Sly and I am from Canada !', z.object({ name: z.string(), country: z.string() }))
52
+
53
+ // Not implemented yet
54
+ // await zai.extend({ name: 'Sylvain' }, z.object({ country: z.string() }))
55
+ // await zai.diff(before, after)
56
+ // await zai.edit(object, '')
57
+ ```
@@ -0,0 +1,27 @@
1
+ import { GenerationMetadata } from '../utils';
2
+ export type SaveExampleProps<TInput, TOutput> = {
3
+ key: string;
4
+ taskType: string;
5
+ taskId: string;
6
+ instructions: string;
7
+ input: TInput;
8
+ output: TOutput;
9
+ explanation?: string;
10
+ metadata: GenerationMetadata;
11
+ status?: 'pending' | 'approved';
12
+ };
13
+ export type GetExamplesProps<TInput> = {
14
+ taskType: string;
15
+ taskId: string;
16
+ input: TInput;
17
+ };
18
+ export declare abstract class Adapter {
19
+ abstract getExamples<TInput, TOutput>(props: GetExamplesProps<TInput>): Promise<Array<{
20
+ key: string;
21
+ input: TInput;
22
+ output: TOutput;
23
+ explanation?: string;
24
+ similarity: number;
25
+ }>>;
26
+ abstract saveExample<TInput, TOutput>(props: SaveExampleProps<TInput, TOutput>): Promise<void>;
27
+ }
@@ -0,0 +1,3 @@
1
+ export class Adapter {
2
+ }
3
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/adapters/adapter.ts"],"names":[],"mappings":"AAoBA,MAAM,OAAgB,OAAO;CAc5B"}
@@ -0,0 +1,155 @@
1
+ import { type Client } from '@botpress/client';
2
+ import { z } from '@bpinternal/zui';
3
+ import { Adapter, GetExamplesProps, SaveExampleProps } from './adapter';
4
+ declare const Props: import("@bpinternal/zui").ZodObject<{
5
+ client: z.Schema<Client, import("@bpinternal/zui").ZodTypeDef, Client>;
6
+ tableName: import("@bpinternal/zui").ZodString;
7
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
8
+ client: Client;
9
+ tableName: string;
10
+ }, {
11
+ client: Client;
12
+ tableName: string;
13
+ }>;
14
+ export type TableSchema = z.input<typeof TableSchema>;
15
+ declare const TableSchema: import("@bpinternal/zui").ZodObject<{
16
+ taskType: import("@bpinternal/zui").ZodString;
17
+ taskId: import("@bpinternal/zui").ZodString;
18
+ key: import("@bpinternal/zui").ZodString;
19
+ instructions: import("@bpinternal/zui").ZodString;
20
+ input: import("@bpinternal/zui").ZodObject<{}, "passthrough", import("@bpinternal/zui").ZodTypeAny, import("@bpinternal/zui").objectOutputType<{}, import("@bpinternal/zui").ZodTypeAny, "passthrough">, import("@bpinternal/zui").objectInputType<{}, import("@bpinternal/zui").ZodTypeAny, "passthrough">>;
21
+ output: import("@bpinternal/zui").ZodObject<{}, "passthrough", import("@bpinternal/zui").ZodTypeAny, import("@bpinternal/zui").objectOutputType<{}, import("@bpinternal/zui").ZodTypeAny, "passthrough">, import("@bpinternal/zui").objectInputType<{}, import("@bpinternal/zui").ZodTypeAny, "passthrough">>;
22
+ explanation: import("@bpinternal/zui").ZodNullable<import("@bpinternal/zui").ZodString>;
23
+ metadata: import("@bpinternal/zui").ZodObject<{
24
+ model: import("@bpinternal/zui").ZodString;
25
+ cost: import("@bpinternal/zui").ZodObject<{
26
+ input: import("@bpinternal/zui").ZodNumber;
27
+ output: import("@bpinternal/zui").ZodNumber;
28
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
29
+ input: number;
30
+ output: number;
31
+ }, {
32
+ input: number;
33
+ output: number;
34
+ }>;
35
+ latency: import("@bpinternal/zui").ZodNumber;
36
+ tokens: import("@bpinternal/zui").ZodObject<{
37
+ input: import("@bpinternal/zui").ZodNumber;
38
+ output: import("@bpinternal/zui").ZodNumber;
39
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
40
+ input: number;
41
+ output: number;
42
+ }, {
43
+ input: number;
44
+ output: number;
45
+ }>;
46
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
47
+ model: string;
48
+ cost: {
49
+ input: number;
50
+ output: number;
51
+ };
52
+ latency: number;
53
+ tokens: {
54
+ input: number;
55
+ output: number;
56
+ };
57
+ }, {
58
+ model: string;
59
+ cost: {
60
+ input: number;
61
+ output: number;
62
+ };
63
+ latency: number;
64
+ tokens: {
65
+ input: number;
66
+ output: number;
67
+ };
68
+ }>;
69
+ status: import("@bpinternal/zui").ZodEnum<["pending", "rejected", "approved"]>;
70
+ feedback: import("@bpinternal/zui").ZodDefault<import("@bpinternal/zui").ZodNullable<import("@bpinternal/zui").ZodObject<{
71
+ rating: import("@bpinternal/zui").ZodEnum<["very-bad", "bad", "good", "very-good"]>;
72
+ comment: import("@bpinternal/zui").ZodNullable<import("@bpinternal/zui").ZodString>;
73
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
74
+ rating: "very-bad" | "bad" | "good" | "very-good";
75
+ comment: string | null;
76
+ }, {
77
+ rating: "very-bad" | "bad" | "good" | "very-good";
78
+ comment: string | null;
79
+ }>>>;
80
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
81
+ status: "pending" | "approved" | "rejected";
82
+ input: {} & {
83
+ [k: string]: unknown;
84
+ };
85
+ output: {} & {
86
+ [k: string]: unknown;
87
+ };
88
+ taskType: string;
89
+ taskId: string;
90
+ key: string;
91
+ instructions: string;
92
+ explanation: string | null;
93
+ metadata: {
94
+ model: string;
95
+ cost: {
96
+ input: number;
97
+ output: number;
98
+ };
99
+ latency: number;
100
+ tokens: {
101
+ input: number;
102
+ output: number;
103
+ };
104
+ };
105
+ feedback: {
106
+ rating: "very-bad" | "bad" | "good" | "very-good";
107
+ comment: string | null;
108
+ } | null;
109
+ }, {
110
+ status: "pending" | "approved" | "rejected";
111
+ input: {} & {
112
+ [k: string]: unknown;
113
+ };
114
+ output: {} & {
115
+ [k: string]: unknown;
116
+ };
117
+ taskType: string;
118
+ taskId: string;
119
+ key: string;
120
+ instructions: string;
121
+ explanation: string | null;
122
+ metadata: {
123
+ model: string;
124
+ cost: {
125
+ input: number;
126
+ output: number;
127
+ };
128
+ latency: number;
129
+ tokens: {
130
+ input: number;
131
+ output: number;
132
+ };
133
+ };
134
+ feedback?: {
135
+ rating: "very-bad" | "bad" | "good" | "very-good";
136
+ comment: string | null;
137
+ } | null | undefined;
138
+ }>;
139
+ export declare class TableAdapter extends Adapter {
140
+ private client;
141
+ private tableName;
142
+ private status;
143
+ private errors;
144
+ constructor(props: z.input<typeof Props>);
145
+ getExamples<TInput, TOutput>({ taskType, taskId, input }: GetExamplesProps<TInput>): Promise<{
146
+ key: any;
147
+ input: TInput;
148
+ output: TOutput;
149
+ explanation: any;
150
+ similarity: any;
151
+ }[]>;
152
+ saveExample<TInput, TOutput>({ key, taskType, taskId, instructions, input, output, explanation, metadata, status }: SaveExampleProps<TInput, TOutput>): Promise<void>;
153
+ private assertTableExists;
154
+ }
155
+ export {};
@@ -0,0 +1,170 @@
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
20
+ .string()
21
+ .regex(/^[a-zA-Z0-9_]{1,45}Table$/, 'Table name must be lowercase and contain only letters, numbers and underscores')
22
+ });
23
+ const TableSchema = z.object({
24
+ taskType: z.string().describe('The type of the task (filter, extract, etc.)'),
25
+ taskId: z.string(),
26
+ key: z.string().describe('A unique key for the task (e.g. a hash of the input, taskId, taskType and instructions)'),
27
+ instructions: z.string(),
28
+ input: z.object({}).passthrough().describe('The input to the task'),
29
+ output: z.object({}).passthrough().describe('The expected output'),
30
+ explanation: z.string().nullable(),
31
+ metadata: GenerationMetadata,
32
+ status: z.enum(['pending', 'rejected', 'approved']),
33
+ feedback: z
34
+ .object({
35
+ rating: z.enum(['very-bad', 'bad', 'good', 'very-good']),
36
+ comment: z.string().nullable()
37
+ })
38
+ .nullable()
39
+ .default(null)
40
+ });
41
+ const searchableColumns = ['input'];
42
+ const TableJsonSchema = Object.entries(TableSchema.shape).reduce((acc, [key, value]) => {
43
+ acc[key] = value.toJsonSchema();
44
+ acc[key]['x-zui'] ??= {};
45
+ acc[key]['x-zui'].searchable = searchableColumns.includes(key);
46
+ return acc;
47
+ }, {});
48
+ export class TableAdapter extends Adapter {
49
+ client;
50
+ tableName;
51
+ status;
52
+ errors = [];
53
+ constructor(props) {
54
+ super();
55
+ props = Props.parse(props);
56
+ this.client = props.client;
57
+ this.tableName = props.tableName;
58
+ this.status = 'ready';
59
+ }
60
+ async getExamples({ taskType, taskId, input }) {
61
+ await this.assertTableExists();
62
+ const { rows } = await this.client
63
+ .findTableRows({
64
+ table: this.tableName,
65
+ search: JSON.stringify({ value: input }).substring(0, 1023), // Search is limited to 1024 characters
66
+ limit: 10, // TODO
67
+ filter: {
68
+ // Proximity match of approved examples
69
+ taskType,
70
+ taskId,
71
+ status: 'approved'
72
+ }
73
+ })
74
+ .catch((err) => {
75
+ // TODO: handle error
76
+ console.error(`Error fetching examples: ${err.message}`);
77
+ return { rows: [] };
78
+ });
79
+ return rows.map((row) => ({
80
+ key: row.key,
81
+ input: row.input.value,
82
+ output: row.output.value,
83
+ explanation: row.explanation,
84
+ similarity: row.similarity ?? 0
85
+ }));
86
+ }
87
+ async saveExample({ key, taskType, taskId, instructions, input, output, explanation, metadata, status = 'pending' }) {
88
+ await this.assertTableExists();
89
+ await this.client
90
+ .upsertTableRows({
91
+ table: this.tableName,
92
+ keyColumn: 'key',
93
+ rows: [
94
+ {
95
+ key,
96
+ taskType,
97
+ taskId,
98
+ instructions,
99
+ input: { value: input },
100
+ output: { value: output },
101
+ explanation: explanation ?? null,
102
+ status,
103
+ metadata
104
+ }
105
+ ]
106
+ })
107
+ .catch(() => {
108
+ // TODO: handle error
109
+ });
110
+ }
111
+ async assertTableExists() {
112
+ if (this.status !== 'ready') {
113
+ return;
114
+ }
115
+ const { table, created } = await this.client
116
+ .getOrCreateTable({
117
+ table: this.tableName,
118
+ factor: FACTOR,
119
+ frozen: true,
120
+ isComputeEnabled: false,
121
+ tags: {
122
+ ...CRITICAL_TAGS,
123
+ ...OPTIONAL_TAGS
124
+ },
125
+ schema: TableJsonSchema
126
+ })
127
+ .catch((err) => {
128
+ this.status = 'error';
129
+ this.errors = [err.message];
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
+ this.errors = issues;
165
+ }
166
+ }
167
+ this.status = 'initialized';
168
+ }
169
+ }
170
+ //# sourceMappingURL=botpress-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"botpress-table.js","sourceRoot":"","sources":["../../../src/adapters/botpress-table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAsC,MAAM,WAAW,CAAA;AAEvE,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,MAAM;IACd,gBAAgB,EAAE,iBAAiB;IACnC,gBAAgB,EAAE,UAAU;CACpB,CAAA;AAEV,MAAM,aAAa,GAAG;IACpB,gBAAgB,EAAE,iB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,MAAM,GAAG,aAAa,CAAA;IAC7B,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import { Adapter } from './adapter';
2
+ export declare class MemoryAdapter extends Adapter {
3
+ examples: any[];
4
+ constructor(examples: any[]);
5
+ getExamples(): Promise<any[]>;
6
+ saveExample(): Promise<void>;
7
+ }
@@ -0,0 +1,13 @@
1
+ import { Adapter } from './adapter';
2
+ export class MemoryAdapter extends Adapter {
3
+ examples;
4
+ constructor(examples) {
5
+ super();
6
+ this.examples = examples;
7
+ }
8
+ async getExamples() {
9
+ return this.examples;
10
+ }
11
+ async saveExample() { }
12
+ }
13
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/adapters/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,OAAO,aAAc,SAAQ,OAAO;IACrB;IAAnB,YAAmB,QAAe;QAChC,KAAK,EAAE,CAAA;QADU,aAAQ,GAAR,QAAQ,CAAO;IAElC,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,WAAW,KAAI,CAAC;CACvB"}
@@ -0,0 +1,37 @@
1
+ import { z } from '@bpinternal/zui';
2
+ declare const envVariables: import("@bpinternal/zui").ZodObject<{
3
+ CI: import("@bpinternal/zui").ZodOptional<import("@bpinternal/zui").ZodBoolean>;
4
+ VITE_CLOUD_API_ENDPOINT: import("@bpinternal/zui").ZodString;
5
+ VITE_BOT_ID: import("@bpinternal/zui").ZodString;
6
+ VITE_CLOUD_PAT: import("@bpinternal/zui").ZodString;
7
+ VITEST_CLOUD_PAT: import("@bpinternal/zui").ZodOptional<import("@bpinternal/zui").ZodString>;
8
+ VITEST_BOT_ID: import("@bpinternal/zui").ZodOptional<import("@bpinternal/zui").ZodString>;
9
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
10
+ VITE_CLOUD_API_ENDPOINT: string;
11
+ VITE_BOT_ID: string;
12
+ VITE_CLOUD_PAT: string;
13
+ CI?: boolean | undefined;
14
+ VITEST_CLOUD_PAT?: string | undefined;
15
+ VITEST_BOT_ID?: string | undefined;
16
+ }, {
17
+ VITE_CLOUD_API_ENDPOINT: string;
18
+ VITE_BOT_ID: string;
19
+ VITE_CLOUD_PAT: string;
20
+ CI?: boolean | undefined;
21
+ VITEST_CLOUD_PAT?: string | undefined;
22
+ VITEST_BOT_ID?: string | undefined;
23
+ }>;
24
+ type Deprecated = Omit<{
25
+ [key: string]: any;
26
+ }, keyof z.infer<typeof envVariables>>;
27
+ type AllEnv = z.infer<typeof envVariables> & Deprecated;
28
+ /** @internal */
29
+ declare global {
30
+ namespace NodeJS {
31
+ interface ProcessEnv extends AllEnv {
32
+ /** @deprecated please define your ENV variable in {@link env.ts} */
33
+ [key: keyof Deprecated]: any;
34
+ }
35
+ }
36
+ }
37
+ export {};
@@ -0,0 +1,27 @@
1
+ import { z } from '@bpinternal/zui';
2
+ import dotenv from 'dotenv';
3
+ dotenv.config({ override: false });
4
+ dotenv.populate(process.env, {
5
+ VITE_CLOUD_API_ENDPOINT: 'https://api.botpress.dev'
6
+ }, { override: false });
7
+ const envVariables = z.object({
8
+ CI: z.coerce.boolean().optional().describe('Indicates whether the tests are running in a CI environment'),
9
+ VITE_CLOUD_API_ENDPOINT: z.string(),
10
+ VITE_BOT_ID: z.string(),
11
+ VITE_CLOUD_PAT: z.string(),
12
+ // for CI
13
+ VITEST_CLOUD_PAT: z.string().optional(),
14
+ VITEST_BOT_ID: z.string().optional()
15
+ });
16
+ const result = envVariables.safeParse(process.env);
17
+ if (!result.success) {
18
+ for (const error of result.error.errors) {
19
+ if (error.code === 'invalid_type') {
20
+ console.error(`Missing environment variable: ${error.path.join('.')}`);
21
+ }
22
+ else {
23
+ console.error(error);
24
+ }
25
+ }
26
+ }
27
+ //# sourceMappingURL=env.js.map
@@ -0,0 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A;QACtB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Zai } from './zai';
2
+ import './operations/text';
3
+ import './operations/rewrite';
4
+ import './operations/summarize';
5
+ import './operations/check';
6
+ import './operations/filter';
7
+ import './operations/extract';
8
+ import './operations/label';
9
+ export { Zai };
@@ -0,0 +1,10 @@
1
+ import { Zai } from './zai';
2
+ import './operations/text';
3
+ import './operations/rewrite';
4
+ import './operations/summarize';
5
+ import './operations/check';
6
+ import './operations/filter';
7
+ import './operations/extract';
8
+ import './operations/label';
9
+ export { Zai };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,OAAO,mBAAmB,CAAA;AAC1B,OAAO,sBAAsB,CAAA;AAC7B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,oBAAoB,CAAA;AAC3B,OAAO,qBAAqB,CAAA;AAC5B,OAAO,sBAAsB,CAAA;AAC7B,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,GAAG,EAAE,CAAA"}