altair-graphql-plugin-ai 7.3.0 → 7.3.2
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/dist/plugin.css +1 -0
- package/dist/plugin.js +318 -0
- package/manifest.json +1 -1
- package/package.json +9 -3
- package/.eslintrc.cjs +0 -18
- package/index.html +0 -97
- package/src/assets/react.svg +0 -1
- package/src/components/Chat/Chat.css +0 -220
- package/src/components/Chat/Chat.tsx +0 -153
- package/src/components/Chat/ChatEmptySession.tsx +0 -38
- package/src/components/Chat/ChatMessage.tsx +0 -86
- package/src/components/Chat/ChatWrapper.tsx +0 -23
- package/src/components/Chat/Spinner.tsx +0 -5
- package/src/dev.tsx +0 -37
- package/src/panel.tsx +0 -194
- package/src/plugin.tsx +0 -31
- package/src/utils.ts +0 -8
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -27
- package/tsconfig.json +0 -11
- package/tsconfig.node.json +0 -13
- package/vite.config.ts +0 -22
- /package/{public → dist}/vite.svg +0 -0
package/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "altair-graphql-plugin-ai",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@tanstack/react-query": "^5.51.5",
|
|
14
|
-
"altair-graphql-core": "^7.3.
|
|
14
|
+
"altair-graphql-core": "^7.3.2",
|
|
15
15
|
"classnames": "^2.5.1",
|
|
16
16
|
"lucide-react": "^0.408.0",
|
|
17
17
|
"react": "^18.3.1",
|
|
@@ -32,5 +32,11 @@
|
|
|
32
32
|
"eslint-plugin-react-refresh": "^0.4.7",
|
|
33
33
|
"typescript": "^5.2.2",
|
|
34
34
|
"vite": "^5.3.4"
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"package.json",
|
|
39
|
+
"manifest.json",
|
|
40
|
+
"README.md"
|
|
41
|
+
]
|
|
36
42
|
}
|
package/.eslintrc.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: { browser: true, es2020: true },
|
|
4
|
-
extends: [
|
|
5
|
-
'eslint:recommended',
|
|
6
|
-
'plugin:@typescript-eslint/recommended',
|
|
7
|
-
'plugin:react-hooks/recommended',
|
|
8
|
-
],
|
|
9
|
-
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
10
|
-
parser: '@typescript-eslint/parser',
|
|
11
|
-
plugins: ['react-refresh'],
|
|
12
|
-
rules: {
|
|
13
|
-
'react-refresh/only-export-components': [
|
|
14
|
-
'warn',
|
|
15
|
-
{ allowConstantExport: true },
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
}
|
package/index.html
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
NOTE: This is only used for development of the plugin, to mimic the Altair UI closely enough for standalone development.
|
|
3
|
-
Changes made here will not affect the plugin embedded within the Altair UI.
|
|
4
|
-
-->
|
|
5
|
-
<!doctype html>
|
|
6
|
-
<html lang="en">
|
|
7
|
-
<head>
|
|
8
|
-
<meta charset="UTF-8" />
|
|
9
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
10
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
11
|
-
<title>Vite + React + TS</title>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<style>
|
|
15
|
-
:root {
|
|
16
|
-
--baseline-size: 24;
|
|
17
|
-
--rem-base: 24;
|
|
18
|
-
--body-font-size: 13;
|
|
19
|
-
--app-easing: ease;
|
|
20
|
-
--black-color: #201e1f;
|
|
21
|
-
--dark-grey-color: #a6a6a6;
|
|
22
|
-
--grey-color: #eaeaea;
|
|
23
|
-
--light-grey-color: #f0f0f0;
|
|
24
|
-
--white-color: #ffffff;
|
|
25
|
-
--green-color: #64cb29;
|
|
26
|
-
--blue-color: #2d9ee0;
|
|
27
|
-
--cerise-color: #f00faa;
|
|
28
|
-
--red-color: #ed6a5a;
|
|
29
|
-
--rose-color: #f45b69;
|
|
30
|
-
--orange-color: #edae49;
|
|
31
|
-
--yellow-color: #e4ce44;
|
|
32
|
-
--light-red-color: #cc998d;
|
|
33
|
-
--dark-purple-color: #303965;
|
|
34
|
-
--primary-color: #64cb29;
|
|
35
|
-
--secondary-color: #2d9ee0;
|
|
36
|
-
--tertiary-color: #f45b69;
|
|
37
|
-
--shadow-bg: rgba(32, 30, 31, 0.3);
|
|
38
|
-
--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
|
|
39
|
-
'Helvetica Neue', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji',
|
|
40
|
-
'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
41
|
-
--rgb-black: 32, 30, 31;
|
|
42
|
-
--rgb-dark-grey: 166, 166, 166;
|
|
43
|
-
--rgb-grey: 234, 234, 234;
|
|
44
|
-
--rgb-light-grey: 240, 240, 240;
|
|
45
|
-
--rgb-white: 255, 255, 255;
|
|
46
|
-
--rgb-green: 100, 203, 41;
|
|
47
|
-
--rgb-blue: 45, 158, 224;
|
|
48
|
-
--rgb-cerise: 240, 15, 170;
|
|
49
|
-
--rgb-red: 237, 106, 90;
|
|
50
|
-
--rgb-orange: 237, 174, 73;
|
|
51
|
-
--rgb-yellow: 228, 206, 68;
|
|
52
|
-
--rgb-light-red: 204, 153, 141;
|
|
53
|
-
--rgb-dark-purple: 48, 57, 101;
|
|
54
|
-
--editor-font-family: JetBrains Mono;
|
|
55
|
-
--editor-font-size: 12;
|
|
56
|
-
--theme-bg-color: #201e1f;
|
|
57
|
-
--theme-off-bg-color: #343233;
|
|
58
|
-
--theme-font-color: #ffffff;
|
|
59
|
-
--theme-off-font-color: #f0f0f0;
|
|
60
|
-
--theme-border-color: #565c64;
|
|
61
|
-
--theme-off-border-color: #565656;
|
|
62
|
-
--header-bg-color: #343233;
|
|
63
|
-
--rgb-primary: 100, 203, 41;
|
|
64
|
-
--rgb-secondary: 45, 158, 224;
|
|
65
|
-
--rgb-tertiary: 244, 91, 105;
|
|
66
|
-
--rgb-theme-bg: 32, 30, 31;
|
|
67
|
-
--rgb-theme-off-bg: 52, 50, 51;
|
|
68
|
-
--rgb-theme-font: 255, 255, 255;
|
|
69
|
-
--rgb-theme-off-font: 240, 240, 240;
|
|
70
|
-
--rgb-theme-border: 86, 92, 100;
|
|
71
|
-
--rgb-theme-off-border: 86, 86, 86;
|
|
72
|
-
--rgb-header-bg: 52, 50, 51;
|
|
73
|
-
--editor-comment-color: #a6a6a6;
|
|
74
|
-
--editor-string-color: #edae49;
|
|
75
|
-
--editor-number-color: #edae49;
|
|
76
|
-
--editor-variable-color: #ffffff;
|
|
77
|
-
--editor-attribute-color: #64cb29;
|
|
78
|
-
--editor-keyword-color: #2d9ee0;
|
|
79
|
-
--editor-atom-color: #ffffff;
|
|
80
|
-
--editor-property-color: #2d9ee0;
|
|
81
|
-
--editor-punctuation-color: #2d9ee0;
|
|
82
|
-
--editor-cursor-color: #2d9ee0;
|
|
83
|
-
--editor-def-color: #edae49;
|
|
84
|
-
--editor-builtin-color: #edae49;
|
|
85
|
-
}
|
|
86
|
-
#root {
|
|
87
|
-
display: flex;
|
|
88
|
-
flex-direction: column;
|
|
89
|
-
background: rgba(var(--rgb-theme-bg), 0.8);
|
|
90
|
-
-webkit-backdrop-filter: blur(20px);
|
|
91
|
-
backdrop-filter: blur(20px);
|
|
92
|
-
}
|
|
93
|
-
</style>
|
|
94
|
-
<div id="root"></div>
|
|
95
|
-
<script type="module" src="/src/dev.tsx"></script>
|
|
96
|
-
</body>
|
|
97
|
-
</html>
|
package/src/assets/react.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
@import url('https://cdn.jsdelivr.net/npm/altair-static@latest/build/dist/styles.css');
|
|
2
|
-
|
|
3
|
-
.ai-chat-wrapper {
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
height: 100vh;
|
|
7
|
-
align-items: center;
|
|
8
|
-
}
|
|
9
|
-
.ai-chat {
|
|
10
|
-
display: flex;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
height: 100%;
|
|
13
|
-
padding: 10px;
|
|
14
|
-
max-width: 800px;
|
|
15
|
-
width: 100%;
|
|
16
|
-
color: var(--theme-font-color);
|
|
17
|
-
}
|
|
18
|
-
.ai-chat__messages {
|
|
19
|
-
flex: 1;
|
|
20
|
-
overflow-y: auto;
|
|
21
|
-
margin: 0;
|
|
22
|
-
padding: 0;
|
|
23
|
-
}
|
|
24
|
-
.ai-chat__input-actions {
|
|
25
|
-
display: flex;
|
|
26
|
-
gap: 10px;
|
|
27
|
-
}
|
|
28
|
-
.ai-chat__message {
|
|
29
|
-
position: relative;
|
|
30
|
-
display: flex;
|
|
31
|
-
gap: 10px;
|
|
32
|
-
margin-bottom: 10px;
|
|
33
|
-
}
|
|
34
|
-
.ai-chat__message--user {
|
|
35
|
-
justify-content: flex-end;
|
|
36
|
-
}
|
|
37
|
-
.ai-chat__message--assistant {
|
|
38
|
-
justify-content: flex-start;
|
|
39
|
-
}
|
|
40
|
-
.ai-chat__message-avatar {
|
|
41
|
-
width: 32px;
|
|
42
|
-
height: 32px;
|
|
43
|
-
border-radius: 50%;
|
|
44
|
-
background-color: var(--theme-off-bg-color);
|
|
45
|
-
display: flex;
|
|
46
|
-
justify-content: center;
|
|
47
|
-
align-items: center;
|
|
48
|
-
}
|
|
49
|
-
.ai-chat__message-content {
|
|
50
|
-
padding: 10px;
|
|
51
|
-
border-radius: 10px;
|
|
52
|
-
max-width: 70%;
|
|
53
|
-
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
|
54
|
-
background: rgba(var(--rgb-theme-font), 0.1);
|
|
55
|
-
}
|
|
56
|
-
.ai-chat__message-content pre {
|
|
57
|
-
white-space: pre-wrap;
|
|
58
|
-
font-family: inherit;
|
|
59
|
-
}
|
|
60
|
-
.ai-chat__message-content p:last-child {
|
|
61
|
-
margin: 0;
|
|
62
|
-
}
|
|
63
|
-
.ai-chat__message--user .ai-chat__message-content {
|
|
64
|
-
background: rgba(var(--rgb-primary), 0.1);
|
|
65
|
-
}
|
|
66
|
-
.ai-chat__message-actions {
|
|
67
|
-
position: absolute;
|
|
68
|
-
bottom: 0;
|
|
69
|
-
margin-bottom: -10px;
|
|
70
|
-
display: flex;
|
|
71
|
-
gap: 5px;
|
|
72
|
-
background-color: var(--theme-off-bg-color);
|
|
73
|
-
opacity: 0;
|
|
74
|
-
}
|
|
75
|
-
.ai-chat__message:hover .ai-chat__message-actions {
|
|
76
|
-
opacity: 1;
|
|
77
|
-
}
|
|
78
|
-
button.ai-chat__message-action {
|
|
79
|
-
height: fit-content;
|
|
80
|
-
padding: 5px;
|
|
81
|
-
}
|
|
82
|
-
.ai-chat__disclaimer {
|
|
83
|
-
margin-top: 10px;
|
|
84
|
-
font-size: 0.8em;
|
|
85
|
-
color: var(--theme-font-color);
|
|
86
|
-
opacity: 0.5;
|
|
87
|
-
text-align: center;
|
|
88
|
-
}
|
|
89
|
-
.ai-chat__loader {
|
|
90
|
-
position: fixed;
|
|
91
|
-
top: 0;
|
|
92
|
-
left: 0;
|
|
93
|
-
width: 100%;
|
|
94
|
-
height: 100%;
|
|
95
|
-
z-index: 1;
|
|
96
|
-
background: rgba(var(--rgb-theme-off-bg), 0.5);
|
|
97
|
-
display: flex;
|
|
98
|
-
justify-content: center;
|
|
99
|
-
align-items: center;
|
|
100
|
-
}
|
|
101
|
-
.ai-chat__loader__spinner {
|
|
102
|
-
width: 32px;
|
|
103
|
-
height: 32px;
|
|
104
|
-
animation: ai-chat-spin 1s linear infinite;
|
|
105
|
-
}
|
|
106
|
-
.spinner {
|
|
107
|
-
animation: ai-chat-spin 1s linear infinite;
|
|
108
|
-
}
|
|
109
|
-
@keyframes ai-chat-spin {
|
|
110
|
-
0% {
|
|
111
|
-
transform: rotate(0deg);
|
|
112
|
-
}
|
|
113
|
-
100% {
|
|
114
|
-
transform: rotate(360deg);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.ai-chat__notice {
|
|
119
|
-
flex: 1;
|
|
120
|
-
display: flex;
|
|
121
|
-
justify-content: center;
|
|
122
|
-
align-items: center;
|
|
123
|
-
}
|
|
124
|
-
.ai-chat__notice-inner {
|
|
125
|
-
display: flex;
|
|
126
|
-
flex-direction: column;
|
|
127
|
-
align-items: center;
|
|
128
|
-
justify-content: center;
|
|
129
|
-
gap: 10px;
|
|
130
|
-
padding: 16px;
|
|
131
|
-
border-radius: 10px;
|
|
132
|
-
background: rgba(var(--rgb-theme-font), 0.03);
|
|
133
|
-
}
|
|
134
|
-
.ai-chat__notice-icon {
|
|
135
|
-
display: flex;
|
|
136
|
-
gap: 4px;
|
|
137
|
-
opacity: 0.9;
|
|
138
|
-
}
|
|
139
|
-
.ai-chat__notice-text {
|
|
140
|
-
color: var(--theme-font-color);
|
|
141
|
-
opacity: 0.8;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.ai-chat__empty-session {
|
|
145
|
-
flex: 1;
|
|
146
|
-
display: flex;
|
|
147
|
-
justify-content: center;
|
|
148
|
-
align-items: center;
|
|
149
|
-
}
|
|
150
|
-
.ai-chat__empty-session-inner {
|
|
151
|
-
display: flex;
|
|
152
|
-
flex-direction: column;
|
|
153
|
-
align-items: center;
|
|
154
|
-
justify-content: center;
|
|
155
|
-
gap: 10px;
|
|
156
|
-
}
|
|
157
|
-
.ai-chat__empty-session-icon {
|
|
158
|
-
display: flex;
|
|
159
|
-
gap: 4px;
|
|
160
|
-
opacity: 0.9;
|
|
161
|
-
padding: 16px;
|
|
162
|
-
}
|
|
163
|
-
.ai-chat__empty-session-text {
|
|
164
|
-
color: var(--theme-font-color);
|
|
165
|
-
opacity: 0.8;
|
|
166
|
-
}
|
|
167
|
-
.ai-chat__empty-session-prompts {
|
|
168
|
-
display: flex;
|
|
169
|
-
flex-direction: column;
|
|
170
|
-
gap: 10px;
|
|
171
|
-
}
|
|
172
|
-
.ai-chat__empty-session-prompt {
|
|
173
|
-
color: var(--theme-font-color);
|
|
174
|
-
opacity: 0.8;
|
|
175
|
-
text-align: center;
|
|
176
|
-
padding: 16px;
|
|
177
|
-
border-radius: 10px;
|
|
178
|
-
background: rgba(var(--rgb-theme-font), 0.03);
|
|
179
|
-
max-width: 300px;
|
|
180
|
-
}
|
|
181
|
-
/*
|
|
182
|
-
<div className="ai-chat__top-bar">
|
|
183
|
-
<div className="ai-chat__top-bar-inner">
|
|
184
|
-
<div className="ai-chat__top-bar-title">
|
|
185
|
-
{activeSession ? 'Active session' : 'No active session'}
|
|
186
|
-
</div>
|
|
187
|
-
<div className="ai-chat__top-bar-actions">
|
|
188
|
-
<button
|
|
189
|
-
className="btn btn--primary btn--light"
|
|
190
|
-
onClick={() => onStartNewSession()}
|
|
191
|
-
>
|
|
192
|
-
<Plus size={16} />
|
|
193
|
-
Start new session
|
|
194
|
-
</button>
|
|
195
|
-
</div>
|
|
196
|
-
</div>
|
|
197
|
-
</div> */
|
|
198
|
-
.ai-chat__top-bar {
|
|
199
|
-
display: flex;
|
|
200
|
-
justify-content: space-between;
|
|
201
|
-
align-items: center;
|
|
202
|
-
padding: 10px;
|
|
203
|
-
background: rgba(var(--rgb-theme-font), 0.03);
|
|
204
|
-
margin-bottom: 10px;
|
|
205
|
-
border-radius: 10px;
|
|
206
|
-
}
|
|
207
|
-
.ai-chat__credits {
|
|
208
|
-
display: flex;
|
|
209
|
-
align-items: center;
|
|
210
|
-
justify-content: center;
|
|
211
|
-
gap: 4px;
|
|
212
|
-
}
|
|
213
|
-
.ai-chat__tag {
|
|
214
|
-
padding: 5px;
|
|
215
|
-
border-radius: 5px;
|
|
216
|
-
background: rgba(var(--rgb-theme-font), 0.1);
|
|
217
|
-
color: var(--theme-font-color);
|
|
218
|
-
text-transform: uppercase;
|
|
219
|
-
font-size: 0.8em;
|
|
220
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { IMessage, ISession } from 'altair-graphql-core/build/ai/types';
|
|
2
|
-
import './Chat.css';
|
|
3
|
-
import { PluginUserInfo } from 'altair-graphql-core/build/plugin/v3/context';
|
|
4
|
-
import { Coins, Dot, Plus, SendHorizonal, Sparkles, User } from 'lucide-react';
|
|
5
|
-
import { ChatWrapper } from './ChatWrapper';
|
|
6
|
-
import { ChatMessage } from './ChatMessage';
|
|
7
|
-
import { ChatEmptySession } from './ChatEmptySession';
|
|
8
|
-
import { useEffect, useRef, useState } from 'react';
|
|
9
|
-
import { Spinner } from './Spinner';
|
|
10
|
-
|
|
11
|
-
export interface ChatProps {
|
|
12
|
-
loggedIn: boolean;
|
|
13
|
-
loading: boolean;
|
|
14
|
-
sendMessageIsPending: boolean;
|
|
15
|
-
availableCredits: number;
|
|
16
|
-
userInfo?: PluginUserInfo;
|
|
17
|
-
activeSession?: ISession;
|
|
18
|
-
messages?: IMessage[];
|
|
19
|
-
isPro?: boolean;
|
|
20
|
-
onStartNewSession?: () => void;
|
|
21
|
-
onSendMessage?: (message: string) => void;
|
|
22
|
-
onUseQuery?: (query: string) => void;
|
|
23
|
-
onRateMessage?: (messageId: string, rating: number) => void;
|
|
24
|
-
}
|
|
25
|
-
function Chat({
|
|
26
|
-
loggedIn,
|
|
27
|
-
loading,
|
|
28
|
-
sendMessageIsPending,
|
|
29
|
-
availableCredits,
|
|
30
|
-
activeSession,
|
|
31
|
-
messages,
|
|
32
|
-
isPro,
|
|
33
|
-
onStartNewSession = () => {},
|
|
34
|
-
onSendMessage = () => {},
|
|
35
|
-
onUseQuery = () => {},
|
|
36
|
-
onRateMessage = () => {},
|
|
37
|
-
}: ChatProps) {
|
|
38
|
-
const [message, setMessage] = useState('');
|
|
39
|
-
const listRef = useRef<HTMLUListElement>(null);
|
|
40
|
-
|
|
41
|
-
const sendMessage = () => {
|
|
42
|
-
onSendMessage(message);
|
|
43
|
-
setMessage('');
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
listRef.current?.lastElementChild?.scrollIntoView();
|
|
48
|
-
}, [messages]);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<ChatWrapper loading={loading}>
|
|
52
|
-
{!loggedIn ? (
|
|
53
|
-
<div className="ai-chat__notice">
|
|
54
|
-
<div className="ai-chat__notice-inner glassy-border">
|
|
55
|
-
<div className="ai-chat__notice-icon">
|
|
56
|
-
<User size={20} />
|
|
57
|
-
<Dot size={20} />
|
|
58
|
-
<Sparkles size={20} />
|
|
59
|
-
</div>
|
|
60
|
-
<div className="ai-chat__notice-text">
|
|
61
|
-
Please log in to use the AI assistant
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
) : (
|
|
66
|
-
<>
|
|
67
|
-
<div className="ai-chat__top-bar">
|
|
68
|
-
<button
|
|
69
|
-
className="btn btn--primary btn--light btn--small"
|
|
70
|
-
onClick={() => onStartNewSession()}
|
|
71
|
-
>
|
|
72
|
-
<Plus size={16} />
|
|
73
|
-
</button>
|
|
74
|
-
<div>
|
|
75
|
-
AI <span className="ai-chat__tag">Beta</span>
|
|
76
|
-
</div>
|
|
77
|
-
<div className="ai-chat__credits" title="Available credits">
|
|
78
|
-
{availableCredits} <Coins size={16} />
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
{messages?.length ? (
|
|
82
|
-
<ul ref={listRef} className="ai-chat__messages">
|
|
83
|
-
{messages.map((message) => (
|
|
84
|
-
<ChatMessage
|
|
85
|
-
key={message.id}
|
|
86
|
-
message={message.message}
|
|
87
|
-
isUser={message.role === 'USER'}
|
|
88
|
-
onUseQuery={onUseQuery}
|
|
89
|
-
onRateMessage={(rating) => onRateMessage(message.id, rating)}
|
|
90
|
-
/>
|
|
91
|
-
))}
|
|
92
|
-
</ul>
|
|
93
|
-
) : (
|
|
94
|
-
<ChatEmptySession />
|
|
95
|
-
)}
|
|
96
|
-
<div className="ai-chat__input-actions">
|
|
97
|
-
{!activeSession ? (
|
|
98
|
-
<button
|
|
99
|
-
className="btn btn--primary btn--light btn--full-width"
|
|
100
|
-
onClick={() => onStartNewSession()}
|
|
101
|
-
>
|
|
102
|
-
<Plus size={16} />
|
|
103
|
-
Start new session
|
|
104
|
-
</button>
|
|
105
|
-
) : (
|
|
106
|
-
<>
|
|
107
|
-
{availableCredits > 0 ? (
|
|
108
|
-
<>
|
|
109
|
-
<input
|
|
110
|
-
type="text"
|
|
111
|
-
className="input"
|
|
112
|
-
value={message}
|
|
113
|
-
onChange={(e) => setMessage(e.target.value)}
|
|
114
|
-
onKeyDown={(e) => {
|
|
115
|
-
if (e.key === 'Enter') {
|
|
116
|
-
sendMessage();
|
|
117
|
-
}
|
|
118
|
-
}}
|
|
119
|
-
disabled={sendMessageIsPending}
|
|
120
|
-
/>
|
|
121
|
-
<button
|
|
122
|
-
className="btn btn--primary btn--light"
|
|
123
|
-
onClick={() => sendMessage()}
|
|
124
|
-
disabled={sendMessageIsPending}
|
|
125
|
-
>
|
|
126
|
-
{sendMessageIsPending ? (
|
|
127
|
-
<Spinner size={16} />
|
|
128
|
-
) : (
|
|
129
|
-
<SendHorizonal size={16} />
|
|
130
|
-
)}{' '}
|
|
131
|
-
Send
|
|
132
|
-
</button>
|
|
133
|
-
</>
|
|
134
|
-
) : (
|
|
135
|
-
<>
|
|
136
|
-
<p>You are out of credits. Buy more credits to continue.</p>
|
|
137
|
-
{!isPro && <p>Upgrade to pro plan to buy credits.</p>}
|
|
138
|
-
</>
|
|
139
|
-
)}
|
|
140
|
-
</>
|
|
141
|
-
)}
|
|
142
|
-
</div>
|
|
143
|
-
<div className="ai-chat__disclaimer">
|
|
144
|
-
Disclaimer: The information provided by this assistant can be incorrect.
|
|
145
|
-
Please verify the information before using it.
|
|
146
|
-
</div>
|
|
147
|
-
</>
|
|
148
|
-
)}
|
|
149
|
-
</ChatWrapper>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export default Chat;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Sparkles } from 'lucide-react';
|
|
2
|
-
import { randomSampling } from '../../utils';
|
|
3
|
-
|
|
4
|
-
const allSamplePrompts = [
|
|
5
|
-
`Can you generate a GraphQL query to fetch all users with their names and email addresses?`,
|
|
6
|
-
`Create a query to get the list of products with their prices and availability status`,
|
|
7
|
-
`Explain the 'User' type from the schema`,
|
|
8
|
-
`What fields are available in the 'Product' type and what are their types?`,
|
|
9
|
-
`How do I use variables in a query in Altair?`,
|
|
10
|
-
`Can you show me an example of using fragments in Altair?`,
|
|
11
|
-
`Why am I getting a 'field not found' error in my query?`,
|
|
12
|
-
`How can I optimize this query to reduce response time?`,
|
|
13
|
-
`What are some best practices for writing GraphQL queries in Altair?`,
|
|
14
|
-
`How can I save and reuse my GraphQL queries in Altair?`,
|
|
15
|
-
];
|
|
16
|
-
const prompts = randomSampling(allSamplePrompts, 3);
|
|
17
|
-
|
|
18
|
-
export const ChatEmptySession = () => {
|
|
19
|
-
return (
|
|
20
|
-
<div className="ai-chat__empty-session">
|
|
21
|
-
<div className="ai-chat__empty-session-inner">
|
|
22
|
-
<div className="ai-chat__empty-session-icon">
|
|
23
|
-
<Sparkles size={20} />
|
|
24
|
-
</div>
|
|
25
|
-
<div className="ai-chat__empty-session-prompts">
|
|
26
|
-
{prompts.map((prompt) => (
|
|
27
|
-
<div
|
|
28
|
-
key={prompt}
|
|
29
|
-
className="ai-chat__empty-session-prompt glassy-border"
|
|
30
|
-
>
|
|
31
|
-
{prompt}
|
|
32
|
-
</div>
|
|
33
|
-
))}
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { ThumbsDown, ThumbsUp } from 'lucide-react';
|
|
3
|
-
import Markdown from 'react-markdown';
|
|
4
|
-
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
5
|
-
import { darcula } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
6
|
-
|
|
7
|
-
export interface ChatMessageProps {
|
|
8
|
-
message: string;
|
|
9
|
-
isUser?: boolean;
|
|
10
|
-
onUseQuery: (query: string) => void;
|
|
11
|
-
onRateMessage: (rating: number) => void;
|
|
12
|
-
}
|
|
13
|
-
export const ChatMessage = ({
|
|
14
|
-
message,
|
|
15
|
-
isUser,
|
|
16
|
-
onUseQuery,
|
|
17
|
-
onRateMessage,
|
|
18
|
-
}: ChatMessageProps) => {
|
|
19
|
-
return (
|
|
20
|
-
<li
|
|
21
|
-
className={classNames({
|
|
22
|
-
'ai-chat__message': true,
|
|
23
|
-
'ai-chat__message--user': isUser,
|
|
24
|
-
'ai-chat__message--assistant': !isUser,
|
|
25
|
-
})}
|
|
26
|
-
>
|
|
27
|
-
{/* <div className="ai-chat__message-avatar">
|
|
28
|
-
<Sparkles size={16} />
|
|
29
|
-
</div> */}
|
|
30
|
-
<div className="ai-chat__message-content">
|
|
31
|
-
<Markdown
|
|
32
|
-
children={message}
|
|
33
|
-
components={{
|
|
34
|
-
code(props) {
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
|
-
const { children, className, node, ref, ...rest } = props;
|
|
37
|
-
const match = /language-(\w+)/.exec(className || '');
|
|
38
|
-
const childrenString = String(children).replace(/\n$/, '');
|
|
39
|
-
return match ? (
|
|
40
|
-
<>
|
|
41
|
-
<SyntaxHighlighter
|
|
42
|
-
{...rest}
|
|
43
|
-
PreTag="div"
|
|
44
|
-
children={childrenString}
|
|
45
|
-
language={match[1]}
|
|
46
|
-
style={darcula}
|
|
47
|
-
/>
|
|
48
|
-
{match[1] === 'graphql' && (
|
|
49
|
-
<button
|
|
50
|
-
className="btn btn--small"
|
|
51
|
-
onClick={() => onUseQuery(childrenString)}
|
|
52
|
-
>
|
|
53
|
-
Use query
|
|
54
|
-
</button>
|
|
55
|
-
)}
|
|
56
|
-
</>
|
|
57
|
-
) : (
|
|
58
|
-
<code ref={ref} {...rest} className={className}>
|
|
59
|
-
{children}
|
|
60
|
-
</code>
|
|
61
|
-
);
|
|
62
|
-
},
|
|
63
|
-
}}
|
|
64
|
-
/>
|
|
65
|
-
</div>
|
|
66
|
-
<div className="ai-chat__message-actions">
|
|
67
|
-
{!isUser && (
|
|
68
|
-
<>
|
|
69
|
-
<button
|
|
70
|
-
className="ai-chat__message-action btn btn--small"
|
|
71
|
-
onClick={() => onRateMessage(1)}
|
|
72
|
-
>
|
|
73
|
-
<ThumbsUp size={8} />
|
|
74
|
-
</button>
|
|
75
|
-
<button
|
|
76
|
-
className="ai-chat__message-action btn btn--small"
|
|
77
|
-
onClick={() => onRateMessage(-1)}
|
|
78
|
-
>
|
|
79
|
-
<ThumbsDown size={8} />
|
|
80
|
-
</button>
|
|
81
|
-
</>
|
|
82
|
-
)}
|
|
83
|
-
</div>
|
|
84
|
-
</li>
|
|
85
|
-
);
|
|
86
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { Spinner } from './Spinner';
|
|
3
|
-
|
|
4
|
-
interface ChatWrapperProps {
|
|
5
|
-
loading: boolean;
|
|
6
|
-
}
|
|
7
|
-
export const ChatWrapper = ({
|
|
8
|
-
children,
|
|
9
|
-
loading,
|
|
10
|
-
}: PropsWithChildren<ChatWrapperProps>) => {
|
|
11
|
-
return (
|
|
12
|
-
<div className="ai-chat-wrapper">
|
|
13
|
-
<div className="ai-chat">
|
|
14
|
-
{loading && (
|
|
15
|
-
<div className="ai-chat__loader">
|
|
16
|
-
<Spinner className="ai-chat__loader__spinner" size={16} />
|
|
17
|
-
</div>
|
|
18
|
-
)}
|
|
19
|
-
{children}
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
};
|