@botpress/zai 1.0.1 → 1.2.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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/build.ts +9 -0
  3. package/dist/adapters/adapter.js +2 -0
  4. package/dist/adapters/botpress-table.js +168 -0
  5. package/dist/adapters/memory.js +12 -0
  6. package/dist/index.d.ts +111 -609
  7. package/dist/index.js +9 -1873
  8. package/dist/operations/check.js +153 -0
  9. package/dist/operations/constants.js +2 -0
  10. package/dist/operations/errors.js +15 -0
  11. package/dist/operations/extract.js +232 -0
  12. package/dist/operations/filter.js +191 -0
  13. package/dist/operations/label.js +249 -0
  14. package/dist/operations/rewrite.js +123 -0
  15. package/dist/operations/summarize.js +133 -0
  16. package/dist/operations/text.js +47 -0
  17. package/dist/utils.js +37 -0
  18. package/dist/zai.js +100 -0
  19. package/e2e/data/botpress_docs.txt +26040 -0
  20. package/e2e/data/cache.jsonl +107 -0
  21. package/e2e/utils.ts +89 -0
  22. package/package.json +33 -29
  23. package/src/adapters/adapter.ts +35 -0
  24. package/src/adapters/botpress-table.ts +210 -0
  25. package/src/adapters/memory.ts +13 -0
  26. package/src/index.ts +11 -0
  27. package/src/operations/check.ts +201 -0
  28. package/src/operations/constants.ts +2 -0
  29. package/src/operations/errors.ts +9 -0
  30. package/src/operations/extract.ts +309 -0
  31. package/src/operations/filter.ts +244 -0
  32. package/src/operations/label.ts +345 -0
  33. package/src/operations/rewrite.ts +161 -0
  34. package/src/operations/summarize.ts +195 -0
  35. package/src/operations/text.ts +65 -0
  36. package/src/utils.ts +52 -0
  37. package/src/zai.ts +147 -0
  38. package/tsconfig.json +3 -23
  39. package/dist/index.cjs +0 -1903
  40. package/dist/index.cjs.map +0 -1
  41. package/dist/index.d.cts +0 -916
  42. package/dist/index.js.map +0 -1
  43. package/tsup.config.ts +0 -16
  44. package/vitest.config.ts +0 -9
  45. package/vitest.setup.ts +0 -24
package/dist/index.d.ts CHANGED
@@ -1,53 +1,54 @@
1
- import { Client } from '@botpress/client';
2
- import sdk from '@botpress/sdk';
3
- import { TextTokenizer } from '@botpress/wasm';
1
+ import * as _bpinternal_zui from '@bpinternal/zui';
2
+ import { z, ZodObject } from '@bpinternal/zui';
3
+ import { Cognitive, Model, BotpressClientLike } from '@botpress/cognitive';
4
+ import { TextTokenizer } from '@bpinternal/thicktoken';
4
5
 
5
- type GenerationMetadata = sdk.z.input<typeof GenerationMetadata>;
6
- declare const GenerationMetadata: sdk.ZodObject<{
7
- model: sdk.ZodString;
8
- cost: sdk.ZodObject<{
9
- input: sdk.ZodNumber;
10
- output: sdk.ZodNumber;
11
- }, "strip", sdk.ZodTypeAny, {
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: sdk.ZodNumber;
19
- tokens: sdk.ZodObject<{
20
- input: sdk.ZodNumber;
21
- output: sdk.ZodNumber;
22
- }, "strip", sdk.ZodTypeAny, {
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", sdk.ZodTypeAny, {
30
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
30
31
  model?: string;
31
32
  cost?: {
32
33
  input?: number;
33
34
  output?: number;
34
35
  };
35
- latency?: number;
36
36
  tokens?: {
37
37
  input?: number;
38
38
  output?: number;
39
39
  };
40
+ latency?: number;
40
41
  }, {
41
42
  model?: string;
42
43
  cost?: {
43
44
  input?: number;
44
45
  output?: number;
45
46
  };
46
- latency?: number;
47
47
  tokens?: {
48
48
  input?: number;
49
49
  output?: number;
50
50
  };
51
+ latency?: number;
51
52
  }>;
52
53
 
53
54
  type SaveExampleProps<TInput, TOutput> = {
@@ -77,493 +78,13 @@ declare abstract class Adapter {
77
78
  abstract saveExample<TInput, TOutput>(props: SaveExampleProps<TInput, TOutput>): Promise<void>;
78
79
  }
79
80
 
80
- declare const Models: readonly [{
81
- readonly id: "anthropic__claude-3-haiku-20240307";
82
- readonly name: "Claude 3 Haiku";
83
- readonly integration: "anthropic";
84
- readonly input: {
85
- readonly maxTokens: 200000;
86
- };
87
- readonly output: {
88
- readonly maxTokens: 4096;
89
- };
90
- }, {
91
- readonly id: "anthropic__claude-3-5-sonnet-20240620";
92
- readonly name: "Claude 3.5 Sonnet";
93
- readonly integration: "anthropic";
94
- readonly input: {
95
- readonly maxTokens: 200000;
96
- };
97
- readonly output: {
98
- readonly maxTokens: 4096;
99
- };
100
- }, {
101
- readonly id: "cerebras__llama3.1-70b";
102
- readonly name: "Llama 3.1 70B";
103
- readonly integration: "cerebras";
104
- readonly input: {
105
- readonly maxTokens: 8192;
106
- };
107
- readonly output: {
108
- readonly maxTokens: 8192;
109
- };
110
- }, {
111
- readonly id: "cerebras__llama3.1-8b";
112
- readonly name: "Llama 3.1 8B";
113
- readonly integration: "cerebras";
114
- readonly input: {
115
- readonly maxTokens: 8192;
116
- };
117
- readonly output: {
118
- readonly maxTokens: 8192;
119
- };
120
- }, {
121
- readonly id: "fireworks-ai__accounts/fireworks/models/deepseek-coder-v2-instruct";
122
- readonly name: "DeepSeek Coder V2 Instruct";
123
- readonly integration: "fireworks-ai";
124
- readonly input: {
125
- readonly maxTokens: 131072;
126
- };
127
- readonly output: {
128
- readonly maxTokens: 131072;
129
- };
130
- }, {
131
- readonly id: "fireworks-ai__accounts/fireworks/models/deepseek-coder-v2-lite-instruct";
132
- readonly name: "DeepSeek Coder V2 Lite";
133
- readonly integration: "fireworks-ai";
134
- readonly input: {
135
- readonly maxTokens: 163840;
136
- };
137
- readonly output: {
138
- readonly maxTokens: 163840;
139
- };
140
- }, {
141
- readonly id: "fireworks-ai__accounts/fireworks/models/firellava-13b";
142
- readonly name: "FireLLaVA-13B";
143
- readonly integration: "fireworks-ai";
144
- readonly input: {
145
- readonly maxTokens: 4096;
146
- };
147
- readonly output: {
148
- readonly maxTokens: 4096;
149
- };
150
- }, {
151
- readonly id: "fireworks-ai__accounts/fireworks/models/firefunction-v2";
152
- readonly name: "Firefunction V2";
153
- readonly integration: "fireworks-ai";
154
- readonly input: {
155
- readonly maxTokens: 8192;
156
- };
157
- readonly output: {
158
- readonly maxTokens: 8192;
159
- };
160
- }, {
161
- readonly id: "fireworks-ai__accounts/fireworks/models/gemma2-9b-it";
162
- readonly name: "Gemma 2 9B Instruct";
163
- readonly integration: "fireworks-ai";
164
- readonly input: {
165
- readonly maxTokens: 8192;
166
- };
167
- readonly output: {
168
- readonly maxTokens: 8192;
169
- };
170
- }, {
171
- readonly id: "fireworks-ai__accounts/fireworks/models/llama-v3p1-405b-instruct";
172
- readonly name: "Llama 3.1 405B Instruct";
173
- readonly integration: "fireworks-ai";
174
- readonly input: {
175
- readonly maxTokens: 131072;
176
- };
177
- readonly output: {
178
- readonly maxTokens: 131072;
179
- };
180
- }, {
181
- readonly id: "fireworks-ai__accounts/fireworks/models/llama-v3p1-70b-instruct";
182
- readonly name: "Llama 3.1 70B Instruct";
183
- readonly integration: "fireworks-ai";
184
- readonly input: {
185
- readonly maxTokens: 131072;
186
- };
187
- readonly output: {
188
- readonly maxTokens: 131072;
189
- };
190
- }, {
191
- readonly id: "fireworks-ai__accounts/fireworks/models/llama-v3p1-8b-instruct";
192
- readonly name: "Llama 3.1 8B Instruct";
193
- readonly integration: "fireworks-ai";
194
- readonly input: {
195
- readonly maxTokens: 131072;
196
- };
197
- readonly output: {
198
- readonly maxTokens: 131072;
199
- };
200
- }, {
201
- readonly id: "fireworks-ai__accounts/fireworks/models/mixtral-8x22b-instruct";
202
- readonly name: "Mixtral MoE 8x22B Instruct";
203
- readonly integration: "fireworks-ai";
204
- readonly input: {
205
- readonly maxTokens: 65536;
206
- };
207
- readonly output: {
208
- readonly maxTokens: 65536;
209
- };
210
- }, {
211
- readonly id: "fireworks-ai__accounts/fireworks/models/mixtral-8x7b-instruct";
212
- readonly name: "Mixtral MoE 8x7B Instruct";
213
- readonly integration: "fireworks-ai";
214
- readonly input: {
215
- readonly maxTokens: 32768;
216
- };
217
- readonly output: {
218
- readonly maxTokens: 32768;
219
- };
220
- }, {
221
- readonly id: "fireworks-ai__accounts/fireworks/models/mythomax-l2-13b";
222
- readonly name: "MythoMax L2 13b";
223
- readonly integration: "fireworks-ai";
224
- readonly input: {
225
- readonly maxTokens: 4096;
226
- };
227
- readonly output: {
228
- readonly maxTokens: 4096;
229
- };
230
- }, {
231
- readonly id: "fireworks-ai__accounts/fireworks/models/qwen2-72b-instruct";
232
- readonly name: "Qwen2 72b Instruct";
233
- readonly integration: "fireworks-ai";
234
- readonly input: {
235
- readonly maxTokens: 32768;
236
- };
237
- readonly output: {
238
- readonly maxTokens: 32768;
239
- };
240
- }, {
241
- readonly id: "groq__gemma2-9b-it";
242
- readonly name: "Gemma2 9B";
243
- readonly integration: "groq";
244
- readonly input: {
245
- readonly maxTokens: 8192;
246
- };
247
- readonly output: {
248
- readonly maxTokens: 8192;
249
- };
250
- }, {
251
- readonly id: "groq__llama3-70b-8192";
252
- readonly name: "LLaMA 3 70B";
253
- readonly integration: "groq";
254
- readonly input: {
255
- readonly maxTokens: 8192;
256
- };
257
- readonly output: {
258
- readonly maxTokens: 8192;
259
- };
260
- }, {
261
- readonly id: "groq__llama3-8b-8192";
262
- readonly name: "LLaMA 3 8B";
263
- readonly integration: "groq";
264
- readonly input: {
265
- readonly maxTokens: 8192;
266
- };
267
- readonly output: {
268
- readonly maxTokens: 8192;
269
- };
270
- }, {
271
- readonly id: "groq__llama-3.1-70b-versatile";
272
- readonly name: "LLaMA 3.1 70B";
273
- readonly integration: "groq";
274
- readonly input: {
275
- readonly maxTokens: 128000;
276
- };
277
- readonly output: {
278
- readonly maxTokens: 8192;
279
- };
280
- }, {
281
- readonly id: "groq__llama-3.1-8b-instant";
282
- readonly name: "LLaMA 3.1 8B";
283
- readonly integration: "groq";
284
- readonly input: {
285
- readonly maxTokens: 128000;
286
- };
287
- readonly output: {
288
- readonly maxTokens: 8192;
289
- };
290
- }, {
291
- readonly id: "groq__llama-3.2-11b-vision-preview";
292
- readonly name: "LLaMA 3.2 11B Vision";
293
- readonly integration: "groq";
294
- readonly input: {
295
- readonly maxTokens: 128000;
296
- };
297
- readonly output: {
298
- readonly maxTokens: 8192;
299
- };
300
- }, {
301
- readonly id: "groq__llama-3.2-1b-preview";
302
- readonly name: "LLaMA 3.2 1B";
303
- readonly integration: "groq";
304
- readonly input: {
305
- readonly maxTokens: 128000;
306
- };
307
- readonly output: {
308
- readonly maxTokens: 8192;
309
- };
310
- }, {
311
- readonly id: "groq__llama-3.2-3b-preview";
312
- readonly name: "LLaMA 3.2 3B";
313
- readonly integration: "groq";
314
- readonly input: {
315
- readonly maxTokens: 128000;
316
- };
317
- readonly output: {
318
- readonly maxTokens: 8192;
319
- };
320
- }, {
321
- readonly id: "groq__llama-3.2-90b-vision-preview";
322
- readonly name: "LLaMA 3.2 90B Vision";
323
- readonly integration: "groq";
324
- readonly input: {
325
- readonly maxTokens: 128000;
326
- };
327
- readonly output: {
328
- readonly maxTokens: 8192;
329
- };
330
- }, {
331
- readonly id: "groq__llama-3.3-70b-versatile";
332
- readonly name: "LLaMA 3.3 70B";
333
- readonly integration: "groq";
334
- readonly input: {
335
- readonly maxTokens: 128000;
336
- };
337
- readonly output: {
338
- readonly maxTokens: 32768;
339
- };
340
- }, {
341
- readonly id: "groq__mixtral-8x7b-32768";
342
- readonly name: "Mixtral 8x7B";
343
- readonly integration: "groq";
344
- readonly input: {
345
- readonly maxTokens: 32768;
346
- };
347
- readonly output: {
348
- readonly maxTokens: 32768;
349
- };
350
- }, {
351
- readonly id: "openai__o1-2024-12-17";
352
- readonly name: "GPT o1";
353
- readonly integration: "openai";
354
- readonly input: {
355
- readonly maxTokens: 200000;
356
- };
357
- readonly output: {
358
- readonly maxTokens: 100000;
359
- };
360
- }, {
361
- readonly id: "openai__o1-mini-2024-09-12";
362
- readonly name: "GPT o1-mini";
363
- readonly integration: "openai";
364
- readonly input: {
365
- readonly maxTokens: 128000;
366
- };
367
- readonly output: {
368
- readonly maxTokens: 65536;
369
- };
370
- }, {
371
- readonly id: "openai__gpt-3.5-turbo-0125";
372
- readonly name: "GPT-3.5 Turbo";
373
- readonly integration: "openai";
374
- readonly input: {
375
- readonly maxTokens: 128000;
376
- };
377
- readonly output: {
378
- readonly maxTokens: 4096;
379
- };
380
- }, {
381
- readonly id: "openai__gpt-4-turbo-2024-04-09";
382
- readonly name: "GPT-4 Turbo";
383
- readonly integration: "openai";
384
- readonly input: {
385
- readonly maxTokens: 128000;
386
- };
387
- readonly output: {
388
- readonly maxTokens: 4096;
389
- };
390
- }, {
391
- readonly id: "openai__gpt-4o-2024-08-06";
392
- readonly name: "GPT-4o (August 2024)";
393
- readonly integration: "openai";
394
- readonly input: {
395
- readonly maxTokens: 128000;
396
- };
397
- readonly output: {
398
- readonly maxTokens: 16384;
399
- };
400
- }, {
401
- readonly id: "openai__gpt-4o-2024-05-13";
402
- readonly name: "GPT-4o (May 2024)";
403
- readonly integration: "openai";
404
- readonly input: {
405
- readonly maxTokens: 128000;
406
- };
407
- readonly output: {
408
- readonly maxTokens: 4096;
409
- };
410
- }, {
411
- readonly id: "openai__gpt-4o-2024-11-20";
412
- readonly name: "GPT-4o (November 2024)";
413
- readonly integration: "openai";
414
- readonly input: {
415
- readonly maxTokens: 128000;
416
- };
417
- readonly output: {
418
- readonly maxTokens: 16384;
419
- };
420
- }, {
421
- readonly id: "openai__gpt-4o-mini-2024-07-18";
422
- readonly name: "GPT-4o Mini";
423
- readonly integration: "openai";
424
- readonly input: {
425
- readonly maxTokens: 128000;
426
- };
427
- readonly output: {
428
- readonly maxTokens: 16384;
429
- };
430
- }];
431
-
432
- declare namespace llm {
433
- namespace generateContent {
434
- type Input = {
435
- /** Model to use for content generation */
436
- model?: {
437
- id: string;
438
- };
439
- /** Optional system prompt to guide the model */
440
- systemPrompt?: string;
441
- /** Array of messages for the model to process */
442
- messages: Array<{
443
- role: 'user' | 'assistant';
444
- type?: 'text' | 'tool_calls' | 'tool_result' | 'multipart';
445
- /** Required if `type` is "tool_calls" */
446
- toolCalls?: Array<{
447
- id: string;
448
- type: 'function';
449
- function: {
450
- name: string;
451
- /** Some LLMs may generate invalid JSON for a tool call, so this will be `null` when it happens. */
452
- arguments: {
453
- [key: string]: any;
454
- } | null;
455
- };
456
- }>;
457
- /** Required if `type` is "tool_result" */
458
- toolResultCallId?: string;
459
- /** Required unless `type` is "tool_call". If `type` is "multipart", this field must be an array of content objects. If `type` is "tool_result" then this field should be the result of the tool call (a plain string or a JSON-encoded array or object). If `type` is "tool_call" then the `toolCalls` field should be used instead. */
460
- content: string | Array<{
461
- type: 'text' | 'image';
462
- /** Indicates the MIME type of the content. If not provided it will be detected from the content-type header of the provided URL. */
463
- mimeType?: string;
464
- /** Required if part type is "text" */
465
- text?: string;
466
- /** Required if part type is "image" */
467
- url?: string;
468
- }> | null;
469
- }>;
470
- /** Response format expected from the model. If "json_object" is chosen, you must instruct the model to generate JSON either via the system prompt or a user message. */
471
- responseFormat?: 'text' | 'json_object';
472
- /** Maximum number of tokens allowed in the generated response */
473
- maxTokens?: number;
474
- /** Sampling temperature for the model. Higher values result in more random outputs. */
475
- temperature?: number;
476
- /** Top-p sampling parameter. Limits sampling to the smallest set of tokens with a cumulative probability above the threshold. */
477
- topP?: number;
478
- /** Sequences where the model should stop generating further tokens. */
479
- stopSequences?: string[];
480
- tools?: Array<{
481
- type: 'function';
482
- function: {
483
- /** Function name */
484
- name: string;
485
- description?: string;
486
- /** JSON schema of the function arguments */
487
- argumentsSchema?: {};
488
- };
489
- }>;
490
- toolChoice?: {
491
- type?: 'auto' | 'specific' | 'any' | 'none' | '';
492
- /** Required if `type` is "specific" */
493
- functionName?: string;
494
- };
495
- userId?: string;
496
- /** Set to `true` to output debug information to the bot logs */
497
- debug?: boolean;
498
- meta?: {
499
- /** Source of the prompt, e.g. agent/:id/:version cards/ai-generate, cards/ai-task, nodes/autonomous, etc. */
500
- promptSource?: string;
501
- promptCategory?: string;
502
- /** Name of the integration that originally received the message that initiated this action */
503
- integrationName?: string;
504
- };
505
- };
506
- type Output = {
507
- /** Response ID from LLM provider */
508
- id: string;
509
- /** LLM provider name */
510
- provider: string;
511
- /** Model name */
512
- model: string;
513
- choices: Array<{
514
- type?: 'text' | 'tool_calls' | 'tool_result' | 'multipart';
515
- /** Required if `type` is "tool_calls" */
516
- toolCalls?: Array<{
517
- id: string;
518
- type: 'function';
519
- function: {
520
- name: string;
521
- /** Some LLMs may generate invalid JSON for a tool call, so this will be `null` when it happens. */
522
- arguments: {
523
- [key: string]: any;
524
- } | null;
525
- };
526
- }>;
527
- /** Required if `type` is "tool_result" */
528
- toolResultCallId?: string;
529
- /** Required unless `type` is "tool_call". If `type` is "multipart", this field must be an array of content objects. If `type` is "tool_result" then this field should be the result of the tool call (a plain string or a JSON-encoded array or object). If `type` is "tool_call" then the `toolCalls` field should be used instead. */
530
- content: string | Array<{
531
- type: 'text' | 'image';
532
- /** Indicates the MIME type of the content. If not provided it will be detected from the content-type header of the provided URL. */
533
- mimeType?: string;
534
- /** Required if part type is "text" */
535
- text?: string;
536
- /** Required if part type is "image" */
537
- url?: string;
538
- }> | null;
539
- role: 'assistant';
540
- index: number;
541
- stopReason: 'stop' | 'max_tokens' | 'tool_calls' | 'content_filter' | 'other';
542
- }>;
543
- usage: {
544
- /** Number of input tokens used by the model */
545
- inputTokens: number;
546
- /** Cost of the input tokens received by the model, in U.S. dollars */
547
- inputCost: number;
548
- /** Number of output tokens used by the model */
549
- outputTokens: number;
550
- /** Cost of the output tokens generated by the model, in U.S. dollars */
551
- outputCost: number;
552
- };
553
- botpress: {
554
- /** Total cost of the content generation, in U.S. dollars */
555
- cost: number;
556
- };
557
- };
558
- }
559
- }
560
-
561
- type ActiveLearning = sdk.z.input<typeof ActiveLearning>;
562
- declare const ActiveLearning: sdk.ZodObject<{
563
- enable: sdk.ZodDefault<sdk.ZodBoolean>;
564
- tableName: sdk.ZodDefault<sdk.ZodString>;
565
- taskId: sdk.ZodDefault<sdk.ZodString>;
566
- }, "strip", sdk.ZodTypeAny, {
81
+ type ModelId = Required<Parameters<Cognitive['generateContent']>[0]['model']>;
82
+ type ActiveLearning = z.input<typeof ActiveLearning>;
83
+ declare const ActiveLearning: _bpinternal_zui.ZodObject<{
84
+ enable: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodBoolean>;
85
+ tableName: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
86
+ taskId: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
87
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
567
88
  tableName?: string;
568
89
  taskId?: string;
569
90
  enable?: boolean;
@@ -572,23 +93,16 @@ declare const ActiveLearning: sdk.ZodObject<{
572
93
  taskId?: string;
573
94
  enable?: boolean;
574
95
  }>;
575
- type ZaiConfig = sdk.z.input<typeof ZaiConfig>;
576
- declare const ZaiConfig: sdk.ZodObject<{
577
- client: sdk.Schema<Client, sdk.ZodTypeDef, Client>;
578
- userId: sdk.ZodOptional<sdk.ZodString>;
579
- retry: sdk.ZodDefault<sdk.ZodObject<{
580
- maxRetries: sdk.ZodNumber;
581
- }, "strip", sdk.ZodTypeAny, {
582
- maxRetries?: number;
583
- }, {
584
- maxRetries?: number;
585
- }>>;
586
- modelId: sdk.ZodDefault<sdk.Schema<string, sdk.ZodTypeDef, string>>;
587
- activeLearning: sdk.ZodDefault<sdk.ZodObject<{
588
- enable: sdk.ZodDefault<sdk.ZodBoolean>;
589
- tableName: sdk.ZodDefault<sdk.ZodString>;
590
- taskId: sdk.ZodDefault<sdk.ZodString>;
591
- }, "strip", sdk.ZodTypeAny, {
96
+ type ZaiConfig = z.input<typeof ZaiConfig>;
97
+ declare const ZaiConfig: _bpinternal_zui.ZodObject<{
98
+ client: z.Schema<Cognitive | BotpressClientLike, _bpinternal_zui.ZodTypeDef, Cognitive | BotpressClientLike>;
99
+ userId: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
100
+ modelId: _bpinternal_zui.ZodDefault<z.Schema<string, _bpinternal_zui.ZodTypeDef, string>>;
101
+ activeLearning: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodObject<{
102
+ enable: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodBoolean>;
103
+ tableName: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
104
+ taskId: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
105
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
592
106
  tableName?: string;
593
107
  taskId?: string;
594
108
  enable?: boolean;
@@ -597,13 +111,10 @@ declare const ZaiConfig: sdk.ZodObject<{
597
111
  taskId?: string;
598
112
  enable?: boolean;
599
113
  }>>;
600
- namespace: sdk.ZodDefault<sdk.ZodString>;
601
- }, "strip", sdk.ZodTypeAny, {
602
- client?: Client;
114
+ namespace: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
115
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
603
116
  userId?: string;
604
- retry?: {
605
- maxRetries?: number;
606
- };
117
+ client?: Cognitive | BotpressClientLike;
607
118
  modelId?: string;
608
119
  activeLearning?: {
609
120
  tableName?: string;
@@ -612,11 +123,8 @@ declare const ZaiConfig: sdk.ZodObject<{
612
123
  };
613
124
  namespace?: string;
614
125
  }, {
615
- client?: Client;
616
126
  userId?: string;
617
- retry?: {
618
- maxRetries?: number;
619
- };
127
+ client?: Cognitive | BotpressClientLike;
620
128
  modelId?: string;
621
129
  activeLearning?: {
622
130
  tableName?: string;
@@ -627,33 +135,28 @@ declare const ZaiConfig: sdk.ZodObject<{
627
135
  }>;
628
136
  declare class Zai {
629
137
  protected static tokenizer: TextTokenizer;
630
- protected client: Client;
631
- private originalConfig;
632
- private userId;
633
- private integration;
634
- private model;
635
- private retry;
636
- protected Model: (typeof Models)[number];
138
+ protected client: Cognitive;
139
+ private _originalConfig;
140
+ private _userId;
141
+ protected Model: ModelId;
142
+ protected ModelDetails: Model;
637
143
  protected namespace: string;
638
144
  protected adapter: Adapter;
639
145
  protected activeLearning: ActiveLearning;
640
146
  constructor(config: ZaiConfig);
641
147
  /** @internal */
642
- protected callModel(props: Partial<llm.generateContent.Input>): Promise<llm.generateContent.Output & {
643
- metadata: GenerationMetadata;
644
- }>;
645
- /** @internal */
646
- private _callModel;
148
+ protected callModel(props: Parameters<Cognitive['generateContent']>[0]): ReturnType<Cognitive['generateContent']>;
647
149
  protected getTokenizer(): Promise<TextTokenizer>;
150
+ protected fetchModelDetails(): Promise<void>;
648
151
  protected get taskId(): string;
649
152
  with(options: Partial<ZaiConfig>): Zai;
650
153
  learn(taskId: string): Zai;
651
154
  }
652
155
 
653
- type Options$6 = sdk.z.input<typeof Options$6>;
654
- declare const Options$6: sdk.ZodObject<{
655
- length: sdk.ZodOptional<sdk.ZodNumber>;
656
- }, "strip", sdk.ZodTypeAny, {
156
+ type Options$6 = z.input<typeof Options$6>;
157
+ declare const Options$6: _bpinternal_zui.ZodObject<{
158
+ length: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>;
159
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
657
160
  length?: number;
658
161
  }, {
659
162
  length?: number;
@@ -665,20 +168,20 @@ declare module '@botpress/zai' {
665
168
  }
666
169
  }
667
170
 
668
- type Options$5 = sdk.z.input<typeof Options$5>;
669
- declare const Options$5: sdk.ZodObject<{
670
- examples: sdk.ZodDefault<sdk.ZodArray<sdk.ZodObject<{
671
- input: sdk.ZodString;
672
- output: sdk.ZodString;
673
- }, "strip", sdk.ZodTypeAny, {
171
+ type Options$5 = z.input<typeof Options$5>;
172
+ declare const Options$5: _bpinternal_zui.ZodObject<{
173
+ examples: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodArray<_bpinternal_zui.ZodObject<{
174
+ input: _bpinternal_zui.ZodString;
175
+ output: _bpinternal_zui.ZodString;
176
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
674
177
  input?: string;
675
178
  output?: string;
676
179
  }, {
677
180
  input?: string;
678
181
  output?: string;
679
182
  }>, "many">>;
680
- length: sdk.ZodOptional<sdk.ZodNumber>;
681
- }, "strip", sdk.ZodTypeAny, {
183
+ length: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>;
184
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
682
185
  length?: number;
683
186
  examples?: {
684
187
  input?: string;
@@ -698,24 +201,24 @@ declare module '@botpress/zai' {
698
201
  }
699
202
  }
700
203
 
701
- type Options$4 = sdk.z.input<typeof Options$4>;
702
- declare const Options$4: sdk.ZodObject<{
703
- prompt: sdk.ZodDefault<sdk.ZodString>;
704
- format: sdk.ZodDefault<sdk.ZodString>;
705
- length: sdk.ZodDefault<sdk.ZodNumber>;
706
- intermediateFactor: sdk.ZodDefault<sdk.ZodNumber>;
707
- maxIterations: sdk.ZodDefault<sdk.ZodNumber>;
708
- sliding: sdk.ZodDefault<sdk.ZodObject<{
709
- window: sdk.ZodNumber;
710
- overlap: sdk.ZodNumber;
711
- }, "strip", sdk.ZodTypeAny, {
204
+ type Options$4 = z.input<typeof Options$4>;
205
+ declare const Options$4: _bpinternal_zui.ZodObject<{
206
+ prompt: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
207
+ format: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodString>;
208
+ length: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodNumber>;
209
+ intermediateFactor: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodNumber>;
210
+ maxIterations: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodNumber>;
211
+ sliding: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodObject<{
212
+ window: _bpinternal_zui.ZodNumber;
213
+ overlap: _bpinternal_zui.ZodNumber;
214
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
712
215
  window?: number;
713
216
  overlap?: number;
714
217
  }, {
715
218
  window?: number;
716
219
  overlap?: number;
717
220
  }>>;
718
- }, "strip", sdk.ZodTypeAny, {
221
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
719
222
  length?: number;
720
223
  prompt?: string;
721
224
  format?: string;
@@ -743,13 +246,13 @@ declare module '@botpress/zai' {
743
246
  }
744
247
  }
745
248
 
746
- type Options$3 = sdk.z.input<typeof Options$3>;
747
- declare const Options$3: sdk.ZodObject<{
748
- examples: sdk.ZodDefault<sdk.ZodArray<sdk.ZodObject<{
749
- input: sdk.ZodAny;
750
- check: sdk.ZodBoolean;
751
- reason: sdk.ZodOptional<sdk.ZodString>;
752
- }, "strip", sdk.ZodTypeAny, {
249
+ type Options$3 = z.input<typeof Options$3>;
250
+ declare const Options$3: _bpinternal_zui.ZodObject<{
251
+ examples: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodArray<_bpinternal_zui.ZodObject<{
252
+ input: _bpinternal_zui.ZodAny;
253
+ check: _bpinternal_zui.ZodBoolean;
254
+ reason: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
255
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
753
256
  input?: any;
754
257
  check?: boolean;
755
258
  reason?: string;
@@ -758,7 +261,7 @@ declare const Options$3: sdk.ZodObject<{
758
261
  check?: boolean;
759
262
  reason?: string;
760
263
  }>, "many">>;
761
- }, "strip", sdk.ZodTypeAny, {
264
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
762
265
  examples?: {
763
266
  input?: any;
764
267
  check?: boolean;
@@ -778,33 +281,33 @@ declare module '@botpress/zai' {
778
281
  }
779
282
  }
780
283
 
781
- type Options$2 = sdk.z.input<typeof Options$2>;
782
- declare const Options$2: sdk.ZodObject<{
783
- tokensPerItem: sdk.ZodDefault<sdk.ZodOptional<sdk.ZodNumber>>;
784
- examples: sdk.ZodDefault<sdk.ZodArray<sdk.ZodObject<{
785
- input: sdk.ZodAny;
786
- filter: sdk.ZodBoolean;
787
- reason: sdk.ZodOptional<sdk.ZodString>;
788
- }, "strip", sdk.ZodTypeAny, {
789
- input?: any;
284
+ type Options$2 = z.input<typeof Options$2>;
285
+ declare const Options$2: _bpinternal_zui.ZodObject<{
286
+ tokensPerItem: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>>;
287
+ examples: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodArray<_bpinternal_zui.ZodObject<{
288
+ input: _bpinternal_zui.ZodAny;
289
+ filter: _bpinternal_zui.ZodBoolean;
290
+ reason: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
291
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
790
292
  filter?: boolean;
293
+ input?: any;
791
294
  reason?: string;
792
295
  }, {
793
- input?: any;
794
296
  filter?: boolean;
297
+ input?: any;
795
298
  reason?: string;
796
299
  }>, "many">>;
797
- }, "strip", sdk.ZodTypeAny, {
300
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
798
301
  examples?: {
799
- input?: any;
800
302
  filter?: boolean;
303
+ input?: any;
801
304
  reason?: string;
802
305
  }[];
803
306
  tokensPerItem?: number;
804
307
  }, {
805
308
  examples?: {
806
- input?: any;
807
309
  filter?: boolean;
310
+ input?: any;
808
311
  reason?: string;
809
312
  }[];
810
313
  tokensPerItem?: number;
@@ -816,11 +319,11 @@ declare module '@botpress/zai' {
816
319
  }
817
320
  }
818
321
 
819
- type Options$1 = sdk.z.input<typeof Options$1>;
820
- declare const Options$1: sdk.ZodObject<{
821
- instructions: sdk.ZodOptional<sdk.ZodString>;
822
- chunkLength: sdk.ZodDefault<sdk.ZodOptional<sdk.ZodNumber>>;
823
- }, "strip", sdk.ZodTypeAny, {
322
+ type Options$1 = z.input<typeof Options$1>;
323
+ declare const Options$1: ZodObject<{
324
+ instructions: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
325
+ chunkLength: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>>;
326
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
824
327
  instructions?: string;
825
328
  chunkLength?: number;
826
329
  }, {
@@ -830,8 +333,7 @@ declare const Options$1: sdk.ZodObject<{
830
333
  declare module '@botpress/zai' {
831
334
  interface Zai {
832
335
  /** Extracts one or many elements from an arbitrary input */
833
- extract<S extends sdk.z.AnyZodObject>(input: unknown, schema: S, options?: Options$1): Promise<sdk.z.infer<S>>;
834
- extract<S extends sdk.z.AnyZodObject>(input: unknown, schema: sdk.z.ZodArray<S>, options?: Options$1): Promise<Array<sdk.z.infer<S>>>;
336
+ extract<S extends z.AnyZodObject | z.ZodArray>(input: unknown, schema: S, options?: Options$1): Promise<z.TypeOf<S>>;
835
337
  }
836
338
  }
837
339
 
@@ -850,23 +352,23 @@ type Example<T extends string> = {
850
352
  explanation?: string;
851
353
  }>>;
852
354
  };
853
- type Options<T extends string> = Omit<sdk.z.input<typeof Options>, 'examples'> & {
355
+ type Options<T extends string> = Omit<z.input<typeof Options>, 'examples'> & {
854
356
  examples?: Array<Partial<Example<T>>>;
855
357
  };
856
- declare const Options: sdk.ZodObject<{
857
- examples: sdk.ZodDefault<sdk.ZodArray<sdk.ZodObject<{
858
- input: sdk.ZodAny;
859
- labels: sdk.ZodRecord<sdk.ZodString, sdk.ZodObject<{
860
- label: sdk.ZodEnum<never>;
861
- explanation: sdk.ZodOptional<sdk.ZodString>;
862
- }, "strip", sdk.ZodTypeAny, {
358
+ declare const Options: _bpinternal_zui.ZodObject<{
359
+ examples: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodArray<_bpinternal_zui.ZodObject<{
360
+ input: _bpinternal_zui.ZodAny;
361
+ labels: _bpinternal_zui.ZodRecord<_bpinternal_zui.ZodString, _bpinternal_zui.ZodObject<{
362
+ label: _bpinternal_zui.ZodEnum<never>;
363
+ explanation: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
364
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
863
365
  label: never;
864
366
  explanation?: string;
865
367
  }, {
866
368
  label: never;
867
369
  explanation?: string;
868
370
  }>>;
869
- }, "strip", sdk.ZodTypeAny, {
371
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
870
372
  input?: any;
871
373
  labels?: Record<string, {
872
374
  label: never;
@@ -879,9 +381,9 @@ declare const Options: sdk.ZodObject<{
879
381
  explanation?: string;
880
382
  }>;
881
383
  }>, "many">>;
882
- instructions: sdk.ZodOptional<sdk.ZodString>;
883
- chunkLength: sdk.ZodDefault<sdk.ZodOptional<sdk.ZodNumber>>;
884
- }, "strip", sdk.ZodTypeAny, {
384
+ instructions: _bpinternal_zui.ZodOptional<_bpinternal_zui.ZodString>;
385
+ chunkLength: _bpinternal_zui.ZodDefault<_bpinternal_zui.ZodOptional<_bpinternal_zui.ZodNumber>>;
386
+ }, "strip", _bpinternal_zui.ZodTypeAny, {
885
387
  instructions?: string;
886
388
  examples?: {
887
389
  input?: any;
@@ -903,7 +405,7 @@ declare const Options: sdk.ZodObject<{
903
405
  chunkLength?: number;
904
406
  }>;
905
407
  type Labels<T extends string> = Record<T, string>;
906
- declare const Labels: sdk.ZodEffects<sdk.ZodRecord<sdk.ZodString, sdk.ZodString>, Record<string, string>, Record<string, string>>;
408
+ declare const Labels: z.ZodTransformer<_bpinternal_zui.ZodRecord<_bpinternal_zui.ZodString, _bpinternal_zui.ZodString>, Record<string, string>, Record<string, string>>;
907
409
  declare module '@botpress/zai' {
908
410
  interface Zai {
909
411
  /** Tags the provided input with a list of predefined labels */