@sqlrooms/ai 0.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.
@@ -0,0 +1,354 @@
1
+ import { z } from 'zod';
2
+ export declare const QueryToolParameters: z.ZodObject<{
3
+ type: z.ZodLiteral<"query">;
4
+ sqlQuery: z.ZodString;
5
+ reasoning: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ type: "query";
8
+ sqlQuery: string;
9
+ reasoning: string;
10
+ }, {
11
+ type: "query";
12
+ sqlQuery: string;
13
+ reasoning: string;
14
+ }>;
15
+ export type QueryToolParameters = z.infer<typeof QueryToolParameters>;
16
+ export declare const AnswerToolParameters: z.ZodObject<{
17
+ type: z.ZodLiteral<"answer">;
18
+ answer: z.ZodString;
19
+ chart: z.ZodUnion<[z.ZodObject<{
20
+ sqlQuery: z.ZodString;
21
+ vegaLiteSpec: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ sqlQuery: string;
24
+ vegaLiteSpec: string;
25
+ }, {
26
+ sqlQuery: string;
27
+ vegaLiteSpec: string;
28
+ }>, z.ZodNull]>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ type: "answer";
31
+ answer: string;
32
+ chart: {
33
+ sqlQuery: string;
34
+ vegaLiteSpec: string;
35
+ } | null;
36
+ }, {
37
+ type: "answer";
38
+ answer: string;
39
+ chart: {
40
+ sqlQuery: string;
41
+ vegaLiteSpec: string;
42
+ } | null;
43
+ }>;
44
+ export type AnswerToolParameters = z.infer<typeof AnswerToolParameters>;
45
+ export declare const ToolCallSchema: z.ZodObject<{
46
+ toolName: z.ZodString;
47
+ toolCallId: z.ZodString;
48
+ args: z.ZodUnion<[z.ZodObject<{
49
+ type: z.ZodLiteral<"query">;
50
+ sqlQuery: z.ZodString;
51
+ reasoning: z.ZodString;
52
+ }, "strip", z.ZodTypeAny, {
53
+ type: "query";
54
+ sqlQuery: string;
55
+ reasoning: string;
56
+ }, {
57
+ type: "query";
58
+ sqlQuery: string;
59
+ reasoning: string;
60
+ }>, z.ZodObject<{
61
+ type: z.ZodLiteral<"answer">;
62
+ answer: z.ZodString;
63
+ chart: z.ZodUnion<[z.ZodObject<{
64
+ sqlQuery: z.ZodString;
65
+ vegaLiteSpec: z.ZodString;
66
+ }, "strip", z.ZodTypeAny, {
67
+ sqlQuery: string;
68
+ vegaLiteSpec: string;
69
+ }, {
70
+ sqlQuery: string;
71
+ vegaLiteSpec: string;
72
+ }>, z.ZodNull]>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ type: "answer";
75
+ answer: string;
76
+ chart: {
77
+ sqlQuery: string;
78
+ vegaLiteSpec: string;
79
+ } | null;
80
+ }, {
81
+ type: "answer";
82
+ answer: string;
83
+ chart: {
84
+ sqlQuery: string;
85
+ vegaLiteSpec: string;
86
+ } | null;
87
+ }>]>;
88
+ }, "strip", z.ZodTypeAny, {
89
+ toolName: string;
90
+ toolCallId: string;
91
+ args: {
92
+ type: "query";
93
+ sqlQuery: string;
94
+ reasoning: string;
95
+ } | {
96
+ type: "answer";
97
+ answer: string;
98
+ chart: {
99
+ sqlQuery: string;
100
+ vegaLiteSpec: string;
101
+ } | null;
102
+ };
103
+ }, {
104
+ toolName: string;
105
+ toolCallId: string;
106
+ args: {
107
+ type: "query";
108
+ sqlQuery: string;
109
+ reasoning: string;
110
+ } | {
111
+ type: "answer";
112
+ answer: string;
113
+ chart: {
114
+ sqlQuery: string;
115
+ vegaLiteSpec: string;
116
+ } | null;
117
+ };
118
+ }>;
119
+ export type ToolCallSchema = z.infer<typeof ToolCallSchema>;
120
+ export declare const ToolResultSchema: z.ZodObject<{
121
+ toolName: z.ZodString;
122
+ toolCallId: z.ZodString;
123
+ args: z.ZodRecord<z.ZodString, z.ZodAny>;
124
+ result: z.ZodUnion<[z.ZodObject<{
125
+ success: z.ZodLiteral<false>;
126
+ error: z.ZodString;
127
+ }, "strip", z.ZodTypeAny, {
128
+ success: false;
129
+ error: string;
130
+ }, {
131
+ success: false;
132
+ error: string;
133
+ }>, z.ZodObject<{
134
+ success: z.ZodLiteral<true>;
135
+ data: z.ZodRecord<z.ZodString, z.ZodAny>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ success: true;
138
+ data: Record<string, any>;
139
+ }, {
140
+ success: true;
141
+ data: Record<string, any>;
142
+ }>]>;
143
+ }, "strip", z.ZodTypeAny, {
144
+ toolName: string;
145
+ toolCallId: string;
146
+ args: Record<string, any>;
147
+ result: {
148
+ success: false;
149
+ error: string;
150
+ } | {
151
+ success: true;
152
+ data: Record<string, any>;
153
+ };
154
+ }, {
155
+ toolName: string;
156
+ toolCallId: string;
157
+ args: Record<string, any>;
158
+ result: {
159
+ success: false;
160
+ error: string;
161
+ } | {
162
+ success: true;
163
+ data: Record<string, any>;
164
+ };
165
+ }>;
166
+ export type ToolResultSchema = z.infer<typeof ToolResultSchema>;
167
+ export declare const AnalysisResultSchema: z.ZodObject<{
168
+ id: z.ZodString;
169
+ prompt: z.ZodString;
170
+ toolResults: z.ZodArray<z.ZodObject<{
171
+ toolName: z.ZodString;
172
+ toolCallId: z.ZodString;
173
+ args: z.ZodRecord<z.ZodString, z.ZodAny>;
174
+ result: z.ZodUnion<[z.ZodObject<{
175
+ success: z.ZodLiteral<false>;
176
+ error: z.ZodString;
177
+ }, "strip", z.ZodTypeAny, {
178
+ success: false;
179
+ error: string;
180
+ }, {
181
+ success: false;
182
+ error: string;
183
+ }>, z.ZodObject<{
184
+ success: z.ZodLiteral<true>;
185
+ data: z.ZodRecord<z.ZodString, z.ZodAny>;
186
+ }, "strip", z.ZodTypeAny, {
187
+ success: true;
188
+ data: Record<string, any>;
189
+ }, {
190
+ success: true;
191
+ data: Record<string, any>;
192
+ }>]>;
193
+ }, "strip", z.ZodTypeAny, {
194
+ toolName: string;
195
+ toolCallId: string;
196
+ args: Record<string, any>;
197
+ result: {
198
+ success: false;
199
+ error: string;
200
+ } | {
201
+ success: true;
202
+ data: Record<string, any>;
203
+ };
204
+ }, {
205
+ toolName: string;
206
+ toolCallId: string;
207
+ args: Record<string, any>;
208
+ result: {
209
+ success: false;
210
+ error: string;
211
+ } | {
212
+ success: true;
213
+ data: Record<string, any>;
214
+ };
215
+ }>, "many">;
216
+ toolCalls: z.ZodArray<z.ZodObject<{
217
+ toolName: z.ZodString;
218
+ toolCallId: z.ZodString;
219
+ args: z.ZodUnion<[z.ZodObject<{
220
+ type: z.ZodLiteral<"query">;
221
+ sqlQuery: z.ZodString;
222
+ reasoning: z.ZodString;
223
+ }, "strip", z.ZodTypeAny, {
224
+ type: "query";
225
+ sqlQuery: string;
226
+ reasoning: string;
227
+ }, {
228
+ type: "query";
229
+ sqlQuery: string;
230
+ reasoning: string;
231
+ }>, z.ZodObject<{
232
+ type: z.ZodLiteral<"answer">;
233
+ answer: z.ZodString;
234
+ chart: z.ZodUnion<[z.ZodObject<{
235
+ sqlQuery: z.ZodString;
236
+ vegaLiteSpec: z.ZodString;
237
+ }, "strip", z.ZodTypeAny, {
238
+ sqlQuery: string;
239
+ vegaLiteSpec: string;
240
+ }, {
241
+ sqlQuery: string;
242
+ vegaLiteSpec: string;
243
+ }>, z.ZodNull]>;
244
+ }, "strip", z.ZodTypeAny, {
245
+ type: "answer";
246
+ answer: string;
247
+ chart: {
248
+ sqlQuery: string;
249
+ vegaLiteSpec: string;
250
+ } | null;
251
+ }, {
252
+ type: "answer";
253
+ answer: string;
254
+ chart: {
255
+ sqlQuery: string;
256
+ vegaLiteSpec: string;
257
+ } | null;
258
+ }>]>;
259
+ }, "strip", z.ZodTypeAny, {
260
+ toolName: string;
261
+ toolCallId: string;
262
+ args: {
263
+ type: "query";
264
+ sqlQuery: string;
265
+ reasoning: string;
266
+ } | {
267
+ type: "answer";
268
+ answer: string;
269
+ chart: {
270
+ sqlQuery: string;
271
+ vegaLiteSpec: string;
272
+ } | null;
273
+ };
274
+ }, {
275
+ toolName: string;
276
+ toolCallId: string;
277
+ args: {
278
+ type: "query";
279
+ sqlQuery: string;
280
+ reasoning: string;
281
+ } | {
282
+ type: "answer";
283
+ answer: string;
284
+ chart: {
285
+ sqlQuery: string;
286
+ vegaLiteSpec: string;
287
+ } | null;
288
+ };
289
+ }>, "many">;
290
+ }, "strip", z.ZodTypeAny, {
291
+ id: string;
292
+ prompt: string;
293
+ toolResults: {
294
+ toolName: string;
295
+ toolCallId: string;
296
+ args: Record<string, any>;
297
+ result: {
298
+ success: false;
299
+ error: string;
300
+ } | {
301
+ success: true;
302
+ data: Record<string, any>;
303
+ };
304
+ }[];
305
+ toolCalls: {
306
+ toolName: string;
307
+ toolCallId: string;
308
+ args: {
309
+ type: "query";
310
+ sqlQuery: string;
311
+ reasoning: string;
312
+ } | {
313
+ type: "answer";
314
+ answer: string;
315
+ chart: {
316
+ sqlQuery: string;
317
+ vegaLiteSpec: string;
318
+ } | null;
319
+ };
320
+ }[];
321
+ }, {
322
+ id: string;
323
+ prompt: string;
324
+ toolResults: {
325
+ toolName: string;
326
+ toolCallId: string;
327
+ args: Record<string, any>;
328
+ result: {
329
+ success: false;
330
+ error: string;
331
+ } | {
332
+ success: true;
333
+ data: Record<string, any>;
334
+ };
335
+ }[];
336
+ toolCalls: {
337
+ toolName: string;
338
+ toolCallId: string;
339
+ args: {
340
+ type: "query";
341
+ sqlQuery: string;
342
+ reasoning: string;
343
+ } | {
344
+ type: "answer";
345
+ answer: string;
346
+ chart: {
347
+ sqlQuery: string;
348
+ vegaLiteSpec: string;
349
+ } | null;
350
+ };
351
+ }[];
352
+ }>;
353
+ export type AnalysisResultSchema = z.infer<typeof AnalysisResultSchema>;
354
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ export const QueryToolParameters = z.object({
3
+ type: z.literal('query'),
4
+ sqlQuery: z.string(),
5
+ reasoning: z.string(),
6
+ });
7
+ export const AnswerToolParameters = z.object({
8
+ type: z.literal('answer'),
9
+ answer: z.string(),
10
+ chart: z.union([
11
+ z.object({
12
+ sqlQuery: z.string(),
13
+ vegaLiteSpec: z.string(),
14
+ }),
15
+ z.null(),
16
+ ]),
17
+ });
18
+ export const ToolCallSchema = z.object({
19
+ toolName: z.string(),
20
+ toolCallId: z.string(),
21
+ args: z.union([QueryToolParameters, AnswerToolParameters]),
22
+ });
23
+ export const ToolResultSchema = z.object({
24
+ toolName: z.string(),
25
+ toolCallId: z.string(),
26
+ args: z.record(z.any()),
27
+ result: z.union([
28
+ z.object({
29
+ success: z.literal(false),
30
+ error: z.string(),
31
+ }),
32
+ z.object({
33
+ success: z.literal(true),
34
+ data: z.record(z.any()),
35
+ }),
36
+ ]),
37
+ });
38
+ export const AnalysisResultSchema = z.object({
39
+ id: z.string().cuid2(),
40
+ prompt: z.string(),
41
+ toolResults: z.array(ToolResultSchema),
42
+ toolCalls: z.array(ToolCallSchema),
43
+ });
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@sqlrooms/ai",
3
+ "version": "0.1.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "module": "dist/index.js",
7
+ "type": "module",
8
+ "private": false,
9
+ "author": "Ilya Boyandin <ilya@boyandin.me>",
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/sqlrooms/sqlrooms.git"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "dependencies": {
22
+ "@ai-sdk/provider": "^1.0.7",
23
+ "@paralleldrive/cuid2": "^2.2.2",
24
+ "@sqlrooms/duckdb": "0.1.0",
25
+ "@sqlrooms/project-builder": "0.1.0",
26
+ "@sqlrooms/project-config": "0.1.0",
27
+ "@sqlrooms/ui": "0.1.0",
28
+ "@sqlrooms/vega": "0.1.0",
29
+ "ai": "^4.1.28",
30
+ "immer": "^10.1.1",
31
+ "lucide-react": "^0.475.0",
32
+ "react-markdown": "^9.0.3",
33
+ "react-vega": "^7.6.0",
34
+ "zod": "^3.24.1"
35
+ },
36
+ "peerDependencies": {
37
+ "react": "*",
38
+ "react-dom": "*"
39
+ },
40
+ "scripts": {
41
+ "dev": "tsc -w",
42
+ "build": "tsc",
43
+ "lint": "eslint .",
44
+ "typedoc": "typedoc"
45
+ },
46
+ "gitHead": "2d44f6636dbd53d18c32a422351e93caa182ada6"
47
+ }