@lobehub/chat 0.151.8 → 0.151.10

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 (41) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/locales/ar/common.json +5 -0
  3. package/locales/bg-BG/common.json +5 -0
  4. package/locales/de-DE/common.json +5 -0
  5. package/locales/en-US/common.json +5 -0
  6. package/locales/es-ES/common.json +5 -0
  7. package/locales/fr-FR/common.json +5 -0
  8. package/locales/it-IT/common.json +5 -0
  9. package/locales/ja-JP/common.json +5 -0
  10. package/locales/ko-KR/common.json +5 -0
  11. package/locales/nl-NL/common.json +5 -0
  12. package/locales/pl-PL/common.json +5 -0
  13. package/locales/pt-BR/common.json +5 -0
  14. package/locales/ru-RU/common.json +5 -0
  15. package/locales/tr-TR/common.json +5 -0
  16. package/locales/vi-VN/common.json +5 -0
  17. package/locales/zh-CN/common.json +5 -0
  18. package/locales/zh-TW/common.json +5 -0
  19. package/package.json +32 -32
  20. package/src/app/(main)/welcome/_layout/Desktop.tsx +21 -19
  21. package/src/app/(main)/welcome/_layout/Mobile.tsx +9 -6
  22. package/src/app/(main)/welcome/features/Actions.tsx +39 -0
  23. package/src/app/(main)/welcome/features/Hero.tsx +63 -0
  24. package/src/app/(main)/welcome/features/Logo.tsx +30 -0
  25. package/src/app/(main)/welcome/{layout.ts → layout.tsx} +2 -0
  26. package/src/app/(main)/welcome/page.tsx +16 -9
  27. package/src/const/url.ts +3 -0
  28. package/src/features/Follow/index.tsx +64 -0
  29. package/src/libs/agent-runtime/minimax/index.test.ts +18 -4
  30. package/src/libs/agent-runtime/minimax/index.ts +22 -8
  31. package/src/locales/default/common.ts +7 -0
  32. package/src/server/globalConfig/index.ts +2 -0
  33. package/src/app/(main)/welcome/(desktop)/features/Footer.tsx +0 -45
  34. package/src/app/(main)/welcome/(desktop)/features/Showcase.tsx +0 -23
  35. package/src/app/(main)/welcome/(desktop)/index.tsx +0 -17
  36. package/src/app/(main)/welcome/(mobile)/index.tsx +0 -16
  37. package/src/app/(main)/welcome/features/Banner/AgentCard.tsx +0 -71
  38. package/src/app/(main)/welcome/features/Banner/AgentTemplate.tsx +0 -43
  39. package/src/app/(main)/welcome/features/Banner/Hero.tsx +0 -50
  40. package/src/app/(main)/welcome/features/Banner/index.tsx +0 -56
  41. package/src/app/(main)/welcome/features/Banner/style.ts +0 -71
@@ -4,6 +4,7 @@
4
4
  "appInitializing": "LobeChat 初始化中,請耐心等候...",
5
5
  "autoGenerate": "自動生成",
6
6
  "autoGenerateTooltip": "基於提示詞自動生成助手描述",
7
+ "blog": "產品部落格",
7
8
  "cancel": "取消",
8
9
  "changelog": "變更日誌",
9
10
  "close": "關閉",
@@ -26,6 +27,7 @@
26
27
  "globalSetting": "匯出全域設定"
27
28
  },
28
29
  "feedback": "回饋與建議",
30
+ "follow": "在 {{name}} 上關注我們",
29
31
  "historyRange": "歷史範圍",
30
32
  "import": "匯入設定",
31
33
  "importModal": {
@@ -88,10 +90,12 @@
88
90
  "layoutInitializing": "正在載入版面配置...",
89
91
  "noDescription": "暫無描述",
90
92
  "oauth": "單一登錄(SSO)",
93
+ "officialSite": "官方網站",
91
94
  "ok": "確定",
92
95
  "password": "密碼",
93
96
  "pin": "置頂",
94
97
  "pinOff": "取消置頂",
98
+ "privacy": "隱私政策",
95
99
  "regenerate": "重新生成",
96
100
  "rename": "重新命名",
97
101
  "reset": "重置",
@@ -146,6 +150,7 @@
146
150
  "title": "幫助 LobeChat 做得更好"
147
151
  },
148
152
  "temp": "臨時",
153
+ "terms": "服務條款",
149
154
  "updateAgent": "更新助理資訊",
150
155
  "upgradeVersion": {
151
156
  "action": "升級",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.151.8",
3
+ "version": "0.151.10",
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",
@@ -83,8 +83,8 @@
83
83
  "@ant-design/icons": "^5.3.6",
84
84
  "@anthropic-ai/sdk": "^0.18.0",
85
85
  "@auth/core": "0.28.0",
86
- "@aws-sdk/client-bedrock-runtime": "^3.556.0",
87
- "@azure/openai": "^1.0.0-beta.12",
86
+ "@aws-sdk/client-bedrock-runtime": "^3.565.0",
87
+ "@azure/openai": "1.0.0-beta.12",
88
88
  "@cfworker/json-schema": "^1.12.8",
89
89
  "@google/generative-ai": "^0.8.0",
90
90
  "@icons-pack/react-simple-icons": "^9.4.1",
@@ -92,9 +92,9 @@
92
92
  "@lobehub/chat-plugins-gateway": "latest",
93
93
  "@lobehub/icons": "latest",
94
94
  "@lobehub/tts": "latest",
95
- "@lobehub/ui": "^1.138.8",
96
- "@next/third-parties": "^14.2.2",
97
- "@sentry/nextjs": "^7.111.0",
95
+ "@lobehub/ui": "^1.138.17",
96
+ "@next/third-parties": "^14.2.3",
97
+ "@sentry/nextjs": "^7.112.2",
98
98
  "@t3-oss/env-nextjs": "^0.10.1",
99
99
  "@trpc/client": "next",
100
100
  "@trpc/next": "next",
@@ -103,48 +103,48 @@
103
103
  "@vercel/speed-insights": "^1.0.10",
104
104
  "ahooks": "^3.7.11",
105
105
  "ai": "3.0.19",
106
- "antd": "^5.16.2",
106
+ "antd": "^5.16.5",
107
107
  "antd-style": "^3.6.2",
108
108
  "brotli-wasm": "^3.0.0",
109
109
  "chroma-js": "^2.4.2",
110
- "dayjs": "^1.11.10",
110
+ "dayjs": "^1.11.11",
111
111
  "debug": "^4.3.4",
112
112
  "dexie": "^3.2.7",
113
113
  "diff": "^5.2.0",
114
114
  "fast-deep-equal": "^3.1.3",
115
115
  "gpt-tokenizer": "^2.1.2",
116
- "i18next": "^23.11.2",
116
+ "i18next": "^23.11.3",
117
117
  "i18next-browser-languagedetector": "^7.2.1",
118
118
  "i18next-resources-to-backend": "^1.2.1",
119
119
  "idb-keyval": "^6.2.1",
120
- "immer": "^10.0.4",
120
+ "immer": "^10.1.1",
121
121
  "ip": "^2.0.1",
122
122
  "jose": "^5.2.4",
123
- "langfuse": "^3.7.0",
124
- "langfuse-core": "^3.7.0",
123
+ "langfuse": "^3.8.0",
124
+ "langfuse-core": "^3.8.0",
125
125
  "lodash-es": "^4.17.21",
126
126
  "lucide-react": "latest",
127
127
  "modern-screenshot": "^4.4.39",
128
128
  "nanoid": "^5.0.7",
129
- "next": "^14.2.1",
129
+ "next": "^14.2.3",
130
130
  "next-auth": "5.0.0-beta.15",
131
131
  "next-sitemap": "^4.2.3",
132
132
  "numeral": "^2.0.6",
133
133
  "nuqs": "^1.17.1",
134
134
  "ollama": "^0.5.0",
135
- "openai": "^4.38.2",
135
+ "openai": "^4.39.0",
136
136
  "pino": "^9.0.0",
137
137
  "polished": "^4.3.1",
138
- "posthog-js": "^1.128.1",
138
+ "posthog-js": "^1.130.1",
139
139
  "query-string": "^9.0.0",
140
140
  "random-words": "^2.0.1",
141
- "react": "^18.2.0",
142
- "react-dom": "^18.2.0",
141
+ "react": "^18.3.1",
142
+ "react-dom": "^18.3.1",
143
143
  "react-hotkeys-hook": "^4.5.0",
144
- "react-i18next": "^14.1.0",
144
+ "react-i18next": "^14.1.1",
145
145
  "react-layout-kit": "^1.9.0",
146
146
  "react-lazy-load": "^4.0.1",
147
- "react-virtuoso": "^4.7.9",
147
+ "react-virtuoso": "^4.7.10",
148
148
  "react-wrap-balancer": "^1.1.0",
149
149
  "remark": "^14.0.3",
150
150
  "remark-gfm": "^3.0.1",
@@ -154,7 +154,7 @@
154
154
  "sharp": "^0.33.3",
155
155
  "superjson": "^2.2.1",
156
156
  "swr": "^2.2.5",
157
- "systemjs": "^6.14.3",
157
+ "systemjs": "^6.15.1",
158
158
  "ts-md5": "^1.3.1",
159
159
  "ua-parser-js": "^1.0.37",
160
160
  "url-join": "^5.0.0",
@@ -163,24 +163,24 @@
163
163
  "uuid": "^9.0.1",
164
164
  "y-protocols": "^1.0.6",
165
165
  "y-webrtc": "^10.3.0",
166
- "yaml": "^2.4.1",
167
- "yjs": "^13.6.14",
168
- "zod": "^3.22.5",
166
+ "yaml": "^2.4.2",
167
+ "yjs": "^13.6.15",
168
+ "zod": "^3.23.5",
169
169
  "zustand": "^4.5.2",
170
170
  "zustand-utils": "^1.3.2"
171
171
  },
172
172
  "devDependencies": {
173
- "@commitlint/cli": "^19.2.2",
173
+ "@commitlint/cli": "^19.3.0",
174
174
  "@ducanh2912/next-pwa": "^10.2.6",
175
175
  "@edge-runtime/vm": "^3.2.0",
176
176
  "@lobehub/i18n-cli": "^1.18.1",
177
- "@lobehub/lint": "^1.23.3",
177
+ "@lobehub/lint": "^1.23.4",
178
178
  "@lobehub/seo-cli": "^1.4.1",
179
- "@next/bundle-analyzer": "^14.2.2",
180
- "@next/eslint-plugin-next": "^14.2.2",
179
+ "@next/bundle-analyzer": "^14.2.3",
180
+ "@next/eslint-plugin-next": "^14.2.3",
181
181
  "@peculiar/webcrypto": "^1.4.6",
182
182
  "@testing-library/jest-dom": "^6.4.2",
183
- "@testing-library/react": "^15.0.4",
183
+ "@testing-library/react": "^15.0.5",
184
184
  "@types/chroma-js": "^2.4.4",
185
185
  "@types/debug": "^4.1.12",
186
186
  "@types/diff": "^5.2.0",
@@ -190,8 +190,8 @@
190
190
  "@types/lodash-es": "^4.17.12",
191
191
  "@types/node": "^20.12.7",
192
192
  "@types/numeral": "^2.0.5",
193
- "@types/react": "^18.2.79",
194
- "@types/react-dom": "^18.2.25",
193
+ "@types/react": "^18.3.1",
194
+ "@types/react-dom": "^18.3.0",
195
195
  "@types/rtl-detect": "^1.0.3",
196
196
  "@types/semver": "^7.5.8",
197
197
  "@types/systemjs": "^6.13.5",
@@ -200,7 +200,7 @@
200
200
  "@umijs/lint": "^4.1.10",
201
201
  "@vitest/coverage-v8": "~1.2.2",
202
202
  "ajv-keywords": "^5.1.0",
203
- "commitlint": "^19.2.2",
203
+ "commitlint": "^19.3.0",
204
204
  "consola": "^3.2.3",
205
205
  "dpdm": "^3.14.0",
206
206
  "eslint": "^8.57.0",
@@ -222,7 +222,7 @@
222
222
  "remark-parse": "^10.0.2",
223
223
  "semantic-release": "^21.1.2",
224
224
  "stylelint": "^15.11.0",
225
- "tsx": "^4.7.2",
225
+ "tsx": "^4.7.3",
226
226
  "typescript": "^5.4.5",
227
227
  "unified": "^11.0.4",
228
228
  "unist-util-visit": "^5.0.0",
@@ -1,29 +1,31 @@
1
- 'use client';
1
+ import { GridShowcase, Logo } from '@lobehub/ui';
2
+ import { PropsWithChildren } from 'react';
3
+ import { Flexbox } from 'react-layout-kit';
2
4
 
3
- import { Logo } from '@lobehub/ui';
4
- import { PropsWithChildren, memo } from 'react';
5
- import { Center, Flexbox } from 'react-layout-kit';
5
+ import Follow from '@/features/Follow';
6
6
 
7
- import ClientResponsiveLayout from '@/components/client/ClientResponsiveLayout';
7
+ const COPYRIGHT = `© ${new Date().getFullYear()} LobeHub, LLC`;
8
8
 
9
- import { useStyles } from '../features/Banner/style';
10
-
11
- const Desktop = memo<PropsWithChildren>(({ children }) => {
12
- const { styles } = useStyles();
9
+ const DesktopLayout = ({ children }: PropsWithChildren) => {
13
10
  return (
14
- <Center
15
- className={styles.layout}
16
- flex={1}
11
+ <Flexbox
12
+ align={'center'}
17
13
  height={'100%'}
18
- horizontal
19
- style={{ position: 'relative' }}
14
+ justify={'space-between'}
15
+ padding={16}
16
+ style={{ overflow: 'hidden', position: 'relative' }}
17
+ width={'100%'}
20
18
  >
21
- <Logo className={styles.logo} size={36} type={'text'} />
22
- <Flexbox className={styles.view} flex={1}>
19
+ <Logo size={36} style={{ alignSelf: 'flex-start' }} type={'text'} />
20
+ <GridShowcase innerProps={{ gap: 24 }} style={{ maxWidth: 1024 }} width={'100%'}>
23
21
  {children}
22
+ </GridShowcase>
23
+ <Flexbox align={'center'} horizontal justify={'space-between'}>
24
+ <span style={{ opacity: 0.5 }}>{COPYRIGHT}</span>
25
+ <Follow />
24
26
  </Flexbox>
25
- </Center>
27
+ </Flexbox>
26
28
  );
27
- });
29
+ };
28
30
 
29
- export default ClientResponsiveLayout({ Desktop, Mobile: () => import('./Mobile') });
31
+ export default DesktopLayout;
@@ -1,9 +1,12 @@
1
- 'use client';
1
+ import { PropsWithChildren } from 'react';
2
+ import { Center } from 'react-layout-kit';
2
3
 
3
- import { PropsWithChildren, memo } from 'react';
4
-
5
- const MobileLayout = memo<PropsWithChildren>(({ children }) => {
6
- return <div style={{ height: '100%', paddingInline: 16 }}>{children}</div>;
7
- });
4
+ const MobileLayout = ({ children }: PropsWithChildren) => {
5
+ return (
6
+ <Center gap={16} style={{ height: '100%', paddingInline: 16 }}>
7
+ {children}
8
+ </Center>
9
+ );
10
+ };
8
11
 
9
12
  export default MobileLayout;
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+
3
+ import { Icon } from '@lobehub/ui';
4
+ import { Button } from 'antd';
5
+ import { SendHorizonal } from 'lucide-react';
6
+ import Link from 'next/link';
7
+ import { useRouter } from 'next/navigation';
8
+ import { memo } from 'react';
9
+ import { useTranslation } from 'react-i18next';
10
+ import { Flexbox } from 'react-layout-kit';
11
+
12
+ const Actions = memo<{ mobile?: boolean }>(({ mobile }) => {
13
+ const { t } = useTranslation('welcome');
14
+ const router = useRouter();
15
+
16
+ return (
17
+ <Flexbox gap={16} horizontal={!mobile} justify={'center'} width={'100%'} wrap={'wrap'}>
18
+ <Link href={'/market'}>
19
+ <Button block={mobile} size={'large'} style={{ minWidth: 160 }} type={'default'}>
20
+ {t('button.market')}
21
+ </Button>
22
+ </Link>
23
+ <Button
24
+ block={mobile}
25
+ onClick={() => router.push('/chat')}
26
+ size={'large'}
27
+ style={{ minWidth: 160 }}
28
+ type={'primary'}
29
+ >
30
+ <Flexbox align={'center'} gap={4} horizontal justify={'center'}>
31
+ {t('button.start')}
32
+ <Icon icon={SendHorizonal} />
33
+ </Flexbox>
34
+ </Button>
35
+ </Flexbox>
36
+ );
37
+ });
38
+
39
+ export default Actions;
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+
3
+ import { createStyles } from 'antd-style';
4
+ import { rgba } from 'polished';
5
+ import { memo } from 'react';
6
+ import { useTranslation } from 'react-i18next';
7
+ import { Flexbox } from 'react-layout-kit';
8
+
9
+ const useStyles = createStyles(({ css, token }) => {
10
+ return {
11
+ desc: css`
12
+ font-size: min(24px, 4vw);
13
+ font-weight: 400;
14
+ color: ${rgba(token.colorText, 0.8)};
15
+ text-align: center;
16
+ text-wrap: balance;
17
+ `,
18
+ title: css`
19
+ margin-bottom: 0;
20
+
21
+ font-size: min(56px, 7vw);
22
+ font-weight: 800;
23
+ line-height: 1;
24
+ text-align: center;
25
+ text-wrap: balance;
26
+ `,
27
+ };
28
+ });
29
+
30
+ const Hero = memo(() => {
31
+ const { styles } = useStyles();
32
+
33
+ const { t } = useTranslation('welcome');
34
+
35
+ return (
36
+ <>
37
+ <Flexbox
38
+ align={'center'}
39
+ as={'h1'}
40
+ className={styles.title}
41
+ gap={16}
42
+ horizontal
43
+ justify={'center'}
44
+ wrap={'wrap'}
45
+ >
46
+ <strong style={{ fontSize: 'min(56px, 8vw)' }}>LobeChat</strong>
47
+ <span>{t('slogan.title')}</span>
48
+ </Flexbox>
49
+ <Flexbox
50
+ align={'center'}
51
+ as={'h2'}
52
+ className={styles.desc}
53
+ horizontal
54
+ justify={'center'}
55
+ wrap={'wrap'}
56
+ >
57
+ {t('slogan.desc1')}
58
+ </Flexbox>
59
+ </>
60
+ );
61
+ });
62
+
63
+ export default Hero;
@@ -0,0 +1,30 @@
1
+ 'use client';
2
+
3
+ import dynamic from 'next/dynamic';
4
+ import { memo } from 'react';
5
+ import { Center } from 'react-layout-kit';
6
+
7
+ const LogoThree = dynamic(() => import('@lobehub/ui/es/LogoThree'), { ssr: false });
8
+ const LogoSpline = dynamic(() => import('@lobehub/ui/es/LogoThree/LogoSpline'), { ssr: false });
9
+
10
+ const Logo = memo<{ mobile?: boolean }>(({ mobile }) => {
11
+ return mobile ? (
12
+ <Center height={240} width={240}>
13
+ <LogoThree size={240} />
14
+ </Center>
15
+ ) : (
16
+ <Center
17
+ style={{
18
+ height: `min(482px, 40vw)`,
19
+ marginBottom: '-10%',
20
+ marginTop: '-20%',
21
+ position: 'relative',
22
+ width: `min(976px, 80vw)`,
23
+ }}
24
+ >
25
+ <LogoSpline height={'min(482px, 40vw)'} width={'min(976px, 80vw)'} />
26
+ </Center>
27
+ );
28
+ });
29
+
30
+ export default Logo;
@@ -5,4 +5,6 @@ import Mobile from './_layout/Mobile';
5
5
 
6
6
  const WelcomeLayout = ServerLayout({ Desktop, Mobile });
7
7
 
8
+ WelcomeLayout.displayName = 'WelcomeLayout';
9
+
8
10
  export default WelcomeLayout;
@@ -3,19 +3,26 @@ import { Metadata } from 'next';
3
3
  import { getCanonicalUrl } from '@/const/url';
4
4
  import { isMobileDevice } from '@/utils/responsive';
5
5
 
6
- import DesktopPage from './(desktop)';
7
- import MobilePage from './(mobile)';
6
+ import Actions from './features/Actions';
7
+ import Hero from './features/Hero';
8
+ import Logo from './features/Logo';
9
+
10
+ export const metadata: Metadata = {
11
+ alternates: { canonical: getCanonicalUrl('/welcome') },
12
+ };
8
13
 
9
14
  const Page = () => {
10
15
  const mobile = isMobileDevice();
11
16
 
12
- const Page = mobile ? MobilePage : DesktopPage;
13
-
14
- return <Page />;
17
+ return (
18
+ <>
19
+ <Logo mobile={mobile} />
20
+ <Hero />
21
+ <Actions mobile={mobile} />
22
+ </>
23
+ );
15
24
  };
16
25
 
17
- export default Page;
26
+ Page.displayName = 'Welcome';
18
27
 
19
- export const metadata: Metadata = {
20
- alternates: { canonical: getCanonicalUrl('/welcome') },
21
- };
28
+ export default Page;
package/src/const/url.ts CHANGED
@@ -45,3 +45,6 @@ export const imageUrl = (filename: string) => withBasePath(`/images/${filename}`
45
45
 
46
46
  export const EMAIL_SUPPORT = 'support@lobehub.com';
47
47
  export const EMAIL_BUSINESS = 'hello@lobehub.com';
48
+
49
+ export const MEDIDUM = 'https://medium.com/@lobehub';
50
+ export const X = 'https://x.com/lobehub';
@@ -0,0 +1,64 @@
1
+ 'use client';
2
+
3
+ import { SiDiscord, SiGithub, SiMedium, SiX } from '@icons-pack/react-simple-icons';
4
+ import { ActionIcon } from '@lobehub/ui';
5
+ import { createStyles } from 'antd-style';
6
+ import Link from 'next/link';
7
+ import { memo } from 'react';
8
+ import { useTranslation } from 'react-i18next';
9
+ import { Flexbox } from 'react-layout-kit';
10
+
11
+ import { DISCORD, GITHUB, MEDIDUM, X } from '@/const/url';
12
+
13
+ const useStyles = createStyles(({ css, token }) => {
14
+ return {
15
+ icon: css`
16
+ svg {
17
+ fill: ${token.colorTextDescription};
18
+ }
19
+
20
+ &:hover {
21
+ svg {
22
+ fill: ${token.colorText};
23
+ }
24
+ }
25
+ `,
26
+ };
27
+ });
28
+
29
+ const Follow = memo(() => {
30
+ const { styles } = useStyles();
31
+ const { t } = useTranslation('common');
32
+ return (
33
+ <Flexbox gap={8} horizontal>
34
+ <Link href={GITHUB} rel="noreferrer" target={'_blank'}>
35
+ <ActionIcon
36
+ className={styles.icon}
37
+ icon={SiGithub as any}
38
+ title={t('follow', { name: 'GitHub' })}
39
+ />
40
+ </Link>
41
+ <Link href={X} rel="noreferrer" target={'_blank'}>
42
+ <ActionIcon className={styles.icon} icon={SiX as any} title={t('follow', { name: 'X' })} />
43
+ </Link>
44
+ <Link href={DISCORD} rel="noreferrer" target={'_blank'}>
45
+ <ActionIcon
46
+ className={styles.icon}
47
+ icon={SiDiscord as any}
48
+ title={t('follow', { name: 'Discord' })}
49
+ />
50
+ </Link>
51
+ <Link href={MEDIDUM} rel="noreferrer" target={'_blank'}>
52
+ <ActionIcon
53
+ className={styles.icon}
54
+ icon={SiMedium as any}
55
+ title={t('follow', { name: 'Medium' })}
56
+ />
57
+ </Link>
58
+ </Flexbox>
59
+ );
60
+ });
61
+
62
+ Follow.displayName = 'Follow';
63
+
64
+ export default Follow;
@@ -223,7 +223,6 @@ describe('LobeMinimaxAI', () => {
223
223
  model: 'text-davinci-003',
224
224
  temperature: 0.5,
225
225
  top_p: 0.8,
226
- max_tokens: 100,
227
226
  };
228
227
 
229
228
  const result = instance['buildCompletionsParams'](payload);
@@ -234,7 +233,6 @@ describe('LobeMinimaxAI', () => {
234
233
  stream: true,
235
234
  temperature: 0.5,
236
235
  top_p: 0.8,
237
- max_tokens: 100,
238
236
  });
239
237
  });
240
238
 
@@ -244,7 +242,6 @@ describe('LobeMinimaxAI', () => {
244
242
  model: 'text-davinci-003',
245
243
  temperature: 0,
246
244
  top_p: 0,
247
- max_tokens: 100,
248
245
  };
249
246
 
250
247
  const result = instance['buildCompletionsParams'](payload);
@@ -253,7 +250,24 @@ describe('LobeMinimaxAI', () => {
253
250
  messages: [{ content: 'Hello', role: 'user' }],
254
251
  model: 'text-davinci-003',
255
252
  stream: true,
256
- max_tokens: 100,
253
+ });
254
+ });
255
+
256
+ it('should include max tokens when model is abab6.5-chat', () => {
257
+ const payload: ChatStreamPayload = {
258
+ messages: [{ content: 'Hello', role: 'user' }],
259
+ model: 'abab6.5-chat',
260
+ temperature: 0,
261
+ top_p: 0,
262
+ };
263
+
264
+ const result = instance['buildCompletionsParams'](payload);
265
+
266
+ expect(result).toEqual({
267
+ messages: [{ content: 'Hello', role: 'user' }],
268
+ model: 'abab6.5-chat',
269
+ stream: true,
270
+ max_tokens: 2048,
257
271
  });
258
272
  });
259
273
  });
@@ -49,7 +49,7 @@ function throwIfErrorResponse(data: MinimaxResponse) {
49
49
  });
50
50
  }
51
51
 
52
- function parseMinimaxResponse(chunk: string): string | undefined {
52
+ function parseMinimaxResponse(chunk: string): MinimaxResponse | undefined {
53
53
  let body = chunk;
54
54
  if (body.startsWith('data:')) {
55
55
  body = body.slice(5).trim();
@@ -57,10 +57,7 @@ function parseMinimaxResponse(chunk: string): string | undefined {
57
57
  if (isEmpty(body)) {
58
58
  return;
59
59
  }
60
- const data = JSON.parse(body) as MinimaxResponse;
61
- if (data.choices?.at(0)?.delta?.content) {
62
- return data.choices.at(0)?.delta.content || undefined;
63
- }
60
+ return JSON.parse(body) as MinimaxResponse;
64
61
  }
65
62
 
66
63
  export class LobeMinimaxAI implements LobeRuntimeAI {
@@ -136,11 +133,25 @@ export class LobeMinimaxAI implements LobeRuntimeAI {
136
133
  }
137
134
  }
138
135
 
136
+ // the document gives the default value of max tokens, but abab6.5 and abab6.5s
137
+ // will meet length finished error, and output is truncationed
138
+ // so here fill the max tokens number to fix it
139
+ // https://www.minimaxi.com/document/guides/chat-model/V2
140
+ private getMaxTokens(model: string): number | undefined {
141
+ switch (model) {
142
+ case 'abab6.5-chat':
143
+ case 'abab6.5s-chat': {
144
+ return 2048;
145
+ }
146
+ }
147
+ }
148
+
139
149
  private buildCompletionsParams(payload: ChatStreamPayload) {
140
150
  const { temperature, top_p, ...params } = payload;
141
151
 
142
152
  return {
143
153
  ...params,
154
+ max_tokens: this.getMaxTokens(payload.model),
144
155
  stream: true,
145
156
  temperature: temperature === 0 ? undefined : temperature,
146
157
  top_p: top_p === 0 ? undefined : top_p,
@@ -159,7 +170,8 @@ export class LobeMinimaxAI implements LobeRuntimeAI {
159
170
  const { value, done: doneReading } = await reader.read();
160
171
  done = doneReading;
161
172
  const chunkValue = decoder.decode(value, { stream: true });
162
- const text = parseMinimaxResponse(chunkValue);
173
+ const data = parseMinimaxResponse(chunkValue);
174
+ const text = data?.choices?.at(0)?.delta?.content || undefined;
163
175
  streamController?.enqueue(encoder.encode(text));
164
176
  }
165
177
 
@@ -173,12 +185,14 @@ export class LobeMinimaxAI implements LobeRuntimeAI {
173
185
  const chunkValue = decoder.decode(value, { stream: true });
174
186
  let data;
175
187
  try {
176
- data = JSON.parse(chunkValue) as MinimaxResponse;
188
+ data = parseMinimaxResponse(chunkValue);
177
189
  } catch {
178
190
  // parse error, skip it
179
191
  return;
180
192
  }
181
- throwIfErrorResponse(data);
193
+ if (data) {
194
+ throwIfErrorResponse(data);
195
+ }
182
196
  }
183
197
  }
184
198