ai-chat-bot-interface 1.0.8 → 1.0.9

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.0.8",
4
+ "version": "1.0.9",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
7
  "description": "A AI chat bot interface. (private)",
package/src/ChatUi.vue CHANGED
@@ -44,8 +44,9 @@
44
44
  <p class="text" v-html="conv.content"></p>
45
45
  <div v-if="conv.extra.length && !isAnswering">
46
46
  <template v-for="(comp, idx) in conv.extra" :key="idx">
47
- <dishes-list v-if="comp.showType === 'card'" :sku-list="comp.skuList" @select="handleCardTap"/>
48
- <plan-card v-if="comp.showType === 'plan'" @select="handleCardTap({ type: 'match'})" />
47
+ <dishes-list v-if="comp.showType === 'card'" :sku-list="comp.skuList"
48
+ @select="(data) => handleCardTap(data, comp)"/>
49
+ <plan-card v-if="comp.showType === 'plan'" @select="handleCardTap({ type: 'match'}, comp)"/>
49
50
  </template>
50
51
  </div>
51
52
  </div>
@@ -61,7 +62,7 @@
61
62
  <img class="avatar" :src="avatar" alt="avatar">
62
63
  </div>
63
64
  </template>
64
- <!-- <div ref="endTarget" style="height: 100px;"/>-->
65
+ <div ref="endTarget" style="height: 100px;"/>
65
66
  </div>
66
67
  <div class="cui_operate">
67
68
  <button class="btn" @click.stop="createConv">
@@ -86,7 +87,6 @@ import ClearIcon from './components/icons/ClearIcon.vue';
86
87
  import CloseIcon from './components/icons/CloseIcon.vue';
87
88
  import NewSessionIcon from './components/icons/NewSessionIcon.vue';
88
89
  import SendIcon from './components/icons/SendIcon.vue';
89
- import mock from './mock';
90
90
  import {get, post} from './utils/request';
91
91
  import DishesCard from './components/DishesCard.vue';
92
92
  import DishesList from './components/DishesList.vue';
@@ -162,6 +162,7 @@ const createConv = async () => {
162
162
  localStorage.setItem('conversationId', conversationId.value);
163
163
  historyList.value = [];
164
164
  await queryBotInfo();
165
+ // await messageCreate();
165
166
  }
166
167
  };
167
168
  // const messageCreate = async () => {
@@ -171,7 +172,7 @@ const createConv = async () => {
171
172
  // { "role":"user","content":`#userid_${props.uid}`,"content_type":"text"},
172
173
  // {...chatOptions.value});
173
174
  // };
174
- const messageCreate = async () => {
175
+ /*const messageCreate = async () => {
175
176
  const res = await fetch(
176
177
  `https://api.coze.cn/v3/chat?conversation_id=${conversationId.value}`,
177
178
  {
@@ -190,6 +191,7 @@ const messageCreate = async () => {
190
191
  'role': 'user',
191
192
  'content_type': 'text',
192
193
  'content': `#userid_${props.uid}`,
194
+
193
195
  }],
194
196
  }),
195
197
  credentials: 'same-origin', // 默认同源策略
@@ -197,7 +199,7 @@ const messageCreate = async () => {
197
199
  cache: 'default', // 默认缓存策略
198
200
  },
199
201
  );
200
- };
202
+ };*/
201
203
  const chatConv = async (data) => {
202
204
  let isInCode = data.hasOwnProperty('text') && data.hasOwnProperty('code');
203
205
  if (!(!isAnswering.value && (inputText.value || isInCode))) {
@@ -233,6 +235,9 @@ const chatConv = async (data) => {
233
235
  'content_type': 'text',
234
236
  'content': isInCode ? data.code : inText, // '配餐1600kcal,身高173,体重60kg,生成一天的套餐',
235
237
  }],
238
+ custom_variables: {
239
+ 'uid': props.uid,
240
+ },
236
241
  }),
237
242
  credentials: 'same-origin', // 默认同源策略
238
243
  mode: 'cors', // 默认跨域模式
@@ -295,11 +300,11 @@ const chatConv = async (data) => {
295
300
  } else if (strObj.hasOwnProperty('type')
296
301
  && strObj.type === 'tool_response') {
297
302
  const extraObj = JSON.parse(strObj.content);
298
- if(extraObj.hasOwnProperty('showType')) {
303
+ if (extraObj.hasOwnProperty('showType')) {
299
304
  historyList.value[idx].extra.push({...extraObj});
300
- }else if(extraObj.hasOwnProperty('response_for_model')){
305
+ } else if (extraObj.hasOwnProperty('response_for_model')) {
301
306
  const modelObj = JSON.parse(extraObj.response_for_model);
302
- if(modelObj.hasOwnProperty('showType')) {
307
+ if (modelObj.hasOwnProperty('showType')) {
303
308
  historyList.value[idx].extra.push({...modelObj});
304
309
  }
305
310
  }
@@ -320,8 +325,8 @@ const queryHistoryList = async () => {
320
325
  historyList.value = [];
321
326
  const cardList = [];
322
327
  res.data.forEach(row => {
323
- if(row.hasOwnProperty('content_type')) {
324
- if(row.content_type === 'text') {
328
+ if (row.hasOwnProperty('content_type')) {
329
+ if (row.content_type === 'text') {
325
330
  historyList.value.push({
326
331
  chat_id: row.chat_id,
327
332
  conversation_id: row.conversation_id,
@@ -331,30 +336,30 @@ const queryHistoryList = async () => {
331
336
  status: 'ended',
332
337
  extra: [],
333
338
  });
334
- }else if(row.content_type === 'card' && row.role === 'assistant') {
339
+ } else if (row.content_type === 'card' && row.role === 'assistant') {
335
340
  try {
336
341
  const cardObj = JSON.parse(row.content);
337
- if(cardObj.hasOwnProperty('showType')) {
342
+ if (cardObj.hasOwnProperty('showType')) {
338
343
  cardList.push({
339
344
  chat_id: row.chat_id,
340
345
  conversation_id: row.conversation_id,
341
346
  bot_id: row.bot_id,
342
347
  role: row.role,
343
- extra:[{...cardObj}]
344
- })
345
- }else if(cardObj.hasOwnProperty('response_for_model')){
348
+ extra: [{...cardObj}],
349
+ });
350
+ } else if (cardObj.hasOwnProperty('response_for_model')) {
346
351
  const modelObj = JSON.parse(cardObj.response_for_model);
347
- if(modelObj.hasOwnProperty('showType')) {
352
+ if (modelObj.hasOwnProperty('showType')) {
348
353
  cardList.push({
349
354
  chat_id: row.chat_id,
350
355
  conversation_id: row.conversation_id,
351
356
  bot_id: row.bot_id,
352
357
  role: row.role,
353
- extra:[{...modelObj}]
354
- })
358
+ extra: [{...modelObj}],
359
+ });
355
360
  }
356
361
  }
357
- }catch (e) {
362
+ } catch (e) {
358
363
  console.log('== 解析错误 ==');
359
364
  }
360
365
  }
@@ -362,10 +367,10 @@ const queryHistoryList = async () => {
362
367
  });
363
368
  cardList.forEach(card => {
364
369
  const idx = historyList.value.findIndex(c => c.chat_id === card.chat_id && c.role === 'assistant');
365
- if(idx > -1) {
370
+ if (idx > -1) {
366
371
  historyList.value[idx].extra = [...card.extra];
367
372
  }
368
- })
373
+ });
369
374
  console.log(historyList.value, cardList);
370
375
  }
371
376
  };
@@ -386,7 +391,7 @@ const handleText = (str) => {
386
391
  return str.replaceAll(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/ig, '<a href="$2" target="_blank">[$1]</a>');
387
392
  };
388
393
 
389
- const handleCardTap = ({type}) => {
394
+ const handleCardTap = ({type}, info) => {
390
395
  switch (type) {
391
396
  case 'change':
392
397
  chatConv({code: '換一套菜品', text: '換一套菜品'});
@@ -395,7 +400,7 @@ const handleCardTap = ({type}) => {
395
400
  chatConv({code: '請用以上方案為我配餐', text: '請用以上方案為我配餐'});
396
401
  break;
397
402
  default:
398
- Emits('call', { type });
403
+ Emits('call', {type, info});
399
404
  }
400
405
  };
401
406
 
@@ -2,17 +2,17 @@
2
2
  <div class="dl_wrap">
3
3
  <template v-for="cate in skuList" :key="cate.category">
4
4
  <div v-if="cate.list && cate.list.length">
5
- <p class="title">{{ cate.category }}</p>
5
+ <p class="title">{{ cate.categoryType }}</p>
6
6
  <div>
7
7
  <template v-for="dList in cate.list" :key="dList.id">
8
- <dishes-card v-for="(info, idx) in dList.categoryList" :key="idx" :info="info"/>
8
+ <dishes-card v-for="(info, idx) in dList.getCategoryList" :key="idx" :info="info"/>
9
9
  </template>
10
10
  </div>
11
11
  </div>
12
12
  </template>
13
13
  <div class="btn_group">
14
- <!-- <div class="btn btn_1" @click.stop="handleBtn('change')">換一套菜品</div>-->
15
- <div class="btn btn_2" @click.stop="handleBtn('order')">去下單</div>
14
+ <div class="btn btn_1" @click.stop="handleBtn('ship_order')">配送下单</div>
15
+ <div class="btn btn_2" @click.stop="handleBtn('pick_order')">自取下单</div>
16
16
  </div>
17
17
  </div>
18
18
 
@@ -69,7 +69,7 @@ const handleBtn = (type) => {
69
69
 
70
70
  &_group {
71
71
  display: grid;
72
- grid-template-columns: 1fr;
72
+ grid-template-columns: 1fr 1fr;
73
73
  grid-column-gap: 10px;
74
74
  margin-top: 20px;
75
75
  }
package/src/mock.js CHANGED
@@ -1,162 +0,0 @@
1
- export default [
2
- {
3
- "conversation_id": "7472317677525188619",
4
- "bot_id": "7468975471649194018",
5
- "role": "assistant",
6
- "content": "您好,我是Nutribite",
7
- "status": "ended",
8
- "extra": []
9
- },
10
- {
11
- conversation_id: '7472317677525188619',
12
- bot_id: '7468975471649194018',
13
- role: `user_555`,
14
- content: '配餐1600kcal,身高173,体重60kg,生成一天的套餐',
15
- status: 'ended',
16
- extra: [],
17
- },
18
- {
19
- "conversation_id": "7472317677525188619",
20
- "bot_id": "7468975471649194018",
21
- "role": "assistant",
22
- "content": "为你生成的一天1600kcal套餐如下:\n- **早餐(约450kcal)**:\n - 火腿汁烧豆腐,能量82kcal,蛋白质8.7g,脂肪3.1g,碳水化合物4.7g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2024122015441833302.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 五彩鸡块,能量156kcal,蛋白质16.5g,脂肪6.8g,碳水化合物7.2g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2024120910310309135.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 素炒云南小瓜,能量39kcal,蛋白质1.7g,脂肪1.3g,碳水化合物5g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318161342225.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 牛肉焖饭,能量178kcal,蛋白质7.6g,脂肪2.4g,碳水化合物31.6g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318062384767.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n- **午餐(约540kcal)**:\n - 粟米蒸水蛋,能量117kcal,蛋白质9.9g,脂肪6.6g,碳水化合物4.5g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318155462227.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 豉油鸡扒,能量174kcal,蛋白质26.2g,脂肪6.8g,碳水化合物1.9g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318254931832.png?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 清炒菠菜,能量49kcal,蛋白质4g,脂肪1.5g,碳水化合物4.9g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010317554302323.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 红米飯,能量182kcal,蛋白质3.4g,脂肪0.1g,碳水化合物41.9g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318002606875.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n- **晚餐(约450kcal)**:\n - 番茄大虾面,能量430kcal,蛋白质26.3g,脂肪5.6g,碳水化合物68.5g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2024092513400322999.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a> \n\n这份套餐营养较为均衡,包含了蛋白质、碳水化合物、脂肪、维生素和矿物质等多种营养成分,希望能满足你的需求。 为你生成的一天1600kcal套餐如下:\n- **早餐(约450kcal)**:\n - 火腿汁烧豆腐,能量82kcal,蛋白质8.7g,脂肪3.1g,碳水化合物4.7g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2024122015441833302.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 五彩鸡块,能量156kcal,蛋白质16.5g,脂肪6.8g,碳水化合物7.2g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2024120910310309135.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 素炒云南小瓜,能量39kcal,蛋白质1.7g,脂肪1.3g,碳水化合物5g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318161342225.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 牛肉焖饭,能量178kcal,蛋白质7.6g,脂肪2.4g,碳水化合物31.6g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318062384767.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n- **午餐(约540kcal)**:\n - 粟米蒸水蛋,能量117kcal,蛋白质9.9g,脂肪6.6g,碳水化合物4.5g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318155462227.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 豉油鸡扒,能量174kcal,蛋白质26.2g,脂肪6.8g,碳水化合物1.9g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318254931832.png?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 清炒菠菜,能量49kcal,蛋白质4g,脂肪1.5g,碳水化合物4.9g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010317554302323.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n - 红米飯,能量182kcal,蛋白质3.4g,脂肪0.1g,碳水化合物41.9g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2025010318002606875.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a>\n- **晚餐(约450kcal)**:\n - 番茄大虾面,能量430kcal,蛋白质26.3g,脂肪5.6g,碳水化合物68.5g,<a href=\"https://prodstatic.weis1606.cn/api/diet/2024092513400322999.jpg?x-oss-process=image/resize,h_750\" target=\"_blank\">[点击查看]</a> \n\n这份套餐营养较为均衡,包含了蛋白质、碳水化合物、脂肪、维生素和矿物质等多种营养成分,希望能满足你的需求。 ",
23
- "status": "ended",
24
- "extra": [
25
- {
26
- "type": "tool_response",
27
- "content": {
28
- "code": 0,
29
- "skuList": [
30
- {
31
- "category": "早餐",
32
- "totalKcal": 450,
33
- "sequentialDays": 1,
34
- "list": [
35
- {
36
- "id": 3,
37
- "name": "五彩雞塊饭",
38
- "categoryList": [
39
- {
40
- "energy": 82,
41
- "skuname": "火腿汁燒豆腐",
42
- "skunameEn": "Braised Tofu in Ham Sauce",
43
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2024122015441833302.jpg?x-oss-process=image/resize,h_750",
44
- "protein": 8.7,
45
- "fat": 3.1,
46
- "carbonwater": 4.7
47
- },
48
- {
49
- "fat": 6.8,
50
- "carbonwater": 7.2,
51
- "energy": 156,
52
- "skuname": "五彩雞塊",
53
- "skunameEn": "Five-Colored Chicken Cubes",
54
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2024120910310309135.jpg?x-oss-process=image/resize,h_750",
55
- "protein": 16.5
56
- },
57
- {
58
- "skuname": "素炒雲南小瓜",
59
- "skunameEn": "Stir-Fried Yunnan Zucchini",
60
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2025010318161342225.jpg?x-oss-process=image/resize,h_750",
61
- "protein": 1.7,
62
- "fat": 1.3,
63
- "carbonwater": 5,
64
- "energy": 39
65
- },
66
- {
67
- "carbonwater": 31.6,
68
- "energy": 178,
69
- "skuname": "牛肉燜飯",
70
- "skunameEn": "Stewed Rice with Braised Beef",
71
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2025010318062384767.jpg?x-oss-process=image/resize,h_750",
72
- "protein": 7.6,
73
- "fat": 2.4
74
- }
75
- ]
76
- }
77
- ]
78
- },
79
- {
80
- "category": "午餐",
81
- "totalKcal": 540,
82
- "sequentialDays": 1,
83
- "list": [
84
- {
85
- "categoryList": [
86
- {
87
- "carbonwater": 4.5,
88
- "energy": 117,
89
- "skuname": "粟米蒸水蛋",
90
- "skunameEn": "Steamed Eggs with Corn",
91
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2025010318155462227.jpg?x-oss-process=image/resize,h_750",
92
- "protein": 9.9,
93
- "fat": 6.6
94
- },
95
- {
96
- "energy": 174,
97
- "skuname": "豉油雞扒",
98
- "skunameEn": "Grilled Chicken Steak with Soy Sauce",
99
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2025010318254931832.png?x-oss-process=image/resize,h_750",
100
- "protein": 26.2,
101
- "fat": 6.8,
102
- "carbonwater": 1.9
103
- },
104
- {
105
- "carbonwater": 4.9,
106
- "energy": 49,
107
- "skuname": "清炒菠菜",
108
- "skunameEn": "Stir-Fried Spinach",
109
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2025010317554302323.jpg?x-oss-process=image/resize,h_750",
110
- "protein": 4,
111
- "fat": 1.5
112
- },
113
- {
114
- "energy": 182,
115
- "skuname": "紅米飯",
116
- "skunameEn": "Red rice",
117
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2025010318002606875.jpg?x-oss-process=image/resize,h_750",
118
- "protein": 3.4,
119
- "fat": 0.1,
120
- "carbonwater": 41.9
121
- }
122
- ],
123
- "id": 4,
124
- "name": "豉油雞扒饭"
125
- }
126
- ]
127
- },
128
- {
129
- "sequentialDays": 1,
130
- "list": [
131
- {
132
- "id": 5,
133
- "name": "番茄大蝦麵",
134
- "categoryList": [
135
- {
136
- "energy": 430,
137
- "skuname": "番茄大蝦麵",
138
- "skunameEn": "Tomato Prawn Noodles",
139
- "primaryImgUrl": "https://prodstatic.weis1606.cn/api/diet/2024092513400322999.jpg?x-oss-process=image/resize,h_750",
140
- "protein": 26.3,
141
- "fat": 5.6,
142
- "carbonwater": 68.5
143
- }
144
- ]
145
- }
146
- ],
147
- "category": "晚餐",
148
- "totalKcal": 450
149
- },
150
- {
151
- "totalKcal": 360,
152
- "sequentialDays": 1,
153
- "list": [],
154
- "category": "加餐"
155
- }
156
- ],
157
- "msg": "success"
158
- }
159
- }
160
- ]
161
- }
162
- ]
@@ -1,43 +0,0 @@
1
- <script setup>
2
- import { ref } from 'vue'
3
-
4
- defineProps({
5
- msg: String,
6
- })
7
-
8
- const count = ref(0)
9
- </script>
10
-
11
- <template>
12
- <h1>{{ msg }}</h1>
13
-
14
- <div class="card">
15
- <button type="button" @click="count++">count is {{ count }}</button>
16
- <p>
17
- Edit
18
- <code>components/HelloWorld.vue</code> to test HMR
19
- </p>
20
- </div>
21
-
22
- <p>
23
- Check out
24
- <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
25
- >create-vue</a
26
- >, the official Vue + Vite starter
27
- </p>
28
- <p>
29
- Learn more about IDE Support for Vue in the
30
- <a
31
- href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
32
- target="_blank"
33
- >Vue Docs Scaling up Guide</a
34
- >.
35
- </p>
36
- <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
37
- </template>
38
-
39
- <style scoped>
40
- .read-the-docs {
41
- color: #888;
42
- }
43
- </style>