@sqlrooms/ai 0.19.2 → 0.21.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.
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAU5D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAG5D,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAInC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAIhF,eAAO,MAAM,aAAa;;;;;;;;;;;;iBAIxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGhC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB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ant/core';
3
2
  export const QueryToolParameters = z.object({
4
3
  type: z.literal('query'),
5
4
  sqlQuery: z.string(),
6
5
  reasoning: z.string(),
7
6
  });
8
- export const AnalysisSchema = z.string();
9
- // ChartToolParameters is now in @sqlrooms/vega package
10
- // export const ChartToolParameters = z.object({
11
- // sqlQuery: z.string(),
12
- // vegaLiteSpec: z.string(),
13
- // reasoning: z.string(),
14
- // });
15
- // export type ChartToolParameters = z.infer<typeof ChartToolParameters>;
16
- export const ToolCallSchema = z.object({
17
- toolName: z.string(),
18
- toolCallId: z.string(),
19
- args: QueryToolParameters, // Simplified since we only have one default tool now
20
- });
21
- // Define specific schemas for message elements
22
- export const QueryResultElementSchema = z.object({
23
- type: z.literal('query-result'),
24
- title: z.string(),
25
- sqlQuery: z.string(),
26
- });
27
- // Define a union of all possible element types
28
- // Add more element types here as needed
29
- export const ElementSchema = z.union([
30
- QueryResultElementSchema,
31
- z.string(), // For simple string messages
32
- // Add more element types here as they are created
33
- ]);
34
- export const ToolCallMessageSchema = z.object({
35
- toolCallId: z.string(),
36
- element: ElementSchema,
37
- });
38
- export const ToolResultSchema = z.object({
39
- toolName: z.string(),
40
- toolCallId: z.string(),
41
- args: z.record(z.any()),
42
- result: z.union([
43
- z.object({
44
- success: z.literal(false),
45
- error: z.string(),
46
- }),
47
- z.object({
48
- success: z.literal(true),
49
- data: z.record(z.any()),
50
- }),
51
- ]),
52
- });
53
7
  export const ErrorMessageSchema = z.object({
54
8
  error: z.string(),
55
9
  });
10
+ // TODO: StreamMessagePart schema should be provided by @openassistant/core
11
+ export const StreamMessagePartSchema = z.union([
12
+ z.object({
13
+ type: z.literal('text'),
14
+ text: z.string(),
15
+ additionalData: z.any().optional(),
16
+ isCompleted: z.boolean().optional(),
17
+ }),
18
+ z.object({
19
+ type: z.literal('tool-invocation'),
20
+ toolInvocation: z.object({
21
+ toolCallId: z.string(),
22
+ toolName: z.string(),
23
+ args: z.any(),
24
+ state: z.string(),
25
+ result: z.any().optional(),
26
+ }),
27
+ additionalData: z.any().optional(),
28
+ isCompleted: z.boolean().optional(),
29
+ }),
30
+ // Add a catch-all for other part types that might exist
31
+ z
32
+ .object({
33
+ type: z.string(),
34
+ additionalData: z.any().optional(),
35
+ isCompleted: z.boolean().optional(),
36
+ })
37
+ .passthrough(),
38
+ ]);
39
+ // migrate from old streamMessage to new streamMessage
40
+ const migrateStreamMessage = z.preprocess((data) => {
41
+ if (data &&
42
+ typeof data === 'object' &&
43
+ 'toolCallMessages' in data &&
44
+ 'parts' in data) {
45
+ // migrate from old streamMessage to new streamMessage
46
+ const parts = data.parts;
47
+ const newParts = [];
48
+ for (const part of parts) {
49
+ if (part.type === 'text') {
50
+ const text = part.text;
51
+ newParts.push({
52
+ type: 'text',
53
+ text,
54
+ });
55
+ }
56
+ else if (part.type === 'tool') {
57
+ const toolCallMessages = part.toolCallMessages;
58
+ for (const toolCallMessage of toolCallMessages) {
59
+ const toolCallId = toolCallMessage.toolCallId;
60
+ const toolName = toolCallMessage.toolName;
61
+ const args = toolCallMessage.args;
62
+ const isCompleted = toolCallMessage.isCompleted;
63
+ const llmResult = toolCallMessage.llmResult;
64
+ const additionalData = toolCallMessage.additionalData;
65
+ const toolInvocation = {
66
+ toolCallId,
67
+ toolName,
68
+ args,
69
+ state: isCompleted ? 'result' : 'call',
70
+ result: llmResult,
71
+ };
72
+ newParts.push({
73
+ type: 'tool-invocation',
74
+ toolInvocation,
75
+ additionalData,
76
+ isCompleted,
77
+ });
78
+ }
79
+ }
80
+ }
81
+ return {
82
+ parts: newParts,
83
+ };
84
+ }
85
+ return data;
86
+ }, z.object({
87
+ parts: z.array(StreamMessagePartSchema).optional(),
88
+ }));
56
89
  export const AnalysisResultSchema = z.object({
57
90
  id: z.string().cuid2(),
58
91
  prompt: z.string(),
59
- streamMessage: StreamMessageSchema,
92
+ streamMessage: migrateStreamMessage,
60
93
  errorMessage: ErrorMessageSchema.optional(),
61
94
  isCompleted: z.boolean(),
62
95
  });
@@ -1 +1 @@
1
-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IACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAC9C,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC","sourcesContent":["import {z} from 'zod';\nimport {StreamMessageSchema} from '@openassistant/core';\n\nexport const QueryToolParameters = z.object({\n type: z.literal('query'),\n sqlQuery: z.string(),\n reasoning: z.string(),\n});\nexport type QueryToolParameters = z.infer<typeof QueryToolParameters>;\n\nexport const AnalysisSchema = z.string();\nexport type AnalysisSchema = z.infer<typeof AnalysisSchema>;\n\n// ChartToolParameters is now in @sqlrooms/vega package\n// export const ChartToolParameters = z.object({\n// sqlQuery: z.string(),\n// vegaLiteSpec: z.string(),\n// reasoning: z.string(),\n// });\n// export type ChartToolParameters = z.infer<typeof ChartToolParameters>;\n\nexport const ToolCallSchema = z.object({\n toolName: z.string(),\n toolCallId: z.string(),\n args: QueryToolParameters, // Simplified since we only have one default tool now\n});\nexport type ToolCallSchema = z.infer<typeof ToolCallSchema>;\n\n// Define specific schemas for message elements\nexport const QueryResultElementSchema = z.object({\n type: z.literal('query-result'),\n title: z.string(),\n sqlQuery: z.string(),\n});\nexport type QueryResultElementSchema = z.infer<typeof QueryResultElementSchema>;\n\n// Define a union of all possible element types\n// Add more element types here as needed\nexport const ElementSchema = z.union([\n QueryResultElementSchema,\n z.string(), // For simple string messages\n // Add more element types here as they are created\n]);\nexport type ElementSchema = z.infer<typeof ElementSchema>;\n\nexport const ToolCallMessageSchema = z.object({\n toolCallId: z.string(),\n element: ElementSchema,\n});\nexport type ToolCallMessageSchema = z.infer<typeof ToolCallMessageSchema>;\n\nexport const ToolResultSchema = z.object({\n toolName: z.string(),\n toolCallId: z.string(),\n args: z.record(z.any()),\n result: z.union([\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n z.object({\n success: z.literal(true),\n data: z.record(z.any()),\n }),\n ]),\n});\nexport type ToolResultSchema = z.infer<typeof ToolResultSchema>;\n\nexport const ErrorMessageSchema = z.object({\n error: z.string(),\n});\nexport type ErrorMessageSchema = z.infer<typeof ErrorMessageSchema>;\n\nexport const AnalysisResultSchema = z.object({\n id: z.string().cuid2(),\n prompt: z.string(),\n streamMessage: StreamMessageSchema,\n errorMessage: ErrorMessageSchema.optional(),\n isCompleted: z.boolean(),\n});\nexport type AnalysisResultSchema = z.infer<typeof AnalysisResultSchema>;\n\nexport const AnalysisSessionSchema = z.object({\n id: z.string().cuid2(),\n name: z.string(),\n modelProvider: z.string(),\n model: z.string(),\n analysisResults: z.array(AnalysisResultSchema),\n createdAt: z.coerce.date().optional(),\n});\nexport type AnalysisSessionSchema = z.infer<typeof AnalysisSessionSchema>;\n"]}
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;AAGH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC7C,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE,CAAC,CAAC,MAA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EF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;IACtB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,aAAa,EAAE,oBAAoB;IACnC,YAAY,EAAE,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE;CACzB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;IACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAC9C,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC","sourcesContent":["import {z} from 'zod';\n\nexport const QueryToolParameters = z.object({\n type: z.literal('query'),\n sqlQuery: z.string(),\n reasoning: z.string(),\n});\nexport type QueryToolParameters = z.infer<typeof QueryToolParameters>;\n\nexport const ErrorMessageSchema = z.object({\n error: z.string(),\n});\nexport type ErrorMessageSchema = z.infer<typeof ErrorMessageSchema>;\n\n// TODO: StreamMessagePart schema should be provided by @openassistant/core\nexport const StreamMessagePartSchema = z.union([\n z.object({\n type: z.literal('text'),\n text: z.string(),\n additionalData: z.any().optional(),\n isCompleted: z.boolean().optional(),\n }),\n z.object({\n type: z.literal('tool-invocation'),\n toolInvocation: z.object({\n toolCallId: z.string(),\n toolName: z.string(),\n args: z.any(),\n state: z.string(),\n result: z.any().optional(),\n }),\n additionalData: z.any().optional(),\n isCompleted: z.boolean().optional(),\n }),\n // Add a catch-all for other part types that might exist\n z\n .object({\n type: z.string(),\n additionalData: z.any().optional(),\n isCompleted: z.boolean().optional(),\n })\n .passthrough(),\n]);\n\n// migrate from old streamMessage to new streamMessage\nconst migrateStreamMessage = z.preprocess(\n (data) => {\n if (\n data &&\n typeof data === 'object' &&\n 'toolCallMessages' in data &&\n 'parts' in data\n ) {\n // migrate from old streamMessage to new streamMessage\n const parts = (data as any).parts as any[];\n\n const newParts = [];\n for (const part of parts) {\n if (part.type === 'text') {\n const text = part.text;\n newParts.push({\n type: 'text',\n text,\n });\n } else if (part.type === 'tool') {\n const toolCallMessages = part.toolCallMessages;\n for (const toolCallMessage of toolCallMessages) {\n const toolCallId = toolCallMessage.toolCallId;\n const toolName = toolCallMessage.toolName;\n const args = toolCallMessage.args;\n const isCompleted = toolCallMessage.isCompleted;\n const llmResult = toolCallMessage.llmResult;\n const additionalData = toolCallMessage.additionalData;\n\n const toolInvocation = {\n toolCallId,\n toolName,\n args,\n state: isCompleted ? 'result' : 'call',\n result: llmResult,\n };\n\n newParts.push({\n type: 'tool-invocation',\n toolInvocation,\n additionalData,\n isCompleted,\n });\n }\n }\n }\n\n return {\n parts: newParts,\n };\n }\n return data;\n },\n z.object({\n parts: z.array(StreamMessagePartSchema).optional(),\n }),\n);\n\nexport const AnalysisResultSchema = z.object({\n id: z.string().cuid2(),\n prompt: z.string(),\n streamMessage: migrateStreamMessage,\n errorMessage: ErrorMessageSchema.optional(),\n isCompleted: z.boolean(),\n});\nexport type AnalysisResultSchema = z.infer<typeof AnalysisResultSchema>;\n\nexport const AnalysisSessionSchema = z.object({\n id: z.string().cuid2(),\n name: z.string(),\n modelProvider: z.string(),\n model: z.string(),\n analysisResults: z.array(AnalysisResultSchema),\n createdAt: z.coerce.date().optional(),\n});\nexport type AnalysisSessionSchema = z.infer<typeof AnalysisSessionSchema>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqlrooms/ai",
3
- "version": "0.19.2",
3
+ "version": "0.21.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -19,15 +19,16 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@ai-sdk/provider": "^1.1.3",
22
- "@openassistant/core": "^0.2.7",
22
+ "@openassistant/core": "^0.5.13",
23
+ "@openassistant/utils": "^0.5.13",
23
24
  "@paralleldrive/cuid2": "^2.2.2",
24
- "@sqlrooms/data-table": "0.19.2",
25
- "@sqlrooms/duckdb": "0.19.2",
26
- "@sqlrooms/monaco-editor": "0.19.2",
27
- "@sqlrooms/room-config": "0.19.2",
28
- "@sqlrooms/room-shell": "0.19.2",
29
- "@sqlrooms/ui": "0.19.2",
30
- "@sqlrooms/utils": "0.19.2",
25
+ "@sqlrooms/data-table": "0.21.0",
26
+ "@sqlrooms/duckdb": "0.21.0",
27
+ "@sqlrooms/monaco-editor": "0.21.0",
28
+ "@sqlrooms/room-config": "0.21.0",
29
+ "@sqlrooms/room-shell": "0.21.0",
30
+ "@sqlrooms/ui": "0.21.0",
31
+ "@sqlrooms/utils": "0.21.0",
31
32
  "ai": "^4.3.16",
32
33
  "immer": "^10.1.1",
33
34
  "lucide-react": "^0.475.0",
@@ -45,5 +46,5 @@
45
46
  "typecheck": "tsc --noEmit",
46
47
  "typedoc": "typedoc"
47
48
  },
48
- "gitHead": "92b70398a085ebbf622c4f18e44b1ef60139096e"
49
+ "gitHead": "8411bc915049f20dbcd48a60493907ddda8b7b38"
49
50
  }