@lobehub/chat 1.122.6 → 1.123.0
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/changelog/v1.json +18 -0
- package/package.json +2 -2
- package/packages/model-bank/package.json +1 -0
- package/packages/model-bank/src/aiModels/index.ts +3 -1
- package/packages/model-bank/src/aiModels/newapi.ts +11 -0
- package/packages/model-runtime/src/RouterRuntime/createRuntime.test.ts +60 -0
- package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +6 -3
- package/packages/model-runtime/src/index.ts +1 -0
- package/packages/model-runtime/src/newapi/index.test.ts +618 -0
- package/packages/model-runtime/src/newapi/index.ts +245 -0
- package/packages/model-runtime/src/runtimeMap.ts +2 -0
- package/packages/model-runtime/src/types/type.ts +1 -0
- package/packages/types/src/user/settings/keyVaults.ts +1 -0
- package/packages/utils/src/server/__tests__/auth.test.ts +1 -1
- package/packages/utils/src/server/auth.ts +2 -2
- package/src/app/(backend)/api/auth/adapter/route.ts +137 -0
- package/src/app/(backend)/api/webhooks/logto/route.ts +9 -0
- package/src/app/[variants]/(main)/settings/provider/(detail)/newapi/page.tsx +27 -0
- package/src/config/auth.ts +4 -0
- package/src/config/modelProviders/index.ts +3 -0
- package/src/config/modelProviders/newapi.ts +17 -0
- package/src/libs/next-auth/adapter/index.ts +103 -201
- package/src/libs/next-auth/auth.config.ts +22 -5
- package/src/libs/next-auth/index.ts +11 -24
- package/src/libs/trpc/edge/context.ts +2 -2
- package/src/libs/trpc/lambda/context.ts +2 -2
- package/src/locales/default/modelProvider.ts +26 -0
- package/src/middleware.ts +2 -2
- package/src/server/routers/lambda/user.test.ts +4 -17
- package/src/server/routers/lambda/user.ts +6 -15
- package/src/server/services/nextAuthUser/index.ts +282 -6
- package/packages/database/src/server/models/__tests__/nextauth.test.ts +0 -556
- package/src/libs/next-auth/edge.ts +0 -26
- package/src/server/services/nextAuthUser/index.test.ts +0 -108
- /package/{.env.development → .env.example.development} +0 -0
- /package/src/{libs/next-auth/adapter → server/services/nextAuthUser}/utils.ts +0 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
## [Version 1.123.0](https://github.com/lobehub/lobe-chat/compare/v1.122.7...v1.123.0)
|
6
|
+
|
7
|
+
<sup>Released on **2025-09-04**</sup>
|
8
|
+
|
9
|
+
#### ✨ Features
|
10
|
+
|
11
|
+
- **misc**: Add NewAPI as a router provider for multi-model aggregation.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### What's improved
|
19
|
+
|
20
|
+
- **misc**: Add NewAPI as a router provider for multi-model aggregation, closes [#9041](https://github.com/lobehub/lobe-chat/issues/9041) [/github.com/lobehub/lobe-chat/pull/9041#pullrequestreview-3183464594](https://github.com//github.com/lobehub/lobe-chat/pull/9041/issues/pullrequestreview-3183464594) ([7e291c2](https://github.com/lobehub/lobe-chat/commit/7e291c2))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
### [Version 1.122.7](https://github.com/lobehub/lobe-chat/compare/v1.122.6...v1.122.7)
|
31
|
+
|
32
|
+
<sup>Released on **2025-09-04**</sup>
|
33
|
+
|
34
|
+
#### ♻ Code Refactoring
|
35
|
+
|
36
|
+
- **misc**: Make LobeNextAuthDBAdapter Edge Compatible.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### Code refactoring
|
44
|
+
|
45
|
+
- **misc**: Make LobeNextAuthDBAdapter Edge Compatible, closes [#9088](https://github.com/lobehub/lobe-chat/issues/9088) ([411f88e](https://github.com/lobehub/lobe-chat/commit/411f88e))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.122.6](https://github.com/lobehub/lobe-chat/compare/v1.122.5...v1.122.6)
|
6
56
|
|
7
57
|
<sup>Released on **2025-09-04**</sup>
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"features": [
|
5
|
+
"Add NewAPI as a router provider for multi-model aggregation."
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"date": "2025-09-04",
|
9
|
+
"version": "1.123.0"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"children": {
|
13
|
+
"improvements": [
|
14
|
+
"Make LobeNextAuthDBAdapter Edge Compatible."
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"date": "2025-09-04",
|
18
|
+
"version": "1.122.7"
|
19
|
+
},
|
2
20
|
{
|
3
21
|
"children": {},
|
4
22
|
"date": "2025-09-04",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.123.0",
|
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",
|
@@ -154,7 +154,7 @@
|
|
154
154
|
"@lobehub/charts": "^2.0.0",
|
155
155
|
"@lobehub/chat-plugin-sdk": "^1.32.4",
|
156
156
|
"@lobehub/chat-plugins-gateway": "^1.9.0",
|
157
|
-
"@lobehub/icons": "^2.
|
157
|
+
"@lobehub/icons": "^2.31.0",
|
158
158
|
"@lobehub/market-sdk": "^0.22.7",
|
159
159
|
"@lobehub/tts": "^2.0.1",
|
160
160
|
"@lobehub/ui": "^2.8.3",
|
@@ -37,6 +37,7 @@
|
|
37
37
|
"./modelscope": "./src/aiModels/modelscope.ts",
|
38
38
|
"./moonshot": "./src/aiModels/moonshot.ts",
|
39
39
|
"./nebius": "./src/aiModels/nebius.ts",
|
40
|
+
"./newapi": "./src/aiModels/newapi.ts",
|
40
41
|
"./novita": "./src/aiModels/novita.ts",
|
41
42
|
"./nvidia": "./src/aiModels/nvidia.ts",
|
42
43
|
"./ollama": "./src/aiModels/ollama.ts",
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { AiFullModelCard, LobeDefaultAiModelListItem } from '../types/aiModel';
|
2
|
-
|
3
2
|
import { default as ai21 } from './ai21';
|
4
3
|
import { default as ai302 } from './ai302';
|
5
4
|
import { default as ai360 } from './ai360';
|
@@ -32,6 +31,7 @@ import { default as mistral } from './mistral';
|
|
32
31
|
import { default as modelscope } from './modelscope';
|
33
32
|
import { default as moonshot } from './moonshot';
|
34
33
|
import { default as nebius } from './nebius';
|
34
|
+
import { default as newapi } from './newapi';
|
35
35
|
import { default as novita } from './novita';
|
36
36
|
import { default as nvidia } from './nvidia';
|
37
37
|
import { default as ollama } from './ollama';
|
@@ -113,6 +113,7 @@ export const LOBE_DEFAULT_MODEL_LIST = buildDefaultModelList({
|
|
113
113
|
modelscope,
|
114
114
|
moonshot,
|
115
115
|
nebius,
|
116
|
+
newapi,
|
116
117
|
novita,
|
117
118
|
nvidia,
|
118
119
|
ollama,
|
@@ -176,6 +177,7 @@ export { default as mistral } from './mistral';
|
|
176
177
|
export { default as modelscope } from './modelscope';
|
177
178
|
export { default as moonshot } from './moonshot';
|
178
179
|
export { default as nebius } from './nebius';
|
180
|
+
export { default as newapi } from './newapi';
|
179
181
|
export { default as novita } from './novita';
|
180
182
|
export { default as nvidia } from './nvidia';
|
181
183
|
export { default as ollama } from './ollama';
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { AIChatModelCard } from '../types/aiModel';
|
2
|
+
|
3
|
+
// NewAPI Router Provider - 聚合多个 AI 服务
|
4
|
+
// 模型通过动态获取,不预定义具体模型
|
5
|
+
const newapiChatModels: AIChatModelCard[] = [
|
6
|
+
// NewAPI 作为路由提供商,模型列表通过 API 动态获取
|
7
|
+
];
|
8
|
+
|
9
|
+
export const allModels = [...newapiChatModels];
|
10
|
+
|
11
|
+
export default allModels;
|
@@ -450,4 +450,64 @@ describe('createRouterRuntime', () => {
|
|
450
450
|
expect(mockTextToSpeech).toHaveBeenCalledWith(payload, options);
|
451
451
|
});
|
452
452
|
});
|
453
|
+
|
454
|
+
describe('dynamic routers configuration', () => {
|
455
|
+
it('should support function-based routers configuration', () => {
|
456
|
+
class MockRuntime implements LobeRuntimeAI {
|
457
|
+
chat = vi.fn();
|
458
|
+
textToImage = vi.fn();
|
459
|
+
models = vi.fn();
|
460
|
+
embeddings = vi.fn();
|
461
|
+
textToSpeech = vi.fn();
|
462
|
+
}
|
463
|
+
|
464
|
+
const dynamicRoutersFunction = (options: any) => [
|
465
|
+
{
|
466
|
+
apiType: 'openai' as const,
|
467
|
+
options: {
|
468
|
+
baseURL: `${options.baseURL || 'https://api.openai.com'}/v1`,
|
469
|
+
},
|
470
|
+
runtime: MockRuntime as any,
|
471
|
+
models: ['gpt-4'],
|
472
|
+
},
|
473
|
+
{
|
474
|
+
apiType: 'anthropic' as const,
|
475
|
+
options: {
|
476
|
+
baseURL: `${options.baseURL || 'https://api.anthropic.com'}/v1`,
|
477
|
+
},
|
478
|
+
runtime: MockRuntime as any,
|
479
|
+
models: ['claude-3'],
|
480
|
+
},
|
481
|
+
];
|
482
|
+
|
483
|
+
const Runtime = createRouterRuntime({
|
484
|
+
id: 'test-runtime',
|
485
|
+
routers: dynamicRoutersFunction,
|
486
|
+
});
|
487
|
+
|
488
|
+
const userOptions = {
|
489
|
+
apiKey: 'test-key',
|
490
|
+
baseURL: 'https://yourapi.cn',
|
491
|
+
};
|
492
|
+
|
493
|
+
const runtime = new Runtime(userOptions);
|
494
|
+
|
495
|
+
expect(runtime).toBeDefined();
|
496
|
+
expect(runtime['_runtimes']).toHaveLength(2);
|
497
|
+
expect(runtime['_runtimes'][0].id).toBe('openai');
|
498
|
+
expect(runtime['_runtimes'][1].id).toBe('anthropic');
|
499
|
+
});
|
500
|
+
|
501
|
+
it('should throw error when dynamic routers function returns empty array', () => {
|
502
|
+
const emptyRoutersFunction = () => [];
|
503
|
+
|
504
|
+
expect(() => {
|
505
|
+
const Runtime = createRouterRuntime({
|
506
|
+
id: 'test-runtime',
|
507
|
+
routers: emptyRoutersFunction,
|
508
|
+
});
|
509
|
+
new Runtime();
|
510
|
+
}).toThrow('empty providers');
|
511
|
+
});
|
512
|
+
});
|
453
513
|
});
|
@@ -104,7 +104,7 @@ interface CreateRouterRuntimeOptions<T extends Record<string, any> = any> {
|
|
104
104
|
options: ConstructorOptions<T>,
|
105
105
|
) => ChatStreamPayload;
|
106
106
|
};
|
107
|
-
routers: RouterInstance[];
|
107
|
+
routers: RouterInstance[] | ((options: ClientOptions & Record<string, any>) => RouterInstance[]);
|
108
108
|
}
|
109
109
|
|
110
110
|
export const createRouterRuntime = ({
|
@@ -125,11 +125,14 @@ export const createRouterRuntime = ({
|
|
125
125
|
baseURL: options.baseURL?.trim(),
|
126
126
|
};
|
127
127
|
|
128
|
-
|
128
|
+
// 支持动态 routers 配置
|
129
|
+
const resolvedRouters = typeof routers === 'function' ? routers(_options) : routers;
|
130
|
+
|
131
|
+
if (resolvedRouters.length === 0) {
|
129
132
|
throw new Error('empty providers');
|
130
133
|
}
|
131
134
|
|
132
|
-
this._runtimes =
|
135
|
+
this._runtimes = resolvedRouters.map((router) => {
|
133
136
|
const providerAI = router.runtime ?? baseRuntimeMap[router.apiType] ?? LobeOpenAI;
|
134
137
|
|
135
138
|
const finalOptions = { ...params, ...options, ...router.options };
|
@@ -14,6 +14,7 @@ export { LobeMistralAI } from './mistral';
|
|
14
14
|
export { ModelRuntime } from './ModelRuntime';
|
15
15
|
export { LobeMoonshotAI } from './moonshot';
|
16
16
|
export { LobeNebiusAI } from './nebius';
|
17
|
+
export { LobeNewAPIAI } from './newapi';
|
17
18
|
export { LobeOllamaAI } from './ollama';
|
18
19
|
export { LobeOpenAI } from './openai';
|
19
20
|
export { LobeOpenRouterAI } from './openrouter';
|