@lobehub/chat 1.36.32 → 1.36.34
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 +50 -0
- package/README.ja-JP.md +150 -115
- package/README.md +63 -28
- package/README.zh-CN.md +65 -30
- package/changelog/v1.json +18 -0
- package/locales/ar/models.json +0 -24
- package/locales/ar/providers.json +10 -4
- package/locales/bg-BG/models.json +0 -24
- package/locales/bg-BG/providers.json +10 -4
- package/locales/de-DE/models.json +0 -24
- package/locales/de-DE/providers.json +10 -4
- package/locales/en-US/models.json +0 -24
- package/locales/en-US/providers.json +10 -4
- package/locales/es-ES/models.json +0 -24
- package/locales/es-ES/providers.json +10 -4
- package/locales/fa-IR/models.json +0 -24
- package/locales/fa-IR/providers.json +10 -4
- package/locales/fr-FR/models.json +0 -24
- package/locales/fr-FR/providers.json +10 -4
- package/locales/it-IT/models.json +0 -24
- package/locales/it-IT/providers.json +10 -4
- package/locales/ja-JP/models.json +0 -24
- package/locales/ja-JP/providers.json +10 -4
- package/locales/ko-KR/models.json +0 -24
- package/locales/ko-KR/providers.json +10 -4
- package/locales/nl-NL/models.json +0 -24
- package/locales/nl-NL/providers.json +10 -4
- package/locales/pl-PL/models.json +0 -24
- package/locales/pl-PL/providers.json +10 -4
- package/locales/pt-BR/models.json +0 -24
- package/locales/pt-BR/providers.json +10 -4
- package/locales/ru-RU/models.json +0 -24
- package/locales/ru-RU/providers.json +10 -4
- package/locales/tr-TR/models.json +0 -24
- package/locales/tr-TR/providers.json +10 -4
- package/locales/vi-VN/models.json +0 -24
- package/locales/vi-VN/providers.json +10 -4
- package/locales/zh-CN/models.json +4 -28
- package/locales/zh-CN/providers.json +10 -4
- package/locales/zh-TW/models.json +0 -24
- package/locales/zh-TW/providers.json +10 -4
- package/package.json +1 -1
- package/scripts/readmeWorkflow/const.ts +22 -8
- package/scripts/readmeWorkflow/index.ts +2 -0
- package/scripts/readmeWorkflow/syncAgentIndex.ts +36 -28
- package/scripts/readmeWorkflow/syncPluginIndex.ts +28 -15
- package/scripts/readmeWorkflow/syncProviderIndex.ts +51 -0
- package/scripts/readmeWorkflow/utlis.ts +23 -12
- package/src/config/modelProviders/ai21.ts +1 -0
- package/src/config/modelProviders/cloudflare.ts +1 -2
- package/src/config/modelProviders/github.ts +19 -10
- package/src/config/modelProviders/higress.ts +2 -1
- package/src/config/modelProviders/sensenova.ts +6 -3
- package/src/features/FileViewer/index.tsx +1 -1
- package/src/libs/agent-runtime/github/index.test.ts +68 -41
- package/src/libs/agent-runtime/github/index.ts +51 -1
- package/src/libs/agent-runtime/togetherai/index.ts +2 -1
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +10 -9
- package/src/locales/default/models.ts +1 -0
- package/src/locales/default/providers.ts +1 -0
@@ -16,7 +16,8 @@ export const LobeTogetherAI = LobeOpenAICompatibleFactory({
|
|
16
16
|
debug: {
|
17
17
|
chatCompletion: () => process.env.DEBUG_TOGETHERAI_CHAT_COMPLETION === '1',
|
18
18
|
},
|
19
|
-
models: async ({
|
19
|
+
models: async ({ client }) => {
|
20
|
+
const apiKey = client.apiKey;
|
20
21
|
const data = await fetch(`${baseURL}/api/models`, {
|
21
22
|
headers: {
|
22
23
|
Authorization: `Bearer ${apiKey}`,
|
@@ -2,17 +2,18 @@ import OpenAI, { ClientOptions } from 'openai';
|
|
2
2
|
import { Stream } from 'openai/streaming';
|
3
3
|
|
4
4
|
import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders';
|
5
|
-
import { ChatModelCard } from '@/types/llm';
|
5
|
+
import type { ChatModelCard } from '@/types/llm';
|
6
6
|
|
7
7
|
import { LobeRuntimeAI } from '../../BaseAI';
|
8
8
|
import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '../../error';
|
9
|
-
import {
|
9
|
+
import type {
|
10
10
|
ChatCompetitionOptions,
|
11
11
|
ChatCompletionErrorPayload,
|
12
12
|
ChatStreamPayload,
|
13
13
|
Embeddings,
|
14
14
|
EmbeddingsOptions,
|
15
15
|
EmbeddingsPayload,
|
16
|
+
ModelProvider,
|
16
17
|
TextToImagePayload,
|
17
18
|
TextToSpeechOptions,
|
18
19
|
TextToSpeechPayload,
|
@@ -26,7 +27,7 @@ import { StreamingResponse } from '../response';
|
|
26
27
|
import { OpenAIStream, OpenAIStreamOptions } from '../streams';
|
27
28
|
|
28
29
|
// the model contains the following keywords is not a chat model, so we should filter them out
|
29
|
-
const CHAT_MODELS_BLOCK_LIST = [
|
30
|
+
export const CHAT_MODELS_BLOCK_LIST = [
|
30
31
|
'embedding',
|
31
32
|
'davinci',
|
32
33
|
'curie',
|
@@ -77,7 +78,7 @@ interface OpenAICompatibleFactoryOptions<T extends Record<string, any> = any> {
|
|
77
78
|
invalidAPIKey: ILobeAgentRuntimeErrorType;
|
78
79
|
};
|
79
80
|
models?:
|
80
|
-
| ((params: {
|
81
|
+
| ((params: { client: OpenAI }) => Promise<ChatModelCard[]>)
|
81
82
|
| {
|
82
83
|
transformModel?: (model: OpenAI.Model) => ChatModelCard;
|
83
84
|
};
|
@@ -157,7 +158,7 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
|
|
157
158
|
client!: OpenAI;
|
158
159
|
|
159
160
|
baseURL!: string;
|
160
|
-
|
161
|
+
protected _options: ConstructorOptions<T>;
|
161
162
|
|
162
163
|
constructor(options: ClientOptions & Record<string, any> = {}) {
|
163
164
|
const _options = {
|
@@ -249,7 +250,7 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
|
|
249
250
|
}
|
250
251
|
|
251
252
|
async models() {
|
252
|
-
if (typeof models === 'function') return models({
|
253
|
+
if (typeof models === 'function') return models({ client: this.client });
|
253
254
|
|
254
255
|
const list = await this.client.models.list();
|
255
256
|
|
@@ -312,7 +313,7 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
|
|
312
313
|
}
|
313
314
|
}
|
314
315
|
|
315
|
-
|
316
|
+
protected handleError(error: any): ChatCompletionErrorPayload {
|
316
317
|
let desensitizedEndpoint = this.baseURL;
|
317
318
|
|
318
319
|
// refs: https://github.com/lobehub/lobe-chat/issues/842
|
@@ -337,7 +338,7 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
|
|
337
338
|
endpoint: desensitizedEndpoint,
|
338
339
|
error: error as any,
|
339
340
|
errorType: ErrorType.invalidAPIKey,
|
340
|
-
provider: provider as
|
341
|
+
provider: provider as ModelProvider,
|
341
342
|
});
|
342
343
|
}
|
343
344
|
|
@@ -353,7 +354,7 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
|
|
353
354
|
endpoint: desensitizedEndpoint,
|
354
355
|
error: errorResult,
|
355
356
|
errorType: RuntimeError || ErrorType.bizError,
|
356
|
-
provider: provider as
|
357
|
+
provider: provider as ModelProvider,
|
357
358
|
});
|
358
359
|
}
|
359
360
|
};
|