@lobehub/chat 1.124.1 → 1.124.3
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 +1 -1
- package/packages/const/package.json +3 -1
- package/packages/const/src/analytics.ts +1 -1
- package/packages/const/src/desktop.ts +3 -2
- package/packages/const/src/discover.ts +3 -2
- package/packages/const/src/guide.ts +2 -2
- package/packages/const/src/hotkeys.ts +1 -1
- package/packages/const/src/index.ts +2 -0
- package/packages/const/src/settings/common.ts +1 -1
- package/packages/const/src/settings/genUserLLMConfig.test.ts +1 -2
- package/packages/const/src/settings/genUserLLMConfig.ts +1 -2
- package/packages/const/src/settings/hotkey.ts +3 -2
- package/packages/const/src/settings/index.ts +1 -3
- package/packages/const/src/settings/knowledge.ts +1 -1
- package/packages/const/src/settings/llm.ts +2 -4
- package/packages/const/src/settings/systemAgent.ts +1 -5
- package/packages/const/src/settings/tts.ts +1 -1
- package/packages/const/src/trace.ts +1 -1
- package/packages/const/src/url.ts +2 -2
- package/packages/const/src/user.ts +1 -2
- package/packages/database/src/client/db.test.ts +19 -13
- package/packages/electron-server-ipc/src/ipcClient.test.ts +783 -1
- package/packages/file-loaders/src/loadFile.test.ts +61 -0
- package/packages/file-loaders/src/utils/isTextReadableFile.test.ts +43 -0
- package/packages/file-loaders/src/utils/parser-utils.test.ts +155 -0
- package/packages/model-runtime/package.json +2 -1
- package/packages/model-runtime/src/ai21/index.test.ts +2 -2
- package/packages/model-runtime/src/ai360/index.test.ts +2 -2
- package/packages/model-runtime/src/akashchat/index.test.ts +19 -0
- package/packages/model-runtime/src/anthropic/index.test.ts +1 -2
- package/packages/model-runtime/src/baichuan/index.test.ts +1 -2
- package/packages/model-runtime/src/bedrock/index.test.ts +1 -2
- package/packages/model-runtime/src/bfl/createImage.test.ts +1 -2
- package/packages/model-runtime/src/bfl/index.test.ts +1 -2
- package/packages/model-runtime/src/cloudflare/index.test.ts +1 -2
- package/packages/model-runtime/src/cohere/index.test.ts +19 -0
- package/packages/model-runtime/src/deepseek/index.test.ts +2 -2
- package/packages/model-runtime/src/fireworksai/index.test.ts +2 -2
- package/packages/model-runtime/src/giteeai/index.test.ts +2 -2
- package/packages/model-runtime/src/github/index.test.ts +2 -2
- package/packages/model-runtime/src/google/createImage.test.ts +1 -2
- package/packages/model-runtime/src/google/index.test.ts +1 -1
- package/packages/model-runtime/src/groq/index.test.ts +2 -3
- package/packages/model-runtime/src/higress/index.ts +2 -3
- package/packages/model-runtime/src/huggingface/index.test.ts +40 -0
- package/packages/model-runtime/src/hunyuan/index.test.ts +2 -3
- package/packages/model-runtime/src/internlm/index.test.ts +2 -2
- package/packages/model-runtime/src/jina/index.test.ts +19 -0
- package/packages/model-runtime/src/lmstudio/index.test.ts +2 -2
- package/packages/model-runtime/src/minimax/index.test.ts +19 -0
- package/packages/model-runtime/src/mistral/index.test.ts +2 -3
- package/packages/model-runtime/src/modelscope/index.test.ts +19 -0
- package/packages/model-runtime/src/moonshot/index.test.ts +1 -2
- package/packages/model-runtime/src/nebius/index.test.ts +19 -0
- package/packages/model-runtime/src/novita/index.test.ts +3 -4
- package/packages/model-runtime/src/nvidia/index.test.ts +19 -0
- package/packages/model-runtime/src/openrouter/index.test.ts +2 -3
- package/packages/model-runtime/src/perplexity/index.test.ts +2 -3
- package/packages/model-runtime/src/ppio/index.test.ts +3 -4
- package/packages/model-runtime/src/qwen/index.test.ts +2 -2
- package/packages/model-runtime/src/sambanova/index.test.ts +19 -0
- package/packages/model-runtime/src/search1api/index.test.ts +19 -0
- package/packages/model-runtime/src/sensenova/index.test.ts +2 -2
- package/packages/model-runtime/src/spark/index.test.ts +2 -2
- package/packages/model-runtime/src/stepfun/index.test.ts +2 -2
- package/packages/model-runtime/src/taichu/index.test.ts +4 -5
- package/packages/model-runtime/src/tencentcloud/index.test.ts +1 -1
- package/packages/model-runtime/src/togetherai/index.test.ts +1 -2
- package/packages/model-runtime/src/upstage/index.test.ts +1 -2
- package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.test.ts +9 -7
- package/packages/model-runtime/src/utils/streams/anthropic.ts +2 -2
- package/packages/model-runtime/src/utils/streams/openai/openai.ts +20 -13
- package/packages/model-runtime/src/utils/streams/openai/responsesStream.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/openai/responsesStream.ts +2 -2
- package/packages/model-runtime/src/utils/streams/protocol.ts +2 -2
- package/packages/model-runtime/src/wenxin/index.test.ts +2 -3
- package/packages/model-runtime/src/xai/index.test.ts +2 -2
- package/packages/model-runtime/src/zeroone/index.test.ts +1 -2
- package/packages/model-runtime/src/zhipu/index.test.ts +2 -3
- package/packages/model-runtime/vitest.config.mts +0 -7
- package/packages/types/src/discover/index.ts +0 -8
- package/packages/types/src/index.ts +4 -0
- package/packages/types/src/message/base.ts +1 -1
- package/packages/types/src/openai/chat.ts +2 -3
- package/packages/types/src/tool/index.ts +1 -0
- package/packages/types/src/tool/tool.ts +1 -1
- package/packages/types/src/user/settings/index.ts +1 -2
- package/packages/utils/package.json +2 -1
- package/packages/utils/src/_deprecated/parseModels.test.ts +1 -1
- package/packages/utils/src/_deprecated/parseModels.ts +1 -1
- package/packages/utils/src/client/topic.test.ts +1 -2
- package/packages/utils/src/client/topic.ts +1 -2
- package/packages/utils/src/electron/desktopRemoteRPCFetch.ts +1 -1
- package/packages/utils/src/fetch/fetchSSE.ts +7 -8
- package/packages/utils/src/fetch/parseError.ts +1 -3
- package/packages/utils/src/format.test.ts +1 -2
- package/packages/utils/src/index.ts +1 -0
- package/packages/utils/src/toolManifest.ts +1 -2
- package/packages/utils/src/trace.ts +1 -1
- package/packages/utils/vitest.config.mts +1 -2
- package/packages/web-crawler/src/__tests__/urlRules.test.ts +275 -0
- package/packages/web-crawler/src/crawImpl/__tests__/exa.test.ts +269 -0
- package/packages/web-crawler/src/crawImpl/__tests__/firecrawl.test.ts +284 -0
- package/packages/web-crawler/src/crawImpl/__tests__/naive.test.ts +234 -0
- package/packages/web-crawler/src/crawImpl/__tests__/tavily.test.ts +359 -0
- package/packages/web-crawler/src/utils/__tests__/errorType.test.ts +217 -0
- package/packages/web-crawler/vitest.config.mts +3 -0
- package/src/app/(backend)/webapi/models/[provider]/pull/route.ts +0 -2
- package/src/app/(backend)/webapi/models/[provider]/route.ts +0 -2
- package/src/app/(backend)/webapi/text-to-image/[provider]/route.ts +0 -2
- package/src/app/(backend)/webapi/trace/route.ts +0 -2
- package/src/components/Thinking/index.tsx +2 -3
- package/src/features/ChatInput/StoreUpdater.tsx +2 -0
- package/src/libs/traces/index.ts +1 -1
- package/src/server/modules/ModelRuntime/trace.ts +1 -2
- package/packages/const/src/settings/sync.ts +0 -5
- package/packages/model-runtime/src/openrouter/__snapshots__/index.test.ts.snap +0 -113
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
3
|
+
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
|
+
import { LobeNebiusAI } from './index';
|
|
6
|
+
|
|
7
|
+
const provider = ModelProvider.Nebius;
|
|
8
|
+
const defaultBaseURL = 'https://api.studio.nebius.com/v1';
|
|
9
|
+
|
|
10
|
+
testProvider({
|
|
11
|
+
Runtime: LobeNebiusAI,
|
|
12
|
+
provider,
|
|
13
|
+
defaultBaseURL,
|
|
14
|
+
chatDebugEnv: 'DEBUG_NEBIUS_CHAT_COMPLETION',
|
|
15
|
+
chatModel: 'meta/llama-3.1-8b-instruct',
|
|
16
|
+
test: {
|
|
17
|
+
skipAPICall: true,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
+
import { LobeOpenAICompatibleRuntime } from '@lobechat/model-runtime';
|
|
3
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
2
4
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
5
|
|
|
4
|
-
import {
|
|
5
|
-
import { ModelProvider } from '@/libs/model-runtime';
|
|
6
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
7
|
-
|
|
6
|
+
import { testProvider } from '../providerTestUtils';
|
|
8
7
|
import models from './fixtures/models.json';
|
|
9
8
|
import { LobeNovitaAI } from './index';
|
|
10
9
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
3
|
+
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
|
+
import { LobeNvidiaAI } from './index';
|
|
6
|
+
|
|
7
|
+
const provider = ModelProvider.Nvidia;
|
|
8
|
+
const defaultBaseURL = 'https://integrate.api.nvidia.com/v1';
|
|
9
|
+
|
|
10
|
+
testProvider({
|
|
11
|
+
Runtime: LobeNvidiaAI,
|
|
12
|
+
provider,
|
|
13
|
+
defaultBaseURL,
|
|
14
|
+
chatDebugEnv: 'DEBUG_NVIDIA_CHAT_COMPLETION',
|
|
15
|
+
chatModel: 'meta/llama-3.1-8b-instruct',
|
|
16
|
+
test: {
|
|
17
|
+
skipAPICall: true,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
+
import { LobeOpenAICompatibleRuntime } from '@lobechat/model-runtime';
|
|
2
3
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
6
|
-
|
|
5
|
+
import { testProvider } from '../providerTestUtils';
|
|
7
6
|
import models from './fixtures/models.json';
|
|
8
7
|
import { LobeOpenRouterAI } from './index';
|
|
9
8
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
+
import { LobeOpenAICompatibleRuntime, ModelProvider } from '@lobechat/model-runtime';
|
|
2
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
6
|
-
|
|
5
|
+
import { testProvider } from '../providerTestUtils';
|
|
7
6
|
import { LobePerplexityAI } from './index';
|
|
8
7
|
|
|
9
8
|
testProvider({
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
+
import { LobeOpenAICompatibleRuntime } from '@lobechat/model-runtime';
|
|
3
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
2
4
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
5
|
|
|
4
|
-
import {
|
|
5
|
-
import { ModelProvider } from '@/libs/model-runtime';
|
|
6
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
7
|
-
|
|
6
|
+
import { testProvider } from '../providerTestUtils';
|
|
8
7
|
import models from './fixtures/models.json';
|
|
9
8
|
import { LobePPIOAI } from './index';
|
|
10
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
-
import { ModelProvider } from '
|
|
3
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
4
3
|
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
5
|
import { LobeQwenAI } from './index';
|
|
6
6
|
|
|
7
7
|
const provider = ModelProvider.Qwen;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
3
|
+
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
|
+
import { LobeSambaNovaAI } from './index';
|
|
6
|
+
|
|
7
|
+
const provider = ModelProvider.SambaNova;
|
|
8
|
+
const defaultBaseURL = 'https://api.sambanova.ai/v1';
|
|
9
|
+
|
|
10
|
+
testProvider({
|
|
11
|
+
Runtime: LobeSambaNovaAI,
|
|
12
|
+
provider,
|
|
13
|
+
defaultBaseURL,
|
|
14
|
+
chatDebugEnv: 'DEBUG_SAMBANOVA_CHAT_COMPLETION',
|
|
15
|
+
chatModel: 'Meta-Llama-3.1-8B-Instruct',
|
|
16
|
+
test: {
|
|
17
|
+
skipAPICall: true,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
3
|
+
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
|
+
import { LobeSearch1API } from './index';
|
|
6
|
+
|
|
7
|
+
const provider = ModelProvider.Search1API;
|
|
8
|
+
const defaultBaseURL = 'https://api.search1api.com/v1';
|
|
9
|
+
|
|
10
|
+
testProvider({
|
|
11
|
+
Runtime: LobeSearch1API,
|
|
12
|
+
provider,
|
|
13
|
+
defaultBaseURL,
|
|
14
|
+
chatDebugEnv: 'DEBUG_SEARCH1API_CHAT_COMPLETION',
|
|
15
|
+
chatModel: 'gpt-4o-mini',
|
|
16
|
+
test: {
|
|
17
|
+
skipAPICall: true,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
-
import { ModelProvider } from '
|
|
3
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
4
3
|
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
5
|
import { LobeSenseNovaAI } from './index';
|
|
6
6
|
|
|
7
7
|
const provider = ModelProvider.SenseNova;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
-
import { ModelProvider } from '
|
|
3
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
4
3
|
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
5
|
import { LobeSparkAI } from './index';
|
|
6
6
|
|
|
7
7
|
const provider = ModelProvider.Spark;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
-
import { ModelProvider } from '
|
|
3
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
4
3
|
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
5
|
import { LobeStepfunAI } from './index';
|
|
6
6
|
|
|
7
7
|
const provider = ModelProvider.Stepfun;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
-
import OpenAI from 'openai';
|
|
3
|
-
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
-
|
|
5
2
|
import {
|
|
6
3
|
ChatStreamCallbacks,
|
|
7
4
|
LobeMoonshotAI,
|
|
8
5
|
LobeOpenAICompatibleRuntime,
|
|
9
6
|
ModelProvider,
|
|
10
|
-
} from '
|
|
11
|
-
import
|
|
7
|
+
} from '@lobechat/model-runtime';
|
|
8
|
+
import OpenAI from 'openai';
|
|
9
|
+
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
12
10
|
|
|
11
|
+
import { testProvider } from '../providerTestUtils';
|
|
13
12
|
import * as debugStreamModule from '../utils/debugStream';
|
|
14
13
|
import { LobeTaichuAI } from './index';
|
|
15
14
|
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
-
import OpenAI from 'openai';
|
|
3
|
-
import type { Stream } from 'openai/streaming';
|
|
4
|
-
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
-
|
|
6
2
|
import {
|
|
7
3
|
AgentRuntimeErrorType,
|
|
8
4
|
ChatStreamCallbacks,
|
|
9
5
|
ChatStreamPayload,
|
|
10
6
|
LobeOpenAICompatibleRuntime,
|
|
11
7
|
ModelProvider,
|
|
12
|
-
} from '
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
8
|
+
} from '@lobechat/model-runtime';
|
|
9
|
+
import OpenAI from 'openai';
|
|
10
|
+
import type { Stream } from 'openai/streaming';
|
|
11
|
+
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
15
12
|
|
|
16
13
|
import * as debugStreamModule from '../debugStream';
|
|
17
14
|
import * as openaiHelpers from '../openaiHelpers';
|
|
18
15
|
import { createOpenAICompatibleRuntime } from './index';
|
|
19
16
|
|
|
17
|
+
const sleep = async (ms: number) =>
|
|
18
|
+
await new Promise((resolve) => {
|
|
19
|
+
setTimeout(resolve, ms);
|
|
20
|
+
});
|
|
21
|
+
|
|
20
22
|
const provider = 'groq';
|
|
21
23
|
const defaultBaseURL = 'https://api.groq.com/openai/v1';
|
|
22
24
|
const bizErrorType = 'ProviderBizError';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
|
2
2
|
import type { Stream } from '@anthropic-ai/sdk/streaming';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ChatCitationItem, ModelTokensUsage } from '@/types/message';
|
|
5
5
|
|
|
6
6
|
import { ChatStreamCallbacks } from '../../types';
|
|
7
7
|
import {
|
|
@@ -180,7 +180,7 @@ export const transformAnthropicStream = (
|
|
|
180
180
|
context.returnedCitationArray.push({
|
|
181
181
|
title: citations.title,
|
|
182
182
|
url: citations.url,
|
|
183
|
-
} as
|
|
183
|
+
} as ChatCitationItem);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
return { data: null, id: context.id, type: 'text' };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
2
|
import type { Stream } from 'openai/streaming';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ChatCitationItem, ChatMessageError } from '@/types/message';
|
|
5
5
|
|
|
6
6
|
import { ChatStreamCallbacks } from '../../../types';
|
|
7
7
|
import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '../../../types/error';
|
|
@@ -21,24 +21,24 @@ import {
|
|
|
21
21
|
} from '../protocol';
|
|
22
22
|
|
|
23
23
|
// Process markdown base64 images: extract URLs and clean text in one pass
|
|
24
|
-
const processMarkdownBase64Images = (text: string): { cleanedText: string
|
|
24
|
+
const processMarkdownBase64Images = (text: string): { cleanedText: string; urls: string[] } => {
|
|
25
25
|
if (!text) return { cleanedText: text, urls: [] };
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
const urls: string[] = [];
|
|
28
28
|
const mdRegex = /!\[[^\]]*]\(\s*(data:image\/[\d+.A-Za-z-]+;base64,[^\s)]+)\s*\)/g;
|
|
29
29
|
let cleanedText = text;
|
|
30
30
|
let m: RegExpExecArray | null;
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
// Reset regex lastIndex to ensure we start from the beginning
|
|
33
33
|
mdRegex.lastIndex = 0;
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
while ((m = mdRegex.exec(text)) !== null) {
|
|
36
36
|
if (m[1]) urls.push(m[1]);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
// Remove all markdown base64 image segments
|
|
40
40
|
cleanedText = text.replaceAll(mdRegex, '').trim();
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
return { cleanedText, urls };
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -159,14 +159,17 @@ const transformOpenAIStream = (
|
|
|
159
159
|
return { data: null, id: chunk.id, type: 'text' };
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
|
|
163
162
|
const text = item.delta.content as string;
|
|
164
163
|
const { urls: images, cleanedText: cleaned } = processMarkdownBase64Images(text);
|
|
165
164
|
if (images.length > 0) {
|
|
166
165
|
const arr: StreamProtocolChunk[] = [];
|
|
167
166
|
if (cleaned) arr.push({ data: cleaned, id: chunk.id, type: 'text' });
|
|
168
167
|
arr.push(
|
|
169
|
-
...images.map((url: string) => ({
|
|
168
|
+
...images.map((url: string) => ({
|
|
169
|
+
data: url,
|
|
170
|
+
id: chunk.id,
|
|
171
|
+
type: 'base64_image' as const,
|
|
172
|
+
})),
|
|
170
173
|
);
|
|
171
174
|
return arr;
|
|
172
175
|
}
|
|
@@ -187,7 +190,7 @@ const transformOpenAIStream = (
|
|
|
187
190
|
({
|
|
188
191
|
title: item.url_citation.title,
|
|
189
192
|
url: item.url_citation.url,
|
|
190
|
-
}) as
|
|
193
|
+
}) as ChatCitationItem,
|
|
191
194
|
),
|
|
192
195
|
},
|
|
193
196
|
id: chunk.id,
|
|
@@ -209,7 +212,7 @@ const transformOpenAIStream = (
|
|
|
209
212
|
({
|
|
210
213
|
title: item.url,
|
|
211
214
|
url: item.url,
|
|
212
|
-
}) as
|
|
215
|
+
}) as ChatCitationItem,
|
|
213
216
|
),
|
|
214
217
|
},
|
|
215
218
|
id: chunk.id,
|
|
@@ -236,7 +239,7 @@ const transformOpenAIStream = (
|
|
|
236
239
|
({
|
|
237
240
|
title: item,
|
|
238
241
|
url: item,
|
|
239
|
-
}) as
|
|
242
|
+
}) as ChatCitationItem,
|
|
240
243
|
),
|
|
241
244
|
},
|
|
242
245
|
id: chunk.id,
|
|
@@ -348,7 +351,11 @@ const transformOpenAIStream = (
|
|
|
348
351
|
const arr: StreamProtocolChunk[] = [];
|
|
349
352
|
if (cleaned) arr.push({ data: cleaned, id: chunk.id, type: 'text' });
|
|
350
353
|
arr.push(
|
|
351
|
-
...urls.map((url: string) => ({
|
|
354
|
+
...urls.map((url: string) => ({
|
|
355
|
+
data: url,
|
|
356
|
+
id: chunk.id,
|
|
357
|
+
type: 'base64_image' as const,
|
|
358
|
+
})),
|
|
352
359
|
);
|
|
353
360
|
return arr;
|
|
354
361
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { AgentRuntimeErrorType } from '@lobechat/model-runtime';
|
|
1
2
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
3
|
|
|
3
|
-
import { AgentRuntimeErrorType } from '@/libs/model-runtime';
|
|
4
|
-
|
|
5
4
|
import { FIRST_CHUNK_ERROR_KEY } from '../protocol';
|
|
6
5
|
import { createReadableStream, readStreamChunk } from '../utils';
|
|
7
6
|
import { OpenAIResponsesStream } from './responsesStream';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
2
|
import type { Stream } from 'openai/streaming';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ChatCitationItem, ChatMessageError } from '@/types/message';
|
|
5
5
|
|
|
6
6
|
import { AgentRuntimeErrorType } from '../../../types/error';
|
|
7
7
|
import { convertResponseUsage } from '../../usageConverter';
|
|
@@ -126,7 +126,7 @@ const transformOpenAIStream = (
|
|
|
126
126
|
streamContext.returnedCitationArray.push({
|
|
127
127
|
title: citations.title,
|
|
128
128
|
url: citations.url,
|
|
129
|
-
} as
|
|
129
|
+
} as ChatCitationItem);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
return { data: null, id: chunk.item_id, type: 'text' };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChatCitationItem, ModelSpeed, ModelTokensUsage } from '@/types/message';
|
|
2
2
|
|
|
3
3
|
import { parseToolCalls } from '../../helpers';
|
|
4
4
|
import { ChatStreamCallbacks } from '../../types';
|
|
@@ -23,7 +23,7 @@ export interface StreamContext {
|
|
|
23
23
|
* relevant to that specific portion of the generated content.
|
|
24
24
|
* This array accumulates all citation items received during the streaming response.
|
|
25
25
|
*/
|
|
26
|
-
returnedCitationArray?:
|
|
26
|
+
returnedCitationArray?: ChatCitationItem[];
|
|
27
27
|
/**
|
|
28
28
|
* O series models need a condition to separate part
|
|
29
29
|
*/
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
+
import { LobeOpenAICompatibleRuntime, ModelProvider } from '@lobechat/model-runtime';
|
|
2
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
6
|
-
|
|
5
|
+
import { testProvider } from '../providerTestUtils';
|
|
7
6
|
import { LobeWenxinAI } from './index';
|
|
8
7
|
|
|
9
8
|
testProvider({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
-
import { ModelProvider } from '
|
|
3
|
-
import { testProvider } from '@/libs/model-runtime/providerTestUtils';
|
|
2
|
+
import { ModelProvider } from '@lobechat/model-runtime';
|
|
4
3
|
|
|
4
|
+
import { testProvider } from '../providerTestUtils';
|
|
5
5
|
import { LobeXAI } from './index';
|
|
6
6
|
|
|
7
7
|
testProvider({
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
+
import { ChatStreamCallbacks, LobeOpenAICompatibleRuntime } from '@lobechat/model-runtime';
|
|
2
3
|
import { OpenAI } from 'openai';
|
|
3
4
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
5
|
|
|
5
|
-
import
|
|
6
|
-
import * as debugStreamModule from '@/libs/model-runtime/utils/debugStream';
|
|
7
|
-
|
|
6
|
+
import * as debugStreamModule from '../utils/debugStream';
|
|
8
7
|
import { LobeZhipuAI } from './index';
|
|
9
8
|
|
|
10
9
|
const bizErrorType = 'ProviderBizError';
|
|
@@ -4,14 +4,7 @@ import { defineConfig } from 'vitest/config';
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
test: {
|
|
6
6
|
alias: {
|
|
7
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
8
|
-
'@/libs/model-runtime': resolve(__dirname, './src'),
|
|
9
|
-
'@/types': resolve(__dirname, '../types/src'),
|
|
10
|
-
'@/utils/errorResponse': resolve(__dirname, '../../src/utils/errorResponse'),
|
|
11
|
-
'@/utils': resolve(__dirname, '../utils/src'),
|
|
12
|
-
'@/const': resolve(__dirname, '../const/src'),
|
|
13
7
|
'@': resolve(__dirname, '../../src'),
|
|
14
|
-
/* eslint-enable */
|
|
15
8
|
},
|
|
16
9
|
coverage: {
|
|
17
10
|
reporter: ['text', 'json', 'lcov', 'text-summary'],
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Locales } from '@/locales/resources';
|
|
2
|
-
import { PageProps } from '@/types/next';
|
|
3
|
-
|
|
4
1
|
export * from './assistants';
|
|
5
2
|
export * from './mcp';
|
|
6
3
|
export * from './models';
|
|
@@ -16,11 +13,6 @@ export enum DiscoverTab {
|
|
|
16
13
|
Providers = 'provider',
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
export type DiscoverPageProps<T = string> = PageProps<
|
|
20
|
-
{ slug: T; variants: string },
|
|
21
|
-
{ hl?: Locales }
|
|
22
|
-
>;
|
|
23
|
-
|
|
24
16
|
export type IdentifiersResponse = {
|
|
25
17
|
identifier: string;
|
|
26
18
|
lastModified: string;
|
|
@@ -6,6 +6,7 @@ export * from './asyncTask';
|
|
|
6
6
|
export * from './auth';
|
|
7
7
|
export * from './chunk';
|
|
8
8
|
export * from './clientDB';
|
|
9
|
+
export * from './discover';
|
|
9
10
|
export * from './eval';
|
|
10
11
|
export * from './fetch';
|
|
11
12
|
export * from './hotkey';
|
|
@@ -14,13 +15,16 @@ export * from './llm';
|
|
|
14
15
|
export * from './message';
|
|
15
16
|
export * from './meta';
|
|
16
17
|
export * from './rag';
|
|
18
|
+
export * from './search';
|
|
17
19
|
export * from './serverConfig';
|
|
18
20
|
export * from './session';
|
|
21
|
+
export * from './tool';
|
|
19
22
|
export * from './topic';
|
|
20
23
|
export * from './user';
|
|
21
24
|
export * from './user/settings';
|
|
22
25
|
// FIXME: I think we need a refactor for the "openai" types
|
|
23
26
|
// it more likes the UI message payload
|
|
24
27
|
export * from './openai/chat';
|
|
28
|
+
export * from './openai/plugin';
|
|
25
29
|
export * from './trace';
|
|
26
30
|
export * from './zustand';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { LLMRoleType } from '
|
|
2
|
-
import { MessageToolCall } from '
|
|
3
|
-
|
|
1
|
+
import { LLMRoleType } from '../llm';
|
|
2
|
+
import { MessageToolCall } from '../message';
|
|
4
3
|
import { OpenAIFunctionCall } from './functionCall';
|
|
5
4
|
|
|
6
5
|
interface UserMessageContentPartText {
|
|
@@ -4,13 +4,13 @@ import { UserGeneralConfig } from './general';
|
|
|
4
4
|
import { UserHotkeyConfig } from './hotkey';
|
|
5
5
|
import { UserKeyVaults } from './keyVaults';
|
|
6
6
|
import { UserModelProviderConfig } from './modelProvider';
|
|
7
|
-
import { UserSyncSettings } from './sync';
|
|
8
7
|
import { UserSystemAgentConfig } from './systemAgent';
|
|
9
8
|
import { UserToolConfig } from './tool';
|
|
10
9
|
import { UserTTSConfig } from './tts';
|
|
11
10
|
|
|
12
11
|
export type UserDefaultAgent = LobeAgentSettings;
|
|
13
12
|
|
|
13
|
+
export * from './filesConfig';
|
|
14
14
|
export * from './general';
|
|
15
15
|
export * from './hotkey';
|
|
16
16
|
export * from './keyVaults';
|
|
@@ -28,7 +28,6 @@ export interface UserSettings {
|
|
|
28
28
|
hotkey: UserHotkeyConfig;
|
|
29
29
|
keyVaults: UserKeyVaults;
|
|
30
30
|
languageModel: UserModelProviderConfig;
|
|
31
|
-
sync?: UserSyncSettings;
|
|
32
31
|
systemAgent: UserSystemAgentConfig;
|
|
33
32
|
tool: UserToolConfig;
|
|
34
33
|
tts: UserTTSConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ChatModelCard } from '@lobechat/types';
|
|
1
2
|
import { describe, expect, it } from 'vitest';
|
|
2
3
|
|
|
3
4
|
import { LOBE_DEFAULT_MODEL_LIST, OpenAIProviderCard } from '@/config/modelProviders';
|
|
4
|
-
import { ChatModelCard } from '@/types/llm';
|
|
5
5
|
|
|
6
6
|
import { parseModelString, transformToChatModelCards } from './parseModels';
|
|
7
7
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { ChatTopic } from '@lobechat/types';
|
|
1
2
|
import dayjs from 'dayjs';
|
|
2
3
|
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
|
|
3
4
|
|
|
4
|
-
import { ChatTopic } from '@/types/topic';
|
|
5
|
-
|
|
6
5
|
import { groupTopicsByTime } from './topic';
|
|
7
6
|
|
|
8
7
|
// Mock current date to ensure consistent test results
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { ChatTopic, GroupedTopic, TimeGroupId } from '@lobechat/types';
|
|
1
2
|
import dayjs from 'dayjs';
|
|
2
3
|
import isToday from 'dayjs/plugin/isToday';
|
|
3
4
|
import isYesterday from 'dayjs/plugin/isYesterday';
|
|
4
5
|
|
|
5
|
-
import { ChatTopic, GroupedTopic, TimeGroupId } from '@/types/topic';
|
|
6
|
-
|
|
7
6
|
// 初始化 dayjs 插件
|
|
8
7
|
dayjs.extend(isToday);
|
|
9
8
|
dayjs.extend(isYesterday);
|