ai-chat-bot-interface 1.5.3 → 1.5.5
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
CHANGED
package/src/App.vue
CHANGED
|
@@ -5,8 +5,8 @@ import ChatUi from './ChatUi.vue';
|
|
|
5
5
|
<template>
|
|
6
6
|
<div style="width: 100vw; height: 100vh">
|
|
7
7
|
<chat-ui
|
|
8
|
-
bot-id="
|
|
9
|
-
token="
|
|
8
|
+
bot-id="5555"
|
|
9
|
+
token="pat_888888"
|
|
10
10
|
uid="262598"
|
|
11
11
|
:def-msg="{ placeholder: '发消息...' }"
|
|
12
12
|
:show-header="true"
|
package/src/ChatUi.vue
CHANGED
|
@@ -146,6 +146,7 @@
|
|
|
146
146
|
:token="token"
|
|
147
147
|
:tag-list="tagList"
|
|
148
148
|
:def-msg="finalDefMsg"
|
|
149
|
+
:is-req="isReq"
|
|
149
150
|
@send="chatConv"
|
|
150
151
|
@tag="handleTagSel"
|
|
151
152
|
@call="handleCall"
|
|
@@ -187,6 +188,7 @@ const chatOptions = computed(() => {
|
|
|
187
188
|
});
|
|
188
189
|
const conversationId = ref('');
|
|
189
190
|
const isAnswering = ref(false);
|
|
191
|
+
const isReq = ref('00');
|
|
190
192
|
const historyList = ref([]);
|
|
191
193
|
|
|
192
194
|
const msgObj = {
|
|
@@ -370,6 +372,7 @@ const createConv = async () => {
|
|
|
370
372
|
};*/
|
|
371
373
|
|
|
372
374
|
const chatConv = async (data) => {
|
|
375
|
+
isReq.value = '01';
|
|
373
376
|
let isInCode = Array.isArray(data); // data.hasOwnProperty('text') && data.hasOwnProperty('code');
|
|
374
377
|
const botId = props.botId;
|
|
375
378
|
if (!(!isAnswering.value && (inputText.value || isInCode))) {
|
|
@@ -426,6 +429,7 @@ const chatConv = async (data) => {
|
|
|
426
429
|
}
|
|
427
430
|
});
|
|
428
431
|
historyList.value.push(uObj);
|
|
432
|
+
isReq.value = '02'
|
|
429
433
|
const res = await fetch(
|
|
430
434
|
`https://api.coze.cn/v3/chat?conversation_id=${conversationId.value}`,
|
|
431
435
|
{
|
|
@@ -460,6 +464,7 @@ const chatConv = async (data) => {
|
|
|
460
464
|
cache: 'default', // 默认缓存策略
|
|
461
465
|
},
|
|
462
466
|
);
|
|
467
|
+
isReq.value = '03';
|
|
463
468
|
historyList.value.push({
|
|
464
469
|
conversation_id: '',
|
|
465
470
|
bot_id: '',
|
|
@@ -481,6 +486,7 @@ const chatConv = async (data) => {
|
|
|
481
486
|
if (done) {
|
|
482
487
|
console.log('Stream has ended.');
|
|
483
488
|
isAnswering.value = false;
|
|
489
|
+
isReq.value = '00';
|
|
484
490
|
historyList.value[idx].status = 'ended';
|
|
485
491
|
scrollToEnd();
|
|
486
492
|
break;
|
|
@@ -500,6 +506,7 @@ const chatConv = async (data) => {
|
|
|
500
506
|
const strObj = JSON.parse(str);
|
|
501
507
|
console.log('Received:', strObj);
|
|
502
508
|
isAnswering.value = true;
|
|
509
|
+
isReq.value = '04';
|
|
503
510
|
if (!historyList.value[idx].bot_id && strObj.bot_id) {
|
|
504
511
|
historyList.value[idx].bot_id = strObj.bot_id;
|
|
505
512
|
}
|
|
@@ -61,7 +61,11 @@
|
|
|
61
61
|
/>
|
|
62
62
|
<div class="btn_group">
|
|
63
63
|
<div class="btn" @click.stop="sendMsg">
|
|
64
|
-
<send-icon :style="{ color: textValue ? '#039938' : '#ccc' }" />
|
|
64
|
+
<send-icon v-if="isReq === '00'" :style="{ color: textValue ? '#039938' : '#ccc' }" />
|
|
65
|
+
<send-loading-icon v-else
|
|
66
|
+
:bg="loadingBtnInfo.bg"
|
|
67
|
+
:color="loadingBtnInfo.color"
|
|
68
|
+
/>
|
|
65
69
|
</div>
|
|
66
70
|
</div>
|
|
67
71
|
</div>
|
|
@@ -113,6 +117,7 @@ import AddIcon from './icons/addIcon.vue';
|
|
|
113
117
|
import CloseBorderIcon from './icons/closeBorderIcon.vue';
|
|
114
118
|
import CloseIcon from './icons/CloseIcon.vue';
|
|
115
119
|
import NewChat from './icons/newChat.vue';
|
|
120
|
+
import SendLoadingIcon from "./icons/sendLoadingIcon.vue";
|
|
116
121
|
const pdfIcon = 'https://prodstatic.weis1606.cn/api/smartFood/icon/pdf_icon.png';
|
|
117
122
|
const extraList = [
|
|
118
123
|
// { name: '相機', icon: CameraIcon, type: 'camera' },
|
|
@@ -147,6 +152,10 @@ const props = defineProps({
|
|
|
147
152
|
type: Object,
|
|
148
153
|
required: true,
|
|
149
154
|
},
|
|
155
|
+
isReq:{
|
|
156
|
+
type: String,
|
|
157
|
+
default: '00'
|
|
158
|
+
}
|
|
150
159
|
});
|
|
151
160
|
const Emits = defineEmits(['update:modelValue', 'send', 'tag', 'call']);
|
|
152
161
|
|
|
@@ -166,6 +175,26 @@ watch(
|
|
|
166
175
|
},
|
|
167
176
|
);
|
|
168
177
|
|
|
178
|
+
/*
|
|
179
|
+
* 00: 初始值;
|
|
180
|
+
* 01: 已传达;
|
|
181
|
+
* 02: 已发送;
|
|
182
|
+
* 03:已接收;
|
|
183
|
+
* 04: 读取中;
|
|
184
|
+
* */
|
|
185
|
+
const loadingBtnInfo = computed(() => {
|
|
186
|
+
switch (props.isReq) {
|
|
187
|
+
case '01':
|
|
188
|
+
return { bg: '#fff', color: '#ccc'};
|
|
189
|
+
case '02':
|
|
190
|
+
return { bg: '#666', color: '#CDEBD7'};
|
|
191
|
+
case '03':
|
|
192
|
+
return { bg: '#ccc', color: '#fff'};
|
|
193
|
+
case '04':
|
|
194
|
+
return { bg: '#E5F4EB', color: '#fff'};
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
|
|
169
198
|
const textValue = computed({
|
|
170
199
|
get: () => {
|
|
171
200
|
return props.modelValue;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
const props = defineProps({
|
|
3
|
+
color: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: '#000'
|
|
6
|
+
},
|
|
7
|
+
bg: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: '#039938'
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
</script>
|
|
13
|
+
<template>
|
|
14
|
+
|
|
15
|
+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
|
|
16
|
+
xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
|
|
17
|
+
<circle cx="512" cy="512" r="512" :fill='bg'/>
|
|
18
|
+
<path :fill="color" d="M512.042667 213.333333v74.666667a224 224 0 1 1-195.626667 114.773333l-65.194667-36.394666A298.666667 298.666667 0 1 0 512.042667 213.333333z"
|
|
19
|
+
>
|
|
20
|
+
<animateTransform
|
|
21
|
+
attributeName="transform"
|
|
22
|
+
type="rotate"
|
|
23
|
+
from="0 512 512"
|
|
24
|
+
to="360 512 512"
|
|
25
|
+
dur="1.5s"
|
|
26
|
+
repeatCount="indefinite"
|
|
27
|
+
fill="freeze"
|
|
28
|
+
/>
|
|
29
|
+
</path>
|
|
30
|
+
</svg>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<style scoped>
|
|
34
|
+
|
|
35
|
+
</style>
|