lke-component 1.1.19-beta-13 → 1.1.19-beta-15

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.
Files changed (3) hide show
  1. package/README.en.md +206 -0
  2. package/README.md +24 -28
  3. package/package.json +1 -1
package/README.en.md ADDED
@@ -0,0 +1,206 @@
1
+ # lke-component
2
+
3
+ English | [中文](./README.md)
4
+
5
+ Message rendering component for LKE (Large Knowledge Engine) conversations, designed for Vue2 and React projects.
6
+
7
+ For other environments:
8
+ * Vue3 projects: [Link](https://www.npmjs.com/package/lke-component-vue3)
9
+ * React projects: [Link](#usage-in-react-projects)
10
+ * Mini Programs: [Link](https://www.npmjs.com/package/lke-utils)
11
+
12
+ ## Components
13
+
14
+ Four components are provided: `LkeMsg`, `MsgContent`, `MsgLoading`, `MsgThought`
15
+
16
+ **MsgLoading**: Shows model loading state
17
+
18
+ ```
19
+ props:
20
+ loadingIcon: String, // Message icon, displays if provided
21
+ loadingMessage: Boolean, // Whether in loading state
22
+ loadingText: String, // Loading message content
23
+ transferStatus: Boolean // Transfer to human agent status
24
+ ```
25
+
26
+ **MsgContent**: Renders Markdown content
27
+
28
+ ```
29
+ props:
30
+ content: String, // Markdown message
31
+ isFinal: Boolean, // Whether the message output is complete
32
+ isReplaceLinks: Boolean, // Whether to replace links with third-party prompts
33
+ styleObj: Object, // Style object for MD message body
34
+ clazzTable: String, // Table class for MD message body (default styles will be added)
35
+ clazzMd: String, // Class for MD message body
36
+ anchorAttributes: Object, // Props passed to vue-markdown, see example
37
+ linkify: Boolean // Props passed to vue-markdown, see example
38
+ ```
39
+
40
+ **LkeMsg**: Aggregated component combining the above
41
+
42
+ ```
43
+ props:
44
+ LoadingIcon: String, // CDN URL for loading icon, not displayed if not provided
45
+ type: String, // Current message type, usually 'reply' or 'token_stat'
46
+ isReplaceLinks: Boolean, // Whether to replace with LLM third-party link prompts
47
+ showProcedures: Boolean, // Whether to show model output status
48
+ transferStatus: Boolean, // Transfer to human agent status
49
+ clazz: String, // Class name for outer wrapper div
50
+ item: Object, // Current message content
51
+ styleObj: Object, // Style object for MD message body
52
+ clazzTable: String, // Table class for MD message body, default styles: table-style, table
53
+ clazzMd: String, // Class for MD message body, default style: answer-md
54
+ anchorAttributes: Object, // Props passed to vue-markdown, see example
55
+ linkify: Boolean // Props passed to vue-markdown, see example
56
+ printCount: Number | undefined // Characters per print for timing control
57
+ hideCursorPoint: Boolean | undefined // Whether to show print cursor icon
58
+ ```
59
+
60
+ **MsgThought**: Renders DeepSeek thinking content
61
+
62
+ ```
63
+ props:
64
+ content: String // Thinking content
65
+ title: String // Title, e.g., "Thinking Complete"
66
+ titleIcon: String // Small icon, 16x16px
67
+ nodeName: String // Optional, e.g., "deepseek"
68
+ status: String // Thinking status: 'success', 'failed', 'processing', 'stop'
69
+ elapsed: number // Time spent thinking in milliseconds, e.g., 17485
70
+ ```
71
+
72
+ ## Usage in Vue2 Projects
73
+
74
+ 1. Install and import
75
+
76
+ ```js
77
+ // Import in Vue entry file
78
+ import lkeComponent from 'lke-component';
79
+ Vue.use(lkeComponent);
80
+
81
+ // Use in Vue pages
82
+ <!-- Loading toggle + Markdown rendering -->
83
+ <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' }" />
84
+
85
+ <!-- Show temporary [Thinking...] message when not transferring to human -->
86
+ <MsgLoading :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" />
87
+
88
+ <!-- DeepSeek thinking content rendering -->
89
+ <MsgThought
90
+ :content="thinkingContent"
91
+ :title="thinkingTitle"
92
+ :titleIcon="test.png"
93
+ :nodeName="deepseek"
94
+ :status="success"
95
+ :elapsed="17485"
96
+ />
97
+
98
+ <!-- Markdown rendering -->
99
+ <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"/>
100
+ ```
101
+
102
+ 2. Import method
103
+
104
+ ```js
105
+ // Import in Vue file, e.g., component.vue
106
+ import { MsgLoading, MsgContent, MsgThought } from '@tencent/lke-component';
107
+
108
+ // Register components
109
+ export default {
110
+ components: {
111
+ MsgContent,
112
+ MsgLoading,
113
+ MsgThought,
114
+ }
115
+ }
116
+
117
+ // Use in template
118
+ <MsgLoading :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" />
119
+
120
+ <!-- Markdown rendering -->
121
+ <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' }" />
122
+
123
+ <!-- DeepSeek thinking content rendering -->
124
+ <MsgThought
125
+ :content="thinkingContent"
126
+ :title="thinkingTitle"
127
+ :titleIcon="test.png"
128
+ :nodeName="deepseek"
129
+ :status="success"
130
+ :elapsed="17485"
131
+ />
132
+ ```
133
+
134
+ ## Usage in React Projects
135
+
136
+ ```jsx
137
+ import { MsgContent, MsgThought } from "lke-component/react";
138
+ import "lke-component/css";
139
+
140
+ const App = () => {
141
+ const [list, setList] = useState([{
142
+ content: "Nice weather today<b>?</b>",
143
+ isFinal: true, // Whether message output is complete
144
+ loadingMessage: false, // Whether loading
145
+ isReplaceLinks: false, // Whether to replace links with third-party prompts
146
+ styleObj: {}, // Style object for MD message body
147
+ clazzTable: '', // Table class for MD message body
148
+ clazzMd: '', // Class for MD message body
149
+ anchorAttributes: {}, // Custom attributes for links, e.g., {target: '_blank'}
150
+ id: 1,
151
+ linkify: false, // Props passed to markdown-it
152
+ thoughts: [{
153
+ title: "Thinking Complete", // Title
154
+ titleIcon: 'test.png', // Icon next to title, usually emoji icon URL from backend
155
+ nodeName: "deepseek", // Optional, shows LLM name
156
+ status: "success", // Thinking status, shows different status icons
157
+ detailVisible: true, // Controls thinking content visibility, use with onTitleClick for expand/collapse
158
+ elapsed: 17485, // Thinking time in ms
159
+ content: ` // Thinking content
160
+ Okay, I need to process the user's question "Hello" and generate a response based on the provided search results while correctly citing sources. First, the user's question is a common greeting, so the answer should explain the meaning and usage of "Hello".
161
+
162
+ Looking at the search result entries. Results 1 to 4, 7, 8 are all about the explanation of the word "Hello", including its pinyin, usage, synonyms, etc. Results 5, 6, 9 are about the Korean movie "Hello", which is irrelevant to the user's question and can be ignored.
163
+
164
+ Next, I need to extract key information from the relevant results. For example, result 1 mentions that "Hello" is used for polite greetings, suitable for non-acquaintances. Results 2 and 3 also give similar explanations, pointing out that it is a common honorific in Chinese. Result 4 introduces different interpretations of "Hello" in detail, including network interpretation and basic interpretation. Results 7 and 8 supplement its usage as a greeting honorific.
165
+
166
+ This information needs to be integrated into a coherent answer with correct citation annotations. For example, combining the content of results 1, 2, 3, 4, 7, 8, explain the basic meaning, usage and applicable occasions of "Hello". Be careful not to mention movie-related information as it is irrelevant to the question.
167
+
168
+ Finally, ensure the answer is concise and clear, using colloquial Chinese expression, avoiding Markdown format, and adding citations at appropriate places, such as [1](@ref), [2](@ref), etc.
169
+ `,
170
+ }]
171
+ }]);
172
+
173
+ return (
174
+ <div className="main">
175
+ {list.map((item, index) => (
176
+ <div>
177
+ {item.thoughts.map((thought, index) => (
178
+ <MsgThought
179
+ key={index}
180
+ detailVisible={thought.detailVisible}
181
+ content={thought.content}
182
+ title={thought.title}
183
+ titleIcon={thought.titleIcon}
184
+ nodeName={thought.nodeName}
185
+ status={thought.status}
186
+ elapsed={thought.elapsed}
187
+ onTitleClick={() => void 0}
188
+ />
189
+ ))}
190
+ </div>
191
+ <MsgContent
192
+ key={id}
193
+ content={item.content}
194
+ isFinal={item.isFinal}
195
+ styleObj={item.styleObj}
196
+ clazzTable={item.clazzTable}
197
+ clazzMd={item.clazzMd}
198
+ anchorAttributes={item.anchorAttributes}
199
+ linkify={item.linkify}
200
+ isReplaceLinks={item.isReplaceLinks}
201
+ />
202
+ ))}
203
+ </div>
204
+ );
205
+ }
206
+ ```
package/README.md CHANGED
@@ -1,21 +1,19 @@
1
1
  # lke-component
2
2
 
3
+ [English](./README.en.md) | 中文
4
+
3
5
  知识引擎大模型对话消息渲染组件,适用于基于vue2和react搭建的项目。
4
6
 
5
7
  其它项目环境参考
6
8
  * 基于vue3的项目参考 [链接](https://www.npmjs.com/package/lke-component-vue3)
7
-
8
- * 基于react的项目参考 [链接](#react)
9
-
9
+ * 基于react的项目参考 [链接](#在react项目中使用)
10
10
  * 小程序参考 [链接](https://www.npmjs.com/package/lke-utils)
11
11
 
12
-
13
12
  ## 组件介绍
14
13
 
15
- 提供三个组件:LkeMsg、MsgContent、MsgLoading
16
-
14
+ 提供四个组件:LkeMsg、MsgContent、MsgLoading、MsgThought
17
15
 
18
- MsgLoading 展示模型加载中的状态
16
+ **MsgLoading**: 展示模型加载中的状态
19
17
 
20
18
  ```
21
19
  props:
@@ -25,7 +23,8 @@ props:
25
23
  transferStatus: Boolean // 转人工状态
26
24
  ```
27
25
 
28
- MsgContent 展示MD内容
26
+ **MsgContent**: 展示MD内容
27
+
29
28
  ```
30
29
  props:
31
30
  content: String, // MD消息
@@ -38,7 +37,8 @@ props:
38
37
  linkify: Boolean // vue-markdown 的props透传,见示例
39
38
  ```
40
39
 
41
- LkeMsg 两个组件的聚合态
40
+ **LkeMsg**: 两个组件的聚合态
41
+
42
42
  ```
43
43
  props:
44
44
  LoadingIcon: String, // 加载中的图标CDN地址,如果没有传的话,默认不显示图标
@@ -57,21 +57,23 @@ props:
57
57
  hideCursorPoint: Boolean | undefined //是否显示打印的图标
58
58
  ```
59
59
 
60
- MsgThought 渲染deepseek 的思考内容
60
+ **MsgThought**: 渲染deepseek 的思考内容
61
+
61
62
  ```
62
63
  props:
63
64
  content: String // 思考内容
64
- title: String // 标题,如“思考完成"
65
+ title: String // 标题,如"思考完成"
65
66
  titleIcon: String // 图标小图标icon 大小16x16px
66
- nodeName: String // 可不填,如”deepseek
67
+ nodeName: String // 可不填,如"deepseek"
67
68
  status: String // 思考状态,可选值'success', 'failed', 'processing', 'stop'
68
69
  elapsed: number // 思考花费时间, 毫秒,如17485
69
70
  ```
70
71
 
71
72
  ## 在vue2项目里使用
73
+
72
74
  1. install方式引入
73
75
 
74
- ```
76
+ ```js
75
77
  // 在vue的入口文件引入组件库
76
78
  import lkeComponent from 'lke-component';
77
79
  Vue.use(lkeComponent);
@@ -98,7 +100,8 @@ Vue.use(lkeComponent);
98
100
  ```
99
101
 
100
102
  2. import方式引入
101
- ```
103
+
104
+ ```js
102
105
  // 在需要使用此组件的vue文件,比如component.vue中引入
103
106
  import { MsgLoading, MsgContent, MsgThought } from '@tencent/lke-component';
104
107
 
@@ -114,7 +117,6 @@ export default {
114
117
  // 在template标签中使用
115
118
  <MsgLoading :loadingIcon="loadingIcon" :loadingMessage="item.loading_message" :loadingText="item.text" :transferStatus="transferStatus" />
116
119
 
117
-
118
120
  <!-- Markdown渲染 -->
119
121
  <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' }" />
120
122
 
@@ -127,17 +129,11 @@ export default {
127
129
  :status="success"
128
130
  :elapsed="17485"
129
131
  />
130
-
131
132
  ```
132
133
 
133
-
134
-
135
-
136
134
  ## 在react项目中使用
137
135
 
138
- <div id="react"></div>
139
-
140
- ```
136
+ ```jsx
141
137
  import { MsgContent, MsgThought } from "lke-component/react";
142
138
  import "lke-component/css";
143
139
 
@@ -152,7 +148,7 @@ const App = () => {
152
148
  clazzMd: '', // MD消息体的类名
153
149
  anchorAttributes: {}, // 为链接添加自定义属性,如{target: '_blank'}
154
150
  id: 1,
155
- linkify: false // markdown-it 的props透传
151
+ linkify: false, // markdown-it 的props透传
156
152
  thoughts: [{
157
153
  title: "思考完成", // 标题
158
154
  titleIcon: 'test.png', // 标题旁的icon,后端一般返回 emoji 图标地址
@@ -160,14 +156,14 @@ const App = () => {
160
156
  status: "success", // 思考状态,用来显示不同状态 icon
161
157
  detailVisible: true, // 控制思考内容区域是否显示,配合onTitleClick,可以控制思考内容展开和收起
162
158
  elapsed: 17485, // 思考时间,单位 ms
163
- content: ` // // 思考内容
164
- 好的,我现在需要处理用户的问题“你好”,并根据提供的搜索结果生成一个回答,同时正确引用来源。首先,用户的问题是一个常见的问候语,所以答案应该解释“你好”的含义和用法。
159
+ content: ` // 思考内容
160
+ 好的,我现在需要处理用户的问题"你好",并根据提供的搜索结果生成一个回答,同时正确引用来源。首先,用户的问题是一个常见的问候语,所以答案应该解释"你好"的含义和用法。
165
161
 
166
- 看一下搜索结果的各个条目。结果1到4、7、8都是关于“你好”这个词语的解释,包括它的拼音、用法、近义词等。而结果5、6、9是关于韩国电影《你好》的信息,和用户的问题无关,可以忽略。
162
+ 看一下搜索结果的各个条目。结果1到4、7、8都是关于"你好"这个词语的解释,包括它的拼音、用法、近义词等。而结果5、6、9是关于韩国电影《你好》的信息,和用户的问题无关,可以忽略。
167
163
 
168
- 接下来,我需要从相关的结果中提取关键信息。例如,结果1提到“你好”是用于礼貌的打招呼或问候,适用于非熟人群体。结果2和3也给出了类似的解释,并指出它是汉语中的常用敬语。结果4详细介绍了“你好”的不同解释,包括网络解释和基础解释。结果7和8补充了其作为打招呼的敬语用法。
164
+ 接下来,我需要从相关的结果中提取关键信息。例如,结果1提到"你好"是用于礼貌的打招呼或问候,适用于非熟人群体。结果2和3也给出了类似的解释,并指出它是汉语中的常用敬语。结果4详细介绍了"你好"的不同解释,包括网络解释和基础解释。结果7和8补充了其作为打招呼的敬语用法。
169
165
 
170
- 需要将这些信息整合成一个连贯的回答,并用正确的引用标注。例如,综合结果1、2、3、4、7、8的内容,说明“你好”的基本含义、用法以及适用场合。注意不要提到电影相关的信息,因为与问题无关。
166
+ 需要将这些信息整合成一个连贯的回答,并用正确的引用标注。例如,综合结果1、2、3、4、7、8的内容,说明"你好"的基本含义、用法以及适用场合。注意不要提到电影相关的信息,因为与问题无关。
171
167
 
172
168
  最后,确保回答简洁明了,使用中文口语化表达,避免使用Markdown格式,并在适当的位置添加引用,如[1](@ref)、[2](@ref)等。同时,根据当前时间2025年2月19日,用户的问题只是问候,不需要时间相关的调整,所以直接回答即可。
173
169
  `,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lke-component",
3
- "version": "1.1.19-beta-13",
3
+ "version": "1.1.19-beta-15",
4
4
  "main": "dist/lke-component.umd.js",
5
5
  "module": "dist/lke-component.esm.js",
6
6
  "files": [