@fe-free/core 4.1.40 → 4.1.42

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.
@@ -1,5 +1,6 @@
1
- import { Markdown } from '@fe-free/core';
1
+ import { Markdown } from '@fe-free/ai';
2
2
  import type { Meta, StoryObj } from '@storybook/react-vite';
3
+ import { useEffect, useState } from 'react';
3
4
 
4
5
  const meta: Meta<typeof Markdown> = {
5
6
  title: '@fe-free/core/Markdown',
@@ -9,11 +10,29 @@ const meta: Meta<typeof Markdown> = {
9
10
 
10
11
  export default meta;
11
12
 
13
+ function StreamingComponent(args) {
14
+ const [index, setIndex] = useState(0);
15
+
16
+ useEffect(() => {
17
+ setInterval(() => {
18
+ setIndex((value) => value + 1);
19
+ }, 50);
20
+ }, []);
21
+
22
+ return (
23
+ <Markdown
24
+ {...args}
25
+ content={args.content.slice(0, index)}
26
+ isStreaming={index !== args.content.length}
27
+ />
28
+ );
29
+ }
30
+
12
31
  type Story = StoryObj<typeof Markdown>;
13
32
 
14
33
  export const Default: Story = {
15
34
  args: {
16
- children: `
35
+ content: `
17
36
  # Markdown 组件示例
18
37
 
19
38
  这是一个 **Markdown** 组件的基本用法示例。
@@ -88,439 +107,78 @@ function hello(name: string): string {
88
107
  },
89
108
  };
90
109
 
91
- export const DeepSeek: Story = {
110
+ export const Streaming: Story = {
111
+ render: StreamingComponent,
92
112
  args: {
93
- children: `<think>
94
- 好的,我现在需要处理用户的问题。用户一开始用中文打招呼“你好”,然后我的回应应该遵循之前设定的角色和技能。首先,我需要确认用户是否是前端工程师求职者,或者他们需要哪方面的帮助。根据角色设定,我应该先了解他们的具体情况,比如技术栈、工作年限、项目经验和目标城市。
95
-
96
- 用户可能没有详细说明他们的需求,所以我需要引导他们提供更多信息。根据技能1中的步骤,我应该先询问他们的技术栈、工作年限、项目经验和目标城市。同时,我需要保持友好和专业,确保用户感到被理解和支持。
97
-
98
- 另外,用户可能对生成卡通头像感兴趣,但根据限制,我需要先处理求职相关的问题,再提及头像生成。因此,在初始回复中,我应该先专注于求职建议,然后在适当的时候提到头像生成选项。
99
-
100
- 我需要确保回复符合Markdown格式,使用适当的标题和列表结构,使信息清晰易读。同时,避免使用复杂术语,保持语言简洁明了,适合不同水平的用户。
101
-
102
- 现在,我需要按照模板组织回复,先欢迎用户,然后分步骤询问必要的信息,最后提到头像生成的选项。确保每个问题都明确,帮助用户逐步提供所需的信息,以便我能够提供有针对性的建议。
103
- </think>
104
-
105
- 你好!欢迎来到前端工程师求职助手。为了提供更有针对性的建议,请告诉我以下信息:
106
-
107
- ### 1. 你的技术栈
108
- - 是否掌握核心三件套(HTML/CSS/JavaScript)?
109
- - 熟悉哪些前端框架(React/Vue/Angular等)?
110
- - 是否有Node.js/Webpack/Vite等工程化经验?
111
-
112
- ### 2. 工作年限
113
- - 应届毕业生/1-3年经验/3-5年经验/5年以上?
114
-
115
- ### 3. 项目亮点
116
- - 请用一句话描述你最具代表性的项目(如:主导开发日均UV百万级的电商前端架构)
113
+ content: `
114
+ # Markdown 组件示例
117
115
 
118
- ### 4. 目标城市
119
- - 期望在哪个城市发展?
116
+ 这是一个 **Markdown** 组件的基本用法示例。
120
117
 
121
118
  ---
122
119
 
123
- 💡 **小贴士**:需要生成专属前端工程师卡通头像吗?可同步告知:
124
- 1. 意向职位(如:高级前端开发)
125
- 2. 工作年限
126
- 3. 目标城市
127
-
128
- 我会根据你的信息提供:求职策略+技术提升路径+简历优化建议+面试指南+定制头像(如需)
129
- `,
130
- },
131
- };
132
-
133
- export const DeepSeekPending: Story = {
134
- args: {
135
- children: `<think>
136
- 好的,我现在需要处理用户的问题。用户一开始用中文打招呼“你好”,然后我的回应应该遵循之前设定的角色和技能。首先,我需要确认用户是否是前端工程师求职者,或者他们需要哪方面的帮助。根据角色设定,我应该先了解他们的具体情况,比如技术栈、工作年限、项目经验和目标城市。
137
-
138
- `,
139
- },
140
- };
141
-
142
- export const Chart: Story = {
143
- args: {
144
- children: `
145
- ## 折线图示例
146
-
147
- \`\`\`chart
148
- {
149
- "data": {
150
- "columns": ["time", "amount"],
151
- "rows": [
152
- ["2025-06-03", 18.23],
153
- ["2025-06-10", 112.2],
154
- ["2025-06-23", 10],
155
- ["2025-07-01", 85.5],
156
- ["2025-07-15", 156.8]
157
- ]
158
- },
159
- "chart": {
160
- "chart_type": "line",
161
- "x_field": "time",
162
- "y_field": "amount",
163
- "title": "张三金额变化趋势图"
164
- }
165
- }
166
- \`\`\`
167
-
168
- 多条折线
169
-
170
- \`\`\`chart
171
- {
172
- "data": {
173
- "columns": ["quarter", "L'Oreal", "P&G", "Proya"],
174
- "rows": [
175
- ["FY23-Q4/23-Q2", 8, 7, null],
176
- ["FY24-Q1/23-Q3", 7, 6, null],
177
- ["FY24-Q2/23-Q4", 4, 3, null],
178
- ["FY24-Q3/24-Q1", 3, null, null],
179
- ["FY24-Q4/24-Q2", null, null, null],
180
- ["FY25-Q1/24-Q34",null,null,null]
181
- ]
182
- },
183
- "chart": {
184
- "chart_type": "line",
185
- "x_field": "quarter",
186
- "y_field": ["L'Oreal", "P&G","Proya"],
187
- "title": "欧莱雅、宝洁及珀莱雅增长率变化趋势"
188
- }
189
- }
190
- \`\`\`
191
-
192
- ## 柱状图示例
193
-
194
- \`\`\`chart
195
- {
196
- "data": {
197
- "columns": ["time", "amount"],
198
- "rows": [
199
- ["2025-06-03", 18.23],
200
- ["2025-06-10", 112.2],
201
- ["2025-06-23", 10],
202
- ["2025-07-01", 85.5],
203
- ["2025-07-15", 156.8]
204
- ]
205
- },
206
- "chart": {
207
- "chart_type": "bar",
208
- "x_field": "time",
209
- "y_field": "amount",
210
- "title": "张三金额变化趋势图"
211
- }
212
- }
213
- \`\`\`
120
+ ## 支持的特性
214
121
 
122
+ - 标题
123
+ - 列表
215
124
 
216
- ## 饼图示例
125
+ ---
217
126
 
218
- \`\`\`chart
219
- {
220
- "data": {
221
- "columns": ["category", "sales"],
222
- "rows": [
223
- ["电子产品", 45],
224
- ["服装", 30],
225
- ["食品", 15],
226
- ["家居", 10]
227
- ]
228
- },
229
- "chart": {
230
- "chart_type": "pie",
231
- "angle_field": "sales",
232
- "color_field": "category",
233
- "title": "销售品类分布"
234
- }
235
- }
236
- \`\`\`
127
+ ## 代码高亮
237
128
 
238
- ## 散点图示例
239
-
240
- \`\`\`chart
241
- {
242
- "data": {
243
- "columns": ["width", "height"],
244
- "rows": [
245
- [100, 200],
246
- [300, 400],
247
- [500, 600]
248
- ]
249
- },
250
- "chart": {
251
- "chart_type": "scatter",
252
- "x_field": "width",
253
- "y_field": "height",
254
- "title": "散点图示例"
255
- }
129
+ \`\`\`typescript
130
+ function hello(name: string): string {
131
+ return \`Hello, \${name}!\`;
256
132
  }
257
133
  \`\`\`
258
134
 
259
- ## 错误处理示例
260
-
261
- ### JSON 解析错误
262
-
263
- \`\`\`chart
264
- {
265
- "data": {
266
- "columns": ["time", "amount"],
267
- "rows": [
268
- ["2025-06-03", 18.23],
269
- ["2025-06-10", 112.2]
270
- ]
271
- },
272
- "chart": {
273
- "chart_type": "line",
274
- "x_field": "time",
275
- "y_field": "amount",
276
- "title": "张三金额变化趋势图"
277
- }
278
- \`\`\`
279
135
 
280
- ### 字段不存在错误
281
-
282
- \`\`\`chart
283
- {
284
- "data": {
285
- "columns": ["time", "amount"],
286
- "rows": [
287
- ["2025-06-03", 18.23],
288
- ["2025-06-10", 112.2]
289
- ]
290
- },
291
- "chart": {
292
- "chart_type": "line",
293
- "x_field": "nonexistent_field",
294
- "y_field": "amount",
295
- "title": "张三金额变化趋势图"
296
- }
297
- }
298
- \`\`\`
136
+ ## 表格
299
137
 
300
- ### 不支持的图表类型
138
+ | 姓名 | 年龄 | 城市 | 职业 | 邮箱 | 状态 |状态 |状态 |状态 |
139
+ | ------ | ---- | ------ | ---------- | --------------------- | ------ |------ |------ |------ |
140
+ | 张三 | 28 | 北京 | 前端开发 | zhangsan@example.com | 在职 |
141
+ | 李四 | 32 | 上海 | 产品经理 | lisi@example.com | 离职 |
142
+ | 王五 | 24 | 广州 | 设计师 | wangwu@example.com | 在职 |
143
+ | 赵六 | 29 | 深圳 | 测试工程师 | zhaoliu@example.com | 实习 |
301
144
 
302
- \`\`\`chart
303
- {
304
- "data": {
305
- "columns": ["time", "amount"],
306
- "rows": [
307
- ["2025-06-03", 18.23],
308
- ["2025-06-10", 112.2]
309
- ]
310
- },
311
- "chart": {
312
- "chart_type": "some_chart_type",
313
- "x_field": "time",
314
- "y_field": "amount",
315
- "title": "张三金额变化趋势图"
316
- }
317
- }
318
- \`\`\`
145
+ ---
319
146
  `,
320
147
  },
321
148
  };
322
149
 
323
- export const HMChart: Story = {
150
+ export const Latex: Story = {
324
151
  args: {
325
- children: `
326
- 类型定义见:https://github.com/frontend-free/free/blob/main/packages/core/src/markdown/hm_chart.tsx
327
-
328
- ## 折线图示例
329
-
330
- \`\`\`hmchart
331
- {
332
- "title": "趋势变化",
333
- "type": "line",
334
- "data": [
335
- { "year": "1991", "value": 3 },
336
- { "year": "1992", "value": 4 },
337
- { "year": "1993", "value": 3.5 }
338
- ],
339
- "xField": "year",
340
- "yField": "value"
341
- }
342
- \`\`\`
343
-
344
- \`\`\`hmchart
345
- {
346
- "title": "多条趋势变化",
347
- "type": "line",
348
- "data": [
349
- { "year": "1991", "type": "A", "value": 3 },
350
- { "year": "1991", "type": "B", "value": 4 },
351
- { "year": "1992", "type": "A", "value": 4 },
352
- { "year": "1992", "type": "B", "value": 4.5 },
353
- { "year": "1993", "type": "A", "value": 3.5 },
354
- { "year": "1993", "type": "B", "value": 6 }
355
- ],
356
- "xField": "year",
357
- "yField": "value",
358
- "seriesField": "type"
359
- }
360
- \`\`\`
361
-
362
- \`\`\`hmchart
363
- {
364
- "title": "柱状图",
365
- "type": "bar",
366
- "data": [
367
- { "year": "1991", "value": 3 },
368
- { "year": "1992", "value": 4 },
369
- { "year": "1993", "value": 3.5 }
370
- ],
371
- "xField": "year",
372
- "yField": "value"
373
- }
374
- \`\`\`
375
-
376
- \`\`\`hmchart
377
- {
378
- "title": "多条柱状图",
379
- "type": "bar",
380
- "data": [
381
- { "year": "1991", "type": "A", "value": 3 },
382
- { "year": "1991", "type": "B", "value": 4 },
383
- { "year": "1992", "type": "A", "value": 4 },
384
- { "year": "1992", "type": "B", "value": 4.5 },
385
- { "year": "1993", "type": "A", "value": 3.5 },
386
- { "year": "1993", "type": "B", "value": 6 }
387
- ],
388
- "xField": "year",
389
- "yField": "value",
390
- "seriesField": "type"
391
- }
392
- \`\`\`
393
-
394
- \`\`\`hmchart
395
- {
396
- "title": "饼图",
397
- "type": "pie",
398
- "data": [
399
- { "year": "1991", "value": 3 },
400
- { "year": "1992", "value": 4 },
401
- { "year": "1993", "value": 3.5 }
402
- ],
403
- "angleField": "value",
404
- "colorField": "year"
405
- }
406
- \`\`\`
407
-
408
- \`\`\`hmchart
409
- {
410
- "title": "散点图示例",
411
- "type": "scatter",
412
- "data": [
413
- {
414
- "gender": "female",
415
- "height": 161.2,
416
- "weight": 51.6
417
- },
418
- {
419
- "gender": "male",
420
- "height": 167.5,
421
- "weight": 59
422
- },
423
- {
424
- "gender": "female",
425
- "height": 159.5,
426
- "weight": 49.2
427
- },
428
- {
429
- "gender": "male",
430
- "height": 157,
431
- "weight": 63
432
- },
433
- {
434
- "gender": "male",
435
- "height": 155.8,
436
- "weight": 53.6
437
- },
438
- {
439
- "gender": "female",
440
- "height": 170,
441
- "weight": 59
442
- },
443
- {
444
- "gender": "female",
445
- "height": 159.1,
446
- "weight": 47.6
447
- },
448
- {
449
- "gender": "female",
450
- "height": 166,
451
- "weight": 69.8
452
- },
453
- {
454
- "gender": "female",
455
- "height": 176.2,
456
- "weight": 66.8
457
- },
458
- {
459
- "gender": "female",
460
- "height": 160.2,
461
- "weight": 75.2
462
- },
463
- {
464
- "gender": "female",
465
- "height": 172.5,
466
- "weight": 55.2
467
- },
468
- {
469
- "gender": "female",
470
- "height": 170.9,
471
- "weight": 54.2
472
- },
473
- {
474
- "gender": "female",
475
- "height": 172.9,
476
- "weight": 62.5
477
- },
478
- {
479
- "gender": "male",
480
- "height": 153.4,
481
- "weight": 42
482
- },
483
- {
484
- "gender": "male",
485
- "height": 160,
486
- "weight": 50
487
- }
488
- ],
489
- "xField": "height",
490
- "yField": "weight",
491
- "colorField": "gender"
492
- }
493
- \`\`\`
152
+ content: `
153
+ ### Latex
154
+ inline standard: $\\frac{df}{dt}$ \n
155
+ block standard:\n
156
+ $$
157
+ \\Delta t' = \\frac{\\Delta t}{\\sqrt{1 - \\frac{v^2}{c^2}}}
158
+ $$
159
+
160
+ inline: \\(\\frac{df}{dt}\\) \n
161
+ block: \n
162
+ \\[
163
+ \\Delta t' = \\frac{\\Delta t}{\\sqrt{1 - \\frac{v^2}{c^2}}}
164
+ \\]
494
165
 
495
166
  `,
496
167
  },
497
168
  };
498
169
 
499
- export const Knowledge: Story = {
170
+ export const Think: Story = {
171
+ render: StreamingComponent,
500
172
  args: {
501
- children: `
502
- 根据检索结果,知识库中包含多个酒店的信息。[^knowledge:1-0]例如:\n\n- **杭州城中香格里拉**:位于杭州长寿路6号,提供多种餐饮选择,包括非凡酒廊、美食汇、城中啤酒餐吧以及城中小馆中餐厅[^knowledge:0-0]。\n- **凯恩斯香格里拉**:位于澳大利亚Pierpoint Road Cairns, Queensland,提供纯正澳式待客之道,靠近马林码头与珊瑚海交汇处[^knowledge:2-0]。\n- **马斯喀特 Al Husn 香格里拉**:位于阿曼P.O. Box 644, Muscat 100,是一个成人专享的世外桃源,拥有私人海滩和海湾[^knowledge:3-0]。\n\n此外,还有一家未直接命名但详细描述了其服务特色的豪华酒店,该酒店以江南丝绸商贸之家为灵感设计,提供独特的入住体验,包括定制贴心体验、精致餐饮及新颖的康养项目[^knowledge:4-0][^knowledge:14-0]。
503
- `,
504
- knowledgeRefs: [
505
- { id: '0-0', title: '杭州城中香格里拉' },
506
- { id: '1-0', title: '巴拉巴拉酒店' },
507
- { id: '2-0', title: '凯恩斯香格里拉' },
508
- { id: '3-0', title: '马斯喀特 Al Husn 香格里拉' },
509
- { id: '4-0', title: '江南丝绸商贸之家' },
510
- ],
511
- onKnowledgeRef: (id?: string) => {
512
- console.log('onKnowledgeRef', id);
513
- },
514
- },
515
- };
516
-
517
- export const KnowledgeWithoutData: Story = {
518
- args: {
519
- children: `
520
- 根据检索结果,知识库中包含多个酒店的信息。[^knowledge:1-0]例如:\n\n- **杭州城中香格里拉**:位于杭州长寿路6号,提供多种餐饮选择,包括非凡酒廊、美食汇、城中啤酒餐吧以及城中小馆中餐厅[^knowledge:0-0]。\n- **凯恩斯香格里拉**:位于澳大利亚Pierpoint Road Cairns, Queensland,提供纯正澳式待客之道,靠近马林码头与珊瑚海交汇处[^knowledge:2-0]。\n- **马斯喀特 Al Husn 香格里拉**:位于阿曼P.O. Box 644, Muscat 100,是一个成人专享的世外桃源,拥有私人海滩和海湾[^knowledge:3-0]。\n\n此外,还有一家未直接命名但详细描述了其服务特色的豪华酒店,该酒店以江南丝绸商贸之家为灵感设计,提供独特的入住体验,包括定制贴心体验、精致餐饮及新颖的康养项目[^knowledge:4-0][^knowledge:14-0]。
521
- `,
522
- onKnowledgeRef: (id?: string) => {
523
- console.log('onKnowledgeRef', id);
524
- },
173
+ content: `
174
+ <think>Deep thinking is a systematic and structured cognitive approach that requires individuals to move beyond intuition and superficial information, delving into the essence of a problem and its underlying principles through logical analysis, multi-perspective examination, and persistent inquiry. Unlike quick reactions or heuristic judgments, deep thinking emphasizes slow thinking, actively engaging knowledge reserves, critical thinking, and creativity to uncover deeper connections and meanings.
175
+ Key characteristics of deep thinking include:
176
+ Probing the Essence: Not settling for "what it is," but continuously asking "why" and "how it works" until reaching the fundamental logic.
177
+ Multidimensional Connections: Placing the issue in a broader context and analyzing it through interdisciplinary knowledge or diverse perspectives.
178
+ Skepticism & Reflection: Challenging existing conclusions, authoritative opinions, and even personal biases, validating them through logic or evidence.
179
+ Long-term Value Focus: Prioritizing systemic consequences and sustainable impact over short-term or localized benefits.
180
+ This mode of thinking helps individuals avoid cognitive biases in complex scenarios, improve decision-making, and generate groundbreaking insights in fields such as academic research, business innovation, and social problem-solving.</think>
181
+ # Hello Deep Thinking\n Deep thinking is over.\n\n You can use the think tag to package your thoughts.
182
+ `,
525
183
  },
526
184
  };
@@ -0,0 +1,69 @@
1
+ import { Think } from '@ant-design/x';
2
+ import Icons from '@fe-free/icons';
3
+ import classNames from 'classnames';
4
+ import { useCallback, useEffect, useState } from 'react';
5
+ import ThinkIcon from './svgs/think.svg?react';
6
+
7
+ interface MessageThinkProps {
8
+ title: string;
9
+ icon?: React.ReactNode;
10
+ loading?: boolean;
11
+ children?: React.ReactNode;
12
+ expanded?: boolean;
13
+ onClick?: () => void;
14
+ className?: string;
15
+ }
16
+
17
+ function MessageThink({
18
+ title,
19
+ icon,
20
+ loading,
21
+ children,
22
+ expanded: propsExpanded,
23
+ onClick,
24
+ className,
25
+ }: MessageThinkProps) {
26
+ const [expanded, setExpanded] = useState(propsExpanded || false);
27
+
28
+ useEffect(() => {
29
+ setExpanded(propsExpanded || false);
30
+ }, [propsExpanded]);
31
+
32
+ useEffect(() => {
33
+ // 如果 propsExpanded 未定义,则根据 loading 状态设置 expanded
34
+ if (propsExpanded === undefined && loading !== undefined) {
35
+ setExpanded(loading ? true : false);
36
+ }
37
+ }, [propsExpanded, loading]);
38
+
39
+ const handleClick = useCallback(() => {
40
+ setExpanded(!expanded);
41
+ onClick?.();
42
+ }, [expanded, onClick]);
43
+
44
+ return (
45
+ <Think
46
+ title={title}
47
+ icon={icon || <Icons component={ThinkIcon} className="!text-sm" />}
48
+ loading={loading}
49
+ blink={loading}
50
+ expanded={expanded}
51
+ onClick={handleClick}
52
+ className={classNames('fea-message-think', className)}
53
+ >
54
+ {children}
55
+ </Think>
56
+ );
57
+ }
58
+
59
+ function MessageThinkOfDeepSeek(props: MessageThinkProps) {
60
+ return (
61
+ <MessageThink
62
+ {...props}
63
+ className={classNames('fea-message-think-deep-seek', props.className)}
64
+ />
65
+ );
66
+ }
67
+
68
+ export { MessageThink, MessageThinkOfDeepSeek };
69
+ export type { MessageThinkProps };
@@ -0,0 +1,3 @@
1
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M9.80022 0.000346623C10.3956 -0.0083669 10.97 0.146298 11.3912 0.566726C11.8123 0.987879 11.9677 1.56297 11.9583 2.1584C11.9496 2.75164 11.7782 3.41387 11.4935 4.09352C11.2145 4.7429 10.8741 5.36414 10.477 5.94878C10.9214 6.60592 11.2793 7.25436 11.5349 7.86575C11.8196 8.54541 11.9902 9.20764 11.9997 9.80088C12.0084 10.3963 11.853 10.9707 11.4326 11.3911C11.0114 11.8123 10.4363 11.9684 9.84088 11.9589C9.24763 11.9502 8.58613 11.7789 7.90575 11.4942C7.29726 11.2401 6.65318 10.8843 5.99894 10.4428C5.34543 10.8843 4.70135 11.2401 4.09286 11.4942C3.4132 11.7789 2.75097 11.9502 2.15773 11.9589C1.5623 11.9684 0.987938 11.8123 0.566784 11.3918C0.14563 10.9707 -0.00903481 10.3963 0.000404838 9.80088C0.00911836 9.20691 0.179032 8.54541 0.463674 7.86575C0.719271 7.25436 1.0758 6.60592 1.52019 5.94878C1.12348 5.36412 0.783555 4.74287 0.505063 4.09352C0.220421 3.41387 0.0505076 2.75164 0.041068 2.1584C0.0323545 1.56297 0.186293 0.988605 0.607447 0.567452C1.0286 0.146298 1.60369 -0.00836689 2.19912 0.00107276C2.79236 0.00978629 3.45387 0.1797 4.13425 0.464342C4.72967 0.713403 5.35922 1.05831 5.99894 1.486C6.63866 1.05759 7.26966 0.713403 7.86509 0.464342C8.54474 0.1797 9.20624 0.00978628 9.80022 0.000346623ZM2.20638 6.89057C1.9225 7.33469 1.67575 7.80148 1.46863 8.28618C1.21667 8.88887 1.09468 9.40805 1.08814 9.81686C1.08233 10.2235 1.18835 10.4733 1.33648 10.6214C1.48533 10.7695 1.73585 10.8756 2.14175 10.8697C2.55056 10.8639 3.06974 10.7419 3.67243 10.49C4.15456 10.2835 4.61891 10.0377 5.06078 9.75514C4.53958 9.34105 4.04257 8.89738 3.57222 8.42632C3.0712 7.9253 2.61374 7.40829 2.20638 6.89057ZM9.7915 6.89057C8.95508 7.9533 7.99736 8.91467 6.93782 9.75514C7.4207 10.0601 7.88905 10.307 8.32618 10.49C8.92886 10.7419 9.44877 10.8639 9.85758 10.8697C10.2642 10.8763 10.514 10.7703 10.6621 10.6214C10.8103 10.4733 10.9163 10.2235 10.9105 9.81686C10.9039 9.40805 10.7819 8.88814 10.53 8.28618C10.3226 7.80147 10.0756 7.33468 9.7915 6.89057ZM5.99894 2.82208C5.39911 3.27502 4.83182 3.76951 4.30126 4.30192C3.78316 4.81841 3.30086 5.36961 2.85772 5.95168C3.31201 6.55419 3.80822 7.12392 4.34264 7.65663C4.86105 8.1765 5.41444 8.66026 5.99894 9.10453C6.5508 8.687 7.10992 8.20268 7.65596 7.65663C8.18989 7.12387 8.68561 6.55414 9.13944 5.95168C8.69678 5.36964 8.21497 4.81845 7.69735 4.30192C7.13824 3.74281 6.56459 3.24686 5.99894 2.82208ZM2.18242 1.08881C1.77579 1.083 1.526 1.18902 1.37787 1.33715C1.22974 1.486 1.12372 1.73579 1.12953 2.14242C1.13607 2.55123 1.25806 3.07041 1.51002 3.6731C1.68647 4.09498 1.92174 4.54445 2.21074 5.00917C2.62264 4.4922 3.06362 3.99909 3.53156 3.53223C4.01281 3.05013 4.52198 2.59673 5.05643 2.17437C4.5888 1.88319 4.13715 1.64648 3.71309 1.4693C3.11041 1.21734 2.59123 1.09535 2.18242 1.08881ZM9.81619 1.08881C9.40738 1.09607 8.88748 1.21734 8.28552 1.4693C7.86146 1.64648 7.40908 1.88319 6.94218 2.17365C7.47661 2.59602 7.98578 3.04942 8.46705 3.5315C8.93477 3.99886 9.37552 4.49245 9.78715 5.0099C10.0761 4.54518 10.3136 4.0957 10.49 3.67382C10.742 3.07114 10.864 2.55196 10.8698 2.14315C10.8763 1.73652 10.7703 1.48673 10.6215 1.33787C10.4733 1.18974 10.2235 1.08373 9.81692 1.08954L9.81619 1.08881Z"/>
3
+ </svg>
@@ -0,0 +1,55 @@
1
+ import type { ComponentProps } from '@ant-design/x-markdown';
2
+ import { memo, useEffect, useState } from 'react';
3
+ import { MessageThinkOfDeepSeek } from './messages/message_think';
4
+
5
+ const ThinkComponent = memo((props: ComponentProps) => {
6
+ const [title, setTitle] = useState('思考中...');
7
+ const [loading, setLoading] = useState(true);
8
+ const [expand, setExpand] = useState(true);
9
+
10
+ useEffect(() => {
11
+ if (props.streamStatus === 'done') {
12
+ setTitle('完成思考');
13
+ setLoading(false);
14
+ setExpand(false);
15
+ }
16
+ }, [props.streamStatus]);
17
+
18
+ return (
19
+ <MessageThinkOfDeepSeek
20
+ title={title}
21
+ loading={loading}
22
+ expanded={expand}
23
+ onClick={() => setExpand(!expand)}
24
+ >
25
+ {props.children}
26
+ </MessageThinkOfDeepSeek>
27
+ );
28
+ });
29
+
30
+ function compatibleWithDeepSeek(text: string) {
31
+ if (!text.startsWith('<think>')) {
32
+ return text;
33
+ }
34
+
35
+ const [left, right] = text.split('</think>');
36
+
37
+ let newText = text;
38
+
39
+ // 如果 think 部分是 <think>\n\n</think>,相当于没有,则直接返回 right
40
+ if (text.startsWith('<think>\n\n</think>')) {
41
+ newText = right;
42
+ }
43
+ // 否则做一些处理
44
+ else {
45
+ newText =
46
+ left
47
+ .replace('<think>\n', '<think>')
48
+ .replace('\n</think>', '</think>')
49
+ .replace(/\n/g, '<br/>') + (right || '');
50
+ }
51
+
52
+ return newText;
53
+ }
54
+
55
+ export { compatibleWithDeepSeek, ThinkComponent };
@@ -2,6 +2,7 @@ import type { ProRenderFieldPropsType } from '@ant-design/pro-components';
2
2
  import { dateRender } from './date';
3
3
  import { jsonRender } from './json';
4
4
  import { jsonModalRender } from './json_modal';
5
+ import { markdownModalRender } from './markdown_modal';
5
6
  import { switchNumberRender, switchOptionsRender } from './switch';
6
7
 
7
8
  enum CustomValueTypeEnum {
@@ -13,6 +14,8 @@ enum CustomValueTypeEnum {
13
14
  CustomJSON = 'CustomJSON',
14
15
  /** JSON Modal */
15
16
  CustomJSONModal = 'CustomJSONModal',
17
+ /** Markdown Modal */
18
+ CustomMarkdownModal = 'CustomMarkdownModal',
16
19
  /** 渲染开关 */
17
20
  CustomSwitchNumber = 'CustomSwitchNumber',
18
21
  CustomSwitchOptions = 'CustomSwitchOptions',
@@ -37,6 +40,10 @@ const customValueTypeMap: Record<string, ProRenderFieldPropsType> = {
37
40
  render: jsonModalRender.render,
38
41
  renderFormItem: jsonModalRender.renderFormItem,
39
42
  },
43
+ [CustomValueTypeEnum.CustomMarkdownModal]: {
44
+ render: markdownModalRender.render,
45
+ renderFormItem: markdownModalRender.renderFormItem,
46
+ },
40
47
  [CustomValueTypeEnum.CustomSwitchNumber]: {
41
48
  render: switchNumberRender.render,
42
49
  renderFormItem: switchNumberRender.renderFormItem,