@sqlrooms/ai 0.6.0 → 0.8.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.
- package/README.md +466 -0
- package/dist/AiSlice.d.ts +489 -307
- package/dist/AiSlice.d.ts.map +1 -1
- package/dist/AiSlice.js +267 -177
- package/dist/AiSlice.js.map +1 -1
- package/dist/analysis.d.ts +25 -19
- package/dist/analysis.d.ts.map +1 -1
- package/dist/analysis.js +86 -145
- package/dist/analysis.js.map +1 -1
- package/dist/components/AnalysisAnswer.d.ts +14 -0
- package/dist/components/AnalysisAnswer.d.ts.map +1 -0
- package/dist/components/AnalysisAnswer.js +14 -0
- package/dist/components/AnalysisAnswer.js.map +1 -0
- package/dist/{AnalysisResult.d.ts → components/AnalysisResult.d.ts} +2 -1
- package/dist/components/AnalysisResult.d.ts.map +1 -0
- package/dist/components/AnalysisResult.js +46 -0
- package/dist/components/AnalysisResult.js.map +1 -0
- package/dist/components/AnalysisResultsContainer.d.ts +5 -0
- package/dist/components/AnalysisResultsContainer.d.ts.map +1 -0
- package/dist/components/AnalysisResultsContainer.js +27 -0
- package/dist/components/AnalysisResultsContainer.js.map +1 -0
- package/dist/components/ErrorMessage.d.ts +4 -0
- package/dist/components/ErrorMessage.d.ts.map +1 -0
- package/dist/components/ErrorMessage.js +7 -0
- package/dist/components/ErrorMessage.js.map +1 -0
- package/dist/components/MessageContainer.d.ts +10 -0
- package/dist/components/MessageContainer.d.ts.map +1 -0
- package/dist/components/MessageContainer.js +17 -0
- package/dist/components/MessageContainer.js.map +1 -0
- package/dist/components/ModelSelector.d.ts +13 -0
- package/dist/components/ModelSelector.d.ts.map +1 -0
- package/dist/components/ModelSelector.js +29 -0
- package/dist/components/ModelSelector.js.map +1 -0
- package/dist/components/QueryControls.d.ts +8 -0
- package/dist/components/QueryControls.d.ts.map +1 -0
- package/dist/components/QueryControls.js +45 -0
- package/dist/components/QueryControls.js.map +1 -0
- package/dist/components/SessionControls.d.ts +17 -0
- package/dist/components/SessionControls.d.ts.map +1 -0
- package/dist/components/SessionControls.js +20 -0
- package/dist/components/SessionControls.js.map +1 -0
- package/dist/components/session/DeleteSessionButton.d.ts +19 -0
- package/dist/components/session/DeleteSessionButton.d.ts.map +1 -0
- package/dist/components/session/DeleteSessionButton.js +54 -0
- package/dist/components/session/DeleteSessionButton.js.map +1 -0
- package/dist/components/session/DeleteSessionDialog.d.ts +27 -0
- package/dist/components/session/DeleteSessionDialog.d.ts.map +1 -0
- package/dist/components/session/DeleteSessionDialog.js +19 -0
- package/dist/components/session/DeleteSessionDialog.js.map +1 -0
- package/dist/components/session/SessionActions.d.ts +18 -0
- package/dist/components/session/SessionActions.d.ts.map +1 -0
- package/dist/components/session/SessionActions.js +19 -0
- package/dist/components/session/SessionActions.js.map +1 -0
- package/dist/components/session/SessionDropdown.d.ts +18 -0
- package/dist/components/session/SessionDropdown.d.ts.map +1 -0
- package/dist/components/session/SessionDropdown.js +21 -0
- package/dist/components/session/SessionDropdown.js.map +1 -0
- package/dist/components/session/SessionTitle.d.ts +18 -0
- package/dist/components/session/SessionTitle.d.ts.map +1 -0
- package/dist/components/session/SessionTitle.js +22 -0
- package/dist/components/session/SessionTitle.js.map +1 -0
- package/dist/components/session/SessionType.d.ts +24 -0
- package/dist/components/session/SessionType.d.ts.map +1 -0
- package/dist/components/session/SessionType.js +2 -0
- package/dist/components/session/SessionType.js.map +1 -0
- package/dist/components/session/index.d.ts +7 -0
- package/dist/components/session/index.d.ts.map +1 -0
- package/dist/components/session/index.js +7 -0
- package/dist/components/session/index.js.map +1 -0
- package/dist/components/tools/QueryToolResult.d.ts +7 -0
- package/dist/components/tools/QueryToolResult.d.ts.map +1 -0
- package/dist/components/tools/QueryToolResult.js +9 -0
- package/dist/components/tools/QueryToolResult.js.map +1 -0
- package/dist/components/tools/ToolChart.d.ts +13 -0
- package/dist/components/tools/ToolChart.d.ts.map +1 -0
- package/dist/components/tools/ToolChart.js +14 -0
- package/dist/components/tools/ToolChart.js.map +1 -0
- package/dist/components/tools/ToolQuery.d.ts +7 -0
- package/dist/components/tools/ToolQuery.d.ts.map +1 -0
- package/dist/components/tools/ToolQuery.js +9 -0
- package/dist/components/tools/ToolQuery.js.map +1 -0
- package/dist/components/tools/ToolResult.d.ts +9 -0
- package/dist/components/tools/ToolResult.d.ts.map +1 -0
- package/dist/components/tools/ToolResult.js +32 -0
- package/dist/components/tools/ToolResult.js.map +1 -0
- package/dist/components/tools/ToolResultErrorBoundary.d.ts +19 -0
- package/dist/components/tools/ToolResultErrorBoundary.d.ts.map +1 -0
- package/dist/components/tools/ToolResultErrorBoundary.js +23 -0
- package/dist/components/tools/ToolResultErrorBoundary.js.map +1 -0
- package/dist/hooks/useScrollToBottom.d.ts +82 -0
- package/dist/hooks/useScrollToBottom.d.ts.map +1 -0
- package/dist/hooks/useScrollToBottom.js +140 -0
- package/dist/hooks/useScrollToBottom.js.map +1 -0
- package/dist/index.d.ts +20 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +592 -201
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +36 -11
- package/dist/schemas.js.map +1 -1
- package/package.json +11 -9
- package/dist/AnalysisResult.d.ts.map +0 -1
- package/dist/AnalysisResult.js +0 -49
- package/dist/AnalysisResult.js.map +0 -1
- package/dist/AnalysisResultsContainer.d.ts +0 -2
- package/dist/AnalysisResultsContainer.d.ts.map +0 -1
- package/dist/AnalysisResultsContainer.js +0 -15
- package/dist/AnalysisResultsContainer.js.map +0 -1
- package/dist/QueryControls.d.ts +0 -6
- package/dist/QueryControls.d.ts.map +0 -1
- package/dist/QueryControls.js +0 -28
- package/dist/QueryControls.js.map +0 -1
- package/dist/QueryResult.d.ts +0 -9
- package/dist/QueryResult.d.ts.map +0 -1
- package/dist/QueryResult.js +0 -46
- package/dist/QueryResult.js.map +0 -1
- package/dist/ToolCall.d.ts +0 -66
- package/dist/ToolCall.d.ts.map +0 -1
- package/dist/ToolCall.js +0 -59
- package/dist/ToolCall.js.map +0 -1
- package/dist/ToolResult.d.ts +0 -10
- package/dist/ToolResult.d.ts.map +0 -1
- package/dist/ToolResult.js +0 -26
- package/dist/ToolResult.js.map +0 -1
- package/dist/hooks/use-scroll-to-bottom.d.ts +0 -7
- package/dist/hooks/use-scroll-to-bottom.d.ts.map +0 -1
- package/dist/hooks/use-scroll-to-bottom.js +0 -51
- package/dist/hooks/use-scroll-to-bottom.js.map +0 -1
package/dist/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;
|
|
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,G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6BAA2C,CAAC;kCAAqC,CAAC;;;;;;;;;;oBAAkP,CAAC;yBAAuC,CAAC;8BAAiC,CAAC;;;;;;;;;;;;;;wBAAyX,CAAC;6BAA2C,CAAC;kCAAqC,CAAC;;;;;;;;;;;;;;;;;;;;;;oBAAhyC,CAAC;yBAAuC,CAAC;8BAAiC,CAAC;;;;;;;;;;;;;;wBAAyX,CAAC;6BAA2C,CAAC;kCAAqC,CAAC;;;;;;;;;;;;;;;;;;oBAAkP,CAAC;yBAAuC,CAAC;8BAAiC,CAAC;;;;;;;;;;;;;;wBAAyX,CAAC;6BAA2C,CAAC;kCAAqC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;oBAAhyC,CAAC;yBAAuC,CAAC;8BAAiC,CAAC;;;;;;;;;;;;;;wBAAyX,CAAC;6BAA2C,CAAC;kCAAqC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;oBAAkP,CAAC;yBAAuC,CAAC;8BAAiC,CAAC;;;;;;;;;;;;;;wBAAyX,CAAC;6BAA2C,CAAC;kCAAqC,CAAC;;;;;;;;;;EAFxsb,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/dist/schemas.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { StreamMessageSchema } from '@openassistant/core';
|
|
2
3
|
export const QueryToolParameters = z.object({
|
|
3
4
|
type: z.literal('query'),
|
|
4
5
|
sqlQuery: z.string(),
|
|
5
6
|
reasoning: z.string(),
|
|
6
7
|
});
|
|
7
8
|
export const AnalysisSchema = z.string();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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>;
|
|
13
16
|
export const ToolCallSchema = z.object({
|
|
14
17
|
toolName: z.string(),
|
|
15
18
|
toolCallId: z.string(),
|
|
16
|
-
args:
|
|
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(),
|
|
17
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
|
+
]);
|
|
18
34
|
export const ToolCallMessageSchema = z.object({
|
|
19
35
|
toolCallId: z.string(),
|
|
20
|
-
element:
|
|
36
|
+
element: ElementSchema,
|
|
21
37
|
});
|
|
22
38
|
export const ToolResultSchema = z.object({
|
|
23
39
|
toolName: z.string(),
|
|
@@ -34,13 +50,22 @@ export const ToolResultSchema = z.object({
|
|
|
34
50
|
}),
|
|
35
51
|
]),
|
|
36
52
|
});
|
|
53
|
+
export const ErrorMessageSchema = z.object({
|
|
54
|
+
error: z.string(),
|
|
55
|
+
});
|
|
37
56
|
export const AnalysisResultSchema = z.object({
|
|
38
57
|
id: z.string().cuid2(),
|
|
39
58
|
prompt: z.string(),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
toolCallMessages: z.array(ToolCallMessageSchema),
|
|
43
|
-
analysis: z.string(),
|
|
59
|
+
streamMessage: StreamMessageSchema,
|
|
60
|
+
errorMessage: ErrorMessageSchema.optional(),
|
|
44
61
|
isCompleted: z.boolean(),
|
|
45
62
|
});
|
|
63
|
+
export const AnalysisSessionSchema = z.object({
|
|
64
|
+
id: z.string().cuid2(),
|
|
65
|
+
name: z.string(),
|
|
66
|
+
modelProvider: z.string(),
|
|
67
|
+
model: z.string(),
|
|
68
|
+
analysisResults: z.array(AnalysisResultSchema),
|
|
69
|
+
createdAt: z.coerce.date().optional(),
|
|
70
|
+
});
|
|
46
71
|
//# sourceMappingURL=schemas.js.map
|
package/dist/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAExD,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,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AAGzC,uDAAuD;AACvD,gDAAgD;AAChD,0BAA0B;AAC1B,8BAA8B;AAC9B,2BAA2B;AAC3B,MAAM;AACN,yEAAyE;AAEzE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,IAAI,EAAE,mBAAmB,EAAE,qDAAqD;CACjF,CAAC,CAAC;AAGH,+CAA+C;AAC/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;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AoB,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,mBAAmB;IAClC,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';\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -20,14 +20,16 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@ai-sdk/provider": "^1.0.7",
|
|
23
|
-
"@
|
|
23
|
+
"@duckdb/duckdb-wasm": "1.29.0",
|
|
24
|
+
"@openassistant/core": "0.2.6",
|
|
24
25
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
25
|
-
"@sqlrooms/data-table": "0.
|
|
26
|
-
"@sqlrooms/duckdb": "0.
|
|
27
|
-
"@sqlrooms/
|
|
28
|
-
"@sqlrooms/project-
|
|
29
|
-
"@sqlrooms/
|
|
30
|
-
"@sqlrooms/
|
|
26
|
+
"@sqlrooms/data-table": "0.8.0",
|
|
27
|
+
"@sqlrooms/duckdb": "0.8.0",
|
|
28
|
+
"@sqlrooms/monaco-editor": "0.8.0",
|
|
29
|
+
"@sqlrooms/project-builder": "0.8.0",
|
|
30
|
+
"@sqlrooms/project-config": "0.8.0",
|
|
31
|
+
"@sqlrooms/ui": "0.8.0",
|
|
32
|
+
"@sqlrooms/utils": "0.8.0",
|
|
31
33
|
"ai": "^4.1.28",
|
|
32
34
|
"immer": "^10.1.1",
|
|
33
35
|
"lucide-react": "^0.475.0",
|
|
@@ -45,5 +47,5 @@
|
|
|
45
47
|
"lint": "eslint .",
|
|
46
48
|
"typedoc": "typedoc"
|
|
47
49
|
},
|
|
48
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "99b46a96ab900e6b005bcd30cfbfe7b3c9d51f8d"
|
|
49
51
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalysisResult.d.ts","sourceRoot":"","sources":["../src/AnalysisResult.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,WAAW,CAAC;AAK/C;;;GAGG;AACH,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,oBAAoB,CAAC;CAC9B,CAAC;AA8BF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAsDxD,CAAC"}
|
package/dist/AnalysisResult.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { SquareTerminalIcon, CodeIcon } from 'lucide-react';
|
|
3
|
-
import { Button, Popover, PopoverContent, PopoverTrigger } from '@sqlrooms/ui';
|
|
4
|
-
import { ToolResult } from './ToolResult';
|
|
5
|
-
/**
|
|
6
|
-
* Stringify the result of the analysis, excluding toolCallMessages.
|
|
7
|
-
* Used to display raw result data in a code view.
|
|
8
|
-
*
|
|
9
|
-
* @param result - The complete analysis result
|
|
10
|
-
* @returns A JSON string representation of the result without toolCallMessages
|
|
11
|
-
*/
|
|
12
|
-
const stringifyResult = (result) => {
|
|
13
|
-
// remove toolCallMessages from the result
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
|
-
const { toolCallMessages, ...rest } = result;
|
|
16
|
-
return JSON.stringify(rest);
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Find a custom message element for a given tool call ID
|
|
20
|
-
* @param toolCallMessages - Array of tool call messages
|
|
21
|
-
* @param toolCallId - The ID of the tool call to find a message for
|
|
22
|
-
* @returns The custom message element if found, undefined otherwise
|
|
23
|
-
*/
|
|
24
|
-
const findCustomMessage = (toolCallMessages, toolCallId) => {
|
|
25
|
-
return toolCallMessages.find((message) => message.toolCallId === toolCallId)
|
|
26
|
-
?.element;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Component that displays the results of an AI analysis.
|
|
30
|
-
* Shows the original prompt, intermediate tool calls, final analysis text,
|
|
31
|
-
* and any tool results.
|
|
32
|
-
*
|
|
33
|
-
* @component
|
|
34
|
-
* @param props - Component props
|
|
35
|
-
* @param props.result - The analysis result data to display
|
|
36
|
-
* @returns A React component displaying the analysis results
|
|
37
|
-
*/
|
|
38
|
-
export const AnalysisResult = ({ result }) => {
|
|
39
|
-
// the toolResults are reasoning steps that the LLM took to achieve the final result
|
|
40
|
-
// by calling function tools to answer the prompt
|
|
41
|
-
const analysisToolResults = result.toolResults;
|
|
42
|
-
return (_jsxs("div", { className: "flex flex-col w-full text-sm gap-5 border py-6 px-4 rounded-md", children: [_jsxs("div", { className: "p-2 mb-2 rounded-md text-gray-700 dark:text-gray-100 flex items-center gap-2", children: [_jsx(SquareTerminalIcon, { className: "w-4 h-4" }), _jsx("div", { className: "text-sm flex-1", children: result.prompt }), _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "w-6 h-6", children: _jsx(CodeIcon, { className: "w-4 h-4" }) }) }), _jsx(PopoverContent, { className: "w-[400px] max-h-[400px] overflow-auto", align: "end", side: "right", children: _jsx("pre", { className: "text-xs", children: stringifyResult(result) }) })] })] }), analysisToolResults.length > 0 && (_jsx("div", { className: "flex flex-col gap-5 px-4", children: analysisToolResults.map((toolResult) => (_jsx(ToolResult, { toolResult: toolResult, customMessage: findCustomMessage(result.toolCallMessages, toolResult.toolCallId) }, toolResult.toolCallId))) })), result.analysis.length > 0 && (_jsx("div", { className: "flex flex-col gap-5 px-4", children: _jsx(ToolResult, { toolResult: {
|
|
43
|
-
toolName: 'answer',
|
|
44
|
-
toolCallId: result.id,
|
|
45
|
-
args: {},
|
|
46
|
-
result: { success: true, data: { analysis: result.analysis } },
|
|
47
|
-
} }, result.id + '-streaming-result') }))] }));
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=AnalysisResult.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalysisResult.js","sourceRoot":"","sources":["../src/AnalysisResult.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAC,UAAU,EAAC,MAAM,c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CAAC,MAAM,GAAG,CAAC,IAAI,CACjC,cAAK,SAAS,EAAC,0BAA0B,YACtC,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CACvC,KAAC,UAAU,IAET,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,iBAAiB,CAC9B,MAAM,CAAC,gBAAgB,EACvB,UAAU,CAAC,UAAU,CACtB,IALI,UAAU,CAAC,UAAU,CAM1B,CACH,CAAC,GACE,CACP,EACA,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAC7B,cAAK,SAAS,EAAC,0BAA0B,YACvC,KAAC,UAAU,IAET,UAAU,EAAE;wBACV,QAAQ,EAAE,QAAQ;wBAClB,UAAU,EAAE,MAAM,CAAC,EAAE;wBACrB,IAAI,EAAE,EAAE;wBACR,MAAM,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAC,EAAC;qBAC3D,IANI,MAAM,CAAC,EAAE,GAAG,mBAAmB,CAOpC,GACE,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {AnalysisResultSchema} from './schemas';\nimport {SquareTerminalIcon, CodeIcon} from 'lucide-react';\nimport {Button, Popover, PopoverContent, PopoverTrigger} from '@sqlrooms/ui';\nimport {ToolResult} from './ToolResult';\n\n/**\n * Props for the AnalysisResult component\n * @property {AnalysisResultSchema} result - The result of the analysis containing prompt, tool calls, and analysis data\n */\ntype AnalysisResultProps = {\n result: AnalysisResultSchema;\n};\n\n/**\n * Stringify the result of the analysis, excluding toolCallMessages.\n * Used to display raw result data in a code view.\n *\n * @param result - The complete analysis result\n * @returns A JSON string representation of the result without toolCallMessages\n */\nconst stringifyResult = (result: AnalysisResultSchema) => {\n // remove toolCallMessages from the result\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {toolCallMessages, ...rest} = result;\n return JSON.stringify(rest);\n};\n\n/**\n * Find a custom message element for a given tool call ID\n * @param toolCallMessages - Array of tool call messages\n * @param toolCallId - The ID of the tool call to find a message for\n * @returns The custom message element if found, undefined otherwise\n */\nconst findCustomMessage = (\n toolCallMessages: AnalysisResultSchema['toolCallMessages'],\n toolCallId: string,\n) => {\n return toolCallMessages.find((message) => message.toolCallId === toolCallId)\n ?.element;\n};\n\n/**\n * Component that displays the results of an AI analysis.\n * Shows the original prompt, intermediate tool calls, final analysis text,\n * and any tool results.\n *\n * @component\n * @param props - Component props\n * @param props.result - The analysis result data to display\n * @returns A React component displaying the analysis results\n */\nexport const AnalysisResult: React.FC<AnalysisResultProps> = ({result}) => {\n // the toolResults are reasoning steps that the LLM took to achieve the final result\n // by calling function tools to answer the prompt\n const analysisToolResults = result.toolResults;\n\n return (\n <div className=\"flex flex-col w-full text-sm gap-5 border py-6 px-4 rounded-md\">\n <div className=\"p-2 mb-2 rounded-md text-gray-700 dark:text-gray-100 flex items-center gap-2\">\n <SquareTerminalIcon className=\"w-4 h-4\" />\n <div className=\"text-sm flex-1\">{result.prompt}</div>\n <Popover>\n <PopoverTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\" className=\"w-6 h-6\">\n <CodeIcon className=\"w-4 h-4\" />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className=\"w-[400px] max-h-[400px] overflow-auto\"\n align=\"end\"\n side=\"right\"\n >\n <pre className=\"text-xs\">{stringifyResult(result)}</pre>\n </PopoverContent>\n </Popover>\n </div>\n {analysisToolResults.length > 0 && (\n <div className=\"flex flex-col gap-5 px-4\">\n {analysisToolResults.map((toolResult) => (\n <ToolResult\n key={toolResult.toolCallId}\n toolResult={toolResult}\n customMessage={findCustomMessage(\n result.toolCallMessages,\n toolResult.toolCallId,\n )}\n />\n ))}\n </div>\n )}\n {result.analysis.length > 0 && (\n <div className=\"flex flex-col gap-5 px-4\">\n <ToolResult\n key={result.id + '-streaming-result'}\n toolResult={{\n toolName: 'answer',\n toolCallId: result.id,\n args: {},\n result: {success: true, data: {analysis: result.analysis}},\n }}\n />\n </div>\n )}\n </div>\n );\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalysisResultsContainer.d.ts","sourceRoot":"","sources":["../src/AnalysisResultsContainer.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EA2C5C,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { cn, SkeletonPane } from '@sqlrooms/ui';
|
|
4
|
-
import { ChevronDown } from 'lucide-react';
|
|
5
|
-
import { useStoreWithAi } from './AiSlice';
|
|
6
|
-
import { AnalysisResult } from './AnalysisResult';
|
|
7
|
-
import { useScrollToBottom, useScrollToBottomButton, } from './hooks/use-scroll-to-bottom';
|
|
8
|
-
export const AnalysisResultsContainer = () => {
|
|
9
|
-
const isRunningAnalysis = useStoreWithAi((s) => s.ai.isRunningAnalysis);
|
|
10
|
-
const analysisResults = useStoreWithAi((s) => s.project.config.ai.analysisResults);
|
|
11
|
-
const [messagesContainerRef, messagesEndRef] = useScrollToBottom();
|
|
12
|
-
const { showButton, scrollToBottom } = useScrollToBottomButton(messagesContainerRef);
|
|
13
|
-
return (_jsxs("div", { className: "flex relative h-full w-full overflow-hidden", children: [_jsxs("div", { className: "flex flex-grow flex-col w-full gap-10 p-4 overflow-auto", ref: messagesContainerRef, children: [analysisResults.map((result) => (_jsx(AnalysisResult, { result: result }, result.id))), isRunningAnalysis && _jsx(SkeletonPane, { className: "p-4" }), _jsx("div", { className: "h-20" }), messagesEndRef && (_jsx("div", { ref: messagesEndRef, className: "shrink-0 min-w-[24px] min-h-[24px]" }))] }), _jsx("div", { className: "absolute inset-x-0 bottom-0 pointer-events-none flex justify-center", children: _jsx("button", { onClick: scrollToBottom, className: cn('pointer-events-auto bg-primary hover:bg-primary/90 text-primary-foreground z-50', 'rounded-full p-2 shadow-md transition-all duration-200 opacity-0 translate-y-4 mb-6', showButton && 'opacity-100 translate-y-0'), "aria-label": "Scroll to bottom", children: _jsx(ChevronDown, { className: "w-5 h-5" }) }) })] }));
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=AnalysisResultsContainer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalysisResultsContainer.js","sourceRoot":"","sources":["../src/AnalysisResultsContainer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAC,EAAE,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAC;AACzC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,CAAC,MAAM,wBAAwB,GAAa,GAAG,EAAE;IACrD,MAAM,iBAAiB,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,cAAc,CACpC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,eAAe,CAC3C,CAAC;IACF,MAAM,CAAC,oBAAoB,EAAE,cAAc,CAAC,GAC1C,iBAAiB,EAAkB,CAAC;IACtC,MAAM,EAAC,UAAU,EAAE,cAAc,EAAC,GAChC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;IAEhD,OAAO,CACL,eAAK,SAAS,EAAC,6CAA6C,aAC1D,eACE,SAAS,EAAC,yDAAyD,EACnE,GAAG,EAAE,oBAAoB,aAExB,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC/B,KAAC,cAAc,IAAiB,MAAM,EAAE,MAAM,IAAzB,MAAM,CAAC,EAAE,CAAoB,CACnD,CAAC,EACD,iBAAiB,IAAI,KAAC,YAAY,IAAC,SAAS,EAAC,KAAK,GAAG,EACtD,cAAK,SAAS,EAAC,MAAM,GAAG,EACvB,cAAc,IAAI,CACjB,cACE,GAAG,EAAE,cAAc,EACnB,SAAS,EAAC,oCAAoC,GAC9C,CACH,IACG,EACN,cAAK,SAAS,EAAC,qEAAqE,YAClF,iBACE,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,EAAE,CACX,iFAAiF,EACjF,qFAAqF,EACrF,UAAU,IAAI,2BAA2B,CAC1C,gBACU,kBAAkB,YAE7B,KAAC,WAAW,IAAC,SAAS,EAAC,SAAS,GAAG,GAC5B,GACL,IACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["'use client';\nimport {cn, SkeletonPane} from '@sqlrooms/ui';\nimport {ChevronDown} from 'lucide-react';\nimport {useStoreWithAi} from './AiSlice';\nimport {AnalysisResult} from './AnalysisResult';\nimport {\n useScrollToBottom,\n useScrollToBottomButton,\n} from './hooks/use-scroll-to-bottom';\n\nexport const AnalysisResultsContainer: React.FC = () => {\n const isRunningAnalysis = useStoreWithAi((s) => s.ai.isRunningAnalysis);\n const analysisResults = useStoreWithAi(\n (s) => s.project.config.ai.analysisResults,\n );\n const [messagesContainerRef, messagesEndRef] =\n useScrollToBottom<HTMLDivElement>();\n const {showButton, scrollToBottom} =\n useScrollToBottomButton(messagesContainerRef);\n\n return (\n <div className=\"flex relative h-full w-full overflow-hidden\">\n <div\n className=\"flex flex-grow flex-col w-full gap-10 p-4 overflow-auto\"\n ref={messagesContainerRef}\n >\n {analysisResults.map((result) => (\n <AnalysisResult key={result.id} result={result} />\n ))}\n {isRunningAnalysis && <SkeletonPane className=\"p-4\" />}\n <div className=\"h-20\" />\n {messagesEndRef && (\n <div\n ref={messagesEndRef}\n className=\"shrink-0 min-w-[24px] min-h-[24px]\"\n />\n )}\n </div>\n <div className=\"absolute inset-x-0 bottom-0 pointer-events-none flex justify-center\">\n <button\n onClick={scrollToBottom}\n className={cn(\n 'pointer-events-auto bg-primary hover:bg-primary/90 text-primary-foreground z-50',\n 'rounded-full p-2 shadow-md transition-all duration-200 opacity-0 translate-y-4 mb-6',\n showButton && 'opacity-100 translate-y-0',\n )}\n aria-label=\"Scroll to bottom\"\n >\n <ChevronDown className=\"w-5 h-5\" />\n </button>\n </div>\n </div>\n );\n};\n"]}
|
package/dist/QueryControls.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryControls.d.ts","sourceRoot":"","sources":["../src/QueryControls.tsx"],"names":[],"mappings":"AAKA,UAAU,kBAAkB;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsEtD,CAAC"}
|
package/dist/QueryControls.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, cn, Spinner, Textarea } from '@sqlrooms/ui';
|
|
3
|
-
import { OctagonXIcon } from 'lucide-react';
|
|
4
|
-
import { useCallback } from 'react';
|
|
5
|
-
import { useStoreWithAi } from './AiSlice';
|
|
6
|
-
export const QueryControls = ({ className }) => {
|
|
7
|
-
const isRunningAnalysis = useStoreWithAi((s) => s.ai.isRunningAnalysis);
|
|
8
|
-
const runAnalysis = useStoreWithAi((s) => s.ai.startAnalysis);
|
|
9
|
-
const cancelAnalysis = useStoreWithAi((s) => s.ai.cancelAnalysis);
|
|
10
|
-
const analysisPrompt = useStoreWithAi((s) => s.ai.analysisPrompt);
|
|
11
|
-
const setAnalysisPrompt = useStoreWithAi((s) => s.ai.setAnalysisPrompt);
|
|
12
|
-
const model = useStoreWithAi((s) => s.project.config.ai.model);
|
|
13
|
-
const handleKeyDown = useCallback((e) => {
|
|
14
|
-
if (e.key === 'Enter' &&
|
|
15
|
-
!e.shiftKey &&
|
|
16
|
-
!e.ctrlKey &&
|
|
17
|
-
!e.altKey &&
|
|
18
|
-
!e.metaKey) {
|
|
19
|
-
e.preventDefault();
|
|
20
|
-
if (!isRunningAnalysis && model && analysisPrompt.trim().length) {
|
|
21
|
-
runAnalysis();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}, [isRunningAnalysis, model, analysisPrompt, runAnalysis]);
|
|
25
|
-
const canStart = Boolean(!isRunningAnalysis && model && analysisPrompt.trim().length);
|
|
26
|
-
return (_jsxs("div", { className: cn('flex flex-col items-center justify-center gap-4 w-full p-4', className), children: [_jsx("div", { className: "flex items-center justify-between gap-4 w-full", children: _jsx("div", { className: "font-semibold text-lg pl-1", children: "What would you like to learn about the data?" }) }), _jsxs("div", { className: "relative w-full", children: [_jsx(Textarea, { disabled: isRunningAnalysis, className: "h-[100px]", value: analysisPrompt, onChange: (e) => setAnalysisPrompt(e.target.value), onKeyDown: handleKeyDown }), _jsxs("div", { className: "absolute top-1 right-1 flex items-center gap-2", children: [isRunningAnalysis && (_jsxs(Button, { variant: "outline", onClick: cancelAnalysis, children: [_jsx(OctagonXIcon, { className: "w-4 h-4" }), "Stop"] })), _jsx(Button, { variant: "outline", onClick: runAnalysis, disabled: !canStart, children: isRunningAnalysis ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Spinner, { className: "w-4 h-4" }), " Running\u2026"] })) : ('Start Analysis') })] })] })] }));
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=QueryControls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryControls.js","sourceRoot":"","sources":["../src/QueryControls.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1C,O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AC;YAChB,CAAC;QACH,CAAC;IACH,CAAC,EACD,CAAC,iBAAiB,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,CAAC,CACxD,CAAC;IAEF,MAAM,QAAQ,GAAG,OAAO,CACtB,CAAC,iBAAiB,IAAI,KAAK,IAAI,cAAc,CAAC,IAAI,EAAE,CAAC,MAAM,CAC5D,CAAC;IACF,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,4DAA4D,EAC5D,SAAS,CACV,aAED,cAAK,SAAS,EAAC,gDAAgD,YAC7D,cAAK,SAAS,EAAC,4BAA4B,6DAErC,GACF,EAEN,eAAK,SAAS,EAAC,iBAAiB,aAC9B,KAAC,QAAQ,IACP,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EAAC,WAAW,EACrB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAClD,SAAS,EAAE,aAAa,GACxB,EACF,eAAK,SAAS,EAAC,gDAAgD,aAC5D,iBAAiB,IAAI,CACpB,MAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,cAAc,aAC/C,KAAC,YAAY,IAAC,SAAS,EAAC,SAAS,GAAG,YAE7B,CACV,EACD,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,QAAQ,YAChE,iBAAiB,CAAC,CAAC,CAAC,CACnB,eAAK,SAAS,EAAC,yBAAyB,aACtC,KAAC,OAAO,IAAC,SAAS,EAAC,SAAS,GAAG,sBAC3B,CACP,CAAC,CAAC,CAAC,CACF,gBAAgB,CACjB,GACM,IACL,IACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Button, cn, Spinner, Textarea} from '@sqlrooms/ui';\nimport {OctagonXIcon} from 'lucide-react';\nimport {useCallback} from 'react';\nimport {useStoreWithAi} from './AiSlice';\n\ninterface QueryControlsProps {\n className?: string;\n}\n\nexport const QueryControls: React.FC<QueryControlsProps> = ({className}) => {\n const isRunningAnalysis = useStoreWithAi((s) => s.ai.isRunningAnalysis);\n const runAnalysis = useStoreWithAi((s) => s.ai.startAnalysis);\n const cancelAnalysis = useStoreWithAi((s) => s.ai.cancelAnalysis);\n const analysisPrompt = useStoreWithAi((s) => s.ai.analysisPrompt);\n const setAnalysisPrompt = useStoreWithAi((s) => s.ai.setAnalysisPrompt);\n const model = useStoreWithAi((s) => s.project.config.ai.model);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (\n e.key === 'Enter' &&\n !e.shiftKey &&\n !e.ctrlKey &&\n !e.altKey &&\n !e.metaKey\n ) {\n e.preventDefault();\n if (!isRunningAnalysis && model && analysisPrompt.trim().length) {\n runAnalysis();\n }\n }\n },\n [isRunningAnalysis, model, analysisPrompt, runAnalysis],\n );\n\n const canStart = Boolean(\n !isRunningAnalysis && model && analysisPrompt.trim().length,\n );\n return (\n <div\n className={cn(\n 'flex flex-col items-center justify-center gap-4 w-full p-4',\n className,\n )}\n >\n <div className=\"flex items-center justify-between gap-4 w-full\">\n <div className=\"font-semibold text-lg pl-1\">\n What would you like to learn about the data?\n </div>\n </div>\n\n <div className=\"relative w-full\">\n <Textarea\n disabled={isRunningAnalysis}\n className=\"h-[100px]\"\n value={analysisPrompt}\n onChange={(e) => setAnalysisPrompt(e.target.value)}\n onKeyDown={handleKeyDown}\n />\n <div className=\"absolute top-1 right-1 flex items-center gap-2\">\n {isRunningAnalysis && (\n <Button variant=\"outline\" onClick={cancelAnalysis}>\n <OctagonXIcon className=\"w-4 h-4\" />\n Stop\n </Button>\n )}\n <Button variant=\"outline\" onClick={runAnalysis} disabled={!canStart}>\n {isRunningAnalysis ? (\n <div className=\"flex items-center gap-2\">\n <Spinner className=\"w-4 h-4\" /> Running…\n </div>\n ) : (\n 'Start Analysis'\n )}\n </Button>\n </div>\n </div>\n </div>\n );\n};\n"]}
|
package/dist/QueryResult.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CustomFunctionCall } from '@openassistant/core';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a query result message component based on a custom function call.
|
|
4
|
-
*
|
|
5
|
-
* @param {CustomFunctionCall} props - The custom function call properties
|
|
6
|
-
* @returns {JSX.Element | null} A query result table modal component or null if no data is available
|
|
7
|
-
*/
|
|
8
|
-
export declare function queryMessage(props: CustomFunctionCall): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
-
//# sourceMappingURL=QueryResult.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryResult.d.ts","sourceRoot":"","sources":["../src/QueryResult.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AA6DvD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,kDAarD"}
|
package/dist/QueryResult.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { DataTableModal } from '@sqlrooms/data-table';
|
|
3
|
-
import { Expand, TableIcon } from 'lucide-react';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
/**
|
|
6
|
-
* A modal component that displays a data table with a title.
|
|
7
|
-
*
|
|
8
|
-
* @component
|
|
9
|
-
* @param {Object} props - The component props
|
|
10
|
-
* @param {string} props.title - The title to display in the modal header
|
|
11
|
-
* @param {string} props.sqlQuery - The SQL query that generated the data
|
|
12
|
-
* @returns {JSX.Element} A modal component containing a data table
|
|
13
|
-
*/
|
|
14
|
-
function QueryResultTableModal({ title, sqlQuery, }) {
|
|
15
|
-
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
16
|
-
const handleClick = () => {
|
|
17
|
-
setIsModalOpen(true);
|
|
18
|
-
};
|
|
19
|
-
const onClose = () => {
|
|
20
|
-
setIsModalOpen(false);
|
|
21
|
-
};
|
|
22
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex gap-2 flex-row items-center text-muted-foreground", onClick: handleClick, children: [_jsx(TableIcon, { className: "h-4 w-4" }), _jsx("h3", { className: "ml-1 text-xs uppercase", children: "Query Result" }), _jsx(Expand, { className: "h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200" })] }), _jsx(DataTableModal, { title: title, query: sqlQuery, tableModal: {
|
|
23
|
-
isOpen: isModalOpen,
|
|
24
|
-
onClose: onClose,
|
|
25
|
-
} })] }));
|
|
26
|
-
}
|
|
27
|
-
function isQueryToolOutputData(data) {
|
|
28
|
-
return typeof data === 'object' && data !== null && 'sqlQuery' in data;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Creates a query result message component based on a custom function call.
|
|
32
|
-
*
|
|
33
|
-
* @param {CustomFunctionCall} props - The custom function call properties
|
|
34
|
-
* @returns {JSX.Element | null} A query result table modal component or null if no data is available
|
|
35
|
-
*/
|
|
36
|
-
export function queryMessage(props) {
|
|
37
|
-
const data = props.output?.data;
|
|
38
|
-
if (!isQueryToolOutputData(data)) {
|
|
39
|
-
throw new Error('Invalid query tool output data');
|
|
40
|
-
}
|
|
41
|
-
if (!data.sqlQuery) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
return (_jsx(QueryResultTableModal, { title: data.sqlQuery, sqlQuery: data.sqlQuery }));
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=QueryResult.js.map
|
package/dist/QueryResult.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryResult.js","sourceRoot":"","sources":["../src/QueryResult.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAC/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ED,OAAO,CACL,KAAC,qBAAqB,IAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,GAAI,CACzE,CAAC;AACJ,CAAC","sourcesContent":["import {CustomFunctionCall} from '@openassistant/core';\nimport {DataTableModal} from '@sqlrooms/data-table';\nimport {Expand, TableIcon} from 'lucide-react';\nimport {useState} from 'react';\n\n/**\n * A modal component that displays a data table with a title.\n *\n * @component\n * @param {Object} props - The component props\n * @param {string} props.title - The title to display in the modal header\n * @param {string} props.sqlQuery - The SQL query that generated the data\n * @returns {JSX.Element} A modal component containing a data table\n */\nfunction QueryResultTableModal({\n title,\n sqlQuery,\n}: {\n title: string;\n sqlQuery: string;\n}) {\n const [isModalOpen, setIsModalOpen] = useState(false);\n\n const handleClick = () => {\n setIsModalOpen(true);\n };\n\n const onClose = () => {\n setIsModalOpen(false);\n };\n\n return (\n <>\n <div\n className=\"flex gap-2 flex-row items-center text-muted-foreground\"\n onClick={handleClick}\n >\n <TableIcon className=\"h-4 w-4\" />\n <h3 className=\"ml-1 text-xs uppercase\">Query Result</h3>\n <Expand className=\"h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200\" />\n </div>\n\n <DataTableModal\n title={title}\n query={sqlQuery}\n tableModal={{\n isOpen: isModalOpen,\n onClose: onClose,\n }}\n />\n </>\n );\n}\n\ntype QueryToolOutputData = {\n sqlQuery: string;\n};\n\nfunction isQueryToolOutputData(data: unknown): data is QueryToolOutputData {\n return typeof data === 'object' && data !== null && 'sqlQuery' in data;\n}\n/**\n * Creates a query result message component based on a custom function call.\n *\n * @param {CustomFunctionCall} props - The custom function call properties\n * @returns {JSX.Element | null} A query result table modal component or null if no data is available\n */\nexport function queryMessage(props: CustomFunctionCall) {\n const data = props.output?.data;\n\n if (!isQueryToolOutputData(data)) {\n throw new Error('Invalid query tool output data');\n }\n if (!data.sqlQuery) {\n return null;\n }\n\n return (\n <QueryResultTableModal title={data.sqlQuery} sqlQuery={data.sqlQuery} />\n );\n}\n"]}
|
package/dist/ToolCall.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ChartToolParameters, QueryToolParameters, ToolResultSchema } from './schemas';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* Props for the QueryToolCall component
|
|
6
|
-
* @interface QueryToolCallProps
|
|
7
|
-
* @extends {QueryToolParameters}
|
|
8
|
-
* @property {ReactNode} [customMessage] - Optional custom message to display with the query
|
|
9
|
-
*/
|
|
10
|
-
type QueryToolCallProps = QueryToolParameters & {
|
|
11
|
-
customMessage?: ReactNode;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Type guard to check if an argument object matches QueryToolParameters
|
|
15
|
-
* @param {unknown} args - The arguments to check
|
|
16
|
-
* @returns {boolean} True if args matches QueryToolParameters structure
|
|
17
|
-
*/
|
|
18
|
-
export declare function isQueryToolParameters(args: unknown): args is QueryToolParameters;
|
|
19
|
-
/**
|
|
20
|
-
* Type guard to check if an argument object matches ChartToolParameters
|
|
21
|
-
* @param {unknown} args - The arguments to check
|
|
22
|
-
* @returns {boolean} True if args matches ChartToolParameters structure
|
|
23
|
-
*/
|
|
24
|
-
export declare function isChartToolParameters(args: unknown): args is ChartToolParameters;
|
|
25
|
-
/**
|
|
26
|
-
* Renders a SQL query tool call with reasoning and query text
|
|
27
|
-
* @param {QueryToolCallProps} props - The component props
|
|
28
|
-
* @returns {JSX.Element} The rendered query tool call
|
|
29
|
-
*/
|
|
30
|
-
export declare const QueryToolCall: React.NamedExoticComponent<QueryToolCallProps>;
|
|
31
|
-
/**
|
|
32
|
-
* Renders a chart tool call with visualization using Vega-Lite
|
|
33
|
-
* @param {ChartToolParameters} props - The component props
|
|
34
|
-
* @returns {JSX.Element} The rendered chart tool call
|
|
35
|
-
*/
|
|
36
|
-
export declare const ChartToolCall: React.NamedExoticComponent<{
|
|
37
|
-
sqlQuery: string;
|
|
38
|
-
reasoning: string;
|
|
39
|
-
vegaLiteSpec: string;
|
|
40
|
-
}>;
|
|
41
|
-
/**
|
|
42
|
-
* Type guard to check if a result object matches AnalysisAnswerProps
|
|
43
|
-
* @param {unknown} result - The result to check
|
|
44
|
-
* @returns {boolean} True if result matches AnalysisAnswerProps structure
|
|
45
|
-
*/
|
|
46
|
-
type AnalysisAnswerProps = {
|
|
47
|
-
success: true;
|
|
48
|
-
data: {
|
|
49
|
-
analysis: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Type guard to check if a result object matches AnalysisAnswerProps
|
|
54
|
-
* @param {unknown} result - The result to check
|
|
55
|
-
* @returns {boolean} True if result matches AnalysisAnswerProps structure
|
|
56
|
-
*/
|
|
57
|
-
export declare function isAnalysisAnswer(result: ToolResultSchema['result']): result is AnalysisAnswerProps;
|
|
58
|
-
/**
|
|
59
|
-
* Renders an analysis answer with markdown content of the final streaming response.
|
|
60
|
-
*
|
|
61
|
-
* @param {AnalysisAnswerProps} props - The component props. See {@link AnalysisAnswerProps} for more details.
|
|
62
|
-
* @returns {JSX.Element} The rendered answer tool call
|
|
63
|
-
*/
|
|
64
|
-
export declare const AnalysisAnswer: React.NamedExoticComponent<AnalysisAnswerProps>;
|
|
65
|
-
export {};
|
|
66
|
-
//# sourceMappingURL=ToolCall.d.ts.map
|
package/dist/ToolCall.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCall.d.ts","sourceRoot":"","sources":["../src/ToolCall.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAW,SAAS,EAAC,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;GAKG;AACH,KAAK,kBAAkB,GAAG,mBAAmB,GAAG;IAC9C,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,mBAAmB,CAO7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,mBAAmB,CAE7B;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,gDAYxB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;EAiCxB,CAAC;AAEH;;;;GAIG;AACH,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACjC,MAAM,IAAI,mBAAmB,CAE/B;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,iDAYzB,CAAC"}
|
package/dist/ToolCall.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Spinner } from '@sqlrooms/ui';
|
|
3
|
-
import { Suspense } from 'react';
|
|
4
|
-
import Markdown from 'react-markdown';
|
|
5
|
-
import { VegaLiteChart } from '@sqlrooms/vega';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
/**
|
|
8
|
-
* Type guard to check if an argument object matches QueryToolParameters
|
|
9
|
-
* @param {unknown} args - The arguments to check
|
|
10
|
-
* @returns {boolean} True if args matches QueryToolParameters structure
|
|
11
|
-
*/
|
|
12
|
-
export function isQueryToolParameters(args) {
|
|
13
|
-
return (typeof args === 'object' &&
|
|
14
|
-
args !== null &&
|
|
15
|
-
'reasoning' in args &&
|
|
16
|
-
'sqlQuery' in args);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Type guard to check if an argument object matches ChartToolParameters
|
|
20
|
-
* @param {unknown} args - The arguments to check
|
|
21
|
-
* @returns {boolean} True if args matches ChartToolParameters structure
|
|
22
|
-
*/
|
|
23
|
-
export function isChartToolParameters(args) {
|
|
24
|
-
return typeof args === 'object' && args !== null && 'vegaLiteSpec' in args;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Renders a SQL query tool call with reasoning and query text
|
|
28
|
-
* @param {QueryToolCallProps} props - The component props
|
|
29
|
-
* @returns {JSX.Element} The rendered query tool call
|
|
30
|
-
*/
|
|
31
|
-
export const QueryToolCall = React.memo(function QueryToolCall({ reasoning, sqlQuery, customMessage, }) {
|
|
32
|
-
return (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsx("div", { className: "text-xs text-gray-400", children: reasoning }), _jsx("div", { className: "font-mono", children: sqlQuery }), customMessage] }));
|
|
33
|
-
});
|
|
34
|
-
/**
|
|
35
|
-
* Renders a chart tool call with visualization using Vega-Lite
|
|
36
|
-
* @param {ChartToolParameters} props - The component props
|
|
37
|
-
* @returns {JSX.Element} The rendered chart tool call
|
|
38
|
-
*/
|
|
39
|
-
export const ChartToolCall = React.memo(function ChartToolCall({ reasoning, sqlQuery, vegaLiteSpec, }) {
|
|
40
|
-
return (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsx("div", { className: "text-sm", children: _jsx(Markdown, { children: reasoning }) }), vegaLiteSpec && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "text-xs text-muted-foreground font-mono", children: sqlQuery }), _jsx(Suspense, { fallback: _jsx("div", { className: "w-full h-full flex items-center justify-center", children: _jsx(Spinner, { className: "w-4 h-4" }) }), children: _jsx(VegaLiteChart, { width: 400, height: 250, sqlQuery: sqlQuery, spec: vegaLiteSpec }) })] }))] }));
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* Type guard to check if a result object matches AnalysisAnswerProps
|
|
44
|
-
* @param {unknown} result - The result to check
|
|
45
|
-
* @returns {boolean} True if result matches AnalysisAnswerProps structure
|
|
46
|
-
*/
|
|
47
|
-
export function isAnalysisAnswer(result) {
|
|
48
|
-
return result.success && result.data.analysis !== undefined;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Renders an analysis answer with markdown content of the final streaming response.
|
|
52
|
-
*
|
|
53
|
-
* @param {AnalysisAnswerProps} props - The component props. See {@link AnalysisAnswerProps} for more details.
|
|
54
|
-
* @returns {JSX.Element} The rendered answer tool call
|
|
55
|
-
*/
|
|
56
|
-
export const AnalysisAnswer = React.memo(function AnalysisAnswer(props) {
|
|
57
|
-
return (_jsx("div", { className: "flex flex-col gap-5", children: _jsx("div", { className: "text-xs", children: _jsx(Markdown, { className: "whitespace-pre-wrap break-words", children: props.data.analysis }) }) }));
|
|
58
|
-
});
|
|
59
|
-
//# sourceMappingURL=ToolCall.js.map
|
package/dist/ToolCall.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCall.js","sourceRoot":"","sources":["../src/ToolCall.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAY,MAAM,OAAO,CAAC;AAC1C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAAa;IAEb,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,WAAW,IAAI,IAAI;QACnB,UAAU,IAAI,IAAI,CACnB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAAa;IAEb,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,cAAc,IAAI,IAAI,CAAC;AAC7E,CAAC;AA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OAAO,CACL,cAAK,SAAS,EAAC,qBAAqB,YAClC,cAAK,SAAS,EAAC,SAAS,YACtB,KAAC,QAAQ,IAAC,SAAS,EAAC,iCAAiC,YAClD,KAAK,CAAC,IAAI,CAAC,QAAQ,GACX,GACP,GACF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import {\n ChartToolParameters,\n QueryToolParameters,\n ToolResultSchema,\n} from './schemas';\nimport {Spinner} from '@sqlrooms/ui';\nimport {Suspense, ReactNode} from 'react';\nimport Markdown from 'react-markdown';\nimport {VegaLiteChart} from '@sqlrooms/vega';\nimport React from 'react';\n\n/**\n * Props for the QueryToolCall component\n * @interface QueryToolCallProps\n * @extends {QueryToolParameters}\n * @property {ReactNode} [customMessage] - Optional custom message to display with the query\n */\ntype QueryToolCallProps = QueryToolParameters & {\n customMessage?: ReactNode;\n};\n\n/**\n * Type guard to check if an argument object matches QueryToolParameters\n * @param {unknown} args - The arguments to check\n * @returns {boolean} True if args matches QueryToolParameters structure\n */\nexport function isQueryToolParameters(\n args: unknown,\n): args is QueryToolParameters {\n return (\n typeof args === 'object' &&\n args !== null &&\n 'reasoning' in args &&\n 'sqlQuery' in args\n );\n}\n\n/**\n * Type guard to check if an argument object matches ChartToolParameters\n * @param {unknown} args - The arguments to check\n * @returns {boolean} True if args matches ChartToolParameters structure\n */\nexport function isChartToolParameters(\n args: unknown,\n): args is ChartToolParameters {\n return typeof args === 'object' && args !== null && 'vegaLiteSpec' in args;\n}\n\n/**\n * Renders a SQL query tool call with reasoning and query text\n * @param {QueryToolCallProps} props - The component props\n * @returns {JSX.Element} The rendered query tool call\n */\nexport const QueryToolCall = React.memo(function QueryToolCall({\n reasoning,\n sqlQuery,\n customMessage,\n}: QueryToolCallProps) {\n return (\n <div className=\"flex flex-col gap-5\">\n <div className=\"text-xs text-gray-400\">{reasoning}</div>\n <div className=\"font-mono\">{sqlQuery}</div>\n {customMessage}\n </div>\n );\n});\n\n/**\n * Renders a chart tool call with visualization using Vega-Lite\n * @param {ChartToolParameters} props - The component props\n * @returns {JSX.Element} The rendered chart tool call\n */\nexport const ChartToolCall = React.memo(function ChartToolCall({\n reasoning,\n sqlQuery,\n vegaLiteSpec,\n}: ChartToolParameters) {\n return (\n <div className=\"flex flex-col gap-5\">\n <div className=\"text-sm\">\n <Markdown>{reasoning}</Markdown>\n </div>\n {vegaLiteSpec && (\n <div className=\"flex flex-col gap-2\">\n <div className=\"text-xs text-muted-foreground font-mono\">\n {sqlQuery}\n </div>\n <Suspense\n fallback={\n <div className=\"w-full h-full flex items-center justify-center\">\n <Spinner className=\"w-4 h-4\" />\n </div>\n }\n >\n <VegaLiteChart\n width={400}\n height={250}\n sqlQuery={sqlQuery}\n spec={vegaLiteSpec}\n />\n </Suspense>\n </div>\n )}\n </div>\n );\n});\n\n/**\n * Type guard to check if a result object matches AnalysisAnswerProps\n * @param {unknown} result - The result to check\n * @returns {boolean} True if result matches AnalysisAnswerProps structure\n */\ntype AnalysisAnswerProps = {\n success: true;\n data: {\n analysis: string;\n };\n};\n\n/**\n * Type guard to check if a result object matches AnalysisAnswerProps\n * @param {unknown} result - The result to check\n * @returns {boolean} True if result matches AnalysisAnswerProps structure\n */\nexport function isAnalysisAnswer(\n result: ToolResultSchema['result'],\n): result is AnalysisAnswerProps {\n return result.success && result.data.analysis !== undefined;\n}\n\n/**\n * Renders an analysis answer with markdown content of the final streaming response.\n *\n * @param {AnalysisAnswerProps} props - The component props. See {@link AnalysisAnswerProps} for more details.\n * @returns {JSX.Element} The rendered answer tool call\n */\nexport const AnalysisAnswer = React.memo(function AnalysisAnswer(\n props: AnalysisAnswerProps,\n) {\n return (\n <div className=\"flex flex-col gap-5\">\n <div className=\"text-xs\">\n <Markdown className=\"whitespace-pre-wrap break-words\">\n {props.data.analysis}\n </Markdown>\n </div>\n </div>\n );\n});\n"]}
|
package/dist/ToolResult.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ToolResultSchema } from './schemas';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
interface ToolResultProps {
|
|
5
|
-
toolResult: ToolResultSchema;
|
|
6
|
-
customMessage?: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const ToolResult: React.FC<ToolResultProps>;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=ToolResult.d.ts.map
|
package/dist/ToolResult.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolResult.d.ts","sourceRoot":"","sources":["../src/ToolResult.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAU3C,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAQhC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,eAAe;IACvB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAkBD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqEhD,CAAC"}
|
package/dist/ToolResult.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Badge, Button, Popover, PopoverContent, PopoverTrigger, cn, } from '@sqlrooms/ui';
|
|
3
|
-
import { CheckCircle2Icon, CodeIcon, XCircleIcon } from 'lucide-react';
|
|
4
|
-
import { AnalysisAnswer, ChartToolCall, isAnalysisAnswer, isChartToolParameters, } from './ToolCall';
|
|
5
|
-
import { isQueryToolParameters, QueryToolCall } from './ToolCall';
|
|
6
|
-
function getBorderColor(isSuccess, toolName) {
|
|
7
|
-
if (!isSuccess) {
|
|
8
|
-
return 'border-red-500';
|
|
9
|
-
}
|
|
10
|
-
switch (toolName) {
|
|
11
|
-
case 'query':
|
|
12
|
-
return 'border-green-500';
|
|
13
|
-
case 'chart':
|
|
14
|
-
return 'border-blue-500';
|
|
15
|
-
case 'answer':
|
|
16
|
-
return 'border-gray-500';
|
|
17
|
-
default:
|
|
18
|
-
return 'border-gray-500';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export const ToolResult = ({ toolResult, customMessage, }) => {
|
|
22
|
-
const { toolName, args, result } = toolResult;
|
|
23
|
-
const isSuccess = result.success;
|
|
24
|
-
return (_jsxs("div", { className: cn('border-2 relative bg-gray-100 dark:bg-gray-900 px-5 py-6 rounded-md text-gray-700 dark:text-gray-300 text-xs', getBorderColor(isSuccess, toolName)), children: [_jsxs(Badge, { variant: "secondary", className: cn('text-xs absolute top-[-12px] left-2 dark:text-gray-100 text-gray-700 flex items-center gap-1 border', getBorderColor(isSuccess, toolName)), children: [isSuccess ? (_jsx(CheckCircle2Icon, { className: "w-3 h-3 text-green-500" })) : (_jsx(XCircleIcon, { className: "w-3 h-3 text-red-500" })), toolName] }), _jsx("div", { className: "absolute top-2 right-2", children: _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { variant: "outline", size: "icon", className: "w-6 h-6", children: _jsx(CodeIcon, { className: "w-4 h-4" }) }) }), _jsx(PopoverContent, { className: "w-[400px] max-h-[300px] overflow-auto p-4", side: "right", align: "start", children: _jsx("pre", { className: "whitespace-no-wrap text-xs", children: JSON.stringify(toolResult, null, 2) }) })] }) }), _jsxs("div", { className: "flex flex-col gap-5", children: [toolName === 'query' && isQueryToolParameters(args) ? (_jsx(QueryToolCall, { ...args, customMessage: customMessage })) : toolName === 'chart' && isChartToolParameters(args) ? (_jsx(ChartToolCall, { ...args })) : toolName === 'answer' && isAnalysisAnswer(result) ? (_jsx(AnalysisAnswer, { ...result })) : (Object.keys(args).length > 0 && (_jsx("pre", { children: JSON.stringify(args, null, 2) }))), !result.success && (_jsxs("div", { className: "text-red-500 gap-2 flex flex-col", children: [_jsx("p", { className: "text-sm font-bold", children: "Oops! Something went wrong..." }), _jsx("p", { className: "text-xs", children: result.error })] }))] })] }));
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=ToolResult.js.map
|
package/dist/ToolResult.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolResult.js","sourceRoot":"","sources":["../src/ToolResult.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,cAAc,EACd,cAAc,EACd,EAAE,GACH,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAErE,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,qBAAqB,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAQhE,SAAS,cAAc,CAAC,SAAkB,EAAE,QAAgB;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,kBAAkB,CAAC;QAC5B,KAAK,OAAO;YACV,OAAO,iBAAiB,CAAC;QAC3B,KAAK,QAAQ;YACX,OAAO,iBAAiB,CAAC;QAC3B;YACE,OAAO,iBAAiB,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EACpD,UAAU,EACV,aAAa,GACd,EAAE,EAAE;IACH,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAC,GAAG,UAAU,CAAC;IAC5C,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC;IAEjC,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,8GAA8G,EAC9G,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CACpC,aAED,MAAC,KAAK,IACJ,OAAO,EAAC,WAAW,EACnB,SAAS,EAAE,EAAE,CAC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,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAO,CAC3C,CACF,EACA,CAAC,MAAM,CAAC,OAAO,IAAI,CAClB,eAAK,SAAS,EAAC,kCAAkC,aAC/C,YAAG,SAAS,EAAC,mBAAmB,8CAAkC,EAClE,YAAG,SAAS,EAAC,SAAS,YAAE,MAAM,CAAC,KAAK,GAAK,IACrC,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {ToolResultSchema} from './schemas';\nimport {\n Badge,\n Button,\n Popover,\n PopoverContent,\n PopoverTrigger,\n cn,\n} from '@sqlrooms/ui';\nimport {CheckCircle2Icon, CodeIcon, XCircleIcon} from 'lucide-react';\nimport {ReactNode} from 'react';\nimport {\n AnalysisAnswer,\n ChartToolCall,\n isAnalysisAnswer,\n isChartToolParameters,\n} from './ToolCall';\nimport {isQueryToolParameters, QueryToolCall} from './ToolCall';\nimport React from 'react';\n\ninterface ToolResultProps {\n toolResult: ToolResultSchema;\n customMessage?: ReactNode;\n}\n\nfunction getBorderColor(isSuccess: boolean, toolName: string) {\n if (!isSuccess) {\n return 'border-red-500';\n }\n switch (toolName) {\n case 'query':\n return 'border-green-500';\n case 'chart':\n return 'border-blue-500';\n case 'answer':\n return 'border-gray-500';\n default:\n return 'border-gray-500';\n }\n}\n\nexport const ToolResult: React.FC<ToolResultProps> = ({\n toolResult,\n customMessage,\n}) => {\n const {toolName, args, result} = toolResult;\n const isSuccess = result.success;\n\n return (\n <div\n className={cn(\n 'border-2 relative bg-gray-100 dark:bg-gray-900 px-5 py-6 rounded-md text-gray-700 dark:text-gray-300 text-xs',\n getBorderColor(isSuccess, toolName),\n )}\n >\n <Badge\n variant=\"secondary\"\n className={cn(\n 'text-xs absolute top-[-12px] left-2 dark:text-gray-100 text-gray-700 flex items-center gap-1 border',\n getBorderColor(isSuccess, toolName),\n )}\n >\n {isSuccess ? (\n <CheckCircle2Icon className=\"w-3 h-3 text-green-500\" />\n ) : (\n <XCircleIcon className=\"w-3 h-3 text-red-500\" />\n )}\n {toolName}\n </Badge>\n\n <div className=\"absolute top-2 right-2\">\n <Popover>\n <PopoverTrigger asChild>\n <Button variant=\"outline\" size=\"icon\" className=\"w-6 h-6\">\n <CodeIcon className=\"w-4 h-4\" />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className=\"w-[400px] max-h-[300px] overflow-auto p-4\"\n side=\"right\"\n align=\"start\"\n >\n <pre className=\"whitespace-no-wrap text-xs\">\n {JSON.stringify(toolResult, null, 2)}\n </pre>\n </PopoverContent>\n </Popover>\n </div>\n\n <div className=\"flex flex-col gap-5\">\n {toolName === 'query' && isQueryToolParameters(args) ? (\n <QueryToolCall {...args} customMessage={customMessage} />\n ) : toolName === 'chart' && isChartToolParameters(args) ? (\n <ChartToolCall {...args} />\n ) : toolName === 'answer' && isAnalysisAnswer(result) ? (\n <AnalysisAnswer {...result} />\n ) : (\n Object.keys(args).length > 0 && (\n <pre>{JSON.stringify(args, null, 2)}</pre>\n )\n )}\n {!result.success && (\n <div className=\"text-red-500 gap-2 flex flex-col\">\n <p className=\"text-sm font-bold\">Oops! Something went wrong...</p>\n <p className=\"text-xs\">{result.error}</p>\n </div>\n )}\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type RefObject } from 'react';
|
|
2
|
-
export declare function useScrollToBottom<T extends HTMLElement>(options?: MutationObserverInit): [RefObject<T>, RefObject<T>];
|
|
3
|
-
export declare function useScrollToBottomButton(containerRef: RefObject<HTMLElement>): {
|
|
4
|
-
showButton: boolean;
|
|
5
|
-
scrollToBottom: () => void;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=use-scroll-to-bottom.d.ts.map
|