@blueking/ai-ui-sdk 0.0.15-beta.33 → 0.0.15-beta.34
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/component/render-input/index.vue.css +17 -17
- package/dist/component/render-input/index.vue.js +1 -1
- package/dist/component/render-input/render-drag.vue.css +5 -5
- package/dist/component/render-input/render-drag.vue.js +1 -1
- package/dist/component/render-knowledge-icon/index.vue.css +1 -1
- package/dist/component/render-knowledge-icon/index.vue.js +1 -1
- package/dist/component/render-message/openai-message.vue.css +17 -17
- package/dist/component/render-message/openai-message.vue.js +1 -1
- package/dist/component/render-message/skeleton-message.vue.css +1 -1
- package/dist/component/render-message/skeleton-message.vue.js +1 -1
- package/dist/component/render-message/system-message.vue.css +2 -2
- package/dist/component/render-message/system-message.vue.js +1 -1
- package/dist/component/render-message/time-message.vue.css +1 -1
- package/dist/component/render-message/time-message.vue.js +1 -1
- package/dist/component/render-message/token-expired-message.vue.css +9 -9
- package/dist/component/render-message/token-expired-message.vue.js +1 -1
- package/dist/component/render-message/user-message.vue.css +15 -15
- package/dist/component/render-message/user-message.vue.js +1 -1
- package/dist/component/render-stop/index.vue.css +2 -2
- package/dist/component/render-stop/index.vue.js +1 -1
- package/dist/hooks/use-chat.d.ts +4 -3
- package/dist/hooks/use-chat.js +107 -8
- package/dist/http/helper/agent.js +4 -1
- package/dist/http/helper/session.d.ts +10 -0
- package/dist/http/helper/session.js +28 -0
- package/dist/types/agent.d.ts +7 -0
- package/dist/types/session.d.ts +1 -0
- package/package.json +1 -1
@@ -1,30 +1,30 @@
|
|
1
1
|
|
2
|
-
.send-prompt-container[data-v-
|
2
|
+
.send-prompt-container[data-v-63696u6b] {
|
3
3
|
width: 800px;
|
4
4
|
z-index: 1501;
|
5
5
|
overflow: visible;
|
6
6
|
position: relative;
|
7
7
|
}
|
8
|
-
.send-prompt-container[data-v-
|
8
|
+
.send-prompt-container[data-v-63696u6b] .textarea-list {
|
9
9
|
bottom: var(--textarea-bottom);
|
10
10
|
}
|
11
|
-
.send-prompt-container:hover .clear-icon[data-v-
|
11
|
+
.send-prompt-container:hover .clear-icon[data-v-63696u6b] {
|
12
12
|
display: inline-flex !important;
|
13
13
|
}
|
14
|
-
.quill-container[data-v-
|
14
|
+
.quill-container[data-v-63696u6b] {
|
15
15
|
background: #fff;
|
16
16
|
box-shadow: 0 0 6px 0 #0000001a;
|
17
17
|
border-radius: 4px;
|
18
18
|
box-sizing: border-box !important;
|
19
19
|
border: 1px solid transparent;
|
20
20
|
}
|
21
|
-
.quill-container.active[data-v-
|
21
|
+
.quill-container.active[data-v-63696u6b] {
|
22
22
|
border: 1px solid #3A84FF !important;
|
23
23
|
}
|
24
|
-
.quill-container[data-v-
|
24
|
+
.quill-container[data-v-63696u6b]:has(.ql-editor:focus) {
|
25
25
|
border: 1px solid #3A84FF !important;
|
26
26
|
}
|
27
|
-
.send-prompt[data-v-
|
27
|
+
.send-prompt[data-v-63696u6b] {
|
28
28
|
width: 800px;
|
29
29
|
border: 1px solid transparent;
|
30
30
|
flex-direction: row;
|
@@ -34,26 +34,26 @@
|
|
34
34
|
border-radius: 4px;
|
35
35
|
border: 1px solid transparent !important;
|
36
36
|
}
|
37
|
-
.send-prompt[data-v-
|
37
|
+
.send-prompt[data-v-63696u6b] .content-input-wrapper {
|
38
38
|
padding: 0 !important;
|
39
39
|
height: 100% !important;
|
40
40
|
}
|
41
|
-
.send-prompt[data-v-
|
41
|
+
.send-prompt[data-v-63696u6b] .auto-textarea-wrapper {
|
42
42
|
height: 100% !important;
|
43
43
|
}
|
44
|
-
.send-prompt[data-v-
|
44
|
+
.send-prompt[data-v-63696u6b] .v-note-panel {
|
45
45
|
border-radius: 4px;
|
46
46
|
}
|
47
|
-
.send-prompt[data-v-
|
47
|
+
.send-prompt[data-v-63696u6b] .scroll-style {
|
48
48
|
overflow-y: hidden !important;
|
49
49
|
}
|
50
|
-
.send-prompt[data-v-
|
50
|
+
.send-prompt[data-v-63696u6b] .auto-textarea-block {
|
51
51
|
display: none;
|
52
52
|
}
|
53
|
-
.send-prompt[data-v-
|
53
|
+
.send-prompt[data-v-63696u6b]:has(.ql-editor:focus) {
|
54
54
|
height: var(--text-height);
|
55
55
|
}
|
56
|
-
.ai-ui-sdk-fasong[data-v-
|
56
|
+
.ai-ui-sdk-fasong[data-v-63696u6b] {
|
57
57
|
width: 28px;
|
58
58
|
height: 28px;
|
59
59
|
line-height: 28px;
|
@@ -67,15 +67,15 @@
|
|
67
67
|
text-align: center;
|
68
68
|
z-index: 1501;
|
69
69
|
}
|
70
|
-
.ai-ui-sdk-fasong[data-v-
|
70
|
+
.ai-ui-sdk-fasong[data-v-63696u6b]:hover {
|
71
71
|
background: #F0F5FF;
|
72
72
|
color: #3a84ff;
|
73
73
|
}
|
74
|
-
.ai-ui-sdk-fasong.disable[data-v-
|
74
|
+
.ai-ui-sdk-fasong.disable[data-v-63696u6b] {
|
75
75
|
color: #dcdee5;
|
76
76
|
cursor: not-allowed;
|
77
77
|
}
|
78
|
-
.clear-icon[data-v-
|
78
|
+
.clear-icon[data-v-63696u6b] {
|
79
79
|
display: none !important;
|
80
80
|
position: absolute;
|
81
81
|
bottom: 42px;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
.send-tool-container[data-v-
|
2
|
+
.send-tool-container[data-v-s9bt8v6a] {
|
3
3
|
position: absolute;
|
4
4
|
left: 50%;
|
5
5
|
top: 16px;
|
@@ -12,17 +12,17 @@
|
|
12
12
|
cursor: row-resize;
|
13
13
|
z-index: 15001;
|
14
14
|
}
|
15
|
-
.send-tool-container.bottom[data-v-
|
15
|
+
.send-tool-container.bottom[data-v-s9bt8v6a] {
|
16
16
|
bottom: 0;
|
17
17
|
top: auto;
|
18
18
|
}
|
19
|
-
.send-tool-container.bottom .ai-ui-sdk-gengduo[data-v-
|
19
|
+
.send-tool-container.bottom .ai-ui-sdk-gengduo[data-v-s9bt8v6a] {
|
20
20
|
margin-top: -10px;
|
21
21
|
}
|
22
|
-
.send-tool-container[data-v-
|
22
|
+
.send-tool-container[data-v-s9bt8v6a]:hover, .send-tool-container.is-dragging[data-v-s9bt8v6a] {
|
23
23
|
background: #3A84FF;
|
24
24
|
}
|
25
|
-
.send-tool-container .ai-ui-sdk-gengduo[data-v-
|
25
|
+
.send-tool-container .ai-ui-sdk-gengduo[data-v-s9bt8v6a] {
|
26
26
|
margin-top: -2px;
|
27
27
|
color: #63656E;
|
28
28
|
}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
.ai-message-home[data-v-
|
2
|
+
.ai-message-home[data-v-3oevi9zb] {
|
3
3
|
justify-content: center;
|
4
4
|
align-items: flex-start;
|
5
5
|
width: 100%;
|
6
6
|
}
|
7
|
-
.ai-content[data-v-
|
7
|
+
.ai-content[data-v-3oevi9zb] {
|
8
8
|
flex: 1;
|
9
9
|
max-width: calc(100% - 104px);
|
10
10
|
background: #FFFFFF;
|
@@ -17,26 +17,26 @@
|
|
17
17
|
padding-top: 12px;
|
18
18
|
margin-right: 52px;
|
19
19
|
}
|
20
|
-
.ai-content .ai-ui-sdk-warning-circle-fill[data-v-
|
20
|
+
.ai-content .ai-ui-sdk-warning-circle-fill[data-v-3oevi9zb] {
|
21
21
|
color: #EA3636;
|
22
22
|
font-size: 18px;
|
23
23
|
margin-right: 2px;
|
24
24
|
}
|
25
|
-
.ai-content .ai-ui-sdk-quanquan[data-v-
|
25
|
+
.ai-content .ai-ui-sdk-quanquan[data-v-3oevi9zb] {
|
26
26
|
display: inline-block;
|
27
27
|
color: #3A84FF;
|
28
|
-
animation: rotate-
|
28
|
+
animation: rotate-3oevi9zb 800ms linear infinite;
|
29
29
|
position: absolute;
|
30
30
|
left: 7px;
|
31
31
|
top: 23px;
|
32
32
|
z-index: 1501;
|
33
33
|
}
|
34
|
-
.ai-content .message-check[data-v-
|
34
|
+
.ai-content .message-check[data-v-3oevi9zb] {
|
35
35
|
position: absolute;
|
36
36
|
top: 0;
|
37
37
|
left: -80px;
|
38
38
|
}
|
39
|
-
.ai-content[data-v-
|
39
|
+
.ai-content[data-v-3oevi9zb]::before {
|
40
40
|
position: absolute;
|
41
41
|
content: '';
|
42
42
|
width: 15px;
|
@@ -46,47 +46,47 @@
|
|
46
46
|
rotate: 45deg;
|
47
47
|
background: #FFFFFF;
|
48
48
|
}
|
49
|
-
.ai-content.fail[data-v-
|
49
|
+
.ai-content.fail[data-v-3oevi9zb] {
|
50
50
|
padding: 12px;
|
51
51
|
word-break: break-all;
|
52
52
|
}
|
53
|
-
.ai-content.loading[data-v-
|
53
|
+
.ai-content.loading[data-v-3oevi9zb] {
|
54
54
|
padding: 12px 0;
|
55
55
|
word-break: break-all;
|
56
56
|
}
|
57
|
-
.skeleton-message[data-v-
|
57
|
+
.skeleton-message[data-v-3oevi9zb] {
|
58
58
|
margin-right: 52px;
|
59
59
|
}
|
60
|
-
.message-photo[data-v-
|
60
|
+
.message-photo[data-v-3oevi9zb] {
|
61
61
|
width: 52px;
|
62
62
|
text-align: right;
|
63
63
|
user-select: none;
|
64
64
|
}
|
65
|
-
.message-photo img[data-v-
|
65
|
+
.message-photo img[data-v-3oevi9zb] {
|
66
66
|
margin-right: 16px;
|
67
67
|
margin-top: 5px;
|
68
68
|
width: 36px;
|
69
69
|
height: 36px;
|
70
70
|
}
|
71
|
-
.message-tools[data-v-
|
71
|
+
.message-tools[data-v-3oevi9zb] {
|
72
72
|
margin: 12px 12px 12px;
|
73
73
|
padding-top: 10px;
|
74
74
|
justify-content: space-between;
|
75
75
|
border-top: 1px solid #EAEBF0;
|
76
76
|
}
|
77
|
-
.message-tools .rate-tip[data-v-
|
77
|
+
.message-tools .rate-tip[data-v-3oevi9zb] {
|
78
78
|
font-size: 12px;
|
79
79
|
color: #979BA5;
|
80
80
|
margin-left: 7px;
|
81
81
|
}
|
82
|
-
.message-tools .tool-icons .ai-ui-sdk-icon[data-v-
|
82
|
+
.message-tools .tool-icons .ai-ui-sdk-icon[data-v-3oevi9zb] {
|
83
83
|
cursor: pointer;
|
84
84
|
color: #979BA5;
|
85
85
|
}
|
86
|
-
.message-tools .tool-icons .ai-ui-sdk-icon[data-v-
|
86
|
+
.message-tools .tool-icons .ai-ui-sdk-icon[data-v-3oevi9zb]:hover {
|
87
87
|
color: #3A84FF;
|
88
88
|
}
|
89
|
-
@keyframes rotate-
|
89
|
+
@keyframes rotate-3oevi9zb {
|
90
90
|
0% {
|
91
91
|
transform: rotate(0);
|
92
92
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { render } from './skeleton-message.script.vue.js';
|
2
2
|
const script = { render };
|
3
|
-
script.__scopeId = "data-v-
|
3
|
+
script.__scopeId = "data-v-qhdze8yv";
|
4
4
|
script.__file = "./src/component/render-message/skeleton-message.vue";
|
5
5
|
import './skeleton-message.vue.css';
|
6
6
|
export default script;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
.system-message[data-v-
|
2
|
+
.system-message[data-v-o7joi5rs] {
|
3
3
|
position: relative;
|
4
4
|
width: calc(100% - 204px) !important;
|
5
5
|
max-width: 800px !important;
|
@@ -7,7 +7,7 @@
|
|
7
7
|
border-bottom: 1px dashed #DCDEE5;
|
8
8
|
margin: 24px 0 40px !important;
|
9
9
|
}
|
10
|
-
.system-message span[data-v-
|
10
|
+
.system-message span[data-v-o7joi5rs] {
|
11
11
|
position: absolute;
|
12
12
|
left: 50%;
|
13
13
|
top: 50%;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
.ai-message-home[data-v-
|
2
|
+
.ai-message-home[data-v-hczs7uy1] {
|
3
3
|
justify-content: center;
|
4
4
|
align-items: flex-start;
|
5
5
|
width: 100%;
|
6
6
|
}
|
7
|
-
.ai-content[data-v-
|
7
|
+
.ai-content[data-v-hczs7uy1] {
|
8
8
|
flex: 1;
|
9
9
|
background: #FFFFFF;
|
10
10
|
line-height: 22px;
|
@@ -16,17 +16,17 @@
|
|
16
16
|
padding-top: 12px;
|
17
17
|
margin-right: 52px;
|
18
18
|
}
|
19
|
-
.ai-content .ai-ui-sdk-warning-circle-fill[data-v-
|
19
|
+
.ai-content .ai-ui-sdk-warning-circle-fill[data-v-hczs7uy1] {
|
20
20
|
color: #EA3636;
|
21
21
|
font-size: 18px;
|
22
22
|
margin-right: 2px;
|
23
23
|
}
|
24
|
-
.ai-content .message-check[data-v-
|
24
|
+
.ai-content .message-check[data-v-hczs7uy1] {
|
25
25
|
position: absolute;
|
26
26
|
top: 0;
|
27
27
|
left: -80px;
|
28
28
|
}
|
29
|
-
.ai-content[data-v-
|
29
|
+
.ai-content[data-v-hczs7uy1]::before {
|
30
30
|
position: absolute;
|
31
31
|
content: '';
|
32
32
|
width: 15px;
|
@@ -36,21 +36,21 @@
|
|
36
36
|
rotate: 45deg;
|
37
37
|
background: #FFFFFF;
|
38
38
|
}
|
39
|
-
.ai-content.fail[data-v-
|
39
|
+
.ai-content.fail[data-v-hczs7uy1] {
|
40
40
|
padding: 12px;
|
41
41
|
}
|
42
|
-
.message-photo[data-v-
|
42
|
+
.message-photo[data-v-hczs7uy1] {
|
43
43
|
width: 52px;
|
44
44
|
text-align: right;
|
45
45
|
user-select: none;
|
46
46
|
}
|
47
|
-
.message-photo img[data-v-
|
47
|
+
.message-photo img[data-v-hczs7uy1] {
|
48
48
|
margin-right: 16px;
|
49
49
|
margin-top: 5px;
|
50
50
|
width: 36px;
|
51
51
|
height: 36px;
|
52
52
|
}
|
53
|
-
.clear-message[data-v-
|
53
|
+
.clear-message[data-v-hczs7uy1] {
|
54
54
|
color: #3a84ff;
|
55
55
|
cursor: pointer;
|
56
56
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import script from './token-expired-message.script.vue.js';
|
2
|
-
script.__scopeId = "data-v-
|
2
|
+
script.__scopeId = "data-v-hczs7uy1";
|
3
3
|
script.__file = "./src/component/render-message/token-expired-message.vue";
|
4
4
|
import './token-expired-message.vue.css';
|
5
5
|
export default script;
|
@@ -1,20 +1,20 @@
|
|
1
1
|
|
2
|
-
.user-message-home[data-v-
|
2
|
+
.user-message-home[data-v-8b1soh8y] {
|
3
3
|
align-items: flex-start;
|
4
4
|
justify-content: flex-end;
|
5
5
|
}
|
6
|
-
.user-message-extra[data-v-
|
6
|
+
.user-message-extra[data-v-8b1soh8y] {
|
7
7
|
padding: 0 52px;
|
8
8
|
}
|
9
|
-
.user-message-extra[data-v-
|
9
|
+
.user-message-extra[data-v-8b1soh8y]:after {
|
10
10
|
content: '';
|
11
11
|
display: table;
|
12
12
|
clear: both;
|
13
13
|
}
|
14
|
-
.user-message-extra .ai-ui-sdk-icon[data-v-
|
14
|
+
.user-message-extra .ai-ui-sdk-icon[data-v-8b1soh8y] {
|
15
15
|
font-size: 14px;
|
16
16
|
}
|
17
|
-
.user-content[data-v-
|
17
|
+
.user-content[data-v-8b1soh8y] {
|
18
18
|
flex: 1;
|
19
19
|
max-width: calc(100% - 104px);
|
20
20
|
background: #E1ECFF;
|
@@ -26,7 +26,7 @@
|
|
26
26
|
position: relative;
|
27
27
|
margin-left: 52px;
|
28
28
|
}
|
29
|
-
.user-content .ai-ui-sdk-icon[data-v-
|
29
|
+
.user-content .ai-ui-sdk-icon[data-v-8b1soh8y] {
|
30
30
|
width: 28px;
|
31
31
|
height: 28px;
|
32
32
|
background: #FFFFFF;
|
@@ -41,17 +41,17 @@
|
|
41
41
|
margin-right: 8px;
|
42
42
|
margin-top: 8px;
|
43
43
|
}
|
44
|
-
.user-content .ai-ui-sdk-icon.hover-show[data-v-
|
44
|
+
.user-content .ai-ui-sdk-icon.hover-show[data-v-8b1soh8y] {
|
45
45
|
display: none;
|
46
46
|
}
|
47
|
-
.user-content .ai-ui-sdk-icon.ai-ui-sdk-yinyong-2[data-v-
|
47
|
+
.user-content .ai-ui-sdk-icon.ai-ui-sdk-yinyong-2[data-v-8b1soh8y]:hover, .user-content .ai-ui-sdk-icon.ai-ui-sdk-copy[data-v-8b1soh8y]:hover, .user-content .ai-ui-sdk-icon.ai-ui-sdk-baocun[data-v-8b1soh8y]:hover, .user-content .ai-ui-sdk-icon.ai-ui-sdk-delete[data-v-8b1soh8y]:hover {
|
48
48
|
color: #3A84FF;
|
49
49
|
border-color: #3A84FF;
|
50
50
|
}
|
51
|
-
.user-content:hover .hover-show[data-v-
|
51
|
+
.user-content:hover .hover-show[data-v-8b1soh8y] {
|
52
52
|
display: flex;
|
53
53
|
}
|
54
|
-
.user-content[data-v-
|
54
|
+
.user-content[data-v-8b1soh8y]::after {
|
55
55
|
position: absolute;
|
56
56
|
content: '';
|
57
57
|
width: 15px;
|
@@ -61,23 +61,23 @@
|
|
61
61
|
rotate: 45deg;
|
62
62
|
background: #E1ECFF;
|
63
63
|
}
|
64
|
-
.message-tools[data-v-
|
64
|
+
.message-tools[data-v-8b1soh8y] {
|
65
65
|
justify-content: flex-end;
|
66
66
|
position: absolute;
|
67
67
|
width: 150px;
|
68
68
|
left: -150px;
|
69
69
|
top: 2px;
|
70
70
|
}
|
71
|
-
.message-check[data-v-
|
71
|
+
.message-check[data-v-8b1soh8y] {
|
72
72
|
position: absolute;
|
73
73
|
top: 0;
|
74
74
|
left: -80px;
|
75
75
|
}
|
76
|
-
.message-photo[data-v-
|
76
|
+
.message-photo[data-v-8b1soh8y] {
|
77
77
|
width: 52px;
|
78
78
|
user-select: none;
|
79
79
|
}
|
80
|
-
.message-photo img[data-v-
|
80
|
+
.message-photo img[data-v-8b1soh8y] {
|
81
81
|
margin-left: 16px;
|
82
82
|
margin-top: 5px;
|
83
83
|
width: 36px;
|
@@ -85,6 +85,6 @@
|
|
85
85
|
border: 1px solid #DCDEE5;
|
86
86
|
border-radius: 100%;
|
87
87
|
}
|
88
|
-
.skeleton-message[data-v-
|
88
|
+
.skeleton-message[data-v-8b1soh8y] {
|
89
89
|
margin-left: 52px;
|
90
90
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
.render-stop[data-v-
|
2
|
+
.render-stop[data-v-nszddjty] {
|
3
3
|
background: #FFFFFF;
|
4
4
|
border: 1px solid #DCDEE5;
|
5
5
|
border-radius: 2px;
|
@@ -8,7 +8,7 @@
|
|
8
8
|
font-size: 12px;
|
9
9
|
cursor: pointer;
|
10
10
|
}
|
11
|
-
.render-stop .stop-icon[data-v-
|
11
|
+
.render-stop .stop-icon[data-v-nszddjty] {
|
12
12
|
width: 8px;
|
13
13
|
height: 8px;
|
14
14
|
background: #FFDDDD;
|
package/dist/hooks/use-chat.d.ts
CHANGED
@@ -6,7 +6,7 @@ type SessionContentsMap = {
|
|
6
6
|
type SessionLoadingMap = {
|
7
7
|
[key: string]: boolean;
|
8
8
|
};
|
9
|
-
export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, requestOptions, }: ChatCallbacks<ISessionContent>) => {
|
9
|
+
export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, scrollElement, requestOptions, }: ChatCallbacks<ISessionContent>) => {
|
10
10
|
currentSession: import("vue").Ref<ISession | undefined, ISession | undefined>;
|
11
11
|
sessionContents: import("vue").Ref<{
|
12
12
|
id?: number | undefined;
|
@@ -829,7 +829,7 @@ export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, ha
|
|
829
829
|
currentSessionLoading: import("vue").ComputedRef<boolean>;
|
830
830
|
chat: ({ sessionCode, data, headers, }: {
|
831
831
|
sessionCode: string;
|
832
|
-
data?: Record<string,
|
832
|
+
data?: Record<string, unknown>;
|
833
833
|
headers?: Record<string, string>;
|
834
834
|
}) => void;
|
835
835
|
sendChat: (content: BasicChatContent | ShortcutChatContent, callback?: () => void) => void;
|
@@ -844,7 +844,8 @@ export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, ha
|
|
844
844
|
deleteSessionContent: (sessionCode: string, contentId: number) => Promise<number>;
|
845
845
|
deleteSessionContents: (sessionCode: string, contentIds: number[]) => Promise<number>;
|
846
846
|
handleStartChat: (sessionCode: string) => Promise<void | undefined>;
|
847
|
-
handleErrorChat: (sessionCode: string, message: string, code?: string) => Promise<void
|
847
|
+
handleErrorChat: (sessionCode: string, message: string, code?: string) => Promise<void>;
|
848
|
+
handleCompleteRole: (sessionCode: string, prompts: ISessionPrompt[]) => Promise<void>;
|
848
849
|
reGenerateChat: (sessionCode: string, sessionContent: ISessionContent, sessionIndex: number) => void;
|
849
850
|
reSendChat: (sessionCode: string, sessionContent: ISessionContent, sessionIndex: number) => Promise<void>;
|
850
851
|
deleteChat: (index: number, sessionCode: string) => void;
|
package/dist/hooks/use-chat.js
CHANGED
@@ -55,16 +55,40 @@ function _object_spread(target) {
|
|
55
55
|
}
|
56
56
|
return target;
|
57
57
|
}
|
58
|
-
|
58
|
+
function ownKeys(object, enumerableOnly) {
|
59
|
+
var keys = Object.keys(object);
|
60
|
+
if (Object.getOwnPropertySymbols) {
|
61
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
62
|
+
if (enumerableOnly) {
|
63
|
+
symbols = symbols.filter(function(sym) {
|
64
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
65
|
+
});
|
66
|
+
}
|
67
|
+
keys.push.apply(keys, symbols);
|
68
|
+
}
|
69
|
+
return keys;
|
70
|
+
}
|
71
|
+
function _object_spread_props(target, source) {
|
72
|
+
source = source != null ? source : {};
|
73
|
+
if (Object.getOwnPropertyDescriptors) {
|
74
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
75
|
+
} else {
|
76
|
+
ownKeys(Object(source)).forEach(function(key) {
|
77
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
78
|
+
});
|
79
|
+
}
|
80
|
+
return target;
|
81
|
+
}
|
82
|
+
import { ref, computed, nextTick } from 'vue';
|
59
83
|
import { HttpErrorCode, SessionContentRole, SessionContentStatus } from '../types/enum.js';
|
60
84
|
import { getHtmlContentFromDocuments, removeReferenceDoc } from './use-reference-doc.js';
|
61
85
|
import { getHtmlContentFromThink, isThinking, removeThink } from './use-think.js';
|
62
86
|
import { useHttp } from './use-http.js';
|
63
|
-
import { transferSessionContent2SessionPrompt } from '../http/helper/session.js';
|
87
|
+
import { transferSessionContent2SessionPrompt, transferSessionPrompt2SessionContent } from '../http/helper/session.js';
|
64
88
|
import { ChatHelper } from '../common/chart-helper.js';
|
65
89
|
import { processPromptTemplate, throttle } from '../common/util.js';
|
66
90
|
// ai 聊天
|
67
|
-
export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, requestOptions })=>{
|
91
|
+
export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, scrollElement, requestOptions })=>{
|
68
92
|
// 用 ref 存储 requestOptions,使其可更新
|
69
93
|
const currentRequestOptions = ref(requestOptions);
|
70
94
|
// 创建一个变量保存当前的API实现
|
@@ -84,6 +108,7 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
84
108
|
const sessionLoadingMap = ref({});
|
85
109
|
const sessionContents = ref([]);
|
86
110
|
const sessionContentsMap = {};
|
111
|
+
const sessionWaitingPromptsMap = {};
|
87
112
|
// 通过计算得到的会话列表
|
88
113
|
const calculatedSessionContents = computed(()=>{
|
89
114
|
const calculatedSessionContents = [];
|
@@ -197,6 +222,38 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
197
222
|
handleEnd: handleEndChat,
|
198
223
|
handleError: handleErrorChat
|
199
224
|
});
|
225
|
+
// 滚动到最底部
|
226
|
+
// 聊天滚动到底部
|
227
|
+
function scrollToBottom(sessionCode) {
|
228
|
+
var _currentSession_value;
|
229
|
+
if (((_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : _currentSession_value.sessionCode) !== sessionCode) return;
|
230
|
+
nextTick(()=>{
|
231
|
+
// 文本本身
|
232
|
+
const ele = document.querySelector(scrollElement) || {
|
233
|
+
scrollTop: 0,
|
234
|
+
scrollHeight: 0
|
235
|
+
};
|
236
|
+
if (ele.scrollHeight > ele.scrollTop) {
|
237
|
+
ele.scrollTop = ele.scrollHeight;
|
238
|
+
}
|
239
|
+
});
|
240
|
+
nextTick(()=>{
|
241
|
+
// 代码块也需要滚动到底部
|
242
|
+
const codeElements = document.querySelectorAll('.markdown-body pre');
|
243
|
+
codeElements.forEach((codeElement)=>{
|
244
|
+
if (codeElement.scrollHeight > codeElement.scrollTop) {
|
245
|
+
codeElement.scrollTop = codeElement.scrollHeight;
|
246
|
+
}
|
247
|
+
});
|
248
|
+
});
|
249
|
+
}
|
250
|
+
function scrollToBottomIfAtBottom(sessionCode) {
|
251
|
+
// 如果滚动条在底部,则继续滚动
|
252
|
+
const scrollEle = document.querySelector(scrollElement);
|
253
|
+
if (scrollEle && scrollEle.scrollTop + scrollEle.clientHeight + 10 >= scrollEle.scrollHeight) {
|
254
|
+
scrollToBottom(sessionCode);
|
255
|
+
}
|
256
|
+
}
|
200
257
|
// 新增 db
|
201
258
|
function plusSessionContent2Db(sessionContent) {
|
202
259
|
return apiImpl.plusSessionContent(sessionContent).then((result)=>{
|
@@ -248,6 +305,7 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
248
305
|
function plusSessionContent(sessionCode, sessionContent) {
|
249
306
|
const sessionContents = getSessionContentsBySessionCode(sessionCode);
|
250
307
|
sessionContents.push(sessionContent);
|
308
|
+
scrollToBottom(sessionCode);
|
251
309
|
return plusSessionContent2Db(sessionContent);
|
252
310
|
}
|
253
311
|
// 更新 chatContent
|
@@ -348,7 +406,8 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
348
406
|
const content = getHtmlContentFromDocuments(documents);
|
349
407
|
sessionContent.content = cover ? content : sessionContent.content + content;
|
350
408
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
351
|
-
|
409
|
+
yield handleReferenceDoc === null || handleReferenceDoc === void 0 ? void 0 : handleReferenceDoc(sessionCode, sessionContent);
|
410
|
+
scrollToBottomIfAtBottom(sessionCode);
|
352
411
|
});
|
353
412
|
return _handleReferenceDocChat.apply(this, arguments);
|
354
413
|
}
|
@@ -364,7 +423,8 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
364
423
|
// 更新 db
|
365
424
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
366
425
|
// 调用cb
|
367
|
-
|
426
|
+
yield handleThink === null || handleThink === void 0 ? void 0 : handleThink(sessionCode, sessionContent);
|
427
|
+
scrollToBottomIfAtBottom(sessionCode);
|
368
428
|
});
|
369
429
|
return _handleThinkChat.apply(this, arguments);
|
370
430
|
}
|
@@ -385,7 +445,8 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
385
445
|
// 更新 db
|
386
446
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
387
447
|
// 调用cb
|
388
|
-
|
448
|
+
yield handleText === null || handleText === void 0 ? void 0 : handleText(sessionCode, sessionContent);
|
449
|
+
scrollToBottomIfAtBottom(sessionCode);
|
389
450
|
});
|
390
451
|
return _handleTextChat.apply(this, arguments);
|
391
452
|
}
|
@@ -413,7 +474,8 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
413
474
|
// 更新 db
|
414
475
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
415
476
|
// 调用cb
|
416
|
-
|
477
|
+
yield handleEnd === null || handleEnd === void 0 ? void 0 : handleEnd(sessionCode, sessionContent);
|
478
|
+
scrollToBottomIfAtBottom(sessionCode);
|
417
479
|
}
|
418
480
|
});
|
419
481
|
return _handleEndChat.apply(this, arguments);
|
@@ -440,10 +502,37 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
440
502
|
// 更新 db
|
441
503
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
442
504
|
// 调用cb
|
443
|
-
|
505
|
+
yield handleError === null || handleError === void 0 ? void 0 : handleError(sessionCode, sessionContent, code);
|
506
|
+
scrollToBottomIfAtBottom(sessionCode);
|
444
507
|
});
|
445
508
|
return _handleErrorChat.apply(this, arguments);
|
446
509
|
}
|
510
|
+
function handleCompleteRole(sessionCode, prompts) {
|
511
|
+
return _handleCompleteRole.apply(this, arguments);
|
512
|
+
}
|
513
|
+
function _handleCompleteRole() {
|
514
|
+
_handleCompleteRole = // 完成角色演绎
|
515
|
+
_async_to_generator(function*(sessionCode, prompts) {
|
516
|
+
let isPaused = false;
|
517
|
+
sessionWaitingPromptsMap[sessionCode] = [];
|
518
|
+
for (const prompt of prompts){
|
519
|
+
if (isPaused) {
|
520
|
+
sessionWaitingPromptsMap[sessionCode].push(prompt);
|
521
|
+
} else {
|
522
|
+
const sessionContent = _object_spread_props(_object_spread({}, transferSessionPrompt2SessionContent(prompt)), {
|
523
|
+
sessionCode,
|
524
|
+
status: SessionContentStatus.Success
|
525
|
+
});
|
526
|
+
yield plusSessionContent(sessionCode, sessionContent);
|
527
|
+
// 遇到 pause 就暂停
|
528
|
+
if (sessionContent.role === SessionContentRole.Pause) {
|
529
|
+
isPaused = true;
|
530
|
+
}
|
531
|
+
}
|
532
|
+
}
|
533
|
+
});
|
534
|
+
return _handleCompleteRole.apply(this, arguments);
|
535
|
+
}
|
447
536
|
// 重新生成对话 仅支持重新生成 ai 的回复
|
448
537
|
function reGenerateChat(sessionCode, sessionContent, sessionIndex) {
|
449
538
|
if (sessionContent.role !== SessionContentRole.Ai) {
|
@@ -459,6 +548,15 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
459
548
|
}
|
460
549
|
// 聊天
|
461
550
|
function chat({ sessionCode, data, headers }) {
|
551
|
+
const sessionWaitingPrompts = sessionWaitingPromptsMap[sessionCode];
|
552
|
+
if ((sessionWaitingPrompts === null || sessionWaitingPrompts === void 0 ? void 0 : sessionWaitingPrompts.length) > 0) {
|
553
|
+
handleCompleteRole(sessionCode, sessionWaitingPrompts);
|
554
|
+
} else {
|
555
|
+
streamChat(sessionCode, data, headers);
|
556
|
+
}
|
557
|
+
}
|
558
|
+
// stream 聊天
|
559
|
+
function streamChat(sessionCode, data, headers) {
|
462
560
|
var _currentRequestOptions_value;
|
463
561
|
const sessionContent = getLastSessionContentBySessionCode(sessionCode);
|
464
562
|
// 发送请求
|
@@ -580,6 +678,7 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
580
678
|
deleteSessionContents,
|
581
679
|
handleStartChat,
|
582
680
|
handleErrorChat,
|
681
|
+
handleCompleteRole,
|
583
682
|
reGenerateChat,
|
584
683
|
reSendChat,
|
585
684
|
deleteChat,
|
@@ -3,11 +3,14 @@
|
|
3
3
|
* @param data IAgentInfoApi
|
4
4
|
* @returns IAgentInfo
|
5
5
|
*/ export const transferAgentInfoApi2AgentInfo = (data)=>{
|
6
|
-
var _data_conversation_settings, _data_conversation_settings1;
|
6
|
+
var _data_conversation_settings, _data_conversation_settings1, _data_prompt_setting;
|
7
7
|
return {
|
8
8
|
conversationSettings: {
|
9
9
|
openingRemark: data === null || data === void 0 ? void 0 : (_data_conversation_settings = data.conversation_settings) === null || _data_conversation_settings === void 0 ? void 0 : _data_conversation_settings.opening_remark,
|
10
10
|
predefinedQuestions: data === null || data === void 0 ? void 0 : (_data_conversation_settings1 = data.conversation_settings) === null || _data_conversation_settings1 === void 0 ? void 0 : _data_conversation_settings1.predefined_questions
|
11
|
+
},
|
12
|
+
promptSetting: {
|
13
|
+
content: data === null || data === void 0 ? void 0 : (_data_prompt_setting = data.prompt_setting) === null || _data_prompt_setting === void 0 ? void 0 : _data_prompt_setting.content
|
11
14
|
}
|
12
15
|
};
|
13
16
|
};
|
@@ -1,10 +1,20 @@
|
|
1
1
|
import type { ISession, ISessionApi, ISessionContent, ISessionContentApi, ISessionPrompt } from '@/types/session';
|
2
|
+
import { SessionContentRole } from '@/types/enum';
|
2
3
|
/**
|
3
4
|
* 将 sessionContent 转换为 sessionPrompt
|
4
5
|
* @param sessionContent sessionContent
|
5
6
|
* @returns sessionPrompt
|
6
7
|
*/
|
7
8
|
export declare const transferSessionContent2SessionPrompt: (sessionContent: ISessionContent) => ISessionPrompt;
|
9
|
+
/**
|
10
|
+
* 将前端使用的 session 提示数据转换为前端使用的 session 内容数据
|
11
|
+
* @param prompt 前端使用的 session 提示数据
|
12
|
+
* @returns 前端使用的 session 内容数据
|
13
|
+
*/
|
14
|
+
export declare const transferSessionPrompt2SessionContent: (prompt: ISessionPrompt) => {
|
15
|
+
role: SessionContentRole;
|
16
|
+
content: string;
|
17
|
+
};
|
8
18
|
/**
|
9
19
|
* 将 API 返回的 session 数据转换为前端使用的 session 数据
|
10
20
|
* @param data API 返回的 session 数据
|
@@ -33,6 +33,34 @@ import { SessionContentRole, SessionPromptRole } from '../../types/enum.js';
|
|
33
33
|
role: sessionRoleMap[sessionContent.role]
|
34
34
|
};
|
35
35
|
};
|
36
|
+
/**
|
37
|
+
* 将前端使用的 session 提示数据转换为前端使用的 session 内容数据
|
38
|
+
* @param prompt 前端使用的 session 提示数据
|
39
|
+
* @returns 前端使用的 session 内容数据
|
40
|
+
*/ export const transferSessionPrompt2SessionContent = (prompt)=>{
|
41
|
+
const sessionRoleMap = {
|
42
|
+
[SessionPromptRole.Assistant]: SessionContentRole.Ai,
|
43
|
+
[SessionPromptRole.User]: SessionContentRole.User,
|
44
|
+
[SessionPromptRole.System]: SessionContentRole.Role,
|
45
|
+
[SessionPromptRole.Hidden]: SessionContentRole.Hidden,
|
46
|
+
[SessionPromptRole.Guide]: SessionContentRole.Guide,
|
47
|
+
[SessionPromptRole.HiddenAssistant]: SessionContentRole.HiddenAi,
|
48
|
+
[SessionPromptRole.HiddenGuide]: SessionContentRole.HiddenGuide,
|
49
|
+
[SessionPromptRole.HiddenSystem]: SessionContentRole.HiddenRole,
|
50
|
+
[SessionPromptRole.HiddenUser]: SessionContentRole.HiddenUser,
|
51
|
+
[SessionPromptRole.TemplateAssistant]: SessionContentRole.TemplateAi,
|
52
|
+
[SessionPromptRole.TemplateGuide]: SessionContentRole.TemplateGuide,
|
53
|
+
[SessionPromptRole.TemplateSystem]: SessionContentRole.TemplateRole,
|
54
|
+
[SessionPromptRole.TemplateUser]: SessionContentRole.TemplateUser,
|
55
|
+
[SessionPromptRole.TemplateHidden]: SessionContentRole.TemplateHidden,
|
56
|
+
[SessionPromptRole.Pause]: SessionContentRole.Pause,
|
57
|
+
[SessionPromptRole.UserImage]: SessionContentRole.UserImage
|
58
|
+
};
|
59
|
+
return {
|
60
|
+
content: prompt.content,
|
61
|
+
role: sessionRoleMap[prompt.role]
|
62
|
+
};
|
63
|
+
};
|
36
64
|
/**
|
37
65
|
* 将 API 返回的 session 数据转换为前端使用的 session 数据
|
38
66
|
* @param data API 返回的 session 数据
|
package/dist/types/agent.d.ts
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
+
import type { ISessionPrompt } from '@/types/session';
|
1
2
|
export interface IAgentInfoApi {
|
2
3
|
conversation_settings?: {
|
3
4
|
opening_remark?: string;
|
4
5
|
predefined_questions?: string[];
|
5
6
|
};
|
7
|
+
prompt_setting?: {
|
8
|
+
content?: ISessionPrompt[];
|
9
|
+
};
|
6
10
|
}
|
7
11
|
export interface IAgentInfo {
|
8
12
|
conversationSettings?: {
|
9
13
|
openingRemark?: string;
|
10
14
|
predefinedQuestions?: string[];
|
11
15
|
};
|
16
|
+
promptSetting?: {
|
17
|
+
content?: ISessionPrompt[];
|
18
|
+
};
|
12
19
|
}
|
package/dist/types/session.d.ts
CHANGED
@@ -117,6 +117,7 @@ export interface ChatCallbacks<T extends ISessionContent = ISessionContent> {
|
|
117
117
|
handleThink?: (sessionCode: string, sessionContent: T) => void;
|
118
118
|
handleEnd?: (sessionCode: string, sessionContent: T) => void;
|
119
119
|
handleError?: (sessionCode: string, sessionContent: T, code: string | undefined) => void;
|
120
|
+
scrollElement: string;
|
120
121
|
requestOptions: {
|
121
122
|
url: string;
|
122
123
|
headers?: Record<string, string>;
|