@lobehub/chat 1.19.4 → 1.19.6

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.

Potentially problematic release.


This version of @lobehub/chat might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -2,6 +2,57 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.19.6](https://github.com/lobehub/lobe-chat/compare/v1.19.5...v1.19.6)
6
+
7
+ <sup>Released on **2024-09-19**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor the tts route url.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Refactor the tts route url, closes [#4030](https://github.com/lobehub/lobe-chat/issues/4030) ([60dcf19](https://github.com/lobehub/lobe-chat/commit/60dcf19))
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.5](https://github.com/lobehub/lobe-chat/compare/v1.19.4...v1.19.5)
31
+
32
+ <sup>Released on **2024-09-19**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Enable functioncall for stepfun models, Update qwen models.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Enable functioncall for stepfun models, closes [#4022](https://github.com/lobehub/lobe-chat/issues/4022) ([afb3509](https://github.com/lobehub/lobe-chat/commit/afb3509))
46
+ - **misc**: Update qwen models, closes [#4026](https://github.com/lobehub/lobe-chat/issues/4026) ([6169e8f](https://github.com/lobehub/lobe-chat/commit/6169e8f))
47
+
48
+ </details>
49
+
50
+ <div align="right">
51
+
52
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
53
+
54
+ </div>
55
+
5
56
  ### [Version 1.19.4](https://github.com/lobehub/lobe-chat/compare/v1.19.3...v1.19.4)
6
57
 
7
58
  <sup>Released on **2024-09-19**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.19.4",
3
+ "version": "1.19.6",
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",
@@ -8,6 +8,7 @@ import { checkAuth } from './auth';
8
8
  import { createOpenai } from './createOpenai';
9
9
 
10
10
  /**
11
+ * @deprecated
11
12
  * createOpenAI Instance with Auth and azure openai support
12
13
  * if auth not pass ,just return error response
13
14
  */
@@ -28,6 +28,7 @@ export const preferredRegion = [
28
28
  export const POST = async (req: Request) => {
29
29
  const payload = (await req.json()) as OpenAITTSPayload;
30
30
 
31
+ // need to be refactored with jwt auth mode
31
32
  const openaiOrErrResponse = createBizOpenAI(req);
32
33
 
33
34
  // if resOrOpenAI is a Response, it means there is an error,just return it
@@ -1,22 +1,10 @@
1
1
  import { ModelProviderCard } from '@/types/llm';
2
2
 
3
- // ref :https://help.aliyun.com/zh/dashscope/developer-reference/api-details
3
+ // ref: https://help.aliyun.com/zh/model-studio/getting-started/models
4
4
  const Qwen: ModelProviderCard = {
5
5
  chatModels: [
6
6
  {
7
- description:
8
- '通义千问超大规模语言模型,支持长文本上下文,以及基于长文档、多文档等多个场景的对话功能。',
9
- displayName: 'Qwen Long',
10
- id: 'qwen-long',
11
- pricing: {
12
- currency: 'CNY',
13
- input: 0.5,
14
- output: 2,
15
- },
16
- tokens: 1_000_000, // https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction
17
- },
18
- {
19
- description: '通义千问超大规模语言模型,支持中文、英文等不同语言输入',
7
+ description: '通义千问超大规模语言模型,支持中文、英文等不同语言输入。',
20
8
  displayName: 'Qwen Turbo',
21
9
  enabled: true,
22
10
  functionCall: true,
@@ -26,10 +14,10 @@ const Qwen: ModelProviderCard = {
26
14
  input: 0.3,
27
15
  output: 0.6,
28
16
  },
29
- tokens: 131_072, // https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction
17
+ tokens: 131_072,
30
18
  },
31
19
  {
32
- description: '通义千问超大规模语言模型增强版,支持中文、英文等不同语言输入',
20
+ description: '通义千问超大规模语言模型增强版,支持中文、英文等不同语言输入。',
33
21
  displayName: 'Qwen Plus',
34
22
  enabled: true,
35
23
  functionCall: true,
@@ -39,11 +27,11 @@ const Qwen: ModelProviderCard = {
39
27
  input: 0.8,
40
28
  output: 2,
41
29
  },
42
- tokens: 131_072, // https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction
30
+ tokens: 131_072,
43
31
  },
44
32
  {
45
33
  description:
46
- '通义千问千亿级别超大规模语言模型,支持中文、英文等不同语言输入,当前通义千问2.5产品版本背后的API模型',
34
+ '通义千问千亿级别超大规模语言模型,支持中文、英文等不同语言输入,当前通义千问2.5产品版本背后的API模型。',
47
35
  displayName: 'Qwen Max',
48
36
  enabled: true,
49
37
  functionCall: true,
@@ -53,7 +41,30 @@ const Qwen: ModelProviderCard = {
53
41
  input: 20,
54
42
  output: 60,
55
43
  },
56
- tokens: 32_768, // https://help.aliyun.com/zh/dashscope/developer-reference/model-introduction
44
+ tokens: 32_768,
45
+ },
46
+ {
47
+ description: '通义千问代码模型。',
48
+ displayName: 'Qwen Coder',
49
+ id: 'qwen-coder-turbo-latest',
50
+ pricing: {
51
+ currency: 'CNY',
52
+ input: 2,
53
+ output: 6,
54
+ },
55
+ tokens: 131_072,
56
+ },
57
+ {
58
+ description:
59
+ '通义千问超大规模语言模型,支持长文本上下文,以及基于长文档、多文档等多个场景的对话功能。',
60
+ displayName: 'Qwen Long',
61
+ id: 'qwen-long',
62
+ pricing: {
63
+ currency: 'CNY',
64
+ input: 0.5,
65
+ output: 2,
66
+ },
67
+ tokens: 1_000_000,
57
68
  },
58
69
  {
59
70
  description:
@@ -66,8 +77,8 @@ const Qwen: ModelProviderCard = {
66
77
  input: 8,
67
78
  output: 8,
68
79
  },
69
- tokens: 8192,
70
- vision: true, // https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-vl-plus-api
80
+ tokens: 8000,
81
+ vision: true,
71
82
  },
72
83
  {
73
84
  description:
@@ -80,71 +91,120 @@ const Qwen: ModelProviderCard = {
80
91
  input: 20,
81
92
  output: 20,
82
93
  },
83
- tokens: 32_768,
84
- vision: true, // https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-vl-plus-api
94
+ tokens: 32_000,
95
+ vision: true,
85
96
  },
86
- // ref :https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-7b-14b-72b-api-detailes
87
97
  {
88
- description: '通义千问2.5对外开源的7B规模的模型',
98
+ description:
99
+ '通义千问数学模型是专门用于数学解题的语言模型。',
100
+ displayName: 'Qwen Math Turbo',
101
+ id: 'qwen-math-turbo-latest',
102
+ pricing: {
103
+ currency: 'CNY',
104
+ input: 2,
105
+ output: 6,
106
+ },
107
+ tokens: 4096,
108
+ },
109
+ {
110
+ description:
111
+ '通义千问数学模型是专门用于数学解题的语言模型。',
112
+ displayName: 'Qwen Math Plus',
113
+ id: 'qwen-math-plus-latest',
114
+ pricing: {
115
+ currency: 'CNY',
116
+ input: 4,
117
+ output: 12,
118
+ },
119
+ tokens: 4096,
120
+ },
121
+ {
122
+ description: '通义千问2.5对外开源的7B规模的模型。',
89
123
  displayName: 'Qwen2.5 7B',
90
124
  functionCall: true,
91
125
  id: 'qwen2.5-7b-instruct',
92
- tokens: 131_072, // https://huggingface.co/Qwen/Qwen2.5-7B-Instruct
126
+ tokens: 131_072,
127
+ },
128
+ {
129
+ description: '通义千问2.5对外开源的14B规模的模型。',
130
+ displayName: 'Qwen2.5 14B',
131
+ functionCall: true,
132
+ id: 'qwen2.5-14b-instruct',
133
+ tokens: 131_072,
93
134
  },
94
135
  {
95
- description: '通义千问2.5对外开源的32B规模的模型',
136
+ description: '通义千问2.5对外开源的32B规模的模型。',
96
137
  displayName: 'Qwen2.5 32B',
97
138
  functionCall: true,
98
139
  id: 'qwen2.5-32b-instruct',
99
- tokens: 131_072, // https://huggingface.co/Qwen/Qwen2.5-32B-Instruct
140
+ tokens: 131_072,
100
141
  },
101
142
  {
102
- description: '通义千问2.5对外开源的72B规模的模型',
143
+ description: '通义千问2.5对外开源的72B规模的模型。',
103
144
  displayName: 'Qwen2.5 72B',
104
145
  functionCall: true,
105
146
  id: 'qwen2.5-72b-instruct',
106
- tokens: 131_072, // https://huggingface.co/Qwen/Qwen2.5-72B-Instruct
147
+ tokens: 131_072,
107
148
  },
108
149
  {
109
- description: '通义千问2对外开源的7B规模的模型',
110
- displayName: 'Qwen2 7B',
111
- functionCall: true,
112
- id: 'qwen2-7b-instruct',
113
- tokens: 131_072, // https://huggingface.co/Qwen/Qwen2-7B-Instruct
114
- },
115
- {
116
- description: '通义千问2对外开源的57B规模14B激活参数的MOE模型',
150
+ description: '通义千问2对外开源的57B规模14B激活参数的MOE模型。',
117
151
  displayName: 'Qwen2 57B A14B MoE',
118
152
  functionCall: true,
119
153
  id: 'qwen2-57b-a14b-instruct',
120
- tokens: 65_536, // https://huggingface.co/Qwen/Qwen2-57B-A14B-Instruct
154
+ tokens: 65_536,
121
155
  },
122
156
  {
123
- description: '通义千问2对外开源的72B规模的模型',
124
- displayName: 'Qwen2 72B',
125
- functionCall: true,
126
- id: 'qwen2-72b-instruct',
127
- tokens: 131_072, // https://huggingface.co/Qwen/Qwen2-72B-Instruct
157
+ description: 'Qwen-Math 模型具有强大的数学解题能力。',
158
+ displayName: 'Qwen2.5 Math 1.5B',
159
+ id: 'qwen2.5-math-1.5b-instruct',
160
+ pricing: {
161
+ currency: 'CNY',
162
+ input: 0,
163
+ output: 0,
164
+ },
165
+ tokens: 4096,
128
166
  },
129
167
  {
130
- description: 'Qwen2-Math 模型具有强大的数学解题能力',
131
- displayName: 'Qwen2 Math 72B',
132
- functionCall: true,
133
- id: 'qwen2-math-72b-instruct',
134
- tokens: 4096, // https://help.aliyun.com/zh/dashscope/developer-reference/use-qwen2-math-by-calling-api
168
+ description: 'Qwen-Math 模型具有强大的数学解题能力。',
169
+ displayName: 'Qwen2.5 Math 7B',
170
+ id: 'qwen2.5-math-7b-instruct',
171
+ tokens: 4096,
172
+ },
173
+ {
174
+ description: 'Qwen-Math 模型具有强大的数学解题能力。',
175
+ displayName: 'Qwen2.5 Math 72B',
176
+ id: 'qwen2.5-math-72b-instruct',
177
+ tokens: 4096,
178
+ },
179
+ {
180
+ description: '通义千问代码模型开源版。',
181
+ displayName: 'Qwen2.5 Coder 1.5B',
182
+ id: 'qwen2.5-coder-1.5b-instruct',
183
+ pricing: {
184
+ currency: 'CNY',
185
+ input: 0,
186
+ output: 0,
187
+ },
188
+ tokens: 131_072,
189
+ },
190
+ {
191
+ description: '通义千问代码模型开源版。',
192
+ displayName: 'Qwen2.5 Coder 7B',
193
+ id: 'qwen2.5-coder-7b-instruct',
194
+ tokens: 131_072,
135
195
  },
136
196
  {
137
197
  description: '以 Qwen-7B 语言模型初始化,添加图像模型,图像输入分辨率为448的预训练模型。',
138
198
  displayName: 'Qwen VL',
139
199
  id: 'qwen-vl-v1',
140
- tokens: 8192, // https://huggingface.co/Qwen/Qwen-VL/blob/main/config.json
200
+ tokens: 8000,
141
201
  vision: true,
142
202
  },
143
203
  {
144
204
  description: '通义千问VL支持灵活的交互方式,包括多图、多轮问答、创作等能力的模型。',
145
205
  displayName: 'Qwen VL Chat',
146
206
  id: 'qwen-vl-chat-v1',
147
- tokens: 8192, // https://huggingface.co/Qwen/Qwen-VL-Chat/blob/main/config.json
207
+ tokens: 8000,
148
208
  vision: true,
149
209
  },
150
210
  ],
@@ -160,7 +220,7 @@ const Qwen: ModelProviderCard = {
160
220
  speed: 2,
161
221
  text: true,
162
222
  },
163
- url: 'https://tongyi.aliyun.com',
223
+ url: 'https://www.aliyun.com/product/bailian',
164
224
  };
165
225
 
166
226
  export default Qwen;
@@ -8,12 +8,14 @@ const Stepfun: ModelProviderCard = {
8
8
  description: '支持大规模上下文交互,适合复杂对话场景。',
9
9
  displayName: 'Step 2 16K',
10
10
  enabled: true,
11
+ functionCall: true,
11
12
  id: 'step-2-16k',
12
13
  tokens: 16_000,
13
14
  },
14
15
  {
15
16
  description: '具备超长上下文处理能力,尤其适合长文档分析。',
16
17
  displayName: 'Step 1 256K',
18
+ functionCall: true,
17
19
  id: 'step-1-256k',
18
20
  tokens: 256_000,
19
21
  },
@@ -21,6 +23,7 @@ const Stepfun: ModelProviderCard = {
21
23
  description: '平衡性能与成本,适合一般场景。',
22
24
  displayName: 'Step 1 128K',
23
25
  enabled: true,
26
+ functionCall: true,
24
27
  id: 'step-1-128k',
25
28
  tokens: 128_000,
26
29
  },
@@ -28,6 +31,7 @@ const Stepfun: ModelProviderCard = {
28
31
  description: '支持中等长度的对话,适用于多种应用场景。',
29
32
  displayName: 'Step 1 32K',
30
33
  enabled: true,
34
+ functionCall: true,
31
35
  id: 'step-1-32k',
32
36
  tokens: 32_000,
33
37
  },
@@ -35,6 +39,7 @@ const Stepfun: ModelProviderCard = {
35
39
  description: '小型模型,适合轻量级任务。',
36
40
  displayName: 'Step 1 8K',
37
41
  enabled: true,
42
+ functionCall: true,
38
43
  id: 'step-1-8k',
39
44
  tokens: 8000,
40
45
  },
@@ -42,6 +47,7 @@ const Stepfun: ModelProviderCard = {
42
47
  description: '高速模型,适合实时对话。',
43
48
  displayName: 'Step 1 Flash',
44
49
  enabled: true,
50
+ functionCall: true,
45
51
  id: 'step-1-flash',
46
52
  tokens: 8000,
47
53
  },
@@ -49,6 +55,7 @@ const Stepfun: ModelProviderCard = {
49
55
  description: '支持视觉输入,增强多模态交互体验。',
50
56
  displayName: 'Step 1V 32K',
51
57
  enabled: true,
58
+ functionCall: true,
52
59
  id: 'step-1v-32k',
53
60
  tokens: 32_000,
54
61
  vision: true,
@@ -57,6 +64,7 @@ const Stepfun: ModelProviderCard = {
57
64
  description: '小型视觉模型,适合基本的图文任务。',
58
65
  displayName: 'Step 1V 8K',
59
66
  enabled: true,
67
+ functionCall: true,
60
68
  id: 'step-1v-8k',
61
69
  tokens: 8000,
62
70
  vision: true,
@@ -1,5 +1,6 @@
1
1
  export const OPENAI_END_POINT = 'X-openai-end-point';
2
2
  export const OPENAI_API_KEY_HEADER_KEY = 'X-openai-api-key';
3
+ export const LOBE_USER_ID = 'X-lobe-user-id';
3
4
 
4
5
  export const USE_AZURE_OPENAI = 'X-use-azure-openai';
5
6
 
@@ -19,9 +20,10 @@ export const getOpenAIAuthFromRequest = (req: Request) => {
19
20
  const useAzureStr = req.headers.get(USE_AZURE_OPENAI);
20
21
  const apiVersion = req.headers.get(AZURE_OPENAI_API_VERSION);
21
22
  const oauthAuthorizedStr = req.headers.get(OAUTH_AUTHORIZED);
23
+ const userId = req.headers.get(LOBE_USER_ID);
22
24
 
23
25
  const oauthAuthorized = !!oauthAuthorizedStr;
24
26
  const useAzure = !!useAzureStr;
25
27
 
26
- return { accessCode, apiKey, apiVersion, endpoint, oauthAuthorized, useAzure };
28
+ return { accessCode, apiKey, apiVersion, endpoint, oauthAuthorized, useAzure, userId };
27
29
  };
@@ -35,6 +35,7 @@ import {
35
35
  EmbeddingsPayload,
36
36
  ModelProvider,
37
37
  TextToImagePayload,
38
+ TextToSpeechPayload,
38
39
  } from './types';
39
40
  import { LobeUpstageAI } from './upstage';
40
41
  import { LobeZeroOneAI } from './zeroone';
@@ -97,6 +98,9 @@ class AgentRuntime {
97
98
  async embeddings(payload: EmbeddingsPayload, options?: EmbeddingsOptions) {
98
99
  return this._runtime.embeddings?.(payload, options);
99
100
  }
101
+ async textToSpeech(payload: TextToSpeechPayload, options?: EmbeddingsOptions) {
102
+ return this._runtime.textToSpeech?.(payload, options);
103
+ }
100
104
 
101
105
  /**
102
106
  * @description Initialize the runtime with the provider and the options
@@ -1,6 +1,5 @@
1
1
  import OpenAI from 'openai';
2
2
 
3
- import { TextToImagePayload } from '@/libs/agent-runtime/types/textToImage';
4
3
  import { ChatModelCard } from '@/types/llm';
5
4
 
6
5
  import {
@@ -9,6 +8,9 @@ import {
9
8
  EmbeddingItem,
10
9
  EmbeddingsOptions,
11
10
  EmbeddingsPayload,
11
+ TextToImagePayload,
12
+ TextToSpeechOptions,
13
+ TextToSpeechPayload,
12
14
  } from './types';
13
15
 
14
16
  export interface LobeRuntimeAI {
@@ -20,6 +22,11 @@ export interface LobeRuntimeAI {
20
22
  models?(): Promise<any>;
21
23
 
22
24
  textToImage?: (payload: TextToImagePayload) => Promise<string[]>;
25
+
26
+ textToSpeech?: (
27
+ payload: TextToSpeechPayload,
28
+ options?: TextToSpeechOptions,
29
+ ) => Promise<ArrayBuffer>;
23
30
  }
24
31
 
25
32
  export abstract class LobeOpenAICompatibleRuntime {
@@ -1,4 +1,5 @@
1
1
  export * from './chat';
2
2
  export * from './embeddings';
3
3
  export * from './textToImage';
4
+ export * from './tts';
4
5
  export * from './type';
@@ -0,0 +1,14 @@
1
+ export interface TextToSpeechPayload {
2
+ input: string;
3
+ model: string;
4
+ voice: string;
5
+ }
6
+
7
+ export interface TextToSpeechOptions {
8
+ headers?: Record<string, any>;
9
+ signal?: AbortSignal;
10
+ /**
11
+ * userId for the embeddings
12
+ */
13
+ user?: string;
14
+ }
@@ -1,7 +1,6 @@
1
1
  import OpenAI, { ClientOptions } from 'openai';
2
2
 
3
3
  import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders';
4
- import { TextToImagePayload } from '@/libs/agent-runtime/types/textToImage';
5
4
  import { ChatModelCard } from '@/types/llm';
6
5
 
7
6
  import { LobeRuntimeAI } from '../../BaseAI';
@@ -13,6 +12,9 @@ import {
13
12
  EmbeddingItem,
14
13
  EmbeddingsOptions,
15
14
  EmbeddingsPayload,
15
+ TextToImagePayload,
16
+ TextToSpeechOptions,
17
+ TextToSpeechPayload,
16
18
  } from '../../types';
17
19
  import { AgentRuntimeError } from '../createError';
18
20
  import { debugResponse, debugStream } from '../debugStream';
@@ -253,6 +255,19 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
253
255
  }
254
256
  }
255
257
 
258
+ async textToSpeech(payload: TextToSpeechPayload, options?: TextToSpeechOptions) {
259
+ try {
260
+ const mp3 = await this.client.audio.speech.create(payload as any, {
261
+ headers: options?.headers,
262
+ signal: options?.signal,
263
+ });
264
+
265
+ return mp3.arrayBuffer();
266
+ } catch (error) {
267
+ throw this.handleError(error);
268
+ }
269
+ }
270
+
256
271
  private handleError(error: any): ChatCompletionErrorPayload {
257
272
  let desensitizedEndpoint = this.baseURL;
258
273
 
@@ -1,4 +1,9 @@
1
- import { LOBE_CHAT_ACCESS_CODE, OPENAI_API_KEY_HEADER_KEY, OPENAI_END_POINT } from '@/const/fetch';
1
+ import {
2
+ LOBE_CHAT_ACCESS_CODE,
3
+ LOBE_USER_ID,
4
+ OPENAI_API_KEY_HEADER_KEY,
5
+ OPENAI_END_POINT,
6
+ } from '@/const/fetch';
2
7
  import { useUserStore } from '@/store/user';
3
8
  import { keyVaultsConfigSelectors } from '@/store/user/selectors';
4
9
 
@@ -8,12 +13,14 @@ import { keyVaultsConfigSelectors } from '@/store/user/selectors';
8
13
  */
9
14
  // eslint-disable-next-line no-undef
10
15
  export const createHeaderWithOpenAI = (header?: HeadersInit): HeadersInit => {
11
- const openAIConfig = keyVaultsConfigSelectors.openAIConfig(useUserStore.getState());
16
+ const state = useUserStore.getState();
17
+ const openAIConfig = keyVaultsConfigSelectors.openAIConfig(state);
12
18
 
13
19
  // eslint-disable-next-line no-undef
14
20
  return {
15
21
  ...header,
16
- [LOBE_CHAT_ACCESS_CODE]: keyVaultsConfigSelectors.password(useUserStore.getState()),
22
+ [LOBE_CHAT_ACCESS_CODE]: keyVaultsConfigSelectors.password(state),
23
+ [LOBE_USER_ID]: state.user?.id || '',
17
24
  [OPENAI_API_KEY_HEADER_KEY]: openAIConfig.apiKey || '',
18
25
  [OPENAI_END_POINT]: openAIConfig.baseURL || '',
19
26
  };
@@ -1,4 +1,4 @@
1
- // TODO: 未来所有路由需要全部迁移到 trpc
1
+ // TODO: 未来路由需要迁移到 trpc or /webapi
2
2
 
3
3
  /* eslint-disable sort-keys-fix/sort-keys-fix */
4
4
  import { transform } from 'lodash-es';
@@ -38,9 +38,11 @@ export const API_ENDPOINTS = mapWithBasePath({
38
38
  // image
39
39
  images: '/api/text-to-image/openai',
40
40
 
41
- // TTS & STT
42
- stt: '/api/openai/stt',
43
- tts: '/api/openai/tts',
44
- edge: '/api/tts/edge-speech',
45
- microsoft: '/api/tts/microsoft-speech',
41
+ // STT
42
+ stt: '/webapi/stt/openai',
43
+
44
+ // TTS
45
+ tts: '/webapi/tts/openai',
46
+ edge: '/webapi/tts/edge',
47
+ microsoft: '/webapi/tts/microsoft',
46
48
  });
@@ -39,7 +39,7 @@ export const createTTSFileSlice: StateCreator<
39
39
  };
40
40
  const file = new File([blob], fileName, fileOptions);
41
41
 
42
- const res = await get().uploadWithProgress({ file });
42
+ const res = await get().uploadWithProgress({ file, skipCheckFileType: true });
43
43
 
44
44
  return res?.id;
45
45
  },
@@ -29,6 +29,12 @@ interface UploadWithProgressParams {
29
29
  type: 'removeFile';
30
30
  },
31
31
  ) => void;
32
+ /**
33
+ * Optional flag to indicate whether to skip the file type check.
34
+ * When set to `true`, any file type checks will be bypassed.
35
+ * Default is `false`, which means file type checks will be performed.
36
+ */
37
+ skipCheckFileType?: boolean;
32
38
  }
33
39
 
34
40
  interface UploadWithProgressResult {
@@ -52,8 +58,8 @@ export const createFileUploadSlice: StateCreator<
52
58
  [],
53
59
  FileUploadAction
54
60
  > = (set, get) => ({
55
- internal_uploadToClientDB: async ({ file, onStatusUpdate }) => {
56
- if (!file.type.startsWith('image')) {
61
+ internal_uploadToClientDB: async ({ file, onStatusUpdate, skipCheckFileType }) => {
62
+ if (!skipCheckFileType && !file.type.startsWith('image')) {
57
63
  onStatusUpdate?.({ id: file.name, type: 'removeFile' });
58
64
  message.info({
59
65
  content: t('upload.fileOnlySupportInServerMode', {
@@ -158,11 +164,11 @@ export const createFileUploadSlice: StateCreator<
158
164
  return data;
159
165
  },
160
166
 
161
- uploadWithProgress: async ({ file, onStatusUpdate, knowledgeBaseId }) => {
167
+ uploadWithProgress: async (payload) => {
162
168
  const { internal_uploadToServer, internal_uploadToClientDB } = get();
163
169
 
164
- if (isServerMode) return internal_uploadToServer({ file, knowledgeBaseId, onStatusUpdate });
170
+ if (isServerMode) return internal_uploadToServer(payload);
165
171
 
166
- return internal_uploadToClientDB({ file, onStatusUpdate });
172
+ return internal_uploadToClientDB(payload);
167
173
  },
168
174
  });