@lobehub/chat 1.40.1 → 1.40.2
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 +25 -0
- package/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/Actions.tsx +1 -1
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/Header.tsx +1 -1
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/InfoSidebar/SuggestionItem.tsx +2 -2
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ProviderList/ProviderItem.tsx +1 -1
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/ModelList/ModelItem.tsx +3 -3
- package/src/app/(main)/discover/(list)/models/features/Card.tsx +6 -2
- package/src/app/(main)/settings/llm/ProviderList/Cloudflare/index.tsx +1 -5
- package/src/app/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +2 -2
- package/src/components/ModelSelect/index.tsx +7 -4
- package/src/config/__tests__/app.test.ts +6 -2
- package/src/config/app.ts +1 -2
- package/src/config/modelProviders/ai21.ts +2 -2
- package/src/config/modelProviders/ai360.ts +4 -4
- package/src/config/modelProviders/anthropic.ts +8 -8
- package/src/config/modelProviders/azure.ts +5 -5
- package/src/config/modelProviders/baichuan.ts +6 -6
- package/src/config/modelProviders/bedrock.ts +14 -14
- package/src/config/modelProviders/cloudflare.ts +12 -11
- package/src/config/modelProviders/deepseek.ts +1 -1
- package/src/config/modelProviders/fireworksai.ts +29 -27
- package/src/config/modelProviders/giteeai.ts +7 -7
- package/src/config/modelProviders/github.ts +29 -28
- package/src/config/modelProviders/google.ts +18 -19
- package/src/config/modelProviders/groq.ts +13 -13
- package/src/config/modelProviders/higress.ts +195 -194
- package/src/config/modelProviders/huggingface.ts +7 -7
- package/src/config/modelProviders/hunyuan.ts +25 -17
- package/src/config/modelProviders/internlm.ts +6 -4
- package/src/config/modelProviders/minimax.ts +5 -5
- package/src/config/modelProviders/mistral.ts +14 -16
- package/src/config/modelProviders/moonshot.ts +3 -3
- package/src/config/modelProviders/novita.ts +15 -15
- package/src/config/modelProviders/ollama.ts +46 -46
- package/src/config/modelProviders/openai.ts +23 -22
- package/src/config/modelProviders/openrouter.ts +20 -18
- package/src/config/modelProviders/perplexity.ts +7 -7
- package/src/config/modelProviders/qwen.ts +23 -25
- package/src/config/modelProviders/sensenova.ts +8 -8
- package/src/config/modelProviders/siliconcloud.ts +138 -92
- package/src/config/modelProviders/spark.ts +6 -6
- package/src/config/modelProviders/stepfun.ts +9 -9
- package/src/config/modelProviders/taichu.ts +2 -3
- package/src/config/modelProviders/togetherai.ts +57 -48
- package/src/config/modelProviders/upstage.ts +3 -3
- package/src/config/modelProviders/wenxin.ts +12 -12
- package/src/config/modelProviders/xai.ts +4 -4
- package/src/config/modelProviders/zeroone.ts +11 -11
- package/src/config/modelProviders/zhipu.ts +17 -16
- package/src/database/_deprecated/core/model.ts +1 -1
- package/src/database/_deprecated/models/sessionGroup.ts +4 -1
- package/src/database/client/migrations.json +2 -5
- package/src/database/migrations/meta/0012_snapshot.json +176 -518
- package/src/database/schemas/agent.ts +1 -1
- package/src/database/schemas/message.ts +1 -0
- package/src/database/schemas/session.ts +1 -0
- package/src/database/server/models/topic.ts +19 -17
- package/src/features/DebugUI/Content.tsx +0 -1
- package/src/features/PluginStore/index.tsx +2 -2
- package/src/layout/GlobalProvider/AntdV5MonkeyPatch.tsx +4 -4
- package/src/libs/agent-runtime/google/index.ts +4 -3
- package/src/libs/agent-runtime/higress/index.ts +1 -1
- package/src/libs/agent-runtime/huggingface/index.ts +2 -4
- package/src/libs/agent-runtime/minimax/index.ts +5 -10
- package/src/libs/agent-runtime/mistral/index.ts +3 -6
- package/src/libs/agent-runtime/moonshot/index.ts +3 -6
- package/src/libs/agent-runtime/novita/__snapshots__/index.test.ts.snap +18 -18
- package/src/libs/agent-runtime/novita/index.ts +1 -1
- package/src/libs/agent-runtime/openai/__snapshots__/index.test.ts.snap +10 -10
- package/src/libs/agent-runtime/openrouter/__snapshots__/index.test.ts.snap +168 -168
- package/src/libs/agent-runtime/openrouter/index.ts +1 -1
- package/src/libs/agent-runtime/perplexity/index.ts +4 -4
- package/src/libs/agent-runtime/sensenova/index.ts +9 -3
- package/src/libs/agent-runtime/taichu/index.ts +4 -10
- package/src/libs/agent-runtime/utils/streams/minimax.test.ts +5 -2
- package/src/libs/agent-runtime/utils/streams/minimax.ts +4 -1
- package/src/libs/agent-runtime/zhipu/index.ts +12 -13
- package/src/libs/langchain/loaders/index.ts +2 -2
- package/src/libs/langchain/types.ts +9 -1
- package/src/locales/default/modelProvider.ts +1 -1
- package/src/migrations/FromV3ToV4/fixtures/ollama-output-v4.json +1 -1
- package/src/migrations/FromV6ToV7/types/v7.ts +0 -2
- package/src/server/globalConfig/genServerLLMConfig.test.ts +4 -4
- package/src/server/globalConfig/genServerLLMConfig.ts +29 -24
- package/src/server/globalConfig/index.ts +1 -2
- package/src/server/routers/edge/config/__snapshots__/index.test.ts.snap +9 -9
- package/src/server/routers/lambda/_template.ts +1 -1
- package/src/server/routers/lambda/knowledgeBase.ts +1 -1
- package/src/server/routers/lambda/session.ts +1 -1
- package/src/server/routers/lambda/sessionGroup.ts +1 -1
- package/src/server/routers/lambda/thread.ts +1 -1
- package/src/server/services/nextAuthUser/index.ts +1 -1
- package/src/store/user/slices/modelList/__snapshots__/action.test.ts.snap +1 -1
- package/src/store/user/slices/modelList/action.test.ts +4 -4
- package/src/store/user/slices/modelList/reducers/customModelCard.test.ts +6 -6
- package/src/store/user/slices/modelList/selectors/modelProvider.ts +3 -2
- package/src/tools/dalle/Render/Item/index.tsx +1 -1
- package/src/types/files/index.ts +0 -1
- package/src/types/llm.ts +4 -5
- package/src/utils/__snapshots__/parseModels.test.ts.snap +2 -2
- package/src/utils/genUserLLMConfig.test.ts +4 -4
- package/src/utils/genUserLLMConfig.ts +6 -4
- package/src/utils/parseModels.test.ts +16 -16
- package/src/utils/parseModels.ts +1 -1
- package/src/utils/server/jwt.ts +2 -6
@@ -20,6 +20,7 @@ export const LobeOpenRouterAI = LobeOpenAICompatibleFactory({
|
|
20
20
|
const model = m as unknown as OpenRouterModelCard;
|
21
21
|
|
22
22
|
return {
|
23
|
+
contextWindowTokens: model.context_length,
|
23
24
|
description: model.description,
|
24
25
|
displayName: model.name,
|
25
26
|
enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false,
|
@@ -30,7 +31,6 @@ export const LobeOpenRouterAI = LobeOpenAICompatibleFactory({
|
|
30
31
|
typeof model.top_provider.max_completion_tokens === 'number'
|
31
32
|
? model.top_provider.max_completion_tokens
|
32
33
|
: undefined,
|
33
|
-
tokens: model.context_length,
|
34
34
|
vision:
|
35
35
|
model.description.includes('vision') ||
|
36
36
|
model.description.includes('multimodal') ||
|
@@ -8,7 +8,7 @@ export const LobePerplexityAI = LobeOpenAICompatibleFactory({
|
|
8
8
|
chatCompletion: {
|
9
9
|
handlePayload: (payload: ChatStreamPayload) => {
|
10
10
|
// Set a default frequency penalty value greater than 0
|
11
|
-
const { presence_penalty, frequency_penalty, stream = true, temperature,
|
11
|
+
const { presence_penalty, frequency_penalty, stream = true, temperature, ...res } = payload;
|
12
12
|
|
13
13
|
let param;
|
14
14
|
|
@@ -21,9 +21,9 @@ export const LobePerplexityAI = LobeOpenAICompatibleFactory({
|
|
21
21
|
param = { frequency_penalty: frequency_penalty || defaultFrequencyPenalty };
|
22
22
|
}
|
23
23
|
|
24
|
-
return {
|
25
|
-
...res,
|
26
|
-
...param,
|
24
|
+
return {
|
25
|
+
...res,
|
26
|
+
...param,
|
27
27
|
stream,
|
28
28
|
temperature: temperature >= 2 ? undefined : temperature,
|
29
29
|
} as OpenAI.ChatCompletionCreateParamsStreaming;
|
@@ -9,10 +9,16 @@ export const LobeSenseNovaAI = LobeOpenAICompatibleFactory({
|
|
9
9
|
|
10
10
|
return {
|
11
11
|
...rest,
|
12
|
-
frequency_penalty:
|
12
|
+
frequency_penalty:
|
13
|
+
frequency_penalty !== undefined && frequency_penalty > 0 && frequency_penalty <= 2
|
14
|
+
? frequency_penalty
|
15
|
+
: undefined,
|
13
16
|
stream: true,
|
14
|
-
temperature:
|
15
|
-
|
17
|
+
temperature:
|
18
|
+
temperature !== undefined && temperature > 0 && temperature <= 2
|
19
|
+
? temperature
|
20
|
+
: undefined,
|
21
|
+
top_p: top_p !== undefined && top_p > 0 && top_p < 1 ? top_p : undefined,
|
16
22
|
} as any;
|
17
23
|
},
|
18
24
|
},
|
@@ -9,16 +9,10 @@ export const LobeTaichuAI = LobeOpenAICompatibleFactory({
|
|
9
9
|
handlePayload: (payload: ChatStreamPayload) => {
|
10
10
|
const { temperature, top_p, ...rest } = payload;
|
11
11
|
|
12
|
-
return {
|
13
|
-
...rest,
|
14
|
-
temperature:
|
15
|
-
|
16
|
-
? Math.max(temperature / 2, 0.01)
|
17
|
-
: undefined,
|
18
|
-
top_p:
|
19
|
-
top_p !== undefined
|
20
|
-
? Math.min(9.9, Math.max(top_p / 2, 0.1))
|
21
|
-
: undefined
|
12
|
+
return {
|
13
|
+
...rest,
|
14
|
+
temperature: temperature !== undefined ? Math.max(temperature / 2, 0.01) : undefined,
|
15
|
+
top_p: top_p !== undefined ? Math.min(9.9, Math.max(top_p / 2, 0.1)) : undefined,
|
22
16
|
} as OpenAI.ChatCompletionCreateParamsStreaming;
|
23
17
|
},
|
24
18
|
},
|
@@ -1,5 +1,8 @@
|
|
1
|
-
import { describe,
|
2
|
-
|
1
|
+
import { describe, expect, it } from 'vitest';
|
2
|
+
|
3
|
+
import { processDoubleData } from './minimax';
|
4
|
+
|
5
|
+
// 假设文件名为 minimax.ts
|
3
6
|
|
4
7
|
describe('processDoubleData', () => {
|
5
8
|
it('should remove the second "data: {"id": and everything after it when matchCount is 2', () => {
|
@@ -9,7 +9,10 @@ export const processDoubleData = (chunkValue: string): string => {
|
|
9
9
|
const matchCount = (chunkValue.match(dataPattern) || []).length;
|
10
10
|
let modifiedChunkValue = chunkValue;
|
11
11
|
if (matchCount === 2) {
|
12
|
-
const secondDataIdIndex = chunkValue.indexOf(
|
12
|
+
const secondDataIdIndex = chunkValue.indexOf(
|
13
|
+
'data: {"id":',
|
14
|
+
chunkValue.indexOf('data: {"id":') + 1,
|
15
|
+
);
|
13
16
|
if (secondDataIdIndex !== -1) {
|
14
17
|
modifiedChunkValue = chunkValue.slice(0, secondDataIdIndex).trim();
|
15
18
|
}
|
@@ -11,19 +11,18 @@ export const LobeZhipuAI = LobeOpenAICompatibleFactory({
|
|
11
11
|
...payload,
|
12
12
|
model,
|
13
13
|
stream: true,
|
14
|
-
...(model ===
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}),
|
14
|
+
...(model === 'glm-4-alltools'
|
15
|
+
? {
|
16
|
+
temperature:
|
17
|
+
temperature !== undefined
|
18
|
+
? Math.max(0.01, Math.min(0.99, temperature / 2))
|
19
|
+
: undefined,
|
20
|
+
top_p: top_p !== undefined ? Math.max(0.01, Math.min(0.99, top_p)) : undefined,
|
21
|
+
}
|
22
|
+
: {
|
23
|
+
temperature: temperature !== undefined ? temperature / 2 : undefined,
|
24
|
+
top_p,
|
25
|
+
}),
|
27
26
|
}) as OpenAI.ChatCompletionCreateParamsStreaming,
|
28
27
|
},
|
29
28
|
debug: {
|
@@ -7,13 +7,13 @@ import { LANGCHAIN_SUPPORT_TEXT_LIST } from '@/libs/langchain/file';
|
|
7
7
|
import { LangChainLoaderType } from '@/libs/langchain/types';
|
8
8
|
|
9
9
|
import { CodeLoader } from './code';
|
10
|
+
import { CsVLoader } from './csv';
|
10
11
|
import { DocxLoader } from './docx';
|
11
12
|
import { LatexLoader } from './latex';
|
12
13
|
import { MarkdownLoader } from './markdown';
|
13
14
|
import { PdfLoader } from './pdf';
|
14
15
|
import { PPTXLoader } from './pptx';
|
15
16
|
import { TextLoader } from './txt';
|
16
|
-
import { CsVLoader} from './csv';
|
17
17
|
|
18
18
|
class LangChainError extends Error {
|
19
19
|
constructor(message: string) {
|
@@ -96,7 +96,7 @@ export class ChunkingLoader {
|
|
96
96
|
return 'markdown';
|
97
97
|
}
|
98
98
|
|
99
|
-
if (filename.endsWith('csv')
|
99
|
+
if (filename.endsWith('csv')) {
|
100
100
|
return 'csv';
|
101
101
|
}
|
102
102
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
2
2
|
|
3
|
-
import { genServerLLMConfig } from './genServerLLMConfig';
|
4
|
-
|
5
3
|
import { getLLMConfig } from '@/config/llm';
|
6
4
|
|
5
|
+
import { genServerLLMConfig } from './genServerLLMConfig';
|
6
|
+
|
7
7
|
// Mock ModelProvider enum
|
8
8
|
vi.mock('@/libs/agent-runtime', () => ({
|
9
9
|
ModelProvider: {
|
10
10
|
Azure: 'azure',
|
11
11
|
Bedrock: 'bedrock',
|
12
12
|
Ollama: 'ollama',
|
13
|
-
}
|
13
|
+
},
|
14
14
|
}));
|
15
15
|
|
16
16
|
// Mock ProviderCards
|
@@ -86,7 +86,7 @@ describe('genServerLLMConfig', () => {
|
|
86
86
|
|
87
87
|
expect(config.ollama).toEqual({
|
88
88
|
enabled: true,
|
89
|
-
enabledModels: ['ollamaModels'],
|
89
|
+
enabledModels: ['ollamaModels'],
|
90
90
|
fetchOnClient: true,
|
91
91
|
serverModelCards: ['ollamaModel1', 'ollamaModel2'],
|
92
92
|
});
|
@@ -1,35 +1,40 @@
|
|
1
1
|
import { getLLMConfig } from '@/config/llm';
|
2
2
|
import * as ProviderCards from '@/config/modelProviders';
|
3
|
-
|
4
3
|
import { ModelProvider } from '@/libs/agent-runtime';
|
5
|
-
|
6
|
-
import { extractEnabledModels, transformToChatModelCards } from '@/utils/parseModels';
|
7
|
-
|
8
4
|
import { ModelProviderCard } from '@/types/llm';
|
5
|
+
import { extractEnabledModels, transformToChatModelCards } from '@/utils/parseModels';
|
9
6
|
|
10
7
|
export const genServerLLMConfig = (specificConfig: Record<any, any>) => {
|
11
8
|
const llmConfig = getLLMConfig() as Record<string, any>;
|
12
9
|
|
13
|
-
return Object.values(ModelProvider).reduce(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
return Object.values(ModelProvider).reduce(
|
11
|
+
(config, provider) => {
|
12
|
+
const providerUpperCase = provider.toUpperCase();
|
13
|
+
const providerCard = ProviderCards[
|
14
|
+
`${provider}ProviderCard` as keyof typeof ProviderCards
|
15
|
+
] as ModelProviderCard;
|
16
|
+
const providerConfig = specificConfig[provider as keyof typeof specificConfig] || {};
|
17
|
+
const providerModelList =
|
18
|
+
process.env[providerConfig.modelListKey ?? `${providerUpperCase}_MODEL_LIST`];
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
config[provider] = {
|
21
|
+
enabled: llmConfig[providerConfig.enabledKey || `ENABLED_${providerUpperCase}`],
|
22
|
+
enabledModels: extractEnabledModels(
|
23
|
+
providerModelList,
|
24
|
+
providerConfig.withDeploymentName || false,
|
25
|
+
),
|
26
|
+
serverModelCards: transformToChatModelCards({
|
27
|
+
defaultChatModels: (providerCard as ModelProviderCard)?.chatModels || [],
|
28
|
+
modelString: providerModelList,
|
29
|
+
withDeploymentName: providerConfig.withDeploymentName || false,
|
30
|
+
}),
|
31
|
+
...(providerConfig.fetchOnClient !== undefined && {
|
32
|
+
fetchOnClient: providerConfig.fetchOnClient,
|
33
|
+
}),
|
34
|
+
};
|
32
35
|
|
33
|
-
|
34
|
-
|
36
|
+
return config;
|
37
|
+
},
|
38
|
+
{} as Record<ModelProvider, any>,
|
39
|
+
);
|
35
40
|
};
|
@@ -6,10 +6,9 @@ import { enableNextAuth } from '@/const/auth';
|
|
6
6
|
import { parseSystemAgent } from '@/server/globalConfig/parseSystemAgent';
|
7
7
|
import { GlobalServerConfig } from '@/types/serverConfig';
|
8
8
|
|
9
|
+
import { genServerLLMConfig } from './genServerLLMConfig';
|
9
10
|
import { parseAgentConfig } from './parseDefaultAgent';
|
10
11
|
|
11
|
-
import { genServerLLMConfig } from './genServerLLMConfig'
|
12
|
-
|
13
12
|
export const getServerGlobalConfig = () => {
|
14
13
|
const { ACCESS_CODES, DEFAULT_AGENT_CONFIG } = getAppConfig();
|
15
14
|
|
@@ -20,6 +20,7 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
20
20
|
"id": "claude-2",
|
21
21
|
},
|
22
22
|
{
|
23
|
+
"contextWindowTokens": 128000,
|
23
24
|
"description": "最新的 GPT-4 Turbo 模型具备视觉功能。现在,视觉请求可以使用 JSON 模式和函数调用。 GPT-4 Turbo 是一个增强版本,为多模态任务提供成本效益高的支持。它在准确性和效率之间找到平衡,适合需要进行实时交互的应用程序场景。",
|
24
25
|
"displayName": "gpt-4-32k",
|
25
26
|
"enabled": true,
|
@@ -29,7 +30,6 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
29
30
|
"input": 10,
|
30
31
|
"output": 30,
|
31
32
|
},
|
32
|
-
"tokens": 128000,
|
33
33
|
},
|
34
34
|
],
|
35
35
|
}
|
@@ -38,6 +38,7 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
38
38
|
exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST > should work correct with gpt-4 1`] = `
|
39
39
|
[
|
40
40
|
{
|
41
|
+
"contextWindowTokens": 16385,
|
41
42
|
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125",
|
42
43
|
"displayName": "GPT-3.5 Turbo 1106",
|
43
44
|
"enabled": true,
|
@@ -47,9 +48,9 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
47
48
|
"input": 1,
|
48
49
|
"output": 2,
|
49
50
|
},
|
50
|
-
"tokens": 16385,
|
51
51
|
},
|
52
52
|
{
|
53
|
+
"contextWindowTokens": 16385,
|
53
54
|
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125",
|
54
55
|
"displayName": "GPT-3.5 Turbo",
|
55
56
|
"enabled": true,
|
@@ -59,9 +60,9 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
59
60
|
"input": 0.5,
|
60
61
|
"output": 1.5,
|
61
62
|
},
|
62
|
-
"tokens": 16385,
|
63
63
|
},
|
64
64
|
{
|
65
|
+
"contextWindowTokens": 8192,
|
65
66
|
"description": "GPT-4 提供了一个更大的上下文窗口,能够处理更长的文本输入,适用于需要广泛信息整合和数据分析的场景。",
|
66
67
|
"displayName": "GPT-4",
|
67
68
|
"enabled": true,
|
@@ -71,9 +72,9 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
71
72
|
"input": 30,
|
72
73
|
"output": 60,
|
73
74
|
},
|
74
|
-
"tokens": 8192,
|
75
75
|
},
|
76
76
|
{
|
77
|
+
"contextWindowTokens": 32768,
|
77
78
|
"description": "GPT-4 提供了一个更大的上下文窗口,能够处理更长的文本输入,适用于需要广泛信息整合和数据分析的场景。",
|
78
79
|
"displayName": "GPT-4 32K",
|
79
80
|
"enabled": true,
|
@@ -83,9 +84,9 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
83
84
|
"input": 60,
|
84
85
|
"output": 120,
|
85
86
|
},
|
86
|
-
"tokens": 32768,
|
87
87
|
},
|
88
88
|
{
|
89
|
+
"contextWindowTokens": 128000,
|
89
90
|
"description": "最新的 GPT-4 Turbo 模型具备视觉功能。现在,视觉请求可以使用 JSON 模式和函数调用。 GPT-4 Turbo 是一个增强版本,为多模态任务提供成本效益高的支持。它在准确性和效率之间找到平衡,适合需要进行实时交互的应用程序场景。",
|
90
91
|
"displayName": "GPT-4 Turbo Preview 1106",
|
91
92
|
"enabled": true,
|
@@ -95,7 +96,6 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
95
96
|
"input": 10,
|
96
97
|
"output": 30,
|
97
98
|
},
|
98
|
-
"tokens": 128000,
|
99
99
|
},
|
100
100
|
{
|
101
101
|
"displayName": "gpt-4-vision",
|
@@ -107,6 +107,7 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
107
107
|
|
108
108
|
exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST > show the hidden model 1`] = `
|
109
109
|
{
|
110
|
+
"contextWindowTokens": 128000,
|
110
111
|
"description": "最新的 GPT-4 Turbo 模型具备视觉功能。现在,视觉请求可以使用 JSON 模式和函数调用。 GPT-4 Turbo 是一个增强版本,为多模态任务提供成本效益高的支持。它在准确性和效率之间找到平衡,适合需要进行实时交互的应用程序场景。",
|
111
112
|
"displayName": "GPT-4 Turbo Preview 1106",
|
112
113
|
"enabled": true,
|
@@ -116,7 +117,6 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
116
117
|
"input": 10,
|
117
118
|
"output": 30,
|
118
119
|
},
|
119
|
-
"tokens": 128000,
|
120
120
|
}
|
121
121
|
`;
|
122
122
|
|
@@ -129,18 +129,18 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENROUTER_MODEL_
|
|
129
129
|
],
|
130
130
|
"serverModelCards": [
|
131
131
|
{
|
132
|
+
"contextWindowTokens": 32768,
|
132
133
|
"description": "LLaMA 3.1 提供多语言支持,是业界领先的生成模型之一。",
|
133
134
|
"displayName": "Llama 3.1 8B (Free)",
|
134
135
|
"enabled": true,
|
135
136
|
"id": "meta-llama/llama-3.1-8b-instruct:free",
|
136
|
-
"tokens": 32768,
|
137
137
|
},
|
138
138
|
{
|
139
|
+
"contextWindowTokens": 8192,
|
139
140
|
"description": "Gemma 2 是Google轻量化的开源文本模型系列。",
|
140
141
|
"displayName": "Gemma 2 9B (Free)",
|
141
142
|
"enabled": true,
|
142
143
|
"id": "google/gemma-2-9b-it:free",
|
143
|
-
"tokens": 8192,
|
144
144
|
},
|
145
145
|
],
|
146
146
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
|
3
|
+
import { insertSessionGroupSchema } from '@/database/schemas';
|
3
4
|
import { serverDB } from '@/database/server';
|
4
5
|
import { SessionGroupModel } from '@/database/server/models/sessionGroup';
|
5
|
-
import { insertSessionGroupSchema } from '@/database/schemas';
|
6
6
|
import { authedProcedure, router } from '@/libs/trpc';
|
7
7
|
import { SessionGroupItem } from '@/types/session';
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
|
3
|
+
import { insertKnowledgeBasesSchema } from '@/database/schemas';
|
3
4
|
import { serverDB } from '@/database/server';
|
4
5
|
import { KnowledgeBaseModel } from '@/database/server/models/knowledgeBase';
|
5
|
-
import { insertKnowledgeBasesSchema } from '@/database/schemas';
|
6
6
|
import { authedProcedure, router } from '@/libs/trpc';
|
7
7
|
import { KnowledgeBaseItem } from '@/types/knowledgeBase';
|
8
8
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
|
3
|
+
import { insertAgentSchema, insertSessionSchema } from '@/database/schemas';
|
3
4
|
import { serverDB } from '@/database/server';
|
4
5
|
import { SessionModel } from '@/database/server/models/session';
|
5
6
|
import { SessionGroupModel } from '@/database/server/models/sessionGroup';
|
6
|
-
import { insertAgentSchema, insertSessionSchema } from '@/database/schemas';
|
7
7
|
import { authedProcedure, publicProcedure, router } from '@/libs/trpc';
|
8
8
|
import { AgentChatConfigSchema } from '@/types/agent';
|
9
9
|
import { LobeMetaDataSchema } from '@/types/meta';
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
|
3
|
+
import { insertSessionGroupSchema } from '@/database/schemas';
|
3
4
|
import { serverDB } from '@/database/server';
|
4
5
|
import { SessionGroupModel } from '@/database/server/models/sessionGroup';
|
5
|
-
import { insertSessionGroupSchema } from '@/database/schemas';
|
6
6
|
import { authedProcedure, router } from '@/libs/trpc';
|
7
7
|
import { SessionGroupItem } from '@/types/session';
|
8
8
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
|
3
|
+
import { insertThreadSchema } from '@/database/schemas';
|
3
4
|
import { serverDB } from '@/database/server';
|
4
5
|
import { MessageModel } from '@/database/server/models/message';
|
5
6
|
import { ThreadModel } from '@/database/server/models/thread';
|
6
|
-
import { insertThreadSchema } from '@/database/schemas';
|
7
7
|
import { authedProcedure, router } from '@/libs/trpc';
|
8
8
|
import { ThreadItem, createThreadSchema } from '@/types/topic/thread';
|
9
9
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { NextResponse } from 'next/server';
|
2
2
|
|
3
|
+
import { UserItem } from '@/database/schemas';
|
3
4
|
import { serverDB } from '@/database/server';
|
4
5
|
import { UserModel } from '@/database/server/models/user';
|
5
|
-
import { UserItem } from '@/database/schemas';
|
6
6
|
import { pino } from '@/libs/logger';
|
7
7
|
import { LobeNextAuthDbAdapter } from '@/libs/next-auth/adapter';
|
8
8
|
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
exports[`LLMSettingsSliceAction > refreshModelProviderList > visible 1`] = `
|
4
4
|
{
|
5
|
+
"contextWindowTokens": 4096,
|
5
6
|
"description": "LLaVA 是结合视觉编码器和 Vicuna 的多模态模型,用于强大的视觉和语言理解。",
|
6
7
|
"displayName": "LLaVA 7B",
|
7
8
|
"enabled": true,
|
8
9
|
"id": "llava",
|
9
|
-
"tokens": 4096,
|
10
10
|
"vision": true,
|
11
11
|
}
|
12
12
|
`;
|
@@ -92,14 +92,14 @@ describe('LLMSettingsSliceAction', () => {
|
|
92
92
|
displayName: 'ChatGPT-4',
|
93
93
|
functionCall: true,
|
94
94
|
id: 'gpt-4-0125-preview',
|
95
|
-
|
95
|
+
contextWindowTokens: 128000,
|
96
96
|
enabled: true,
|
97
97
|
},
|
98
98
|
{
|
99
99
|
displayName: 'ChatGPT-4 Vision',
|
100
100
|
functionCall: true,
|
101
101
|
id: 'gpt-4-turbo-2024-04-09',
|
102
|
-
|
102
|
+
contextWindowTokens: 128000,
|
103
103
|
vision: true,
|
104
104
|
enabled: true,
|
105
105
|
},
|
@@ -121,14 +121,14 @@ describe('LLMSettingsSliceAction', () => {
|
|
121
121
|
enabled: true,
|
122
122
|
functionCall: true,
|
123
123
|
id: 'gpt-4-0125-preview',
|
124
|
-
|
124
|
+
contextWindowTokens: 128000,
|
125
125
|
},
|
126
126
|
{
|
127
127
|
displayName: 'ChatGPT-4 Vision',
|
128
128
|
enabled: true,
|
129
129
|
functionCall: true,
|
130
130
|
id: 'gpt-4-turbo-2024-04-09',
|
131
|
-
|
131
|
+
contextWindowTokens: 128000,
|
132
132
|
vision: true,
|
133
133
|
},
|
134
134
|
]);
|
@@ -21,7 +21,7 @@ describe('customModelCardsReducer', () => {
|
|
21
21
|
isCustom: true,
|
22
22
|
legacy: false,
|
23
23
|
maxOutput: 1000,
|
24
|
-
|
24
|
+
contextWindowTokens: 2048,
|
25
25
|
vision: false,
|
26
26
|
},
|
27
27
|
{
|
@@ -33,7 +33,7 @@ describe('customModelCardsReducer', () => {
|
|
33
33
|
isCustom: true,
|
34
34
|
legacy: true,
|
35
35
|
maxOutput: 500,
|
36
|
-
|
36
|
+
contextWindowTokens: 1024,
|
37
37
|
vision: true,
|
38
38
|
},
|
39
39
|
];
|
@@ -49,7 +49,7 @@ describe('customModelCardsReducer', () => {
|
|
49
49
|
isCustom: true,
|
50
50
|
legacy: false,
|
51
51
|
maxOutput: 2000,
|
52
|
-
|
52
|
+
contextWindowTokens: 4096,
|
53
53
|
vision: false,
|
54
54
|
};
|
55
55
|
|
@@ -75,7 +75,7 @@ describe('customModelCardsReducer', () => {
|
|
75
75
|
isCustom: true,
|
76
76
|
legacy: false,
|
77
77
|
maxOutput: 1000,
|
78
|
-
|
78
|
+
contextWindowTokens: 2048,
|
79
79
|
vision: false,
|
80
80
|
};
|
81
81
|
|
@@ -147,7 +147,7 @@ describe('customModelCardsReducer', () => {
|
|
147
147
|
isCustom: true,
|
148
148
|
legacy: false,
|
149
149
|
maxOutput: 1500,
|
150
|
-
|
150
|
+
contextWindowTokens: 2048,
|
151
151
|
vision: false,
|
152
152
|
};
|
153
153
|
|
@@ -187,7 +187,7 @@ describe('customModelCardsReducer', () => {
|
|
187
187
|
isCustom: true,
|
188
188
|
legacy: false,
|
189
189
|
maxOutput: 1500,
|
190
|
-
|
190
|
+
contextWindowTokens: 2048,
|
191
191
|
vision: false,
|
192
192
|
};
|
193
193
|
|
@@ -116,9 +116,10 @@ const isModelEnabledUpload = (id: string) => (s: UserStore) =>
|
|
116
116
|
isModelEnabledVision(id)(s) || isModelEnabledFiles(id)(s);
|
117
117
|
|
118
118
|
const isModelHasMaxToken = (id: string) => (s: UserStore) =>
|
119
|
-
typeof getModelCardById(id)(s)?.
|
119
|
+
typeof getModelCardById(id)(s)?.contextWindowTokens !== 'undefined';
|
120
120
|
|
121
|
-
const modelMaxToken = (id: string) => (s: UserStore) =>
|
121
|
+
const modelMaxToken = (id: string) => (s: UserStore) =>
|
122
|
+
getModelCardById(id)(s)?.contextWindowTokens || 0;
|
122
123
|
|
123
124
|
export const modelProviderSelectors = {
|
124
125
|
defaultModelProviderList,
|
@@ -56,7 +56,7 @@ const ImageItem = memo<DallEImageItem & { index: number; messageId: string }>(
|
|
56
56
|
);
|
57
57
|
|
58
58
|
if (imageId || previewUrl)
|
59
|
-
return <ImagePreview imageId={imageId} previewUrl={previewUrl}
|
59
|
+
return <ImagePreview imageId={imageId} previewUrl={previewUrl} prompt={prompt} />;
|
60
60
|
|
61
61
|
return (
|
62
62
|
<Flexbox className={styles.container} padding={8}>
|
package/src/types/files/index.ts
CHANGED
package/src/types/llm.ts
CHANGED
@@ -3,6 +3,10 @@ import { ReactNode } from 'react';
|
|
3
3
|
export type ModelPriceCurrency = 'CNY' | 'USD';
|
4
4
|
|
5
5
|
export interface ChatModelCard {
|
6
|
+
/**
|
7
|
+
* the context window (or input + output tokens limit)
|
8
|
+
*/
|
9
|
+
contextWindowTokens?: number;
|
6
10
|
/**
|
7
11
|
* only used in azure
|
8
12
|
*/
|
@@ -12,7 +16,6 @@ export interface ChatModelCard {
|
|
12
16
|
* the name show for end user
|
13
17
|
*/
|
14
18
|
displayName?: string;
|
15
|
-
|
16
19
|
/**
|
17
20
|
* whether model is enabled by default
|
18
21
|
*/
|
@@ -53,10 +56,6 @@ export interface ChatModelCard {
|
|
53
56
|
writeCacheInput?: number;
|
54
57
|
};
|
55
58
|
releasedAt?: string;
|
56
|
-
/**
|
57
|
-
* the context window (or input + output tokens limit)
|
58
|
-
*/
|
59
|
-
tokens?: number;
|
60
59
|
|
61
60
|
/**
|
62
61
|
* whether model supports vision
|