ai-chat-bot-interface 1.2.2 → 1.3.0

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ai-chat-bot-interface",
3
3
  "private": false,
4
- "version": "1.2.2",
4
+ "version": "1.3.0",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
7
  "description": "A AI chat bot interface. (private)",
package/src/App.vue CHANGED
@@ -4,7 +4,7 @@ import ChatUi from './ChatUi.vue';
4
4
 
5
5
  <template>
6
6
  <div style="width: 100vw; height: 100vh">
7
- <chat-ui bot-id="000" token="pat_88888" uid="262598" :show-header="true" />
7
+ <chat-ui bot-id="999" token="pat_8888" uid="262598" :show-header="true" />
8
8
  </div>
9
9
  </template>
10
10
  <style></style>
package/src/ChatUi.less CHANGED
@@ -191,6 +191,27 @@
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
+ color: #666;
207
+ font-size: 12px;
208
+ font-weight: 400;
209
+ line-height: 18px;
210
+ padding-left: 8px;
211
+ margin: 15px 0 20px;
212
+ border-left: 4px solid #dadada;
213
+ }
214
+ }
194
215
  }
195
216
 
196
217
  .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">
@@ -77,6 +89,7 @@
77
89
  <dishes-list
78
90
  v-if="comp.showType === 'card'"
79
91
  :sku-list="comp.skuList"
92
+ :is-mini="!showHeader"
80
93
  @select="(data) => handleCardTap(data, comp)"
81
94
  />
82
95
  <plan-card
@@ -147,6 +160,8 @@ import NewChat from './components/icons/newChat.vue';
147
160
  import LoadingIcon from './components/icons/loadingIcon.vue';
148
161
  import LoadingIcon2 from './components/icons/loadingIcon2.vue';
149
162
  import ImgeList from './components/imgeList.vue';
163
+ import ThinkingIcon from './components/icons/ThinkingIcon.vue';
164
+ import OkIcon from './components/icons/OkIcon.vue';
150
165
 
151
166
  const chatOptions = computed(() => {
152
167
  return {
@@ -270,7 +285,6 @@ const createConv = async () => {
270
285
 
271
286
  const chatConv = async (data) => {
272
287
  let isInCode = Array.isArray(data); // data.hasOwnProperty('text') && data.hasOwnProperty('code');
273
- console.log('=========', isInCode, data);
274
288
  let botId = props.botId;
275
289
  if (!(!isAnswering.value && (inputText.value || isInCode))) {
276
290
  return;
@@ -285,6 +299,7 @@ const chatConv = async (data) => {
285
299
  bot_id: botId,
286
300
  role: 'user',
287
301
  content: '',
302
+ reasoning_content: '',
288
303
  status: 'ended',
289
304
  extra: [],
290
305
  };
@@ -365,6 +380,7 @@ const chatConv = async (data) => {
365
380
  bot_id: '',
366
381
  role: 'assistant',
367
382
  content: '',
383
+ reasoning_content: '',
368
384
  status: 'answering',
369
385
  extra: [],
370
386
  });
@@ -399,7 +415,6 @@ const chatConv = async (data) => {
399
415
  const strObj = JSON.parse(str);
400
416
  console.log('Received:', strObj);
401
417
  isAnswering.value = true;
402
- historyList.value[idx].status = 'answering';
403
418
  if (!historyList.value[idx].bot_id && strObj.bot_id) {
404
419
  historyList.value[idx].bot_id = strObj.bot_id;
405
420
  }
@@ -407,6 +422,13 @@ const chatConv = async (data) => {
407
422
  historyList.value[idx].conversation_id = strObj.conversation_id;
408
423
  }
409
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
+ } else if (
410
432
  strObj.hasOwnProperty('content') &&
411
433
  strObj.hasOwnProperty('content_type') &&
412
434
  strObj.content_type === 'text' &&
@@ -414,6 +436,7 @@ const chatConv = async (data) => {
414
436
  strObj.type === 'answer' &&
415
437
  !strObj.hasOwnProperty('created_at')
416
438
  ) {
439
+ historyList.value[idx].status = 'answering';
417
440
  historyList.value[idx].content = handleText(
418
441
  historyList.value[idx].content + strObj.content,
419
442
  );
@@ -459,6 +482,7 @@ const queryHistoryList = async () => {
459
482
  role: row.role,
460
483
  meta_data: row.meta_data,
461
484
  content: handleText(row.content),
485
+ reasoning_content: row.reasoning_content,
462
486
  status: 'ended',
463
487
  extra: [],
464
488
  });
@@ -523,9 +547,9 @@ const queryHistoryList = async () => {
523
547
  historyList.value[idx].extra = [...card.extra];
524
548
  }
525
549
  });
526
-
527
- console.log(historyList.value, cardList);
528
550
  }
551
+
552
+ console.log('== history ==', historyList.value);
529
553
  };
530
554
 
531
555
  const queryBotInfo = async () => {
@@ -20,7 +20,12 @@
20
20
  </div>
21
21
  </div>
22
22
  </template>
23
- <div class="btn_group">
23
+ <div v-if="isMini" class="btn_group">
24
+ <div class="btn btn_2" @click.stop="handleBtn('ship_order')">
25
+ <span class="name">立即下单</span>
26
+ </div>
27
+ </div>
28
+ <div v-else class="btn_group">
24
29
  <div class="btn btn_1" @click.stop="handleBtn('ship_order')">
25
30
  <span class="name">配送下單</span>
26
31
  <span class="sub">(直送到府)</span>
@@ -42,6 +47,10 @@ const props = defineProps({
42
47
  required: true,
43
48
  default: () => [],
44
49
  },
50
+ isMini: {
51
+ type: Boolean,
52
+ default: false,
53
+ },
45
54
  });
46
55
  const Emits = defineEmits(['select']);
47
56
 
@@ -103,9 +112,8 @@ const handleBtn = (type) => {
103
112
  background-color: @primary-color;
104
113
  }
105
114
  &_group {
106
- display: grid;
107
- grid-template-columns: 1fr 1fr;
108
- grid-column-gap: 10px;
115
+ .flexrbc();
116
+ gap: 10px;
109
117
  margin-top: 20px;
110
118
  }
111
119
  }
@@ -155,7 +155,6 @@ const fetchOptions = computed(() => {
155
155
  watch(
156
156
  () => props.modelValue,
157
157
  () => {
158
- console.log('=== ccc ===');
159
158
  resizeTextarea();
160
159
  },
161
160
  );
@@ -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>