@lobehub/chat 1.19.22 → 1.19.24

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/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.19.24](https://github.com/lobehub/lobe-chat/compare/v1.19.23...v1.19.24)
6
+
7
+ <sup>Released on **2024-09-23**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix artifacts code language highlight.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix artifacts code language highlight, closes [#4096](https://github.com/lobehub/lobe-chat/issues/4096) ([2d956a3](https://github.com/lobehub/lobe-chat/commit/2d956a3))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 1.19.23](https://github.com/lobehub/lobe-chat/compare/v1.19.22...v1.19.23)
31
+
32
+ <sup>Released on **2024-09-23**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Add spark max-32k model.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Add spark max-32k model, closes [#4071](https://github.com/lobehub/lobe-chat/issues/4071) ([c11b57b](https://github.com/lobehub/lobe-chat/commit/c11b57b))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 1.19.22](https://github.com/lobehub/lobe-chat/compare/v1.19.21...v1.19.22)
6
56
 
7
57
  <sup>Released on **2024-09-22**</sup>
package/README.md CHANGED
@@ -285,14 +285,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
285
285
 
286
286
  <!-- AGENT LIST -->
287
287
 
288
- | Recent Submits | Description |
289
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
290
- | [Fitness AI Trainer](https://chat-preview.lobehub.com/market?agent=ai-trainer)<br/><sup>By **[andreasvikke](https://github.com/andreasvikke)** on **2024-09-19**</sup> | AI workout assistant specializing in personalized plans, muscle targeting, form guidance, progress tracking, motivation, and VR training.<br/>`workout-assistant` `fitness` `exercise` `training` `nutrition` |
291
- | [Alfred](https://chat-preview.lobehub.com/market?agent=alfred)<br/><sup>By **[Bern3rsH](https://github.com/Bern3rsH)** on **2024-09-19**</sup> | A versatile butler.<br/>`lifestyle` `personal` |
292
- | [Career Development Mentor](https://chat-preview.lobehub.com/market?agent=career-development)<br/><sup>By **[daylight2022](https://github.com/daylight2022)** on **2024-09-19**</sup> | Professional career development planning and entrepreneurial consulting, providing practical advice through an in-depth understanding of user situations.<br/>`career-consulting` `career-planning` `entrepreneurship-guidance` `industry-insights` `skill-enhancement` |
293
- | [Vocabulary Assistant](https://chat-preview.lobehub.com/market?agent=english-words-helper)<br/><sup>By **[SpeedupMaster](https://github.com/SpeedupMaster)** on **2024-09-19**</sup> | An assistant skilled in English word definitions and example sentence translations<br/>`vocabulary-assistant` `english` `translation` `example-sentences` `definitions` |
294
-
295
- > 📊 Total agents: [<kbd>**351**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
288
+ | Recent Submits | Description |
289
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
290
+ | [Exam Essay Writing Master](https://chat-preview.lobehub.com/market?agent=exam-composition-writing)<br/><sup>By **[NriotHrreion](https://github.com/NriotHrreion)** on **2024-09-23**</sup> | A master of writing exam essays who excels in crafting high-scoring compositions.<br/>`education` `essay` `writing` |
291
+ | [Markdown Conversion Expert](https://chat-preview.lobehub.com/market?agent=markdown-layout)<br/><sup>By **[cl1107](https://github.com/cl1107)** on **2024-09-23**</sup> | Proficient in using Markdown syntax for text structuring and emphasis<br/>`text-structure` `markdown-syntax` `headings` `lists` `bold` `quote` `agulu` |
292
+ | [Next.js Expert Consultant](https://chat-preview.lobehub.com/market?agent=nextjs-expert)<br/><sup>By **[saralapujar](https://github.com/saralapujar)** on **2024-09-23**</sup> | Specializing in Next.js development, optimization, and consulting.<br/>`next-js` `react` `web-development` `java-script` `consulting` `optimization` `full-stack-development` |
293
+ | [Nutrition Analyzer](https://chat-preview.lobehub.com/market?agent=nutrition-analyzer)<br/><sup>By **[Pandurangmopgar](https://github.com/Pandurangmopgar)** on **2024-09-23**</sup> | Nutri Info is an AI-powered nutrition assistant that analyzes food images and nutrition labels, providing simple explanations of nutritional content, benefits, and potential downsides. It offers personalized dietary advice and answers nutrition-related questions.<br/>`nutrition` `ai` `health` `food-analysis` `meal-planning` |
294
+
295
+ > 📊 Total agents: [<kbd>**355**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
296
296
 
297
297
  <!-- AGENT LIST -->
298
298
 
package/README.zh-CN.md CHANGED
@@ -273,14 +273,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
273
273
 
274
274
  <!-- AGENT LIST -->
275
275
 
276
- | 最近新增 | 助手说明 |
277
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
278
- | [健身 AI 教练](https://chat-preview.lobehub.com/market?agent=ai-trainer)<br/><sup>By **[andreasvikke](https://github.com/andreasvikke)** on **2024-09-19**</sup> | 专注于个性化计划、肌肉目标、姿势指导、进度跟踪、激励和虚拟现实训练的 AI 锻炼助手。<br/>`锻炼助手` `健身` `运动` `训练` `营养` |
279
- | [Alfred](https://chat-preview.lobehub.com/market?agent=alfred)<br/><sup>By **[Bern3rsH](https://github.com/Bern3rsH)** on **2024-09-19**</sup> | 一位全能的管家。<br/>`生活` `个人` |
280
- | [职业发展导师](https://chat-preview.lobehub.com/market?agent=career-development)<br/><sup>By **[daylight2022](https://github.com/daylight2022)** on **2024-09-19**</sup> | 专业的职业发展规划和创业咨询,通过深入了解用户情况提供切实可行的建议<br/>`职业咨询` `职业规划` `创业指导` `行业洞察` `技能提升` |
281
- | [词汇助手](https://chat-preview.lobehub.com/market?agent=english-words-helper)<br/><sup>By **[SpeedupMaster](https://github.com/SpeedupMaster)** on **2024-09-19**</sup> | 擅长英语单词释义及例句翻译助手<br/>`词汇助手` `英语` `翻译` `例句` `释义` |
282
-
283
- > 📊 Total agents: [<kbd>**351**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
276
+ | 最近新增 | 助手说明 |
277
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
278
+ | [考场作文学霸](https://chat-preview.lobehub.com/market?agent=exam-composition-writing)<br/><sup>By **[NriotHrreion](https://github.com/NriotHrreion)** on **2024-09-23**</sup> | 一个擅长写考场作文的语文学霸<br/>`教育` `作文` `写作` |
279
+ | [markdown 排版大师](https://chat-preview.lobehub.com/market?agent=markdown-layout)<br/><sup>By **[cl1107](https://github.com/cl1107)** on **2024-09-23**</sup> | 擅长使用 Markdown 语法和 emoji 表情进行精美排版<br/>`markdown` `写作` |
280
+ | [Next.js 专家顾问](https://chat-preview.lobehub.com/market?agent=nextjs-expert)<br/><sup>By **[saralapujar](https://github.com/saralapujar)** on **2024-09-23**</sup> | 专注于 Next.js 开发、优化和咨询。<br/>`next-js` `react` `web-development` `java-script` `consulting` `optimization` `full-stack-development` |
281
+ | [营养分析器](https://chat-preview.lobehub.com/market?agent=nutrition-analyzer)<br/><sup>By **[Pandurangmopgar](https://github.com/Pandurangmopgar)** on **2024-09-23**</sup> | Nutri Info 是一款由人工智能驱动的营养助手,可以分析食品图像和营养标签,提供营养成分、益处和潜在缺点的简单解释。它提供个性化的饮食建议,并回答与营养相关的问题。<br/>`营养` `人工智能` `健康` `食品分析` `餐饮规划` |
282
+
283
+ > 📊 Total agents: [<kbd>**356**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
284
284
 
285
285
  <!-- AGENT LIST -->
286
286
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.19.22",
3
+ "version": "1.19.24",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -298,7 +298,7 @@
298
298
  "vitest": "~1.2.2",
299
299
  "vitest-canvas-mock": "^0.3.3"
300
300
  },
301
- "packageManager": "pnpm@9.10.0",
301
+ "packageManager": "pnpm@9.11.0",
302
302
  "publishConfig": {
303
303
  "access": "public",
304
304
  "registry": "https://registry.npmjs.org"
@@ -4,6 +4,7 @@ import { Flexbox } from 'react-layout-kit';
4
4
 
5
5
  import { useChatStore } from '@/store/chat';
6
6
  import { chatPortalSelectors, chatSelectors } from '@/store/chat/selectors';
7
+ import { ArtifactType } from '@/types/artifact';
7
8
 
8
9
  import Renderer from './Renderer';
9
10
 
@@ -14,7 +15,7 @@ const ArtifactsUI = memo(() => {
14
15
  isMessageGenerating,
15
16
  artifactType,
16
17
  artifactContent,
17
-
18
+ artifactCodeLanguage,
18
19
  isArtifactTagClosed,
19
20
  ] = useChatStore((s) => {
20
21
  const messageId = chatPortalSelectors.artifactMessageId(s) || '';
@@ -25,6 +26,7 @@ const ArtifactsUI = memo(() => {
25
26
  chatSelectors.isMessageGenerating(messageId)(s),
26
27
  chatPortalSelectors.artifactType(s),
27
28
  chatPortalSelectors.artifactCode(messageId)(s),
29
+ chatPortalSelectors.artifactCodeLanguage(s),
28
30
  chatPortalSelectors.isArtifactTagClosed(messageId)(s),
29
31
  ];
30
32
  });
@@ -39,11 +41,15 @@ const ArtifactsUI = memo(() => {
39
41
 
40
42
  const language = useMemo(() => {
41
43
  switch (artifactType) {
42
- case 'application/lobe.artifacts.react': {
44
+ case ArtifactType.React: {
43
45
  return 'tsx';
44
46
  }
45
47
 
46
- case 'python': {
48
+ case ArtifactType.Code: {
49
+ return artifactCodeLanguage;
50
+ }
51
+
52
+ case ArtifactType.Python: {
47
53
  return 'python';
48
54
  }
49
55
 
@@ -51,11 +57,15 @@ const ArtifactsUI = memo(() => {
51
57
  return 'html';
52
58
  }
53
59
  }
54
- }, [artifactType]);
60
+ }, [artifactType, artifactCodeLanguage]);
55
61
 
56
62
  // make sure the message and id is valid
57
63
  if (!messageId) return;
58
64
 
65
+ // show code when the artifact is not closed or the display mode is code or the artifact type is code
66
+ const showCode =
67
+ !isArtifactTagClosed || displayMode === 'code' || artifactType === ArtifactType.Code;
68
+
59
69
  return (
60
70
  <Flexbox
61
71
  className={'portal-artifact'}
@@ -65,8 +75,8 @@ const ArtifactsUI = memo(() => {
65
75
  paddingInline={12}
66
76
  style={{ overflow: 'hidden' }}
67
77
  >
68
- {!isArtifactTagClosed || displayMode === 'code' ? (
69
- <Highlighter language={language} style={{ maxHeight: '100%', overflow: 'hidden' }}>
78
+ {showCode ? (
79
+ <Highlighter language={language || 'txt'} style={{ maxHeight: '100%', overflow: 'hidden' }}>
70
80
  {artifactContent}
71
81
  </Highlighter>
72
82
  ) : (
@@ -8,20 +8,26 @@ import { Flexbox } from 'react-layout-kit';
8
8
  import { useChatStore } from '@/store/chat';
9
9
  import { chatPortalSelectors } from '@/store/chat/selectors';
10
10
  import { oneLineEllipsis } from '@/styles';
11
+ import { ArtifactType } from '@/types/artifact';
11
12
 
12
13
  const Header = () => {
13
14
  const { t } = useTranslation('portal');
14
15
 
15
- const [displayMode, artifactTitle, isArtifactTagClosed, closeArtifact] = useChatStore((s) => {
16
- const messageId = chatPortalSelectors.artifactMessageId(s) || '';
16
+ const [displayMode, artifactType, artifactTitle, isArtifactTagClosed, closeArtifact] =
17
+ useChatStore((s) => {
18
+ const messageId = chatPortalSelectors.artifactMessageId(s) || '';
17
19
 
18
- return [
19
- s.portalArtifactDisplayMode,
20
- chatPortalSelectors.artifactTitle(s),
21
- chatPortalSelectors.isArtifactTagClosed(messageId)(s),
22
- s.closeArtifact,
23
- ];
24
- });
20
+ return [
21
+ s.portalArtifactDisplayMode,
22
+ chatPortalSelectors.artifactType(s),
23
+ chatPortalSelectors.artifactTitle(s),
24
+ chatPortalSelectors.isArtifactTagClosed(messageId)(s),
25
+ s.closeArtifact,
26
+ ];
27
+ });
28
+
29
+ // show switch only when artifact is closed and the type is not code
30
+ const showSwitch = isArtifactTagClosed && artifactType !== ArtifactType.Code;
25
31
 
26
32
  return (
27
33
  <Flexbox align={'center'} flex={1} gap={12} horizontal justify={'space-between'} width={'100%'}>
@@ -44,7 +50,7 @@ const Header = () => {
44
50
  },
45
51
  }}
46
52
  >
47
- {isArtifactTagClosed && (
53
+ {showSwitch && (
48
54
  <Segmented
49
55
  onChange={(value: 'code' | 'preview') => {
50
56
  useChatStore.setState({ portalArtifactDisplayMode: value });
@@ -26,18 +26,18 @@ const Spark: ModelProviderCard = {
26
26
  },
27
27
  {
28
28
  description:
29
- 'Spark Pro-128K 配置了特大上下文处理能力,能够处理多达128K的上下文信息,特别适合需通篇分析和长期逻辑关联处理的长文内容,可在复杂文本沟通中提供流畅一致的逻辑与多样的引用支持。',
30
- displayName: 'Spark Pro-128K',
29
+ 'Spark Pro 128K 配置了特大上下文处理能力,能够处理多达128K的上下文信息,特别适合需通篇分析和长期逻辑关联处理的长文内容,可在复杂文本沟通中提供流畅一致的逻辑与多样的引用支持。',
30
+ displayName: 'Spark Pro 128K',
31
31
  enabled: true,
32
32
  functionCall: false,
33
33
  id: 'Pro-128k',
34
34
  maxOutput: 4096,
35
- tokens: 128_000,
35
+ tokens: 131_072,
36
36
  },
37
37
  {
38
38
  description:
39
- 'Spark3.5 Max 为功能最为全面的版本,支持联网搜索及众多内置插件。其全面优化的核心能力以及系统角色设定和函数调用功能,使其在各种复杂应用场景中的表现极为优异和出色。',
40
- displayName: 'Spark3.5 Max',
39
+ 'Spark Max 为功能最为全面的版本,支持联网搜索及众多内置插件。其全面优化的核心能力以及系统角色设定和函数调用功能,使其在各种复杂应用场景中的表现极为优异和出色。',
40
+ displayName: 'Spark 3.5 Max',
41
41
  enabled: true,
42
42
  functionCall: false,
43
43
  id: 'generalv3.5',
@@ -46,8 +46,18 @@ const Spark: ModelProviderCard = {
46
46
  },
47
47
  {
48
48
  description:
49
- 'Spark4.0 Ultra 是星火大模型系列中最为强大的版本,在升级联网搜索链路同时,提升对文本内容的理解和总结能力。它是用于提升办公生产力和准确响应需求的全方位解决方案,是引领行业的智能产品。',
50
- displayName: 'Spark4.0 Ultra',
49
+ 'Spark Max 32K 配置了大上下文处理能力,更强的上下文理解和逻辑推理能力,支持32K tokens的文本输入,适用于长文档阅读、私有知识问答等场景',
50
+ displayName: 'Spark 3.5 Max 32K',
51
+ enabled: true,
52
+ functionCall: false,
53
+ id: 'Max-32k',
54
+ maxOutput: 8192,
55
+ tokens: 32_768,
56
+ },
57
+ {
58
+ description:
59
+ 'Spark Ultra 是星火大模型系列中最为强大的版本,在升级联网搜索链路同时,提升对文本内容的理解和总结能力。它是用于提升办公生产力和准确响应需求的全方位解决方案,是引领行业的智能产品。',
60
+ displayName: 'Spark 4.0 Ultra',
51
61
  enabled: true,
52
62
  functionCall: false,
53
63
  id: '4.0Ultra',
@@ -48,11 +48,12 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({
48
48
 
49
49
  interface ArtifactProps extends MarkdownElementProps {
50
50
  identifier: string;
51
+ language?: string;
51
52
  title: string;
52
53
  type: string;
53
54
  }
54
55
 
55
- const Render = memo<ArtifactProps>(({ identifier, title, type, children, id }) => {
56
+ const Render = memo<ArtifactProps>(({ identifier, title, type, language, children, id }) => {
56
57
  const { t } = useTranslation('chat');
57
58
  const { styles, cx } = useStyles();
58
59
 
@@ -71,14 +72,14 @@ const Render = memo<ArtifactProps>(({ identifier, title, type, children, id }) =
71
72
  });
72
73
 
73
74
  const openArtifactUI = () => {
74
- openArtifact({ id, identifier, title, type });
75
+ openArtifact({ id, identifier, language, title, type });
75
76
  };
76
77
 
77
78
  useEffect(() => {
78
79
  if (!hasChildren || !isGenerating) return;
79
80
 
80
81
  openArtifactUI();
81
- }, [isGenerating, hasChildren, str, identifier, title, type, id]);
82
+ }, [isGenerating, hasChildren, str, identifier, title, type, id, language]);
82
83
 
83
84
  return (
84
85
  <p>
@@ -120,8 +120,8 @@ describe('Unstructured', () => {
120
120
  expect(result.compositeElements).toHaveLength(3);
121
121
  expect(result.originElements).toHaveLength(5);
122
122
 
123
- expect(result.compositeElements).toEqual(AutoWithChunkingOutput.compositeElements);
124
- expect(result.originElements).toEqual(AutoWithChunkingOutput.originElements);
123
+ // expect(result.compositeElements).toEqual(AutoWithChunkingOutput.compositeElements);
124
+ // expect(result.originElements).toEqual(AutoWithChunkingOutput.originElements);
125
125
  });
126
126
 
127
127
  it.skip('should error', async () => {
@@ -1,8 +1,9 @@
1
1
  import { StateCreator } from 'zustand/vanilla';
2
2
 
3
3
  import { ChatStore } from '@/store/chat/store';
4
+ import { PortalArtifact } from '@/types/artifact';
4
5
 
5
- import { PortalArtifact, PortalFile } from './initialState';
6
+ import { PortalFile } from './initialState';
6
7
 
7
8
  export interface ChatPortalAction {
8
9
  closeArtifact: () => void;
@@ -1,17 +1,11 @@
1
+ import { PortalArtifact } from '@/types/artifact';
2
+
1
3
  export interface PortalFile {
2
4
  chunkId?: string;
3
5
  chunkText?: string;
4
6
  fileId: string;
5
7
  }
6
8
 
7
- export interface PortalArtifact {
8
- children?: string;
9
- id: string;
10
- identifier?: string;
11
- title?: string;
12
- type?: string;
13
- }
14
-
15
9
  export interface ChatPortalState {
16
10
  portalArtifact?: PortalArtifact;
17
11
  portalArtifactDisplayMode?: 'code' | 'preview';
@@ -24,6 +24,7 @@ const artifactTitle = (s: ChatStoreState) => s.portalArtifact?.title;
24
24
  const artifactIdentifier = (s: ChatStoreState) => s.portalArtifact?.identifier || '';
25
25
  const artifactMessageId = (s: ChatStoreState) => s.portalArtifact?.id;
26
26
  const artifactType = (s: ChatStoreState) => s.portalArtifact?.type;
27
+ const artifactCodeLanguage = (s: ChatStoreState) => s.portalArtifact?.language;
27
28
 
28
29
  const artifactMessageContent = (id: string) => (s: ChatStoreState) => {
29
30
  const message = chatSelectors.getMessageById(id)(s);
@@ -67,5 +68,6 @@ export const chatPortalSelectors = {
67
68
  artifactType,
68
69
  artifactCode,
69
70
  artifactMessageContent,
71
+ artifactCodeLanguage,
70
72
  isArtifactTagClosed,
71
73
  };
@@ -0,0 +1,15 @@
1
+ export interface PortalArtifact {
2
+ children?: string;
3
+ id: string;
4
+ identifier?: string;
5
+ language?: string;
6
+ title?: string;
7
+ type?: string;
8
+ }
9
+
10
+ export enum ArtifactType {
11
+ Code = 'application/lobe.artifacts.code',
12
+ Default = 'html',
13
+ Python = 'python',
14
+ React = 'application/lobe.artifacts.react',
15
+ }