ai-chat-bot-interface 1.2.3 → 1.3.1
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/package.json +1 -1
- package/src/App.vue +6 -1
- package/src/ChatUi.less +23 -0
- package/src/ChatUi.vue +28 -4
- package/src/components/OperateModule.vue +0 -1
- package/src/components/icons/OkIcon.vue +26 -0
- package/src/components/icons/ThinkingIcon.vue +28 -0
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -4,7 +4,12 @@ import ChatUi from './ChatUi.vue';
|
|
|
4
4
|
|
|
5
5
|
<template>
|
|
6
6
|
<div style="width: 100vw; height: 100vh">
|
|
7
|
-
<chat-ui
|
|
7
|
+
<chat-ui
|
|
8
|
+
bot-id="7471093458661720104"
|
|
9
|
+
token="pat_2yVcSFJUZB6c9Kdcv9iktIVFeGRuzyK3bAJY6GcqKrdGxTdjKMd1iDB09ipJ6YX8"
|
|
10
|
+
uid="262598"
|
|
11
|
+
:show-header="true"
|
|
12
|
+
/>
|
|
8
13
|
</div>
|
|
9
14
|
</template>
|
|
10
15
|
<style></style>
|
package/src/ChatUi.less
CHANGED
|
@@ -191,6 +191,29 @@
|
|
|
191
191
|
color: #039938;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
+
.think {
|
|
195
|
+
&_status {
|
|
196
|
+
.flexrsc();
|
|
197
|
+
gap: 5px;
|
|
198
|
+
font-size: 14px;
|
|
199
|
+
font-weight: 500;
|
|
200
|
+
.icon {
|
|
201
|
+
color: #999;
|
|
202
|
+
font-size: 24px;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
&_text {
|
|
206
|
+
word-break: break-all;
|
|
207
|
+
white-space: pre-wrap;
|
|
208
|
+
color: #666;
|
|
209
|
+
font-size: 12px;
|
|
210
|
+
font-weight: 400;
|
|
211
|
+
line-height: 18px;
|
|
212
|
+
padding-left: 8px;
|
|
213
|
+
margin: 15px 0 20px;
|
|
214
|
+
border-left: 4px solid #dadada;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
194
217
|
}
|
|
195
218
|
|
|
196
219
|
.recm {
|
package/src/ChatUi.vue
CHANGED
|
@@ -62,6 +62,18 @@
|
|
|
62
62
|
<!--<span class="time">12:30</span>-->
|
|
63
63
|
</div>
|
|
64
64
|
<div class="box">
|
|
65
|
+
<template v-if="conv.reasoning_content">
|
|
66
|
+
<div v-if="conv.status === 'thinking'" class="think_status">
|
|
67
|
+
<thinking-icon class="icon" /> 思考中...
|
|
68
|
+
</div>
|
|
69
|
+
<div v-else class="think_status">
|
|
70
|
+
<ok-icon class="icon" /> 思考完成
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<p class="think_text">
|
|
74
|
+
{{ conv.reasoning_content }}
|
|
75
|
+
</p>
|
|
76
|
+
</template>
|
|
65
77
|
<template v-if="conv.content">
|
|
66
78
|
<p class="text" v-html="conv.content"></p>
|
|
67
79
|
<template v-if="!isAnswering">
|
|
@@ -148,6 +160,8 @@ import NewChat from './components/icons/newChat.vue';
|
|
|
148
160
|
import LoadingIcon from './components/icons/loadingIcon.vue';
|
|
149
161
|
import LoadingIcon2 from './components/icons/loadingIcon2.vue';
|
|
150
162
|
import ImgeList from './components/imgeList.vue';
|
|
163
|
+
import ThinkingIcon from './components/icons/ThinkingIcon.vue';
|
|
164
|
+
import OkIcon from './components/icons/OkIcon.vue';
|
|
151
165
|
|
|
152
166
|
const chatOptions = computed(() => {
|
|
153
167
|
return {
|
|
@@ -271,7 +285,6 @@ const createConv = async () => {
|
|
|
271
285
|
|
|
272
286
|
const chatConv = async (data) => {
|
|
273
287
|
let isInCode = Array.isArray(data); // data.hasOwnProperty('text') && data.hasOwnProperty('code');
|
|
274
|
-
console.log('=========', isInCode, data);
|
|
275
288
|
let botId = props.botId;
|
|
276
289
|
if (!(!isAnswering.value && (inputText.value || isInCode))) {
|
|
277
290
|
return;
|
|
@@ -286,6 +299,7 @@ const chatConv = async (data) => {
|
|
|
286
299
|
bot_id: botId,
|
|
287
300
|
role: 'user',
|
|
288
301
|
content: '',
|
|
302
|
+
reasoning_content: '',
|
|
289
303
|
status: 'ended',
|
|
290
304
|
extra: [],
|
|
291
305
|
};
|
|
@@ -366,6 +380,7 @@ const chatConv = async (data) => {
|
|
|
366
380
|
bot_id: '',
|
|
367
381
|
role: 'assistant',
|
|
368
382
|
content: '',
|
|
383
|
+
reasoning_content: '',
|
|
369
384
|
status: 'answering',
|
|
370
385
|
extra: [],
|
|
371
386
|
});
|
|
@@ -400,7 +415,6 @@ const chatConv = async (data) => {
|
|
|
400
415
|
const strObj = JSON.parse(str);
|
|
401
416
|
console.log('Received:', strObj);
|
|
402
417
|
isAnswering.value = true;
|
|
403
|
-
historyList.value[idx].status = 'answering';
|
|
404
418
|
if (!historyList.value[idx].bot_id && strObj.bot_id) {
|
|
405
419
|
historyList.value[idx].bot_id = strObj.bot_id;
|
|
406
420
|
}
|
|
@@ -408,6 +422,14 @@ const chatConv = async (data) => {
|
|
|
408
422
|
historyList.value[idx].conversation_id = strObj.conversation_id;
|
|
409
423
|
}
|
|
410
424
|
if (
|
|
425
|
+
strObj.hasOwnProperty('reasoning_content') &&
|
|
426
|
+
strObj.reasoning_content &&
|
|
427
|
+
strObj.type === 'answer'
|
|
428
|
+
) {
|
|
429
|
+
historyList.value[idx].status = 'thinking';
|
|
430
|
+
historyList.value[idx].reasoning_content += strObj.reasoning_content;
|
|
431
|
+
scrollToEnd();
|
|
432
|
+
} else if (
|
|
411
433
|
strObj.hasOwnProperty('content') &&
|
|
412
434
|
strObj.hasOwnProperty('content_type') &&
|
|
413
435
|
strObj.content_type === 'text' &&
|
|
@@ -415,6 +437,7 @@ const chatConv = async (data) => {
|
|
|
415
437
|
strObj.type === 'answer' &&
|
|
416
438
|
!strObj.hasOwnProperty('created_at')
|
|
417
439
|
) {
|
|
440
|
+
historyList.value[idx].status = 'answering';
|
|
418
441
|
historyList.value[idx].content = handleText(
|
|
419
442
|
historyList.value[idx].content + strObj.content,
|
|
420
443
|
);
|
|
@@ -460,6 +483,7 @@ const queryHistoryList = async () => {
|
|
|
460
483
|
role: row.role,
|
|
461
484
|
meta_data: row.meta_data,
|
|
462
485
|
content: handleText(row.content),
|
|
486
|
+
reasoning_content: row.reasoning_content,
|
|
463
487
|
status: 'ended',
|
|
464
488
|
extra: [],
|
|
465
489
|
});
|
|
@@ -524,9 +548,9 @@ const queryHistoryList = async () => {
|
|
|
524
548
|
historyList.value[idx].extra = [...card.extra];
|
|
525
549
|
}
|
|
526
550
|
});
|
|
527
|
-
|
|
528
|
-
console.log(historyList.value, cardList);
|
|
529
551
|
}
|
|
552
|
+
|
|
553
|
+
console.log('== history ==', historyList.value);
|
|
530
554
|
};
|
|
531
555
|
|
|
532
556
|
const queryBotInfo = async () => {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
width="1em"
|
|
4
|
+
height="1em"
|
|
5
|
+
viewBox="0 0 24 24"
|
|
6
|
+
fill="none"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
>
|
|
9
|
+
<path
|
|
10
|
+
d="M3.78271 12C3.78271 13.0792 3.99526 14.1477 4.40822 15.1447C4.82118 16.1416 5.42646 17.0475 6.18951 17.8106C6.95256 18.5736 7.85843 19.1789 8.8554 19.5919C9.85238 20.0048 10.9209 20.2174 12 20.2174C13.0792 20.2174 14.1477 20.0048 15.1447 19.5919C16.1416 19.1789 17.0475 18.5736 17.8106 17.8106C18.5736 17.0475 19.1789 16.1416 19.5919 15.1447C20.0048 14.1477 20.2174 13.0792 20.2174 12C20.2174 10.9209 20.0048 9.85238 19.5919 8.8554C19.1789 7.85843 18.5736 6.95256 17.8106 6.18951C17.0475 5.42646 16.1416 4.82118 15.1447 4.40822C14.1477 3.99526 13.0792 3.78271 12 3.78271C10.9209 3.78271 9.85238 3.99526 8.8554 4.40822C7.85843 4.82118 6.95256 5.42646 6.18951 6.18951C5.42646 6.95256 4.82118 7.85843 4.40822 8.8554C3.99526 9.85238 3.78271 10.9209 3.78271 12Z"
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
/>
|
|
13
|
+
<path
|
|
14
|
+
d="M11.0677 14.4192L8.08502 11.4365C7.87938 11.2308 7.54542 11.2308 7.33978 11.4365C7.13414 11.6421 7.13414 11.9761 7.33978 12.1817L10.3225 15.1644C10.5281 15.3701 10.8621 15.3701 11.0677 15.1644C11.2751 14.9605 11.2751 14.6266 11.0677 14.4192Z"
|
|
15
|
+
fill="#fff"
|
|
16
|
+
/>
|
|
17
|
+
<path
|
|
18
|
+
d="M16.6693 8.84027C16.4636 8.63462 16.1297 8.63462 15.924 8.84027L10.456 14.31C10.2503 14.5157 10.2503 14.8496 10.456 15.0553C10.6616 15.2609 10.9956 15.2609 11.2012 15.0553L16.6693 9.58727C16.8767 9.37986 16.8767 9.04591 16.6693 8.84027Z"
|
|
19
|
+
fill="#fff"
|
|
20
|
+
/>
|
|
21
|
+
</svg>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script></script>
|
|
25
|
+
|
|
26
|
+
<style scoped></style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
width="1em"
|
|
4
|
+
height="1em"
|
|
5
|
+
viewBox="0 0 24 24"
|
|
6
|
+
fill="none"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
>
|
|
9
|
+
<path
|
|
10
|
+
d="M18.3752 6.19542C18.3663 5.84188 18.0971 5.61907 17.7113 5.62719C17.3249 5.63532 17.1259 5.87105 17.0624 6.22473C17.0295 6.40814 17.0401 6.60002 17.0382 6.78818C17.0349 7.1092 17.0373 7.43028 17.0373 7.75135C16.9871 7.77411 16.9369 7.79688 16.8867 7.81966C16.7181 7.65766 16.5524 7.4926 16.3805 7.33415C14.8317 5.90621 12.9939 5.37461 10.9359 5.69056C8.03017 6.13662 5.87726 8.55583 5.62463 11.5758C5.38764 14.4087 7.21523 17.1459 9.95849 18.0667C12.7336 18.9982 15.8214 17.914 17.3822 15.4574C17.4827 15.2992 17.5871 15.1369 17.6484 14.962C17.7675 14.6224 17.7077 14.3062 17.3722 14.1247C17.049 13.9499 16.7426 14.0201 16.5131 14.3168C16.3983 14.4652 16.3111 14.6344 16.204 14.7891C15.2363 16.1865 13.907 16.9479 12.206 17.0308C9.92842 17.1419 7.84057 15.6645 7.17679 13.487C6.49124 11.238 7.43946 8.81484 9.46764 7.6327C11.4392 6.48354 13.9702 6.81332 15.5656 8.43366C15.6825 8.55231 15.7612 8.70851 15.9506 8.98094C15.3277 8.98094 14.8482 8.95558 14.3726 8.98836C13.9335 9.01865 13.7009 9.27998 13.7045 9.64685C13.708 10.0041 13.9569 10.2996 14.3795 10.31C15.4824 10.3371 16.5866 10.3273 17.6901 10.3155C18.0536 10.3117 18.3546 10.1036 18.3656 9.74431C18.4019 8.56213 18.4048 7.37778 18.3752 6.19542Z"
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
>
|
|
13
|
+
<animateTransform
|
|
14
|
+
attributeName="transform"
|
|
15
|
+
attributeType="XML"
|
|
16
|
+
type="rotate"
|
|
17
|
+
from="0 12 12"
|
|
18
|
+
to="360 12 12"
|
|
19
|
+
dur="1.5s"
|
|
20
|
+
repeatCount="indefinite"
|
|
21
|
+
/>
|
|
22
|
+
</path>
|
|
23
|
+
</svg>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script></script>
|
|
27
|
+
|
|
28
|
+
<style></style>
|