@botpress/zai 1.0.1-beta.3 → 1.0.1-beta.5

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 (66) hide show
  1. package/dist/browser/index.js +1 -4
  2. package/dist/index.d.ts +917 -0
  3. package/dist/index.js +1743 -0
  4. package/dist/node/adapters/adapter.d.js +0 -0
  5. package/dist/node/adapters/botpress-table.d.js +1 -0
  6. package/dist/node/adapters/botpress-table.js +1 -4
  7. package/dist/node/adapters/memory.d.js +0 -0
  8. package/dist/node/index.d.js +9 -0
  9. package/dist/node/models.d.js +0 -0
  10. package/dist/node/operations/check.d.js +1 -0
  11. package/dist/node/operations/check.test.d.js +1 -0
  12. package/dist/node/operations/constants.d.js +0 -0
  13. package/dist/node/operations/errors.d.js +0 -0
  14. package/dist/node/operations/extract.d.js +1 -0
  15. package/dist/node/operations/extract.test.d.js +1 -0
  16. package/dist/node/operations/filter.d.js +1 -0
  17. package/dist/node/operations/filter.test.d.js +1 -0
  18. package/dist/node/operations/label.d.js +1 -0
  19. package/dist/node/operations/label.test.d.js +1 -0
  20. package/dist/node/operations/rewrite.d.js +1 -0
  21. package/dist/node/operations/rewrite.test.d.js +1 -0
  22. package/dist/node/operations/summarize.d.js +1 -0
  23. package/dist/node/operations/summarize.test.d.js +1 -0
  24. package/dist/node/operations/text.d.js +1 -0
  25. package/dist/node/operations/text.test.d.js +1 -0
  26. package/dist/node/operations/zai-learn.test.d.js +1 -0
  27. package/dist/node/operations/zai-retry.test.d.js +1 -0
  28. package/dist/node/utils.d.js +0 -0
  29. package/dist/node/zai.d.js +1 -0
  30. package/package.json +5 -14
  31. package/src/adapters/adapter.d.ts +27 -0
  32. package/src/adapters/botpress-table.d.ts +153 -0
  33. package/src/adapters/botpress-table.ts +1 -4
  34. package/src/adapters/memory.d.ts +7 -0
  35. package/src/index.d.ts +9 -0
  36. package/src/models.d.ts +351 -0
  37. package/src/operations/__tests/index.d.ts +20 -0
  38. package/src/operations/check.d.ts +36 -0
  39. package/src/operations/check.test.d.ts +1 -0
  40. package/src/operations/constants.d.ts +2 -0
  41. package/src/operations/errors.d.ts +5 -0
  42. package/src/operations/extract.d.ts +20 -0
  43. package/src/operations/extract.test.d.ts +1 -0
  44. package/src/operations/filter.d.ts +39 -0
  45. package/src/operations/filter.test.d.ts +1 -0
  46. package/src/operations/label.d.ts +79 -0
  47. package/src/operations/label.test.d.ts +1 -0
  48. package/src/operations/rewrite.d.ts +34 -0
  49. package/src/operations/rewrite.test.d.ts +1 -0
  50. package/src/operations/summarize.d.ts +46 -0
  51. package/src/operations/summarize.test.d.ts +1 -0
  52. package/src/operations/text.d.ts +16 -0
  53. package/src/operations/text.test.d.ts +1 -0
  54. package/src/operations/zai-learn.test.d.ts +1 -0
  55. package/src/operations/zai-retry.test.d.ts +1 -0
  56. package/src/sdk-interfaces/llm/generateContent.d.ts +128 -0
  57. package/src/sdk-interfaces/llm/listLanguageModels.d.ts +25 -0
  58. package/src/utils.d.ts +52 -0
  59. package/src/utils.ts +1 -1
  60. package/src/zai.d.ts +99 -0
  61. package/tsconfig.json +2 -2
  62. package/scripts/update-models.mts +0 -76
  63. package/scripts/update-types.mts +0 -49
  64. package/tsup.config.ts +0 -16
  65. package/vitest.config.ts +0 -9
  66. package/vitest.setup.ts +0 -24
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -47,7 +47,6 @@ export class TableAdapter extends Adapter {
47
47
  client;
48
48
  tableName;
49
49
  status;
50
- errors = [];
51
50
  constructor(props) {
52
51
  super();
53
52
  props = Props.parse(props);
@@ -127,9 +126,8 @@ export class TableAdapter extends Adapter {
127
126
  ...OPTIONAL_TAGS
128
127
  },
129
128
  schema: TableJsonSchema
130
- }).catch((err) => {
129
+ }).catch(() => {
131
130
  this.status = "error";
132
- this.errors = [err.message];
133
131
  return { table: null, created: false };
134
132
  });
135
133
  if (!table) {
@@ -164,7 +162,6 @@ export class TableAdapter extends Adapter {
164
162
  }
165
163
  if (issues.length) {
166
164
  this.status = "error";
167
- this.errors = issues;
168
165
  }
169
166
  }
170
167
  this.status = "initialized";
File without changes
@@ -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 };
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,25 +1,15 @@
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": "1.0.1-beta.3",
5
- "exports": {
6
- ".": {
7
- "types": "./src/index.ts",
8
- "node": "./dist/node/index.js",
9
- "default": "./dist/node/index.js"
10
- },
11
- "./browser": {
12
- "types": "./src/index.ts",
13
- "import": "./dist/browser/index.js"
14
- }
15
- },
4
+ "version": "1.0.1-beta.5",
16
5
  "main": "./dist/node/index.js",
17
6
  "browser": "./dist/browser/index.js",
18
- "types": "./src/index.ts",
7
+ "types": "./dist/index.d.ts",
19
8
  "scripts": {
20
- "build": "npm run build:nodejs && npm run build:browser",
9
+ "build": "npm run build:types && npm run build:nodejs && npm run build:browser",
21
10
  "build:nodejs": "esbuild src/**/*.ts src/*.ts --platform=node --target=node16 --outdir=dist/node",
22
11
  "build:browser": "esbuild src/index.ts --bundle --external:@bpinternal/zui --external:@botpress/client --external:@botpress/wasm --platform=browser --target=chrome58,firefox57,safari11 --outdir=dist/browser",
12
+ "build:types": "tsup",
23
13
  "watch": "tsup --watch",
24
14
  "test": "vitest run --config vitest.config.ts",
25
15
  "test:update": "vitest -u run --config vitest.config.ts",
@@ -38,6 +28,7 @@
38
28
  },
39
29
  "devDependencies": {
40
30
  "@botpress/vai": "0.0.1-beta.7",
31
+ "@microsoft/api-extractor": "^7.48.1",
41
32
  "@types/lodash-es": "^4.17.0",
42
33
  "dotenv": "^16.3.1",
43
34
  "esbuild": "^0.24.2",
@@ -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,153 @@
1
+ import { z } from '@bpinternal/zui';
2
+ import { Adapter, GetExamplesProps, SaveExampleProps } from './adapter';
3
+ declare const Props: import("@bpinternal/zui").ZodObject<{
4
+ client: z.Schema<any, import("@bpinternal/zui").ZodTypeDef, any>;
5
+ tableName: import("@bpinternal/zui").ZodString;
6
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
7
+ client?: any;
8
+ tableName?: string;
9
+ }, {
10
+ client?: any;
11
+ tableName?: string;
12
+ }>;
13
+ export type TableSchema = z.input<typeof TableSchema>;
14
+ declare const TableSchema: import("@bpinternal/zui").ZodObject<{
15
+ taskType: import("@bpinternal/zui").ZodString;
16
+ taskId: import("@bpinternal/zui").ZodString;
17
+ key: import("@bpinternal/zui").ZodString;
18
+ instructions: import("@bpinternal/zui").ZodString;
19
+ 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">>;
20
+ 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">>;
21
+ explanation: import("@bpinternal/zui").ZodNullable<import("@bpinternal/zui").ZodString>;
22
+ metadata: import("@bpinternal/zui").ZodObject<{
23
+ model: import("@bpinternal/zui").ZodString;
24
+ cost: import("@bpinternal/zui").ZodObject<{
25
+ input: import("@bpinternal/zui").ZodNumber;
26
+ output: import("@bpinternal/zui").ZodNumber;
27
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
28
+ input?: number;
29
+ output?: number;
30
+ }, {
31
+ input?: number;
32
+ output?: number;
33
+ }>;
34
+ latency: import("@bpinternal/zui").ZodNumber;
35
+ tokens: import("@bpinternal/zui").ZodObject<{
36
+ input: import("@bpinternal/zui").ZodNumber;
37
+ output: import("@bpinternal/zui").ZodNumber;
38
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
39
+ input?: number;
40
+ output?: number;
41
+ }, {
42
+ input?: number;
43
+ output?: number;
44
+ }>;
45
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
46
+ model?: string;
47
+ cost?: {
48
+ input?: number;
49
+ output?: number;
50
+ };
51
+ latency?: number;
52
+ tokens?: {
53
+ input?: number;
54
+ output?: number;
55
+ };
56
+ }, {
57
+ model?: string;
58
+ cost?: {
59
+ input?: number;
60
+ output?: number;
61
+ };
62
+ latency?: number;
63
+ tokens?: {
64
+ input?: number;
65
+ output?: number;
66
+ };
67
+ }>;
68
+ status: import("@bpinternal/zui").ZodEnum<["pending", "rejected", "approved"]>;
69
+ feedback: import("@bpinternal/zui").ZodDefault<import("@bpinternal/zui").ZodNullable<import("@bpinternal/zui").ZodObject<{
70
+ rating: import("@bpinternal/zui").ZodEnum<["very-bad", "bad", "good", "very-good"]>;
71
+ comment: import("@bpinternal/zui").ZodNullable<import("@bpinternal/zui").ZodString>;
72
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
73
+ rating?: "very-bad" | "bad" | "good" | "very-good";
74
+ comment?: string;
75
+ }, {
76
+ rating?: "very-bad" | "bad" | "good" | "very-good";
77
+ comment?: string;
78
+ }>>>;
79
+ }, "strip", import("@bpinternal/zui").ZodTypeAny, {
80
+ input?: {} & {
81
+ [k: string]: unknown;
82
+ };
83
+ output?: {} & {
84
+ [k: string]: unknown;
85
+ };
86
+ status?: "pending" | "approved" | "rejected";
87
+ taskType?: string;
88
+ taskId?: string;
89
+ key?: string;
90
+ instructions?: string;
91
+ explanation?: string;
92
+ metadata?: {
93
+ model?: string;
94
+ cost?: {
95
+ input?: number;
96
+ output?: number;
97
+ };
98
+ latency?: number;
99
+ tokens?: {
100
+ input?: number;
101
+ output?: number;
102
+ };
103
+ };
104
+ feedback?: {
105
+ rating?: "very-bad" | "bad" | "good" | "very-good";
106
+ comment?: string;
107
+ };
108
+ }, {
109
+ input?: {} & {
110
+ [k: string]: unknown;
111
+ };
112
+ output?: {} & {
113
+ [k: string]: unknown;
114
+ };
115
+ status?: "pending" | "approved" | "rejected";
116
+ taskType?: string;
117
+ taskId?: string;
118
+ key?: string;
119
+ instructions?: string;
120
+ explanation?: string;
121
+ metadata?: {
122
+ model?: string;
123
+ cost?: {
124
+ input?: number;
125
+ output?: number;
126
+ };
127
+ latency?: number;
128
+ tokens?: {
129
+ input?: number;
130
+ output?: number;
131
+ };
132
+ };
133
+ feedback?: {
134
+ rating?: "very-bad" | "bad" | "good" | "very-good";
135
+ comment?: string;
136
+ };
137
+ }>;
138
+ export declare class TableAdapter extends Adapter {
139
+ private client;
140
+ private tableName;
141
+ private status;
142
+ constructor(props: z.input<typeof Props>);
143
+ getExamples<TInput, TOutput>({ taskType, taskId, input }: GetExamplesProps<TInput>): Promise<{
144
+ key: any;
145
+ input: TInput;
146
+ output: TOutput;
147
+ explanation: any;
148
+ similarity: any;
149
+ }[]>;
150
+ saveExample<TInput, TOutput>({ key, taskType, taskId, instructions, input, output, explanation, metadata, status }: SaveExampleProps<TInput, TOutput>): Promise<void>;
151
+ private assertTableExists;
152
+ }
153
+ export {};
@@ -64,7 +64,6 @@ export class TableAdapter extends Adapter {
64
64
  private tableName: string
65
65
 
66
66
  private status: 'initialized' | 'ready' | 'error'
67
- private errors = [] as string[]
68
67
 
69
68
  constructor(props: z.input<typeof Props>) {
70
69
  super()
@@ -157,9 +156,8 @@ export class TableAdapter extends Adapter {
157
156
  },
158
157
  schema: TableJsonSchema
159
158
  })
160
- .catch((err) => {
159
+ .catch(() => {
161
160
  this.status = 'error'
162
- this.errors = [err.message]
163
161
  return { table: null, created: false }
164
162
  })
165
163
 
@@ -204,7 +202,6 @@ export class TableAdapter extends Adapter {
204
202
 
205
203
  if (issues.length) {
206
204
  this.status = 'error'
207
- this.errors = issues
208
205
  }
209
206
  }
210
207
 
@@ -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
+ }
package/src/index.d.ts ADDED
@@ -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 };