@lobehub/chat 1.106.7 → 1.107.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/.env.example +9 -0
- package/CHANGELOG.md +50 -0
- package/Dockerfile +2 -0
- package/Dockerfile.database +2 -0
- package/Dockerfile.pglite +2 -0
- package/changelog/v1.json +18 -0
- package/docs/usage/providers/aihubmix.zh-CN.mdx +101 -0
- package/locales/ar/modelProvider.json +1 -0
- package/locales/ar/providers.json +3 -0
- package/locales/bg-BG/modelProvider.json +1 -0
- package/locales/bg-BG/providers.json +3 -0
- package/locales/de-DE/modelProvider.json +1 -0
- package/locales/de-DE/providers.json +3 -0
- package/locales/en-US/modelProvider.json +1 -0
- package/locales/en-US/providers.json +3 -0
- package/locales/es-ES/modelProvider.json +1 -0
- package/locales/es-ES/providers.json +3 -0
- package/locales/fa-IR/modelProvider.json +1 -0
- package/locales/fa-IR/providers.json +3 -0
- package/locales/fr-FR/modelProvider.json +1 -0
- package/locales/fr-FR/providers.json +3 -0
- package/locales/it-IT/modelProvider.json +1 -0
- package/locales/it-IT/providers.json +3 -0
- package/locales/ja-JP/modelProvider.json +1 -0
- package/locales/ja-JP/providers.json +3 -0
- package/locales/ko-KR/modelProvider.json +1 -0
- package/locales/ko-KR/providers.json +3 -0
- package/locales/nl-NL/modelProvider.json +1 -0
- package/locales/nl-NL/providers.json +3 -0
- package/locales/pl-PL/modelProvider.json +1 -0
- package/locales/pl-PL/providers.json +3 -0
- package/locales/pt-BR/modelProvider.json +1 -0
- package/locales/pt-BR/providers.json +3 -0
- package/locales/ru-RU/modelProvider.json +1 -0
- package/locales/ru-RU/providers.json +3 -0
- package/locales/tr-TR/modelProvider.json +1 -0
- package/locales/tr-TR/providers.json +3 -0
- package/locales/vi-VN/modelProvider.json +1 -0
- package/locales/vi-VN/providers.json +3 -0
- package/locales/zh-CN/modelProvider.json +1 -0
- package/locales/zh-CN/providers.json +3 -0
- package/locales/zh-TW/modelProvider.json +1 -0
- package/locales/zh-TW/providers.json +3 -0
- package/package.json +1 -2
- package/src/app/(backend)/middleware/auth/index.ts +2 -2
- package/src/app/(backend)/webapi/chat/[provider]/route.test.ts +12 -12
- package/src/app/(backend)/webapi/chat/[provider]/route.ts +6 -6
- package/src/app/(backend)/webapi/chat/vertexai/route.ts +2 -2
- package/src/app/(backend)/webapi/models/[provider]/pull/route.ts +2 -2
- package/src/app/(backend)/webapi/models/[provider]/route.ts +2 -2
- package/src/app/(backend)/webapi/text-to-image/[provider]/route.ts +2 -2
- package/src/app/[variants]/(main)/settings/provider/(detail)/github/page.tsx +2 -2
- package/src/app/[variants]/(main)/settings/provider/features/ProviderConfig/index.tsx +17 -2
- package/src/config/aiModels/aihubmix.ts +164 -0
- package/src/config/aiModels/index.ts +3 -0
- package/src/config/aiModels/sensenova.ts +82 -3
- package/src/config/llm.ts +6 -0
- package/src/config/modelProviders/aihubmix.ts +18 -0
- package/src/config/modelProviders/huggingface.ts +1 -0
- package/src/config/modelProviders/index.ts +4 -0
- package/src/libs/model-runtime/ModelRuntime.test.ts +9 -10
- package/src/libs/model-runtime/ModelRuntime.ts +2 -3
- package/src/libs/model-runtime/RouterRuntime/baseRuntimeMap.ts +15 -0
- package/src/libs/model-runtime/RouterRuntime/createRuntime.ts +193 -0
- package/src/libs/model-runtime/RouterRuntime/index.ts +9 -0
- package/src/libs/model-runtime/aihubmix/index.ts +118 -0
- package/src/libs/model-runtime/index.ts +1 -1
- package/src/libs/model-runtime/openrouter/index.ts +2 -2
- package/src/libs/model-runtime/runtimeMap.ts +2 -0
- package/src/libs/model-runtime/sensenova/index.ts +4 -1
- package/src/libs/model-runtime/types/type.ts +1 -0
- package/src/locales/default/modelProvider.ts +1 -0
- package/src/server/modules/{AgentRuntime → ModelRuntime}/index.test.ts +64 -67
- package/src/server/modules/{AgentRuntime → ModelRuntime}/index.ts +3 -3
- package/src/server/routers/async/file.ts +2 -2
- package/src/server/routers/async/image.ts +2 -2
- package/src/server/routers/async/ragEval.ts +2 -2
- package/src/server/routers/lambda/chunk.ts +3 -3
- package/src/services/__tests__/chat.test.ts +21 -21
- package/src/services/chat.ts +2 -2
- package/src/types/aiProvider.ts +1 -0
- package/src/types/llm.ts +4 -0
- package/src/types/user/settings/keyVaults.ts +1 -0
- package/src/app/[variants]/(main)/settings/provider/(detail)/huggingface/page.tsx +0 -67
- /package/src/server/modules/{AgentRuntime → ModelRuntime}/apiKeyManager.test.ts +0 -0
- /package/src/server/modules/{AgentRuntime → ModelRuntime}/apiKeyManager.ts +0 -0
- /package/src/server/modules/{AgentRuntime → ModelRuntime}/trace.ts +0 -0
@@ -26,7 +26,7 @@ import {
|
|
26
26
|
LobeZhipuAI,
|
27
27
|
ModelProvider,
|
28
28
|
} from '@/libs/model-runtime';
|
29
|
-
import {
|
29
|
+
import { ModelRuntime } from '@/libs/model-runtime';
|
30
30
|
import { agentChatConfigSelectors } from '@/store/agent/selectors';
|
31
31
|
import { aiModelSelectors } from '@/store/aiInfra';
|
32
32
|
import { useToolStore } from '@/store/tool';
|
@@ -1694,8 +1694,8 @@ describe('ChatService', () => {
|
|
1694
1694
|
});
|
1695
1695
|
|
1696
1696
|
/**
|
1697
|
-
* Tests for
|
1698
|
-
* initialization of
|
1697
|
+
* Tests for ModelRuntime on client side, aim to test the
|
1698
|
+
* initialization of ModelRuntime with different providers
|
1699
1699
|
*/
|
1700
1700
|
vi.mock('../_auth', async (importOriginal) => {
|
1701
1701
|
return importOriginal();
|
@@ -2074,7 +2074,7 @@ describe('ChatService private methods', () => {
|
|
2074
2074
|
});
|
2075
2075
|
});
|
2076
2076
|
|
2077
|
-
describe('
|
2077
|
+
describe('ModelRuntimeOnClient', () => {
|
2078
2078
|
describe('initializeWithClientStore', () => {
|
2079
2079
|
describe('should initialize with options correctly', () => {
|
2080
2080
|
it('OpenAI provider: with apikey and endpoint', async () => {
|
@@ -2090,7 +2090,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2090
2090
|
},
|
2091
2091
|
} as UserSettingsState) as unknown as UserStore;
|
2092
2092
|
const runtime = await initializeWithClientStore(ModelProvider.OpenAI, {});
|
2093
|
-
expect(runtime).toBeInstanceOf(
|
2093
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2094
2094
|
expect(runtime['_runtime']).toBeInstanceOf(LobeOpenAI);
|
2095
2095
|
expect(runtime['_runtime'].baseURL).toBe('user-openai-endpoint');
|
2096
2096
|
});
|
@@ -2109,7 +2109,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2109
2109
|
} as UserSettingsState) as unknown as UserStore;
|
2110
2110
|
|
2111
2111
|
const runtime = await initializeWithClientStore(ModelProvider.Azure, {});
|
2112
|
-
expect(runtime).toBeInstanceOf(
|
2112
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2113
2113
|
expect(runtime['_runtime']).toBeInstanceOf(LobeAzureOpenAI);
|
2114
2114
|
});
|
2115
2115
|
|
@@ -2124,7 +2124,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2124
2124
|
},
|
2125
2125
|
} as UserSettingsState) as unknown as UserStore;
|
2126
2126
|
const runtime = await initializeWithClientStore(ModelProvider.Google, {});
|
2127
|
-
expect(runtime).toBeInstanceOf(
|
2127
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2128
2128
|
expect(runtime['_runtime']).toBeInstanceOf(LobeGoogleAI);
|
2129
2129
|
});
|
2130
2130
|
|
@@ -2139,7 +2139,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2139
2139
|
},
|
2140
2140
|
} as UserSettingsState) as unknown as UserStore;
|
2141
2141
|
const runtime = await initializeWithClientStore(ModelProvider.Moonshot, {});
|
2142
|
-
expect(runtime).toBeInstanceOf(
|
2142
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2143
2143
|
expect(runtime['_runtime']).toBeInstanceOf(LobeMoonshotAI);
|
2144
2144
|
});
|
2145
2145
|
|
@@ -2156,7 +2156,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2156
2156
|
},
|
2157
2157
|
} as UserSettingsState) as unknown as UserStore;
|
2158
2158
|
const runtime = await initializeWithClientStore(ModelProvider.Bedrock, {});
|
2159
|
-
expect(runtime).toBeInstanceOf(
|
2159
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2160
2160
|
expect(runtime['_runtime']).toBeInstanceOf(LobeBedrockAI);
|
2161
2161
|
});
|
2162
2162
|
|
@@ -2171,7 +2171,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2171
2171
|
},
|
2172
2172
|
} as UserSettingsState) as unknown as UserStore;
|
2173
2173
|
const runtime = await initializeWithClientStore(ModelProvider.Ollama, {});
|
2174
|
-
expect(runtime).toBeInstanceOf(
|
2174
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2175
2175
|
expect(runtime['_runtime']).toBeInstanceOf(LobeOllamaAI);
|
2176
2176
|
});
|
2177
2177
|
|
@@ -2186,7 +2186,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2186
2186
|
},
|
2187
2187
|
} as UserSettingsState) as unknown as UserStore;
|
2188
2188
|
const runtime = await initializeWithClientStore(ModelProvider.Perplexity, {});
|
2189
|
-
expect(runtime).toBeInstanceOf(
|
2189
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2190
2190
|
expect(runtime['_runtime']).toBeInstanceOf(LobePerplexityAI);
|
2191
2191
|
});
|
2192
2192
|
|
@@ -2201,7 +2201,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2201
2201
|
},
|
2202
2202
|
} as UserSettingsState) as unknown as UserStore;
|
2203
2203
|
const runtime = await initializeWithClientStore(ModelProvider.Anthropic, {});
|
2204
|
-
expect(runtime).toBeInstanceOf(
|
2204
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2205
2205
|
expect(runtime['_runtime']).toBeInstanceOf(LobeAnthropicAI);
|
2206
2206
|
});
|
2207
2207
|
|
@@ -2216,7 +2216,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2216
2216
|
},
|
2217
2217
|
} as UserSettingsState) as unknown as UserStore;
|
2218
2218
|
const runtime = await initializeWithClientStore(ModelProvider.Mistral, {});
|
2219
|
-
expect(runtime).toBeInstanceOf(
|
2219
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2220
2220
|
expect(runtime['_runtime']).toBeInstanceOf(LobeMistralAI);
|
2221
2221
|
});
|
2222
2222
|
|
@@ -2231,7 +2231,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2231
2231
|
},
|
2232
2232
|
} as UserSettingsState) as unknown as UserStore;
|
2233
2233
|
const runtime = await initializeWithClientStore(ModelProvider.OpenRouter, {});
|
2234
|
-
expect(runtime).toBeInstanceOf(
|
2234
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2235
2235
|
expect(runtime['_runtime']).toBeInstanceOf(LobeOpenRouterAI);
|
2236
2236
|
});
|
2237
2237
|
|
@@ -2246,7 +2246,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2246
2246
|
},
|
2247
2247
|
} as UserSettingsState) as unknown as UserStore;
|
2248
2248
|
const runtime = await initializeWithClientStore(ModelProvider.TogetherAI, {});
|
2249
|
-
expect(runtime).toBeInstanceOf(
|
2249
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2250
2250
|
expect(runtime['_runtime']).toBeInstanceOf(LobeTogetherAI);
|
2251
2251
|
});
|
2252
2252
|
|
@@ -2261,7 +2261,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2261
2261
|
},
|
2262
2262
|
} as UserSettingsState) as unknown as UserStore;
|
2263
2263
|
const runtime = await initializeWithClientStore(ModelProvider.ZeroOne, {});
|
2264
|
-
expect(runtime).toBeInstanceOf(
|
2264
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2265
2265
|
expect(runtime['_runtime']).toBeInstanceOf(LobeZeroOneAI);
|
2266
2266
|
});
|
2267
2267
|
|
@@ -2277,7 +2277,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2277
2277
|
},
|
2278
2278
|
} as UserSettingsState) as unknown as UserStore;
|
2279
2279
|
const runtime = await initializeWithClientStore(ModelProvider.Groq, {});
|
2280
|
-
expect(runtime).toBeInstanceOf(
|
2280
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2281
2281
|
const lobeOpenAICompatibleInstance = runtime['_runtime'] as LobeOpenAICompatibleRuntime;
|
2282
2282
|
expect(lobeOpenAICompatibleInstance).toBeInstanceOf(LobeGroq);
|
2283
2283
|
expect(lobeOpenAICompatibleInstance.baseURL).toBe('user-groq-endpoint');
|
@@ -2296,7 +2296,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2296
2296
|
},
|
2297
2297
|
} as UserSettingsState) as unknown as UserStore;
|
2298
2298
|
const runtime = await initializeWithClientStore(ModelProvider.DeepSeek, {});
|
2299
|
-
expect(runtime).toBeInstanceOf(
|
2299
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2300
2300
|
expect(runtime['_runtime']).toBeInstanceOf(LobeDeepSeekAI);
|
2301
2301
|
});
|
2302
2302
|
|
@@ -2311,7 +2311,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2311
2311
|
},
|
2312
2312
|
} as UserSettingsState) as unknown as UserStore;
|
2313
2313
|
const runtime = await initializeWithClientStore(ModelProvider.Qwen, {});
|
2314
|
-
expect(runtime).toBeInstanceOf(
|
2314
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2315
2315
|
expect(runtime['_runtime']).toBeInstanceOf(LobeQwenAI);
|
2316
2316
|
});
|
2317
2317
|
|
@@ -2331,7 +2331,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2331
2331
|
},
|
2332
2332
|
} as any as UserSettingsState) as unknown as UserStore;
|
2333
2333
|
const runtime = await initializeWithClientStore('unknown' as ModelProvider, {});
|
2334
|
-
expect(runtime).toBeInstanceOf(
|
2334
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2335
2335
|
expect(runtime['_runtime']).toBeInstanceOf(LobeOpenAI);
|
2336
2336
|
});
|
2337
2337
|
|
@@ -2358,7 +2358,7 @@ describe('AgentRuntimeOnClient', () => {
|
|
2358
2358
|
},
|
2359
2359
|
} as UserSettingsState) as unknown as UserStore;
|
2360
2360
|
const runtime = await initializeWithClientStore(ModelProvider.ZhiPu, {});
|
2361
|
-
expect(runtime).toBeInstanceOf(
|
2361
|
+
expect(runtime).toBeInstanceOf(ModelRuntime);
|
2362
2362
|
expect(runtime['_runtime']).toBeInstanceOf(LobeZhipuAI);
|
2363
2363
|
});
|
2364
2364
|
});
|
package/src/services/chat.ts
CHANGED
@@ -10,10 +10,10 @@ import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
|
10
10
|
import { TracePayload, TraceTagMap } from '@/const/trace';
|
11
11
|
import { isDeprecatedEdition, isDesktop, isServerMode } from '@/const/version';
|
12
12
|
import {
|
13
|
-
AgentRuntime,
|
14
13
|
AgentRuntimeError,
|
15
14
|
ChatCompletionErrorPayload,
|
16
15
|
ModelProvider,
|
16
|
+
ModelRuntime,
|
17
17
|
} from '@/libs/model-runtime';
|
18
18
|
import { parseDataUri } from '@/libs/model-runtime/utils/uriParser';
|
19
19
|
import { filesPrompts } from '@/prompts/files';
|
@@ -168,7 +168,7 @@ export function initializeWithClientStore(provider: string, payload?: any) {
|
|
168
168
|
* Configuration override order:
|
169
169
|
* payload -> providerAuthPayload -> commonOptions
|
170
170
|
*/
|
171
|
-
return
|
171
|
+
return ModelRuntime.initializeWithProvider(provider, {
|
172
172
|
...commonOptions,
|
173
173
|
...providerAuthPayload,
|
174
174
|
...payload,
|
package/src/types/aiProvider.ts
CHANGED
package/src/types/llm.ts
CHANGED
@@ -39,6 +39,7 @@ export interface SearchEngineKeyVaults {
|
|
39
39
|
export interface UserKeyVaults extends SearchEngineKeyVaults {
|
40
40
|
ai21?: OpenAICompatibleKeyVault;
|
41
41
|
ai360?: OpenAICompatibleKeyVault;
|
42
|
+
aihubmix?: OpenAICompatibleKeyVault;
|
42
43
|
anthropic?: OpenAICompatibleKeyVault;
|
43
44
|
azure?: AzureOpenAIKeyVault;
|
44
45
|
azureai?: AzureOpenAIKeyVault;
|
@@ -1,67 +0,0 @@
|
|
1
|
-
'use client';
|
2
|
-
|
3
|
-
import { Markdown } from '@lobehub/ui';
|
4
|
-
import { createStyles } from 'antd-style';
|
5
|
-
import { useTranslation } from 'react-i18next';
|
6
|
-
|
7
|
-
import { FormPassword } from '@/components/FormInput';
|
8
|
-
import { HuggingFaceProviderCard } from '@/config/modelProviders';
|
9
|
-
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
10
|
-
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
11
|
-
|
12
|
-
import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
|
13
|
-
import { SkeletonInput } from '../../features/ProviderConfig';
|
14
|
-
import { ProviderItem } from '../../type';
|
15
|
-
import ProviderDetail from '../[id]';
|
16
|
-
|
17
|
-
const useStyles = createStyles(({ css, token }) => ({
|
18
|
-
markdown: css`
|
19
|
-
p {
|
20
|
-
color: ${token.colorTextDescription} !important;
|
21
|
-
}
|
22
|
-
`,
|
23
|
-
tip: css`
|
24
|
-
font-size: 12px;
|
25
|
-
color: ${token.colorTextDescription};
|
26
|
-
`,
|
27
|
-
}));
|
28
|
-
|
29
|
-
const providerKey: GlobalLLMProviderKey = 'huggingface';
|
30
|
-
|
31
|
-
// Same as OpenAIProvider, but replace API Key with HuggingFace Access Token
|
32
|
-
const useProviderCard = (): ProviderItem => {
|
33
|
-
const { t } = useTranslation('modelProvider');
|
34
|
-
const { styles } = useStyles();
|
35
|
-
const isLoading = useAiInfraStore(aiProviderSelectors.isAiProviderConfigLoading(providerKey));
|
36
|
-
|
37
|
-
return {
|
38
|
-
...HuggingFaceProviderCard,
|
39
|
-
apiKeyItems: [
|
40
|
-
{
|
41
|
-
children: isLoading ? (
|
42
|
-
<SkeletonInput />
|
43
|
-
) : (
|
44
|
-
<FormPassword
|
45
|
-
autoComplete={'new-password'}
|
46
|
-
placeholder={t('huggingface.accessToken.placeholder')}
|
47
|
-
/>
|
48
|
-
),
|
49
|
-
desc: (
|
50
|
-
<Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
|
51
|
-
{t('huggingface.accessToken.desc')}
|
52
|
-
</Markdown>
|
53
|
-
),
|
54
|
-
label: t('huggingface.accessToken.title'),
|
55
|
-
name: [KeyVaultsConfigKey, LLMProviderApiTokenKey],
|
56
|
-
},
|
57
|
-
],
|
58
|
-
};
|
59
|
-
};
|
60
|
-
|
61
|
-
const Page = () => {
|
62
|
-
const card = useProviderCard();
|
63
|
-
|
64
|
-
return <ProviderDetail {...card} />;
|
65
|
-
};
|
66
|
-
|
67
|
-
export default Page;
|
File without changes
|
File without changes
|
File without changes
|