@lobehub/lobehub 2.0.0-next.46 → 2.0.0-next.48
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 +11 -0
- package/CHANGELOG.md +42 -0
- package/apps/desktop/src/main/controllers/AuthCtr.ts +27 -2
- package/apps/desktop/src/main/core/infrastructure/ProtocolManager.ts +9 -4
- package/changelog/v1.json +14 -0
- package/docs/development/database-schema.dbml +2 -0
- package/docs/self-hosting/environment-variables/basic.mdx +49 -3
- package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +49 -4
- package/locales/ar/discover.json +45 -0
- package/locales/ar/marketAuth.json +42 -0
- package/locales/ar/setting.json +94 -1
- package/locales/bg-BG/discover.json +45 -0
- package/locales/bg-BG/marketAuth.json +42 -0
- package/locales/bg-BG/setting.json +94 -1
- package/locales/de-DE/discover.json +45 -0
- package/locales/de-DE/marketAuth.json +42 -0
- package/locales/de-DE/setting.json +94 -1
- package/locales/en-US/discover.json +45 -0
- package/locales/en-US/marketAuth.json +42 -0
- package/locales/en-US/setting.json +94 -1
- package/locales/es-ES/discover.json +45 -0
- package/locales/es-ES/marketAuth.json +42 -0
- package/locales/es-ES/setting.json +94 -1
- package/locales/fa-IR/discover.json +45 -0
- package/locales/fa-IR/marketAuth.json +42 -0
- package/locales/fa-IR/setting.json +94 -1
- package/locales/fr-FR/discover.json +45 -0
- package/locales/fr-FR/marketAuth.json +42 -0
- package/locales/fr-FR/setting.json +94 -1
- package/locales/it-IT/discover.json +45 -0
- package/locales/it-IT/marketAuth.json +42 -0
- package/locales/it-IT/setting.json +94 -1
- package/locales/ja-JP/discover.json +45 -0
- package/locales/ja-JP/marketAuth.json +42 -0
- package/locales/ja-JP/setting.json +94 -1
- package/locales/ko-KR/discover.json +45 -0
- package/locales/ko-KR/marketAuth.json +42 -0
- package/locales/ko-KR/setting.json +94 -1
- package/locales/nl-NL/discover.json +45 -0
- package/locales/nl-NL/marketAuth.json +42 -0
- package/locales/nl-NL/setting.json +94 -1
- package/locales/pl-PL/discover.json +45 -0
- package/locales/pl-PL/marketAuth.json +42 -0
- package/locales/pl-PL/setting.json +94 -1
- package/locales/pt-BR/discover.json +45 -0
- package/locales/pt-BR/marketAuth.json +42 -0
- package/locales/pt-BR/setting.json +94 -1
- package/locales/ru-RU/discover.json +45 -0
- package/locales/ru-RU/marketAuth.json +42 -0
- package/locales/ru-RU/setting.json +94 -1
- package/locales/tr-TR/discover.json +45 -0
- package/locales/tr-TR/marketAuth.json +42 -0
- package/locales/tr-TR/setting.json +94 -1
- package/locales/vi-VN/discover.json +45 -0
- package/locales/vi-VN/marketAuth.json +42 -0
- package/locales/vi-VN/setting.json +94 -1
- package/locales/zh-CN/discover.json +45 -0
- package/locales/zh-CN/marketAuth.json +42 -0
- package/locales/zh-CN/setting.json +94 -1
- package/locales/zh-TW/discover.json +45 -0
- package/locales/zh-TW/marketAuth.json +42 -0
- package/locales/zh-TW/setting.json +94 -1
- package/package.json +27 -26
- package/packages/const/src/url.ts +1 -0
- package/packages/database/migrations/0044_add_tool_intervention.sql +1 -0
- package/packages/database/migrations/0044_high_toxin.sql +1 -0
- package/packages/database/migrations/0045_add_tool_intervention.sql +1 -0
- package/packages/database/migrations/meta/0039_snapshot.json +1 -1
- package/packages/database/migrations/meta/0044_snapshot.json +7813 -0
- package/packages/database/migrations/meta/0045_snapshot.json +8431 -0
- package/packages/database/migrations/meta/_journal.json +14 -0
- package/packages/database/src/core/migrations.json +36 -7
- package/packages/database/src/models/file.ts +15 -1
- package/packages/database/src/models/message.ts +1 -1
- package/packages/database/src/models/session.ts +42 -1
- package/packages/database/src/repositories/aiInfra/index.test.ts +1 -1
- package/packages/database/src/repositories/dataExporter/index.test.ts +1 -1
- package/packages/database/src/repositories/tableViewer/index.test.ts +1 -1
- package/packages/database/src/schemas/agent.ts +1 -0
- package/packages/database/src/schemas/message.ts +5 -8
- package/packages/electron-client-ipc/src/events/index.ts +6 -1
- package/packages/electron-client-ipc/src/events/remoteServer.ts +8 -0
- package/packages/fetch-sse/package.json +29 -0
- package/packages/{utils/src/fetch → fetch-sse/src}/__tests__/fetchSSE.test.ts +4 -4
- package/packages/{utils/src/fetch → fetch-sse/src}/__tests__/parseError.test.ts +7 -4
- package/packages/{utils/src/fetch → fetch-sse/src}/fetchSSE.ts +2 -2
- package/packages/{utils/src/fetch → fetch-sse/src}/parseError.ts +3 -3
- package/packages/model-bank/src/aiModels/mistral.ts +2 -1
- package/packages/model-runtime/src/core/contextBuilders/anthropic.test.ts +17 -11
- package/packages/model-runtime/src/core/contextBuilders/anthropic.ts +1 -1
- package/packages/model-runtime/src/core/contextBuilders/google.test.ts +1 -1
- package/packages/model-runtime/src/core/contextBuilders/google.ts +3 -6
- package/packages/model-runtime/src/core/contextBuilders/openai.test.ts +4 -2
- package/packages/model-runtime/src/core/contextBuilders/openai.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.test.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts +3 -6
- package/packages/model-runtime/src/core/streams/openai/responsesStream.test.ts +1 -1
- package/packages/model-runtime/src/helpers/mergeChatMethodOptions.ts +2 -1
- package/packages/model-runtime/src/providers/aihubmix/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/anthropic/generateObject.test.ts +1 -1
- package/packages/model-runtime/src/providers/anthropic/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/baichuan/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/bedrock/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/bfl/createImage.test.ts +4 -4
- package/packages/model-runtime/src/providers/bfl/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/cloudflare/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/cohere/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/google/createImage.test.ts +2 -2
- package/packages/model-runtime/src/providers/google/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/google/generateObject.test.ts +1 -1
- package/packages/model-runtime/src/providers/google/index.test.ts +1 -4
- package/packages/model-runtime/src/providers/groq/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/hunyuan/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/minimax/createImage.test.ts +1 -1
- package/packages/model-runtime/src/providers/mistral/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/moonshot/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/novita/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/ollama/index.test.ts +43 -32
- package/packages/model-runtime/src/providers/ollama/index.ts +31 -7
- package/packages/model-runtime/src/providers/openrouter/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/perplexity/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/ppio/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/qwen/createImage.test.ts +1 -1
- package/packages/model-runtime/src/providers/search1api/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/siliconcloud/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/taichu/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/wenxin/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/zhipu/index.test.ts +1 -1
- package/packages/model-runtime/src/utils/errorResponse.test.ts +1 -1
- package/packages/ssrf-safe-fetch/index.browser.ts +14 -0
- package/packages/ssrf-safe-fetch/package.json +8 -1
- package/packages/types/src/aiProvider.ts +1 -1
- package/packages/types/src/discover/assistants.ts +16 -0
- package/packages/types/src/document/index.ts +38 -38
- package/packages/types/src/exportConfig.ts +15 -15
- package/packages/types/src/generation/index.ts +5 -5
- package/packages/types/src/index.ts +1 -0
- package/packages/types/src/message/common/tools.ts +10 -0
- package/packages/types/src/message/db/item.ts +15 -1
- package/packages/types/src/message/ui/params.ts +15 -1
- package/packages/types/src/meta.ts +4 -0
- package/packages/types/src/openai/chat.ts +15 -15
- package/packages/types/src/plugins/mcp.ts +29 -29
- package/packages/types/src/plugins/protocol.ts +43 -43
- package/packages/types/src/search.ts +4 -4
- package/packages/types/src/session/agentSession.ts +2 -0
- package/packages/types/src/tool/plugin.ts +3 -3
- package/packages/utils/src/imageToBase64.ts +17 -10
- package/packages/utils/src/index.ts +1 -1
- package/src/app/(backend)/f/[id]/route.ts +55 -0
- package/src/app/(backend)/market/agent/[[...segments]]/route.ts +153 -0
- package/src/app/(backend)/market/oidc/[[...segments]]/route.ts +207 -0
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/useCategory.tsx +1 -0
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/PinList/index.tsx +4 -2
- package/src/app/[variants]/(main)/chat/settings/features/AgentInfoDescription/index.tsx +349 -0
- package/src/app/[variants]/(main)/chat/settings/features/HeaderContent.tsx +2 -2
- package/src/app/[variants]/(main)/chat/settings/features/PublishResultModal/index.tsx +64 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/MarketPublishButton.tsx +196 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/MarketPublishModal.tsx +358 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/index.tsx +75 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/AssistantDetailPage.tsx +11 -2
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/Client.tsx +12 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Nav.tsx +19 -12
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/TagList.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/index.tsx +2 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Related/index.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/TagList.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/index.tsx +43 -29
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Versions/index.tsx +137 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/index.tsx +2 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Header.tsx +9 -10
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/ActionButton/AddAgent.tsx +105 -14
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/Related/index.tsx +20 -6
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/StatusPage/index.tsx +113 -0
- package/src/app/[variants]/(main)/discover/(detail)/features/Breadcrumb.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(list)/_layout/Desktop/Nav.tsx +3 -1
- package/src/app/[variants]/(main)/discover/(list)/assistant/AssistantPage.tsx +4 -1
- package/src/app/[variants]/(main)/discover/(list)/assistant/Client.tsx +6 -2
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/Category/index.tsx +7 -3
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/List/Item.tsx +13 -2
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/MarketSourceSwitch.tsx +64 -0
- package/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx +26 -7
- package/src/app/[variants]/(main)/profile/_layout/Desktop/index.tsx +10 -10
- package/src/app/[variants]/(main)/settings/_layout/type.ts +1 -1
- package/src/app/[variants]/(main)/settings/agent/index.tsx +11 -10
- package/src/app/[variants]/(main)/settings/common/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/page.tsx +13 -10
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/Item.tsx +35 -36
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/SearchResult.tsx +5 -5
- package/src/app/[variants]/(main)/settings/provider/_layout/Desktop/Container.tsx +10 -4
- package/src/app/market-auth-callback/layout.tsx +15 -0
- package/src/app/market-auth-callback/page.tsx +196 -0
- package/src/envs/app.ts +4 -3
- package/src/features/AgentSetting/AgentPrompt/TokenTag.tsx +3 -2
- package/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx +1 -1
- package/src/features/AgentSetting/store/action.ts +1 -1
- package/src/features/ChatInput/ActionBar/STT/browser.tsx +1 -1
- package/src/features/ChatInput/ActionBar/STT/openai.tsx +1 -1
- package/src/features/Conversation/components/Extras/TTS/InitPlayer.tsx +1 -1
- package/src/features/Conversation/components/VirtualizedList/index.tsx +2 -1
- package/src/features/PluginTag/PluginStatus.tsx +1 -1
- package/src/features/PluginsUI/Render/MCPType/index.tsx +26 -6
- package/src/hooks/useAgentOwnershipCheck.ts +143 -0
- package/src/instrumentation.node.ts +3 -2
- package/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx +364 -0
- package/src/layout/AuthProvider/MarketAuth/errors.ts +75 -0
- package/src/layout/AuthProvider/MarketAuth/index.ts +2 -0
- package/src/layout/AuthProvider/MarketAuth/oidc.ts +382 -0
- package/src/layout/AuthProvider/MarketAuth/types.ts +64 -0
- package/src/layout/AuthProvider/index.tsx +17 -4
- package/src/locales/default/discover.ts +46 -0
- package/src/locales/default/index.ts +2 -0
- package/src/locales/default/marketAuth.ts +42 -0
- package/src/locales/default/setting.ts +94 -1
- package/src/server/globalConfig/genServerAiProviderConfig.test.ts +5 -5
- package/src/server/globalConfig/genServerAiProviderConfig.ts +1 -1
- package/src/server/routers/desktop/mcp.ts +23 -8
- package/src/server/routers/lambda/market/index.ts +36 -14
- package/src/server/routers/lambda/message.ts +2 -2
- package/src/server/routers/tools/mcp.ts +24 -4
- package/src/server/services/discover/index.test.ts +153 -11
- package/src/server/services/discover/index.ts +339 -40
- package/src/server/services/file/impls/local.ts +4 -1
- package/src/server/services/file/index.ts +96 -1
- package/src/server/services/mcp/contentProcessor.ts +101 -0
- package/src/server/services/mcp/index.test.ts +52 -10
- package/src/server/services/mcp/index.ts +29 -26
- package/src/server/sitemap.ts +49 -35
- package/src/services/_url.ts +15 -1
- package/src/services/chat/chat.test.ts +5 -5
- package/src/services/chat/clientModelRuntime.test.ts +1 -1
- package/src/services/chat/index.ts +6 -6
- package/src/services/chat/types.ts +1 -2
- package/src/services/discover.ts +16 -5
- package/src/services/electron/remoteServer.ts +8 -1
- package/src/services/marketApi.ts +124 -0
- package/src/services/models.ts +2 -1
- package/src/services/session/index.ts +0 -14
- package/src/store/discover/slices/assistant/action.ts +20 -7
- package/{packages/utils/src → src/utils}/electron/desktopRemoteRPCFetch.ts +1 -1
- package/{packages/utils/src → src/utils/server}/parseModels.ts +1 -2
- package/src/utils/server/routeVariants.test.ts +340 -0
- package/vitest.config.mts +2 -0
- package/packages/model-runtime/src/utils/imageToBase64.test.ts +0 -91
- package/packages/model-runtime/src/utils/imageToBase64.ts +0 -62
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +0 -98
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/index.tsx +0 -35
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/style.ts +0 -47
- /package/packages/{utils/src/fetch → fetch-sse/src}/headers.ts +0 -0
- /package/packages/{utils/src/fetch → fetch-sse/src}/index.ts +0 -0
- /package/packages/{utils/src/fetch → fetch-sse/src}/request.ts +0 -0
- /package/{packages/utils/src → src/utils/server}/__snapshots__/parseModels.test.ts.snap +0 -0
- /package/{packages/utils/src → src/utils/server}/parseModels.test.ts +0 -0
|
@@ -308,6 +308,20 @@
|
|
|
308
308
|
"when": 1762251112601,
|
|
309
309
|
"tag": "0043_add_ai_model_settings",
|
|
310
310
|
"breakpoints": true
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"idx": 44,
|
|
314
|
+
"version": "7",
|
|
315
|
+
"when": 1762870034882,
|
|
316
|
+
"tag": "0044_high_toxin",
|
|
317
|
+
"breakpoints": true
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"idx": 45,
|
|
321
|
+
"version": "7",
|
|
322
|
+
"when": 1762911968658,
|
|
323
|
+
"tag": "0045_add_tool_intervention",
|
|
324
|
+
"breakpoints": true
|
|
311
325
|
}
|
|
312
326
|
],
|
|
313
327
|
"version": "6"
|
|
@@ -223,7 +223,10 @@
|
|
|
223
223
|
"hash": "9646161fa041354714f823d726af27247bcd6e60fa3be5698c0d69f337a5700b"
|
|
224
224
|
},
|
|
225
225
|
{
|
|
226
|
-
"sql": [
|
|
226
|
+
"sql": [
|
|
227
|
+
"DROP TABLE \"user_budgets\";",
|
|
228
|
+
"\nDROP TABLE \"user_subscriptions\";"
|
|
229
|
+
],
|
|
227
230
|
"bps": true,
|
|
228
231
|
"folderMillis": 1729699958471,
|
|
229
232
|
"hash": "7dad43a2a25d1aec82124a4e53f8d82f8505c3073f23606c1dc5d2a4598eacf9"
|
|
@@ -295,7 +298,9 @@
|
|
|
295
298
|
"hash": "845a692ceabbfc3caf252a97d3e19a213bc0c433df2689900135f9cfded2cf49"
|
|
296
299
|
},
|
|
297
300
|
{
|
|
298
|
-
"sql": [
|
|
301
|
+
"sql": [
|
|
302
|
+
"ALTER TABLE \"messages\" ADD COLUMN \"reasoning\" jsonb;"
|
|
303
|
+
],
|
|
299
304
|
"bps": true,
|
|
300
305
|
"folderMillis": 1737609172353,
|
|
301
306
|
"hash": "2cb36ae4fcdd7b7064767e04bfbb36ae34518ff4bb1b39006f2dd394d1893868"
|
|
@@ -510,7 +515,9 @@
|
|
|
510
515
|
"hash": "a7ccf007fd185ff922823148d1eae6fafe652fc98d2fd2793f84a84f29e93cd1"
|
|
511
516
|
},
|
|
512
517
|
{
|
|
513
|
-
"sql": [
|
|
518
|
+
"sql": [
|
|
519
|
+
"ALTER TABLE \"ai_providers\" ADD COLUMN \"config\" jsonb;"
|
|
520
|
+
],
|
|
514
521
|
"bps": true,
|
|
515
522
|
"folderMillis": 1749309388370,
|
|
516
523
|
"hash": "39cea379f08ee4cb944875c0b67f7791387b508c2d47958bb4cd501ed1ef33eb"
|
|
@@ -628,7 +635,9 @@
|
|
|
628
635
|
"hash": "1ba9b1f74ea13348da98d6fcdad7867ab4316ed565bf75d84d160c526cdac14b"
|
|
629
636
|
},
|
|
630
637
|
{
|
|
631
|
-
"sql": [
|
|
638
|
+
"sql": [
|
|
639
|
+
"ALTER TABLE \"agents\" ADD COLUMN IF NOT EXISTS \"virtual\" boolean DEFAULT false;"
|
|
640
|
+
],
|
|
632
641
|
"bps": true,
|
|
633
642
|
"folderMillis": 1759116400580,
|
|
634
643
|
"hash": "433ddae88e785f2db734e49a4c115eee93e60afe389f7919d66e5ba9aa159a37"
|
|
@@ -678,13 +687,17 @@
|
|
|
678
687
|
"hash": "4bdc6505797d7a33b622498c138cfd47f637239f6905e1c484cd01d9d5f21d6b"
|
|
679
688
|
},
|
|
680
689
|
{
|
|
681
|
-
"sql": [
|
|
690
|
+
"sql": [
|
|
691
|
+
"ALTER TABLE \"user_settings\" ADD COLUMN IF NOT EXISTS \"image\" jsonb;"
|
|
692
|
+
],
|
|
682
693
|
"bps": true,
|
|
683
694
|
"folderMillis": 1760108430562,
|
|
684
695
|
"hash": "ce09b301abb80f6563abc2f526bdd20b4f69bae430f09ba2179b9e3bfec43067"
|
|
685
696
|
},
|
|
686
697
|
{
|
|
687
|
-
"sql": [
|
|
698
|
+
"sql": [
|
|
699
|
+
"ALTER TABLE \"documents\" ADD COLUMN IF NOT EXISTS \"editor_data\" jsonb;"
|
|
700
|
+
],
|
|
688
701
|
"bps": true,
|
|
689
702
|
"folderMillis": 1761554153406,
|
|
690
703
|
"hash": "bf2f21293e90e11cf60a784cf3ec219eafa95f7545d7d2f9d1449c0b0949599a"
|
|
@@ -762,5 +775,21 @@
|
|
|
762
775
|
"bps": true,
|
|
763
776
|
"folderMillis": 1762251112601,
|
|
764
777
|
"hash": "923ccbdf46c32be9a981dabd348e6923b4a365444241e9b8cc174bf5b914cbc5"
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
"sql": [
|
|
781
|
+
"ALTER TABLE \"agents\" ADD COLUMN IF NOT EXISTS \"market_identifier\" text;\n"
|
|
782
|
+
],
|
|
783
|
+
"bps": true,
|
|
784
|
+
"folderMillis": 1762870034882,
|
|
785
|
+
"hash": "4178aacb4b8892b7fd15d29209bbf9b1d1f9d7c406ba796f27542c0bcd919680"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"sql": [
|
|
789
|
+
"ALTER TABLE \"message_plugins\" ADD COLUMN IF NOT EXISTS \"intervention\" jsonb;\n"
|
|
790
|
+
],
|
|
791
|
+
"bps": true,
|
|
792
|
+
"folderMillis": 1762911968658,
|
|
793
|
+
"hash": "552a032cc0e595277232e70b5f9338658585bafe9481ae8346a5f322b673a68b"
|
|
765
794
|
}
|
|
766
|
-
]
|
|
795
|
+
]
|
|
@@ -25,8 +25,22 @@ export class FileModel {
|
|
|
25
25
|
this.db = db;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Get file by ID without userId filter (public access)
|
|
30
|
+
* Use this for scenarios like file proxy where file should be accessible by ID alone
|
|
31
|
+
*
|
|
32
|
+
* @param db - Database instance
|
|
33
|
+
* @param id - File ID
|
|
34
|
+
* @returns File record or undefined
|
|
35
|
+
*/
|
|
36
|
+
static async getFileById(db: LobeChatDatabase, id: string): Promise<FileItem | undefined> {
|
|
37
|
+
return db.query.files.findFirst({
|
|
38
|
+
where: eq(files.id, id),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
28
42
|
create = async (
|
|
29
|
-
params: Omit<NewFile, 'id' | 'userId'> & { knowledgeBaseId?: string },
|
|
43
|
+
params: Omit<NewFile, 'id' | 'userId'> & { id?: string; knowledgeBaseId?: string },
|
|
30
44
|
insertToGlobalFiles?: boolean,
|
|
31
45
|
trx?: Transaction,
|
|
32
46
|
) => {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ChatVideoItem,
|
|
9
9
|
CreateMessageParams,
|
|
10
10
|
DBMessageItem,
|
|
11
|
+
MessagePluginItem,
|
|
11
12
|
ModelRankItem,
|
|
12
13
|
NewMessageQueryParams,
|
|
13
14
|
QueryMessageParams,
|
|
@@ -23,7 +24,6 @@ import { merge } from '@/utils/merge';
|
|
|
23
24
|
import { today } from '@/utils/time';
|
|
24
25
|
|
|
25
26
|
import {
|
|
26
|
-
MessagePluginItem,
|
|
27
27
|
chunks,
|
|
28
28
|
documents,
|
|
29
29
|
embeddings,
|
|
@@ -256,6 +256,31 @@ export class SessionModel {
|
|
|
256
256
|
if (existResult) return existResult;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
// Extract and properly map fields for agent creation from DiscoverAssistantDetail
|
|
260
|
+
const {
|
|
261
|
+
// MetaData fields (from discover assistant)
|
|
262
|
+
title,
|
|
263
|
+
description,
|
|
264
|
+
tags = [],
|
|
265
|
+
avatar,
|
|
266
|
+
backgroundColor,
|
|
267
|
+
// LobeAgentConfig fields
|
|
268
|
+
model,
|
|
269
|
+
params,
|
|
270
|
+
systemRole,
|
|
271
|
+
provider,
|
|
272
|
+
plugins = [],
|
|
273
|
+
openingMessage,
|
|
274
|
+
openingQuestions = [],
|
|
275
|
+
// TTS config
|
|
276
|
+
tts,
|
|
277
|
+
// Chat config
|
|
278
|
+
chatConfig,
|
|
279
|
+
// Field name mapping
|
|
280
|
+
examples, // maps to fewShots
|
|
281
|
+
identifier, // maps to marketIdentifier
|
|
282
|
+
marketIdentifier,
|
|
283
|
+
} = config as any;
|
|
259
284
|
if (type === 'group') {
|
|
260
285
|
const result = await trx
|
|
261
286
|
.insert(sessions)
|
|
@@ -276,9 +301,24 @@ export class SessionModel {
|
|
|
276
301
|
const newAgents = await trx
|
|
277
302
|
.insert(agents)
|
|
278
303
|
.values({
|
|
279
|
-
|
|
304
|
+
avatar,
|
|
305
|
+
backgroundColor,
|
|
306
|
+
chatConfig: chatConfig || {},
|
|
280
307
|
createdAt: new Date(),
|
|
308
|
+
description,
|
|
309
|
+
fewShots: examples || null, // Map examples to fewShots field
|
|
281
310
|
id: idGenerator('agents'),
|
|
311
|
+
marketIdentifier: identifier || marketIdentifier,
|
|
312
|
+
model: typeof model === 'string' ? model : null,
|
|
313
|
+
openingMessage,
|
|
314
|
+
openingQuestions,
|
|
315
|
+
params: params || {},
|
|
316
|
+
plugins,
|
|
317
|
+
provider,
|
|
318
|
+
systemRole,
|
|
319
|
+
tags,
|
|
320
|
+
title,
|
|
321
|
+
tts: tts || {},
|
|
282
322
|
updatedAt: new Date(),
|
|
283
323
|
userId: this.userId,
|
|
284
324
|
})
|
|
@@ -595,6 +635,7 @@ export class SessionModel {
|
|
|
595
635
|
avatar: agent?.avatar ?? avatar ?? undefined,
|
|
596
636
|
backgroundColor: agent?.backgroundColor ?? backgroundColor ?? undefined,
|
|
597
637
|
description: agent?.description ?? description ?? undefined,
|
|
638
|
+
marketIdentifier: agent?.marketIdentifier ?? undefined,
|
|
598
639
|
tags: agent?.tags ?? undefined,
|
|
599
640
|
title: agent?.title ?? title ?? undefined,
|
|
600
641
|
},
|
|
@@ -37,6 +37,7 @@ export const agents = pgTable(
|
|
|
37
37
|
tags: jsonb('tags').$type<string[]>().default([]),
|
|
38
38
|
avatar: text('avatar'),
|
|
39
39
|
backgroundColor: text('background_color'),
|
|
40
|
+
marketIdentifier: text('market_identifier'),
|
|
40
41
|
|
|
41
42
|
plugins: jsonb('plugins').$type<string[]>().default([]),
|
|
42
43
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
|
-
import { GroundingSearch, ModelReasoning } from '@lobechat/types';
|
|
2
|
+
import { GroundingSearch, ModelReasoning, ToolIntervention } from '@lobechat/types';
|
|
3
3
|
import {
|
|
4
4
|
boolean,
|
|
5
5
|
index,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
uniqueIndex,
|
|
12
12
|
uuid,
|
|
13
13
|
} from 'drizzle-orm/pg-core';
|
|
14
|
-
import { createInsertSchema
|
|
14
|
+
import { createInsertSchema } from 'drizzle-zod';
|
|
15
15
|
|
|
16
16
|
import { idGenerator } from '../utils/idGenerator';
|
|
17
17
|
import { timestamps, varchar255 } from './_helpers';
|
|
@@ -146,10 +146,10 @@ export const messagePlugins = pgTable(
|
|
|
146
146
|
.primaryKey(),
|
|
147
147
|
|
|
148
148
|
toolCallId: text('tool_call_id'),
|
|
149
|
-
type: text('type',
|
|
150
|
-
enum: ['default', 'markdown', 'standalone', 'builtin'],
|
|
151
|
-
}).default('default'),
|
|
149
|
+
type: text('type').default('default'),
|
|
152
150
|
|
|
151
|
+
// Human intervention fields
|
|
152
|
+
intervention: jsonb('intervention').$type<ToolIntervention>(),
|
|
153
153
|
apiName: text('api_name'),
|
|
154
154
|
arguments: text('arguments'),
|
|
155
155
|
identifier: text('identifier'),
|
|
@@ -168,9 +168,6 @@ export const messagePlugins = pgTable(
|
|
|
168
168
|
}),
|
|
169
169
|
);
|
|
170
170
|
|
|
171
|
-
export type MessagePluginItem = typeof messagePlugins.$inferSelect;
|
|
172
|
-
export const updateMessagePluginSchema = createSelectSchema(messagePlugins);
|
|
173
|
-
|
|
174
171
|
export const messageTTS = pgTable(
|
|
175
172
|
'message_tts',
|
|
176
173
|
{
|
|
@@ -2,7 +2,11 @@ import { LocalSystemDispatchEvents } from './localSystem';
|
|
|
2
2
|
import { MenuDispatchEvents } from './menu';
|
|
3
3
|
import { NotificationDispatchEvents } from './notification';
|
|
4
4
|
import { ProtocolBroadcastEvents, ProtocolDispatchEvents } from './protocol';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
|
|
7
|
+
RemoteServerBroadcastEvents,
|
|
8
|
+
RemoteServerDispatchEvents,
|
|
9
|
+
} from './remoteServer';
|
|
6
10
|
import { DesktopSettingsDispatchEvents } from './settings';
|
|
7
11
|
import { ShortcutDispatchEvents } from './shortcut';
|
|
8
12
|
import { SystemBroadcastEvents, SystemDispatchEvents } from './system';
|
|
@@ -51,4 +55,5 @@ export type MainBroadcastParams<T extends MainBroadcastEventKey> = Parameters<
|
|
|
51
55
|
MainBroadcastEvents[T]
|
|
52
56
|
>[0];
|
|
53
57
|
|
|
58
|
+
export type { MarketAuthorizationParams } from './remoteServer';
|
|
54
59
|
export type { OpenSettingsWindowOptions } from './windows';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { DataSyncConfig } from '../types/dataSync';
|
|
2
2
|
import { ProxyTRPCRequestParams, ProxyTRPCRequestResult } from '../types/proxyTRPCRequest';
|
|
3
3
|
|
|
4
|
+
export interface MarketAuthorizationParams {
|
|
5
|
+
authUrl: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
/**
|
|
5
9
|
* 远程服务器配置相关的事件
|
|
6
10
|
*/
|
|
@@ -21,6 +25,10 @@ export interface RemoteServerDispatchEvents {
|
|
|
21
25
|
error?: string;
|
|
22
26
|
success: boolean;
|
|
23
27
|
};
|
|
28
|
+
requestMarketAuthorization: (params: MarketAuthorizationParams) => {
|
|
29
|
+
error?: string;
|
|
30
|
+
success: boolean;
|
|
31
|
+
};
|
|
24
32
|
setRemoteServerConfig: (config: DataSyncConfig) => boolean;
|
|
25
33
|
}
|
|
26
34
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lobechat/fetch-sse",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "SSE fetch utilities with streaming support",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"default": "./src/index.ts"
|
|
10
|
+
},
|
|
11
|
+
"./parseError": {
|
|
12
|
+
"types": "./src/parseError.ts",
|
|
13
|
+
"default": "./src/parseError.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"main": "./src/index.ts",
|
|
17
|
+
"types": "./src/index.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "vitest",
|
|
20
|
+
"test:coverage": "vitest --coverage --silent='passed-only'"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@lobechat/const": "workspace:*",
|
|
24
|
+
"@lobechat/model-runtime": "workspace:*",
|
|
25
|
+
"@lobechat/types": "workspace:*",
|
|
26
|
+
"@lobechat/utils": "workspace:*",
|
|
27
|
+
"i18next": "^24.2.1"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MESSAGE_CANCEL_FLAT } from '@lobechat/const';
|
|
2
2
|
import { ChatMessageError } from '@lobechat/types';
|
|
3
|
+
import { FetchEventSourceInit } from '@lobechat/utils/client/fetchEventSource/index';
|
|
4
|
+
import { fetchEventSource } from '@lobechat/utils/client/fetchEventSource/index';
|
|
5
|
+
import { sleep } from '@lobechat/utils/sleep';
|
|
3
6
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
4
7
|
|
|
5
|
-
import { FetchEventSourceInit } from '../../client/fetchEventSource';
|
|
6
|
-
import { fetchEventSource } from '../../client/fetchEventSource';
|
|
7
|
-
import { sleep } from '../../sleep';
|
|
8
8
|
import { fetchSSE } from '../fetchSSE';
|
|
9
9
|
|
|
10
10
|
// 模拟 i18next
|
|
@@ -12,7 +12,7 @@ vi.mock('i18next', () => ({
|
|
|
12
12
|
t: vi.fn((key) => `translated_${key}`),
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
-
vi.mock('
|
|
15
|
+
vi.mock('@lobechat/utils/client/fetchEventSource/index', () => ({
|
|
16
16
|
fetchEventSource: vi.fn(),
|
|
17
17
|
}));
|
|
18
18
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ErrorResponse } from '@lobechat/types';
|
|
2
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { getMessageError } from '../parseError';
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// Mock i18next
|
|
7
7
|
vi.mock('i18next', () => ({
|
|
8
8
|
t: vi.fn((key) => `translated_${key}`),
|
|
9
9
|
}));
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// Mock Response
|
|
12
12
|
const createMockResponse = (body: any, ok: boolean, status: number = 200) => ({
|
|
13
13
|
ok,
|
|
14
14
|
status,
|
|
@@ -38,11 +38,14 @@ const createMockResponse = (body: any, ok: boolean, status: number = 200) => ({
|
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
// 在每次测试后清理所有模拟
|
|
42
41
|
afterEach(() => {
|
|
43
42
|
vi.restoreAllMocks();
|
|
44
43
|
});
|
|
45
44
|
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
vi.clearAllMocks();
|
|
47
|
+
});
|
|
48
|
+
|
|
46
49
|
describe('getMessageError', () => {
|
|
47
50
|
it('should handle business error correctly', async () => {
|
|
48
51
|
const mockErrorResponse: ErrorResponse = {
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
ResponseAnimation,
|
|
13
13
|
ResponseAnimationStyle,
|
|
14
14
|
} from '@lobechat/types';
|
|
15
|
+
import { fetchEventSource } from '@lobechat/utils/client/fetchEventSource/index';
|
|
16
|
+
import { nanoid } from '@lobechat/utils/uuid';
|
|
15
17
|
|
|
16
|
-
import { fetchEventSource } from '../client/fetchEventSource';
|
|
17
|
-
import { nanoid } from '../uuid';
|
|
18
18
|
import { getMessageError } from './parseError';
|
|
19
19
|
|
|
20
20
|
type SSEFinishType = 'done' | 'error' | 'abort';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChatMessageError, ErrorResponse, ErrorType } from '@lobechat/types';
|
|
2
2
|
import { t } from 'i18next';
|
|
3
3
|
|
|
4
|
-
export const getMessageError = async (response: Response) => {
|
|
4
|
+
export const getMessageError = async (response: Response): Promise<ChatMessageError> => {
|
|
5
5
|
let chatMessageError: ChatMessageError;
|
|
6
6
|
|
|
7
7
|
// try to get the biz error
|
|
@@ -9,13 +9,13 @@ export const getMessageError = async (response: Response) => {
|
|
|
9
9
|
const data = (await response.json()) as ErrorResponse;
|
|
10
10
|
chatMessageError = {
|
|
11
11
|
body: data.body,
|
|
12
|
-
message: t(`response.${data.errorType}
|
|
12
|
+
message: t(`response.${data.errorType}`, { ns: 'error' }),
|
|
13
13
|
type: data.errorType,
|
|
14
14
|
};
|
|
15
15
|
} catch {
|
|
16
16
|
// if not return, then it's a common error
|
|
17
17
|
chatMessageError = {
|
|
18
|
-
message: t(`response.${response.status}
|
|
18
|
+
message: t(`response.${response.status}`, { ns: 'error' }),
|
|
19
19
|
type: response.status as ErrorType,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -45,7 +45,8 @@ const mistralChatModels: AIChatModelCard[] = [
|
|
|
45
45
|
vision: true,
|
|
46
46
|
},
|
|
47
47
|
contextWindowTokens: 128_000,
|
|
48
|
-
description:
|
|
48
|
+
description:
|
|
49
|
+
'Magistral Small 1.2 是Mistral AI于2025年9月发布的开源小型推理模型,具有视觉支持。',
|
|
49
50
|
displayName: 'Magistral Small 1.2',
|
|
50
51
|
id: 'magistral-small-2509',
|
|
51
52
|
pricing: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
|
1
2
|
import { OpenAI } from 'openai';
|
|
2
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
4
|
|
|
4
5
|
import { OpenAIChatMessage, UserMessageContentPart } from '../../types/chat';
|
|
5
|
-
import { imageUrlToBase64 } from '../../utils/imageToBase64';
|
|
6
6
|
import { parseDataUri } from '../../utils/uriParser';
|
|
7
7
|
import {
|
|
8
8
|
buildAnthropicBlock,
|
|
@@ -12,16 +12,22 @@ import {
|
|
|
12
12
|
} from './anthropic';
|
|
13
13
|
|
|
14
14
|
// Mock the parseDataUri function since it's an implementation detail
|
|
15
|
-
vi.mock('../../utils/uriParser'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
base64: 'base64EncodedString',
|
|
19
|
-
type: 'base64',
|
|
20
|
-
}),
|
|
15
|
+
vi.mock('../../utils/uriParser');
|
|
16
|
+
vi.mock('@lobechat/utils', () => ({
|
|
17
|
+
imageUrlToBase64: vi.fn(),
|
|
21
18
|
}));
|
|
22
|
-
vi.mock('../../utils/imageToBase64');
|
|
23
19
|
|
|
24
20
|
describe('anthropicHelpers', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
vi.resetAllMocks();
|
|
23
|
+
// Set default mock implementation for parseDataUri
|
|
24
|
+
vi.mocked(parseDataUri).mockReturnValue({
|
|
25
|
+
mimeType: 'image/jpeg',
|
|
26
|
+
base64: 'base64EncodedString',
|
|
27
|
+
type: 'base64',
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
25
31
|
describe('buildAnthropicBlock', () => {
|
|
26
32
|
it('should return the content as is for text type', async () => {
|
|
27
33
|
const content: UserMessageContentPart = { type: 'text', text: 'Hello!' };
|
|
@@ -52,7 +58,7 @@ describe('anthropicHelpers', () => {
|
|
|
52
58
|
base64: null,
|
|
53
59
|
type: 'url',
|
|
54
60
|
});
|
|
55
|
-
vi.mocked(imageUrlToBase64).
|
|
61
|
+
vi.mocked(imageUrlToBase64).mockResolvedValueOnce({
|
|
56
62
|
base64: 'convertedBase64String',
|
|
57
63
|
mimeType: 'image/jpg',
|
|
58
64
|
});
|
|
@@ -82,7 +88,7 @@ describe('anthropicHelpers', () => {
|
|
|
82
88
|
base64: null,
|
|
83
89
|
type: 'url',
|
|
84
90
|
});
|
|
85
|
-
vi.mocked(imageUrlToBase64).
|
|
91
|
+
vi.mocked(imageUrlToBase64).mockResolvedValueOnce({
|
|
86
92
|
base64: 'convertedBase64String',
|
|
87
93
|
mimeType: 'image/png',
|
|
88
94
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
|
2
3
|
import OpenAI from 'openai';
|
|
3
4
|
|
|
4
5
|
import { OpenAIChatMessage, UserMessageContentPart } from '../../types';
|
|
5
|
-
import { imageUrlToBase64 } from '../../utils/imageToBase64';
|
|
6
6
|
import { parseDataUri } from '../../utils/uriParser';
|
|
7
7
|
|
|
8
8
|
export const buildAnthropicBlock = async (
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
2
|
import { Type as SchemaType } from '@google/genai';
|
|
3
|
+
import * as imageToBase64Module from '@lobechat/utils';
|
|
3
4
|
import { describe, expect, it, vi } from 'vitest';
|
|
4
5
|
|
|
5
6
|
import { ChatCompletionTool, OpenAIChatMessage, UserMessageContentPart } from '../../types';
|
|
6
|
-
import * as imageToBase64Module from '../../utils/imageToBase64';
|
|
7
7
|
import { parseDataUri } from '../../utils/uriParser';
|
|
8
8
|
import {
|
|
9
9
|
buildGoogleMessage,
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
Part,
|
|
6
6
|
Type as SchemaType,
|
|
7
7
|
} from '@google/genai';
|
|
8
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
|
8
9
|
|
|
9
10
|
import { ChatCompletionTool, OpenAIChatMessage, UserMessageContentPart } from '../../types';
|
|
10
|
-
import { imageUrlToBase64 } from '../../utils/imageToBase64';
|
|
11
11
|
import { safeParseJSON } from '../../utils/safeParseJSON';
|
|
12
12
|
import { parseDataUri } from '../../utils/uriParser';
|
|
13
13
|
|
|
@@ -64,12 +64,9 @@ export const buildGooglePart = async (
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (type === 'url') {
|
|
67
|
-
//
|
|
67
|
+
// Use imageUrlToBase64 for SSRF protection (works for any binary data including videos)
|
|
68
68
|
// Note: This might need size/duration limits for practical use
|
|
69
|
-
const
|
|
70
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
71
|
-
const base64 = Buffer.from(arrayBuffer).toString('base64');
|
|
72
|
-
const mimeType = response.headers.get('content-type') || 'video/mp4';
|
|
69
|
+
const { base64, mimeType } = await imageUrlToBase64(content.video_url.url);
|
|
73
70
|
|
|
74
71
|
return {
|
|
75
72
|
inlineData: { data: base64, mimeType },
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
|
1
2
|
import OpenAI from 'openai';
|
|
2
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
4
|
|
|
4
5
|
import { OpenAIChatMessage } from '../../types';
|
|
5
|
-
import { imageUrlToBase64 } from '../../utils/imageToBase64';
|
|
6
6
|
import { parseDataUri } from '../../utils/uriParser';
|
|
7
7
|
import {
|
|
8
8
|
convertImageUrlToFile,
|
|
@@ -12,7 +12,9 @@ import {
|
|
|
12
12
|
} from './openai';
|
|
13
13
|
|
|
14
14
|
// 模拟依赖
|
|
15
|
-
vi.mock('
|
|
15
|
+
vi.mock('@lobechat/utils', () => ({
|
|
16
|
+
imageUrlToBase64: vi.fn(),
|
|
17
|
+
}));
|
|
16
18
|
vi.mock('../../utils/uriParser');
|
|
17
19
|
|
|
18
20
|
describe('convertMessageContent', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
|
1
2
|
import OpenAI, { toFile } from 'openai';
|
|
2
3
|
|
|
3
4
|
import { disableStreamModels, systemToUserModels } from '../../const/models';
|
|
4
5
|
import { ChatStreamPayload, OpenAIChatMessage } from '../../types';
|
|
5
|
-
import { imageUrlToBase64 } from '../../utils/imageToBase64';
|
|
6
6
|
import { parseDataUri } from '../../utils/uriParser';
|
|
7
7
|
|
|
8
8
|
export const convertMessageContent = async (
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
+
import * as imageToBase64Module from '@lobechat/utils';
|
|
2
3
|
import OpenAI from 'openai';
|
|
3
4
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
5
|
|
|
5
6
|
import { CreateImagePayload } from '../../types/image';
|
|
6
|
-
import * as imageToBase64Module from '../../utils/imageToBase64';
|
|
7
7
|
import * as uriParserModule from '../../utils/uriParser';
|
|
8
8
|
import { createOpenAICompatibleImage } from './createImage';
|
|
9
9
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
|
1
2
|
import { cleanObject } from '@lobechat/utils/object';
|
|
2
3
|
import createDebug from 'debug';
|
|
3
4
|
import { RuntimeImageGenParamsValue } from 'model-bank';
|
|
@@ -5,7 +6,6 @@ import OpenAI from 'openai';
|
|
|
5
6
|
|
|
6
7
|
import { CreateImagePayload, CreateImageResponse } from '../../types/image';
|
|
7
8
|
import { getModelPricing } from '../../utils/getModelPricing';
|
|
8
|
-
import { imageUrlToBase64 } from '../../utils/imageToBase64';
|
|
9
9
|
import { parseDataUri } from '../../utils/uriParser';
|
|
10
10
|
import { convertImageUrlToFile } from '../contextBuilders/openai';
|
|
11
11
|
import { convertOpenAIImageUsage } from '../usageConverters/openai';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
-
import {
|
|
3
|
-
AgentRuntimeErrorType,
|
|
4
|
-
ChatStreamCallbacks,
|
|
5
|
-
ChatStreamPayload,
|
|
6
|
-
LobeOpenAICompatibleRuntime,
|
|
7
|
-
} from '@lobechat/model-runtime';
|
|
8
2
|
import { ModelProvider } from 'model-bank';
|
|
9
3
|
import OpenAI from 'openai';
|
|
10
4
|
import type { Stream } from 'openai/streaming';
|
|
11
5
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
12
6
|
|
|
7
|
+
import { LobeOpenAICompatibleRuntime } from '../../core/BaseAI';
|
|
8
|
+
import { ChatStreamCallbacks, ChatStreamPayload } from '../../types/chat';
|
|
9
|
+
import { AgentRuntimeErrorType } from '../../types/error';
|
|
13
10
|
import * as debugStreamModule from '../../utils/debugStream';
|
|
14
11
|
import * as openaiHelpers from '../contextBuilders/openai';
|
|
15
12
|
import { createOpenAICompatibleRuntime } from './index';
|