@blueking/ai-ui-sdk 0.0.15-beta.34 → 0.0.15-beta.35
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 +2 -3
- package/dist/hooks/use-chat.js +3 -76
- package/dist/types/session.d.ts +0 -1
- package/package.json +1 -1
@@ -1,30 +1,30 @@
|
|
1
1
|
|
2
|
-
.send-prompt-container[data-v-
|
2
|
+
.send-prompt-container[data-v-ets338ln] {
|
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-ets338ln] .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-ets338ln] {
|
12
12
|
display: inline-flex !important;
|
13
13
|
}
|
14
|
-
.quill-container[data-v-
|
14
|
+
.quill-container[data-v-ets338ln] {
|
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-ets338ln] {
|
22
22
|
border: 1px solid #3A84FF !important;
|
23
23
|
}
|
24
|
-
.quill-container[data-v-
|
24
|
+
.quill-container[data-v-ets338ln]:has(.ql-editor:focus) {
|
25
25
|
border: 1px solid #3A84FF !important;
|
26
26
|
}
|
27
|
-
.send-prompt[data-v-
|
27
|
+
.send-prompt[data-v-ets338ln] {
|
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-ets338ln] .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-ets338ln] .auto-textarea-wrapper {
|
42
42
|
height: 100% !important;
|
43
43
|
}
|
44
|
-
.send-prompt[data-v-
|
44
|
+
.send-prompt[data-v-ets338ln] .v-note-panel {
|
45
45
|
border-radius: 4px;
|
46
46
|
}
|
47
|
-
.send-prompt[data-v-
|
47
|
+
.send-prompt[data-v-ets338ln] .scroll-style {
|
48
48
|
overflow-y: hidden !important;
|
49
49
|
}
|
50
|
-
.send-prompt[data-v-
|
50
|
+
.send-prompt[data-v-ets338ln] .auto-textarea-block {
|
51
51
|
display: none;
|
52
52
|
}
|
53
|
-
.send-prompt[data-v-
|
53
|
+
.send-prompt[data-v-ets338ln]: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-ets338ln] {
|
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-ets338ln]: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-ets338ln] {
|
75
75
|
color: #dcdee5;
|
76
76
|
cursor: not-allowed;
|
77
77
|
}
|
78
|
-
.clear-icon[data-v-
|
78
|
+
.clear-icon[data-v-ets338ln] {
|
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-blqgotpc] {
|
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-blqgotpc] {
|
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-blqgotpc] {
|
20
20
|
margin-top: -10px;
|
21
21
|
}
|
22
|
-
.send-tool-container[data-v-
|
22
|
+
.send-tool-container[data-v-blqgotpc]:hover, .send-tool-container.is-dragging[data-v-blqgotpc] {
|
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-blqgotpc] {
|
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-0x5i8c58] {
|
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-0x5i8c58] {
|
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-0x5i8c58] {
|
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-0x5i8c58] {
|
26
26
|
display: inline-block;
|
27
27
|
color: #3A84FF;
|
28
|
-
animation: rotate-
|
28
|
+
animation: rotate-0x5i8c58 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-0x5i8c58] {
|
35
35
|
position: absolute;
|
36
36
|
top: 0;
|
37
37
|
left: -80px;
|
38
38
|
}
|
39
|
-
.ai-content[data-v-
|
39
|
+
.ai-content[data-v-0x5i8c58]::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-0x5i8c58] {
|
50
50
|
padding: 12px;
|
51
51
|
word-break: break-all;
|
52
52
|
}
|
53
|
-
.ai-content.loading[data-v-
|
53
|
+
.ai-content.loading[data-v-0x5i8c58] {
|
54
54
|
padding: 12px 0;
|
55
55
|
word-break: break-all;
|
56
56
|
}
|
57
|
-
.skeleton-message[data-v-
|
57
|
+
.skeleton-message[data-v-0x5i8c58] {
|
58
58
|
margin-right: 52px;
|
59
59
|
}
|
60
|
-
.message-photo[data-v-
|
60
|
+
.message-photo[data-v-0x5i8c58] {
|
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-0x5i8c58] {
|
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-0x5i8c58] {
|
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-0x5i8c58] {
|
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-0x5i8c58] {
|
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-0x5i8c58]:hover {
|
87
87
|
color: #3A84FF;
|
88
88
|
}
|
89
|
-
@keyframes rotate-
|
89
|
+
@keyframes rotate-0x5i8c58 {
|
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-xy2w6wna";
|
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-fb9k5o8k] {
|
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-fb9k5o8k] {
|
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-l023po5v] {
|
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-l023po5v] {
|
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-l023po5v] {
|
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-l023po5v] {
|
25
25
|
position: absolute;
|
26
26
|
top: 0;
|
27
27
|
left: -80px;
|
28
28
|
}
|
29
|
-
.ai-content[data-v-
|
29
|
+
.ai-content[data-v-l023po5v]::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-l023po5v] {
|
40
40
|
padding: 12px;
|
41
41
|
}
|
42
|
-
.message-photo[data-v-
|
42
|
+
.message-photo[data-v-l023po5v] {
|
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-l023po5v] {
|
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-l023po5v] {
|
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-l023po5v";
|
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-ce3vm0gu] {
|
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-ce3vm0gu] {
|
7
7
|
padding: 0 52px;
|
8
8
|
}
|
9
|
-
.user-message-extra[data-v-
|
9
|
+
.user-message-extra[data-v-ce3vm0gu]: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-ce3vm0gu] {
|
15
15
|
font-size: 14px;
|
16
16
|
}
|
17
|
-
.user-content[data-v-
|
17
|
+
.user-content[data-v-ce3vm0gu] {
|
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-ce3vm0gu] {
|
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-ce3vm0gu] {
|
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-ce3vm0gu]:hover, .user-content .ai-ui-sdk-icon.ai-ui-sdk-copy[data-v-ce3vm0gu]:hover, .user-content .ai-ui-sdk-icon.ai-ui-sdk-baocun[data-v-ce3vm0gu]:hover, .user-content .ai-ui-sdk-icon.ai-ui-sdk-delete[data-v-ce3vm0gu]: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-ce3vm0gu] {
|
52
52
|
display: flex;
|
53
53
|
}
|
54
|
-
.user-content[data-v-
|
54
|
+
.user-content[data-v-ce3vm0gu]::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-ce3vm0gu] {
|
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-ce3vm0gu] {
|
72
72
|
position: absolute;
|
73
73
|
top: 0;
|
74
74
|
left: -80px;
|
75
75
|
}
|
76
|
-
.message-photo[data-v-
|
76
|
+
.message-photo[data-v-ce3vm0gu] {
|
77
77
|
width: 52px;
|
78
78
|
user-select: none;
|
79
79
|
}
|
80
|
-
.message-photo img[data-v-
|
80
|
+
.message-photo img[data-v-ce3vm0gu] {
|
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-ce3vm0gu] {
|
89
89
|
margin-left: 52px;
|
90
90
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
.render-stop[data-v-
|
2
|
+
.render-stop[data-v-it3uxfli] {
|
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-it3uxfli] {
|
12
12
|
width: 8px;
|
13
13
|
height: 8px;
|
14
14
|
background: #FFDDDD;
|
package/dist/hooks/use-chat.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ISessionContent, ISession, ISessionPrompt, ChatCallbacks
|
1
|
+
import type { ISessionContent, ISession, ISessionPrompt, ChatCallbacks } from '../types/session';
|
2
2
|
import { SessionContentRole, SessionContentStatus } from '../types/enum';
|
3
3
|
type SessionContentsMap = {
|
4
4
|
[key: string]: ISessionContent[];
|
@@ -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,
|
9
|
+
export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, requestOptions, }: ChatCallbacks<ISessionContent>) => {
|
10
10
|
currentSession: import("vue").Ref<ISession | undefined, ISession | undefined>;
|
11
11
|
sessionContents: import("vue").Ref<{
|
12
12
|
id?: number | undefined;
|
@@ -832,7 +832,6 @@ export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, ha
|
|
832
832
|
data?: Record<string, unknown>;
|
833
833
|
headers?: Record<string, string>;
|
834
834
|
}) => void;
|
835
|
-
sendChat: (content: BasicChatContent | ShortcutChatContent, callback?: () => void) => void;
|
836
835
|
stopChat: (sessionCode: string) => void;
|
837
836
|
plusSessionContent: (sessionCode: string, sessionContent: ISessionContent) => Promise<ISessionContent>;
|
838
837
|
updateSessionContent: (sessionContent: ISessionContent) => false | undefined;
|
package/dist/hooks/use-chat.js
CHANGED
@@ -79,16 +79,16 @@ function _object_spread_props(target, source) {
|
|
79
79
|
}
|
80
80
|
return target;
|
81
81
|
}
|
82
|
-
import { ref, computed
|
82
|
+
import { ref, computed } from 'vue';
|
83
83
|
import { HttpErrorCode, SessionContentRole, SessionContentStatus } from '../types/enum.js';
|
84
84
|
import { getHtmlContentFromDocuments, removeReferenceDoc } from './use-reference-doc.js';
|
85
85
|
import { getHtmlContentFromThink, isThinking, removeThink } from './use-think.js';
|
86
86
|
import { useHttp } from './use-http.js';
|
87
87
|
import { transferSessionContent2SessionPrompt, transferSessionPrompt2SessionContent } from '../http/helper/session.js';
|
88
88
|
import { ChatHelper } from '../common/chart-helper.js';
|
89
|
-
import {
|
89
|
+
import { throttle } from '../common/util.js';
|
90
90
|
// ai 聊天
|
91
|
-
export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError,
|
91
|
+
export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, requestOptions })=>{
|
92
92
|
// 用 ref 存储 requestOptions,使其可更新
|
93
93
|
const currentRequestOptions = ref(requestOptions);
|
94
94
|
// 创建一个变量保存当前的API实现
|
@@ -222,38 +222,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
222
222
|
handleEnd: handleEndChat,
|
223
223
|
handleError: handleErrorChat
|
224
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
|
-
}
|
257
225
|
// 新增 db
|
258
226
|
function plusSessionContent2Db(sessionContent) {
|
259
227
|
return apiImpl.plusSessionContent(sessionContent).then((result)=>{
|
@@ -305,7 +273,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
305
273
|
function plusSessionContent(sessionCode, sessionContent) {
|
306
274
|
const sessionContents = getSessionContentsBySessionCode(sessionCode);
|
307
275
|
sessionContents.push(sessionContent);
|
308
|
-
scrollToBottom(sessionCode);
|
309
276
|
return plusSessionContent2Db(sessionContent);
|
310
277
|
}
|
311
278
|
// 更新 chatContent
|
@@ -407,7 +374,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
407
374
|
sessionContent.content = cover ? content : sessionContent.content + content;
|
408
375
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
409
376
|
yield handleReferenceDoc === null || handleReferenceDoc === void 0 ? void 0 : handleReferenceDoc(sessionCode, sessionContent);
|
410
|
-
scrollToBottomIfAtBottom(sessionCode);
|
411
377
|
});
|
412
378
|
return _handleReferenceDocChat.apply(this, arguments);
|
413
379
|
}
|
@@ -424,7 +390,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
424
390
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
425
391
|
// 调用cb
|
426
392
|
yield handleThink === null || handleThink === void 0 ? void 0 : handleThink(sessionCode, sessionContent);
|
427
|
-
scrollToBottomIfAtBottom(sessionCode);
|
428
393
|
});
|
429
394
|
return _handleThinkChat.apply(this, arguments);
|
430
395
|
}
|
@@ -446,7 +411,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
446
411
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
447
412
|
// 调用cb
|
448
413
|
yield handleText === null || handleText === void 0 ? void 0 : handleText(sessionCode, sessionContent);
|
449
|
-
scrollToBottomIfAtBottom(sessionCode);
|
450
414
|
});
|
451
415
|
return _handleTextChat.apply(this, arguments);
|
452
416
|
}
|
@@ -475,7 +439,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
475
439
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
476
440
|
// 调用cb
|
477
441
|
yield handleEnd === null || handleEnd === void 0 ? void 0 : handleEnd(sessionCode, sessionContent);
|
478
|
-
scrollToBottomIfAtBottom(sessionCode);
|
479
442
|
}
|
480
443
|
});
|
481
444
|
return _handleEndChat.apply(this, arguments);
|
@@ -503,7 +466,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
503
466
|
yield throttleModifySessionContentApi(sessionContent.id, sessionContent);
|
504
467
|
// 调用cb
|
505
468
|
yield handleError === null || handleError === void 0 ? void 0 : handleError(sessionCode, sessionContent, code);
|
506
|
-
scrollToBottomIfAtBottom(sessionCode);
|
507
469
|
});
|
508
470
|
return _handleErrorChat.apply(this, arguments);
|
509
471
|
}
|
@@ -601,40 +563,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
601
563
|
});
|
602
564
|
return _reSendChat.apply(this, arguments);
|
603
565
|
}
|
604
|
-
// 发送聊天
|
605
|
-
function sendChat(content, callback) {
|
606
|
-
var _currentSession_value, _currentRequestOptions_value, _currentSession_value1, _currentSession_value2, _currentRequestOptions_value1;
|
607
|
-
if (!((_currentSession_value = currentSession.value) === null || _currentSession_value === void 0 ? void 0 : _currentSession_value.sessionCode) || !((_currentRequestOptions_value = currentRequestOptions.value) === null || _currentRequestOptions_value === void 0 ? void 0 : _currentRequestOptions_value.url) || currentSessionLoading.value) {
|
608
|
-
return;
|
609
|
-
}
|
610
|
-
const { message, cite, shortcut } = content;
|
611
|
-
let input = '';
|
612
|
-
if (shortcut) {
|
613
|
-
input = processPromptTemplate(shortcut.prompt, cite);
|
614
|
-
} else {
|
615
|
-
input = cite ? `${message}: "${cite}"` : message;
|
616
|
-
}
|
617
|
-
sessionContents.value.push({
|
618
|
-
sessionCode: (_currentSession_value1 = currentSession.value) === null || _currentSession_value1 === void 0 ? void 0 : _currentSession_value1.sessionCode,
|
619
|
-
content: message,
|
620
|
-
role: SessionContentRole.User,
|
621
|
-
status: SessionContentStatus.Success,
|
622
|
-
cite
|
623
|
-
});
|
624
|
-
// 发送请求
|
625
|
-
chatHelper.stream({
|
626
|
-
sessionCode: (_currentSession_value2 = currentSession.value) === null || _currentSession_value2 === void 0 ? void 0 : _currentSession_value2.sessionCode,
|
627
|
-
url: currentRequestOptions.value.url,
|
628
|
-
headers: (_currentRequestOptions_value1 = currentRequestOptions.value) === null || _currentRequestOptions_value1 === void 0 ? void 0 : _currentRequestOptions_value1.headers,
|
629
|
-
data: {
|
630
|
-
inputs: {
|
631
|
-
chat_history: prompts.value.slice(0, prompts.value.length - 1),
|
632
|
-
input
|
633
|
-
}
|
634
|
-
}
|
635
|
-
});
|
636
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
637
|
-
}
|
638
566
|
/**
|
639
567
|
* 删除聊天内容
|
640
568
|
* @param index 要删除的聊天内容索引
|
@@ -665,7 +593,6 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
|
|
665
593
|
prompts,
|
666
594
|
currentSessionLoading,
|
667
595
|
chat,
|
668
|
-
sendChat,
|
669
596
|
stopChat,
|
670
597
|
plusSessionContent,
|
671
598
|
updateSessionContent,
|
package/dist/types/session.d.ts
CHANGED
@@ -117,7 +117,6 @@ 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;
|
121
120
|
requestOptions: {
|
122
121
|
url: string;
|
123
122
|
headers?: Record<string, string>;
|