lke-component 1.1.19-beta-16 → 1.1.20-beta-2

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/README.md CHANGED
@@ -1,224 +1,21 @@
1
1
  # lke-component
2
2
 
3
- [English](#english) | [中文](#中文)
4
-
5
- ---
6
-
7
- <a id="english"></a>
8
-
9
- ## English
10
-
11
- Message rendering component for LKE (Large Knowledge Engine) conversations, designed for Vue2 and React projects.
12
-
13
- For other environments:
14
- * Vue3 projects: [Link](https://www.npmjs.com/package/lke-component-vue3)
15
- * React projects: [Link](#usage-in-react-projects)
16
- * Mini Programs: [Link](https://www.npmjs.com/package/lke-utils)
17
-
18
- ### Components
19
-
20
- Four components are provided: `LkeMsg`, `MsgContent`, `MsgLoading`, `MsgThought`
21
-
22
- **MsgLoading**: Shows model loading state
23
-
24
- ```
25
- props:
26
- loadingIcon: String, // Message icon, displays if provided
27
- loadingMessage: Boolean, // Whether in loading state
28
- loadingText: String, // Loading message content
29
- transferStatus: Boolean // Transfer to human agent status
30
- ```
31
-
32
- **MsgContent**: Renders Markdown content
33
-
34
- ```
35
- props:
36
- content: String, // Markdown message
37
- isFinal: Boolean, // Whether the message output is complete
38
- isReplaceLinks: Boolean, // Whether to replace links with third-party prompts
39
- styleObj: Object, // Style object for MD message body
40
- clazzTable: String, // Table class for MD message body (default styles will be added)
41
- clazzMd: String, // Class for MD message body
42
- anchorAttributes: Object, // Props passed to vue-markdown, see example
43
- linkify: Boolean // Props passed to vue-markdown, see example
44
- ```
45
-
46
- **LkeMsg**: Aggregated component combining the above
47
-
48
- ```
49
- props:
50
- LoadingIcon: String, // CDN URL for loading icon, not displayed if not provided
51
- type: String, // Current message type, usually 'reply' or 'token_stat'
52
- isReplaceLinks: Boolean, // Whether to replace with LLM third-party link prompts
53
- showProcedures: Boolean, // Whether to show model output status
54
- transferStatus: Boolean, // Transfer to human agent status
55
- clazz: String, // Class name for outer wrapper div
56
- item: Object, // Current message content
57
- styleObj: Object, // Style object for MD message body
58
- clazzTable: String, // Table class for MD message body, default styles: table-style, table
59
- clazzMd: String, // Class for MD message body, default style: answer-md
60
- anchorAttributes: Object, // Props passed to vue-markdown, see example
61
- linkify: Boolean // Props passed to vue-markdown, see example
62
- printCount: Number | undefined // Characters per print for timing control
63
- hideCursorPoint: Boolean | undefined // Whether to show print cursor icon
64
- ```
65
-
66
- **MsgThought**: Renders DeepSeek thinking content
67
-
68
- ```
69
- props:
70
- content: String // Thinking content
71
- title: String // Title, e.g., "Thinking Complete"
72
- titleIcon: String // Small icon, 16x16px
73
- nodeName: String // Optional, e.g., "deepseek"
74
- status: String // Thinking status: 'success', 'failed', 'processing', 'stop'
75
- elapsed: number // Time spent thinking in milliseconds, e.g., 17485
76
- ```
77
-
78
- ### Usage in Vue2 Projects
79
-
80
- 1. Install and import
81
-
82
- ```js
83
- // Import in Vue entry file
84
- import lkeComponent from 'lke-component';
85
- Vue.use(lkeComponent);
86
-
87
- // Use in Vue pages
88
- <!-- Loading toggle + Markdown rendering -->
89
- <LkeMsg :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" :isReplaceLinks="true" :content="item.content" :isFinal="item.is_final" />
90
-
91
- <!-- Show temporary [Thinking...] message when not transferring to human -->
92
- <MsgLoading :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" />
93
-
94
- <!-- DeepSeek thinking content rendering -->
95
- <MsgThought
96
- :content="thinkingContent"
97
- :title="thinkingTitle"
98
- :titleIcon="test.png"
99
- :nodeName="deepseek"
100
- :status="success"
101
- :elapsed="17485"
102
- />
103
-
104
- <!-- Markdown rendering -->
105
- <MsgContent :isReplaceLinks="true" :loadingMessage="item.loading_message" :content="item.content" :isFinal="item.is_final" :printCount="1" :hideCursorPoint="true"/>
106
- ```
107
-
108
- 2. Import method
109
-
110
- ```js
111
- // Import in Vue file, e.g., component.vue
112
- import { MsgLoading, MsgContent, MsgThought } from '@tencent/lke-component';
113
-
114
- // Register components
115
- export default {
116
- components: {
117
- MsgContent,
118
- MsgLoading,
119
- MsgThought,
120
- }
121
- }
122
-
123
- // Use in template
124
- <MsgLoading :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" />
125
-
126
- <!-- Markdown rendering -->
127
- <MsgContent :isReplaceLinks="true" :loadingMessage="item.loading_message" :content="item.content" :isFinal="item.is_final" />
128
-
129
- <!-- DeepSeek thinking content rendering -->
130
- <MsgThought
131
- :content="thinkingContent"
132
- :title="thinkingTitle"
133
- :titleIcon="test.png"
134
- :nodeName="deepseek"
135
- :status="success"
136
- :elapsed="17485"
137
- />
138
- ```
139
-
140
- ### Usage in React Projects
141
-
142
- ```jsx
143
- import { MsgContent, MsgThought } from "lke-component/react";
144
- import "lke-component/css";
145
-
146
- const App = () => {
147
- const [list, setList] = useState([{
148
- content: "Nice weather today<b>?</b>",
149
- isFinal: true,
150
- loadingMessage: false,
151
- isReplaceLinks: false,
152
- styleObj: {},
153
- clazzTable: '',
154
- clazzMd: '',
155
- anchorAttributes: {},
156
- id: 1,
157
- linkify: false,
158
- thoughts: [{
159
- title: "Thinking Complete",
160
- titleIcon: 'test.png',
161
- nodeName: "deepseek",
162
- status: "success",
163
- detailVisible: true,
164
- elapsed: 17485,
165
- content: `Okay, I need to process the user's question...`,
166
- }]
167
- }]);
168
-
169
- return (
170
- <div className="main">
171
- {list.map((item, index) => (
172
- <div>
173
- {item.thoughts.map((thought, index) => (
174
- <MsgThought
175
- key={index}
176
- detailVisible={thought.detailVisible}
177
- content={thought.content}
178
- title={thought.title}
179
- titleIcon={thought.titleIcon}
180
- nodeName={thought.nodeName}
181
- status={thought.status}
182
- elapsed={thought.elapsed}
183
- onTitleClick={() => void 0}
184
- />
185
- ))}
186
- </div>
187
- <MsgContent
188
- key={id}
189
- content={item.content}
190
- isFinal={item.isFinal}
191
- styleObj={item.styleObj}
192
- clazzTable={item.clazzTable}
193
- clazzMd={item.clazzMd}
194
- anchorAttributes={item.anchorAttributes}
195
- linkify={item.linkify}
196
- isReplaceLinks={item.isReplaceLinks}
197
- />
198
- ))}
199
- </div>
200
- );
201
- }
202
- ```
203
-
204
- ---
205
-
206
- <a id="中文"></a>
207
-
208
- ## 中文
209
-
210
3
  知识引擎大模型对话消息渲染组件,适用于基于vue2和react搭建的项目。
211
4
 
212
5
  其它项目环境参考
213
6
  * 基于vue3的项目参考 [链接](https://www.npmjs.com/package/lke-component-vue3)
214
- * 基于react的项目参考 [链接](#在react项目中使用)
7
+
8
+ * 基于react的项目参考 [链接](#react)
9
+
215
10
  * 小程序参考 [链接](https://www.npmjs.com/package/lke-utils)
216
11
 
217
- ### 组件介绍
218
12
 
219
- 提供四个组件:LkeMsg、MsgContent、MsgLoading、MsgThought
13
+ ## 组件介绍
14
+
15
+ 提供三个组件:LkeMsg、MsgContent、MsgLoading
220
16
 
221
- **MsgLoading**: 展示模型加载中的状态
17
+
18
+ MsgLoading: 展示模型加载中的状态
222
19
 
223
20
  ```
224
21
  props:
@@ -228,8 +25,7 @@ props:
228
25
  transferStatus: Boolean // 转人工状态
229
26
  ```
230
27
 
231
- **MsgContent**: 展示MD内容
232
-
28
+ MsgContent 展示MD内容
233
29
  ```
234
30
  props:
235
31
  content: String, // MD消息
@@ -242,8 +38,7 @@ props:
242
38
  linkify: Boolean // vue-markdown 的props透传,见示例
243
39
  ```
244
40
 
245
- **LkeMsg**: 两个组件的聚合态
246
-
41
+ LkeMsg 两个组件的聚合态
247
42
  ```
248
43
  props:
249
44
  LoadingIcon: String, // 加载中的图标CDN地址,如果没有传的话,默认不显示图标
@@ -262,30 +57,28 @@ props:
262
57
  hideCursorPoint: Boolean | undefined //是否显示打印的图标
263
58
  ```
264
59
 
265
- **MsgThought**: 渲染deepseek 的思考内容
266
-
60
+ MsgThought 渲染deepseek 的思考内容
267
61
  ```
268
62
  props:
269
63
  content: String // 思考内容
270
- title: String // 标题,如"思考完成"
64
+ title: String // 标题,如“思考完成"
271
65
  titleIcon: String // 图标小图标icon 大小16x16px
272
- nodeName: String // 可不填,如"deepseek"
66
+ nodeName: String // 可不填,如”deepseek
273
67
  status: String // 思考状态,可选值'success', 'failed', 'processing', 'stop'
274
68
  elapsed: number // 思考花费时间, 毫秒,如17485
275
69
  ```
276
70
 
277
- ### 在vue2项目里使用
278
-
71
+ ## 在vue2项目里使用
279
72
  1. install方式引入
280
73
 
281
- ```js
74
+ ```
282
75
  // 在vue的入口文件引入组件库
283
76
  import lkeComponent from 'lke-component';
284
77
  Vue.use(lkeComponent);
285
78
 
286
79
  // 在对应的vue页面里面使用组件
287
80
  <!-- Loading切换 + Markdown渲染 -->
288
- <LkeMsg :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" :isReplaceLinks="true" :content="item.content" :isFinal="item.is_final" />
81
+ <LkeMsg :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" :isReplaceLinks="true" :content="item.content" :isFinal="item.is_final" :clazzMd="`question-text ${webIMSource === 'client' && isMobile ? 'question-text-mobile' : ''}`" :styleObj="{ 'max-width': webIMSource === 'client' && isMobile ? '352px' : '680px' }" />
289
82
 
290
83
  <!-- 非转人工情况下, 展示临时[正在思考中]消息 -->
291
84
  <MsgLoading :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" />
@@ -301,12 +94,11 @@ Vue.use(lkeComponent);
301
94
  />
302
95
 
303
96
  <!-- Markdown渲染 -->
304
- <MsgContent :isReplaceLinks="true" :loadingMessage="item.loading_message" :content="item.content" :isFinal="item.is_final" :printCount="1" :hideCursorPoint="true"/>
97
+ <MsgContent :isReplaceLinks="true" :loadingMessage="item.loading_message" :content="item.content" :isFinal="item.is_final" :clazzMd="`question-text ${webIMSource === 'client' && isMobile ? 'question-text-mobile' : ''}`" :styleObj="{ 'max-width': webIMSource === 'client' && isMobile ? '352px' : '680px' }" :printCount="1" :hideCursorPoint="true"/>
305
98
  ```
306
99
 
307
100
  2. import方式引入
308
-
309
- ```js
101
+ ```
310
102
  // 在需要使用此组件的vue文件,比如component.vue中引入
311
103
  import { MsgLoading, MsgContent, MsgThought } from '@tencent/lke-component';
312
104
 
@@ -322,8 +114,9 @@ export default {
322
114
  // 在template标签中使用
323
115
  <MsgLoading :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" />
324
116
 
117
+
325
118
  <!-- Markdown渲染 -->
326
- <MsgContent :isReplaceLinks="true" :loadingMessage="item.loading_message" :content="item.content" :isFinal="item.is_final" />
119
+ <MsgContent :isReplaceLinks="true" :loadingMessage="item.loading_message" :content="item.content" :isFinal="item.is_final" :clazzMd="`question-text ${webIMSource === 'client' && isMobile ? 'question-text-mobile' : ''}`" :styleObj="{ 'max-width': webIMSource === 'client' && isMobile ? '352px' : '680px' }" />
327
120
 
328
121
  <!-- deepseek 思考内容渲染 -->
329
122
  <MsgThought
@@ -334,34 +127,50 @@ export default {
334
127
  :status="success"
335
128
  :elapsed="17485"
336
129
  />
130
+
337
131
  ```
338
132
 
339
- ### 在react项目中使用
340
133
 
341
- ```jsx
134
+
135
+
136
+ ## 在react项目中使用
137
+
138
+ <div id="react"></div>
139
+
140
+ ```
342
141
  import { MsgContent, MsgThought } from "lke-component/react";
343
142
  import "lke-component/css";
344
143
 
345
144
  const App = () => {
346
145
  const [list, setList] = useState([{
347
146
  content: "天气不错哦<b>?</b>",
348
- isFinal: true,
349
- loadingMessage: false,
350
- isReplaceLinks: false,
351
- styleObj: {},
352
- clazzTable: '',
353
- clazzMd: '',
354
- anchorAttributes: {},
147
+ isFinal: true, // 消息是否输出结束
148
+ loadingMessage: false, // 是否加载中
149
+ isReplaceLinks: false, // 是否替换链接为第三方提示
150
+ styleObj: {}, // MD消息体的style
151
+ clazzTable: '', // MD消息体的 table 样式
152
+ clazzMd: '', // MD消息体的类名
153
+ anchorAttributes: {}, // 为链接添加自定义属性,如{target: '_blank'}
355
154
  id: 1,
356
- linkify: false,
155
+ linkify: false // markdown-it 的props透传
357
156
  thoughts: [{
358
- title: "思考完成",
359
- titleIcon: 'test.png',
360
- nodeName: "deepseek",
361
- status: "success",
362
- detailVisible: true,
363
- elapsed: 17485,
364
- content: `好的,我现在需要处理用户的问题...`,
157
+ title: "思考完成", // 标题
158
+ titleIcon: 'test.png', // 标题旁的icon,后端一般返回 emoji 图标地址
159
+ nodeName: "deepseek", // 非必传,显示大模型名称
160
+ status: "success", // 思考状态,用来显示不同状态 icon
161
+ detailVisible: true, // 控制思考内容区域是否显示,配合onTitleClick,可以控制思考内容展开和收起
162
+ elapsed: 17485, // 思考时间,单位 ms
163
+ content: ` // // 思考内容
164
+ 好的,我现在需要处理用户的问题“你好”,并根据提供的搜索结果生成一个回答,同时正确引用来源。首先,用户的问题是一个常见的问候语,所以答案应该解释“你好”的含义和用法。
165
+
166
+ 看一下搜索结果的各个条目。结果1到4、7、8都是关于“你好”这个词语的解释,包括它的拼音、用法、近义词等。而结果5、6、9是关于韩国电影《你好》的信息,和用户的问题无关,可以忽略。
167
+
168
+ 接下来,我需要从相关的结果中提取关键信息。例如,结果1提到“你好”是用于礼貌的打招呼或问候,适用于非熟人群体。结果2和3也给出了类似的解释,并指出它是汉语中的常用敬语。结果4详细介绍了“你好”的不同解释,包括网络解释和基础解释。结果7和8补充了其作为打招呼的敬语用法。
169
+
170
+ 需要将这些信息整合成一个连贯的回答,并用正确的引用标注。例如,综合结果1、2、3、4、7、8的内容,说明“你好”的基本含义、用法以及适用场合。注意不要提到电影相关的信息,因为与问题无关。
171
+
172
+ 最后,确保回答简洁明了,使用中文口语化表达,避免使用Markdown格式,并在适当的位置添加引用,如[1](@ref)、[2](@ref)等。同时,根据当前时间2025年2月19日,用户的问题只是问候,不需要时间相关的调整,所以直接回答即可。
173
+ `,
365
174
  }]
366
175
  }]);
367
176
 
@@ -34,4 +34,4 @@ PERFORMANCE OF THIS SOFTWARE.
34
34
 
35
35
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
36
36
 
37
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
37
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */