@lobehub/lobehub 2.0.0-next.47 → 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 +17 -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 +5 -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/message.ts +1 -1
- package/packages/database/src/models/session.ts +42 -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/discover/assistants.ts +16 -0
- 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/session/agentSession.ts +2 -0
- package/packages/utils/src/imageToBase64.ts +17 -10
- package/packages/utils/src/index.ts +1 -1
- 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/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/PluginTag/PluginStatus.tsx +1 -1
- 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/lambda/market/index.ts +36 -14
- package/src/server/routers/lambda/message.ts +2 -2
- package/src/server/services/discover/index.test.ts +153 -11
- package/src/server/services/discover/index.ts +339 -40
- 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/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/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
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
import { CopyButton } from '@lobehub/ui';
|
|
4
4
|
import { Breadcrumb as AntdBreadcrumb } from 'antd';
|
|
5
5
|
import { useTheme } from 'antd-style';
|
|
6
|
+
import Link from 'next/link';
|
|
6
7
|
import { memo } from 'react';
|
|
7
8
|
import { useTranslation } from 'react-i18next';
|
|
8
9
|
import { Flexbox } from 'react-layout-kit';
|
|
9
|
-
import
|
|
10
|
+
import urlJoin from 'url-join';
|
|
10
11
|
|
|
11
12
|
import { DiscoverTab } from '@/types/discover';
|
|
12
13
|
|
|
@@ -17,11 +18,11 @@ const Breadcrumb = memo<{ identifier: string; tab: DiscoverTab }>(({ tab, identi
|
|
|
17
18
|
<AntdBreadcrumb
|
|
18
19
|
items={[
|
|
19
20
|
{
|
|
20
|
-
title: <Link
|
|
21
|
+
title: <Link href={'/discover'}>Discover</Link>,
|
|
21
22
|
},
|
|
22
23
|
{
|
|
23
24
|
title: (
|
|
24
|
-
<Link
|
|
25
|
+
<Link href={urlJoin('/discover', tab)}>
|
|
25
26
|
{tab === DiscoverTab.Mcp ? 'MCP Servers' : t(`tab.${tab}` as any)}
|
|
26
27
|
</Link>
|
|
27
28
|
),
|
|
@@ -14,6 +14,7 @@ import { DiscoverTab } from '@/types/discover';
|
|
|
14
14
|
import { MAX_WIDTH, SCROLL_PARENT_ID } from '../../../features/const';
|
|
15
15
|
import { useNav } from '../../../features/useNav';
|
|
16
16
|
import SortButton from '../../features/SortButton';
|
|
17
|
+
import MarketSourceSwitch from '../../assistant/features/MarketSourceSwitch';
|
|
17
18
|
import { useScroll } from './useScroll';
|
|
18
19
|
|
|
19
20
|
export const useStyles = createStyles(({ cx, stylish, css, token }) => ({
|
|
@@ -88,7 +89,8 @@ const Nav = memo(() => {
|
|
|
88
89
|
/>
|
|
89
90
|
</Flexbox>
|
|
90
91
|
{!isHome && (
|
|
91
|
-
<Flexbox align={'center'} gap={
|
|
92
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
|
93
|
+
{activeKey === DiscoverTab.Assistants && <MarketSourceSwitch />}
|
|
92
94
|
<SortButton />
|
|
93
95
|
</Flexbox>
|
|
94
96
|
)}
|
|
@@ -13,7 +13,7 @@ import List from './features/List';
|
|
|
13
13
|
import Loading from './loading';
|
|
14
14
|
|
|
15
15
|
const AssistantPage = memo<{ mobile?: boolean }>(() => {
|
|
16
|
-
const { q, page, category, sort, order } = useQuery() as AssistantQueryParams;
|
|
16
|
+
const { q, page, category, sort, order, source } = useQuery() as AssistantQueryParams;
|
|
17
17
|
const useAssistantList = useDiscoverStore((s) => s.useAssistantList);
|
|
18
18
|
const { data, isLoading } = useAssistantList({
|
|
19
19
|
category,
|
|
@@ -22,8 +22,11 @@ const AssistantPage = memo<{ mobile?: boolean }>(() => {
|
|
|
22
22
|
pageSize: 21,
|
|
23
23
|
q,
|
|
24
24
|
sort,
|
|
25
|
+
source,
|
|
25
26
|
});
|
|
26
27
|
|
|
28
|
+
console.log("data",data)
|
|
29
|
+
|
|
27
30
|
if (isLoading || !data) return <Loading />;
|
|
28
31
|
|
|
29
32
|
const { items, currentPage, pageSize, totalCount } = data;
|
|
@@ -6,22 +6,26 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
6
6
|
import { withSuspense } from '@/components/withSuspense';
|
|
7
7
|
import { useQuery } from '@/hooks/useQuery';
|
|
8
8
|
import { useDiscoverStore } from '@/store/discover';
|
|
9
|
-
import { AssistantQueryParams, DiscoverTab } from '@/types/discover';
|
|
9
|
+
import { AssistantMarketSource, AssistantQueryParams, DiscoverTab } from '@/types/discover';
|
|
10
10
|
|
|
11
11
|
import Pagination from '../features/Pagination';
|
|
12
12
|
import List from './features/List';
|
|
13
13
|
import Loading from './loading';
|
|
14
14
|
|
|
15
15
|
const Client = memo<{ mobile?: boolean }>(() => {
|
|
16
|
-
const { q, page, category, sort, order } =
|
|
16
|
+
const { q, page, category, sort, order, ownerId, source } =
|
|
17
|
+
useQuery() as AssistantQueryParams;
|
|
18
|
+
const marketSource = (source as AssistantMarketSource | undefined) ?? 'new';
|
|
17
19
|
const useAssistantList = useDiscoverStore((s) => s.useAssistantList);
|
|
18
20
|
const { data, isLoading } = useAssistantList({
|
|
19
21
|
category,
|
|
20
22
|
order,
|
|
23
|
+
ownerId,
|
|
21
24
|
page,
|
|
22
25
|
pageSize: 21,
|
|
23
26
|
q,
|
|
24
27
|
sort,
|
|
28
|
+
source: marketSource,
|
|
25
29
|
});
|
|
26
30
|
|
|
27
31
|
if (isLoading || !data) return <Loading />;
|
|
@@ -16,15 +16,19 @@ import { useCategory } from './useCategory';
|
|
|
16
16
|
|
|
17
17
|
const Category = memo(() => {
|
|
18
18
|
const useAssistantCategories = useDiscoverStore((s) => s.useAssistantCategories);
|
|
19
|
-
const {
|
|
20
|
-
|
|
19
|
+
const {
|
|
20
|
+
category = 'all',
|
|
21
|
+
q,
|
|
22
|
+
source,
|
|
23
|
+
} = useQuery() as { category?: AssistantCategory; q?: string; source?: string };
|
|
24
|
+
const { data: items = [] } = useAssistantCategories({ q, source: source as any });
|
|
21
25
|
const navigate = useNavigate();
|
|
22
26
|
const cates = useCategory();
|
|
23
27
|
|
|
24
28
|
const genUrl = (key: AssistantCategory) =>
|
|
25
29
|
qs.stringifyUrl(
|
|
26
30
|
{
|
|
27
|
-
query: { category: key === AssistantCategory.All ? null : key, q },
|
|
31
|
+
query: { category: key === AssistantCategory.All ? null : key, q, source },
|
|
28
32
|
url: '/assistant',
|
|
29
33
|
},
|
|
30
34
|
{ skipNull: true },
|
|
@@ -2,6 +2,7 @@ import { Github } from '@lobehub/icons';
|
|
|
2
2
|
import { ActionIcon, Avatar, Block, Icon, Text } from '@lobehub/ui';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { ClockIcon } from 'lucide-react';
|
|
5
|
+
import qs from 'query-string';
|
|
5
6
|
import { memo } from 'react';
|
|
6
7
|
import { useTranslation } from 'react-i18next';
|
|
7
8
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -9,7 +10,8 @@ import { Link, useNavigate } from 'react-router-dom';
|
|
|
9
10
|
import urlJoin from 'url-join';
|
|
10
11
|
|
|
11
12
|
import PublishedTime from '@/components/PublishedTime';
|
|
12
|
-
import {
|
|
13
|
+
import { useQuery } from '@/hooks/useQuery';
|
|
14
|
+
import { AssistantMarketSource, DiscoverAssistantItem } from '@/types/discover';
|
|
13
15
|
|
|
14
16
|
import TokenTag from './TokenTag';
|
|
15
17
|
|
|
@@ -61,9 +63,18 @@ const AssistantItem = memo<DiscoverAssistantItem>(
|
|
|
61
63
|
knowledgeCount,
|
|
62
64
|
backgroundColor,
|
|
63
65
|
}) => {
|
|
66
|
+
|
|
67
|
+
console.log("author",author)
|
|
64
68
|
const { styles, theme } = useStyles();
|
|
65
69
|
const navigate = useNavigate();
|
|
66
|
-
const
|
|
70
|
+
const { source } = useQuery() as { source?: AssistantMarketSource };
|
|
71
|
+
const link = qs.stringifyUrl(
|
|
72
|
+
{
|
|
73
|
+
query: { source },
|
|
74
|
+
url: urlJoin('/assistant', identifier),
|
|
75
|
+
},
|
|
76
|
+
{ skipNull: true },
|
|
77
|
+
);
|
|
67
78
|
const { t } = useTranslation('discover');
|
|
68
79
|
|
|
69
80
|
return (
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Dropdown, DropdownMenuItemType, Icon } from '@lobehub/ui';
|
|
4
|
+
import { Button } from 'antd';
|
|
5
|
+
import { ChevronDown, Store } from 'lucide-react';
|
|
6
|
+
import { memo, useMemo } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
import { useQuery } from '@/hooks/useQuery';
|
|
10
|
+
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
|
11
|
+
import { AssistantMarketSource } from '@/types/discover';
|
|
12
|
+
|
|
13
|
+
const MarketSourceSwitch = memo(() => {
|
|
14
|
+
const { t } = useTranslation('discover');
|
|
15
|
+
const router = useQueryRoute();
|
|
16
|
+
const query = useQuery() as { source?: AssistantMarketSource };
|
|
17
|
+
const currentSource = (query.source as AssistantMarketSource) ?? 'new';
|
|
18
|
+
|
|
19
|
+
const items = useMemo(
|
|
20
|
+
() =>
|
|
21
|
+
[
|
|
22
|
+
{
|
|
23
|
+
key: 'new',
|
|
24
|
+
label: t('assistants.marketSource.new'),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: 'legacy',
|
|
28
|
+
label: t('assistants.marketSource.legacy'),
|
|
29
|
+
},
|
|
30
|
+
] satisfies DropdownMenuItemType[],
|
|
31
|
+
[t],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const handleChange = (value: AssistantMarketSource) => {
|
|
35
|
+
router.push('/discover/assistant', {
|
|
36
|
+
query: {
|
|
37
|
+
page: null,
|
|
38
|
+
source: value === 'new' ? null : value,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Dropdown
|
|
45
|
+
menu={{
|
|
46
|
+
// @ts-expect-error 等待 antd 修复
|
|
47
|
+
activeKey: currentSource,
|
|
48
|
+
items,
|
|
49
|
+
onClick: ({ key }) => handleChange(key as AssistantMarketSource),
|
|
50
|
+
}}
|
|
51
|
+
trigger={['click', 'hover']}
|
|
52
|
+
>
|
|
53
|
+
<Button icon={<Icon icon={Store} />} type={'text'}>
|
|
54
|
+
{t('assistants.marketSource.label')}:{' '}
|
|
55
|
+
{items.find((item) => item.key === currentSource)?.label}
|
|
56
|
+
<Icon icon={ChevronDown} />
|
|
57
|
+
</Button>
|
|
58
|
+
</Dropdown>
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
MarketSourceSwitch.displayName = 'MarketSourceSwitch';
|
|
63
|
+
|
|
64
|
+
export default MarketSourceSwitch;
|
|
@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
|
|
8
8
|
import { useQuery } from '@/hooks/useQuery';
|
|
9
9
|
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
|
10
|
+
import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
|
|
10
11
|
import {
|
|
11
12
|
AssistantSorts,
|
|
12
13
|
DiscoverTab,
|
|
@@ -21,11 +22,12 @@ const SortButton = memo(() => {
|
|
|
21
22
|
const pathname = usePathname();
|
|
22
23
|
const { sort } = useQuery();
|
|
23
24
|
const router = useQueryRoute();
|
|
25
|
+
const { isAuthenticated, getCurrentUserInfo } = useMarketAuth();
|
|
24
26
|
const activeTab = useMemo(() => pathname.split('discover/')[1] as DiscoverTab, [pathname]);
|
|
25
27
|
const items = useMemo(() => {
|
|
26
28
|
switch (activeTab) {
|
|
27
29
|
case DiscoverTab.Assistants: {
|
|
28
|
-
|
|
30
|
+
const baseItems = [
|
|
29
31
|
{
|
|
30
32
|
key: AssistantSorts.CreatedAt,
|
|
31
33
|
label: t('assistants.sorts.createdAt'),
|
|
@@ -51,6 +53,16 @@ const SortButton = memo(() => {
|
|
|
51
53
|
label: t('assistants.sorts.knowledgeCount'),
|
|
52
54
|
},
|
|
53
55
|
];
|
|
56
|
+
|
|
57
|
+
// Only add "My Own" option if user is authenticated
|
|
58
|
+
if (isAuthenticated) {
|
|
59
|
+
baseItems.push({
|
|
60
|
+
key: AssistantSorts.MyOwn,
|
|
61
|
+
label: t('assistants.sorts.myown'),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return baseItems;
|
|
54
66
|
}
|
|
55
67
|
case DiscoverTab.Plugins: {
|
|
56
68
|
return [
|
|
@@ -144,7 +156,7 @@ const SortButton = memo(() => {
|
|
|
144
156
|
return [];
|
|
145
157
|
}
|
|
146
158
|
}
|
|
147
|
-
}, [t, activeTab]);
|
|
159
|
+
}, [t, activeTab, isAuthenticated]);
|
|
148
160
|
|
|
149
161
|
const activeItem: any = useMemo(() => {
|
|
150
162
|
if (sort) {
|
|
@@ -155,11 +167,18 @@ const SortButton = memo(() => {
|
|
|
155
167
|
}, [items, sort]);
|
|
156
168
|
|
|
157
169
|
const handleSort = (config: string) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
170
|
+
const query: any = { sort: config };
|
|
171
|
+
|
|
172
|
+
// If "My Own" is selected, add ownerId to query
|
|
173
|
+
if (config === AssistantSorts.MyOwn) {
|
|
174
|
+
const userInfo = getCurrentUserInfo();
|
|
175
|
+
console.log('userInfo', userInfo);
|
|
176
|
+
if (userInfo?.accountId) {
|
|
177
|
+
query.ownerId = userInfo.accountId;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
router.push(pathname, { query });
|
|
163
182
|
};
|
|
164
183
|
|
|
165
184
|
if (items?.length === 0) return null;
|
|
@@ -34,16 +34,16 @@ const Layout = memo<LayoutProps>(({ children, category }) => {
|
|
|
34
34
|
{category}
|
|
35
35
|
</Header>
|
|
36
36
|
)}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
<SettingContainer
|
|
38
|
+
addonAfter={<Footer />}
|
|
39
|
+
style={{
|
|
40
|
+
paddingBlock: 24,
|
|
41
|
+
paddingInline: 32,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</SettingContainer>
|
|
46
|
+
</Flexbox>
|
|
47
47
|
);
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -13,15 +13,16 @@ import { useCategory } from '@/features/AgentSetting/AgentCategory/useCategory';
|
|
|
13
13
|
import { ChatSettingsTabs } from '@/store/global/initialState';
|
|
14
14
|
import { useUserStore } from '@/store/user';
|
|
15
15
|
import { settingsSelectors } from '@/store/user/selectors';
|
|
16
|
-
|
|
17
|
-
import
|
|
16
|
+
|
|
17
|
+
import DesktopLayout from './_layout/Desktop';
|
|
18
|
+
import MobileLayout from './_layout/Mobile';
|
|
18
19
|
|
|
19
20
|
type AgentPageType = {
|
|
20
21
|
mobile?: boolean;
|
|
21
|
-
}
|
|
22
|
+
};
|
|
22
23
|
|
|
23
24
|
const Page = memo((props: AgentPageType) => {
|
|
24
|
-
const { mobile } = props
|
|
25
|
+
const { mobile } = props;
|
|
25
26
|
const cateItems = useCategory();
|
|
26
27
|
const [tab, setTab] = useQueryState('tab', {
|
|
27
28
|
defaultValue: ChatSettingsTabs.Prompt,
|
|
@@ -37,7 +38,6 @@ const Page = memo((props: AgentPageType) => {
|
|
|
37
38
|
|
|
38
39
|
if (!isUserStateInit) return <Skeleton active paragraph={{ rows: 5 }} title={false} />;
|
|
39
40
|
|
|
40
|
-
|
|
41
41
|
const PageContent = (
|
|
42
42
|
<>
|
|
43
43
|
{mobile && (
|
|
@@ -65,12 +65,13 @@ const Page = memo((props: AgentPageType) => {
|
|
|
65
65
|
tab={tab as ChatSettingsTabs}
|
|
66
66
|
/>
|
|
67
67
|
</>
|
|
68
|
-
)
|
|
68
|
+
);
|
|
69
69
|
|
|
70
|
-
return mobile ?
|
|
71
|
-
{PageContent}
|
|
72
|
-
|
|
73
|
-
{PageContent}</DesktopLayout
|
|
70
|
+
return mobile ? (
|
|
71
|
+
<MobileLayout>{PageContent}</MobileLayout>
|
|
72
|
+
) : (
|
|
73
|
+
<DesktopLayout>{PageContent}</DesktopLayout>
|
|
74
|
+
);
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
Page.displayName = 'AgentSetting';
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import ServerLayout from '@/components/server/ServerLayout';
|
|
2
|
+
import { serverFeatureFlags } from '@/config/featureFlags';
|
|
2
3
|
import { metadataModule } from '@/server/metadata';
|
|
3
4
|
import { translation } from '@/server/translation';
|
|
4
5
|
import { DynamicLayoutProps } from '@/types/next';
|
|
5
6
|
import { RouteVariants } from '@/utils/server/routeVariants';
|
|
6
7
|
|
|
8
|
+
import SettingsContextProvider from './_layout/ContextProvider';
|
|
7
9
|
import Desktop from './_layout/Desktop';
|
|
8
10
|
import Mobile from './_layout/Mobile';
|
|
9
11
|
import { LayoutProps } from './_layout/type';
|
|
10
12
|
|
|
11
|
-
import { serverFeatureFlags } from '@/config/featureFlags';
|
|
12
|
-
import SettingsContextProvider from './_layout/ContextProvider';
|
|
13
|
-
|
|
14
13
|
export const generateMetadata = async (props: DynamicLayoutProps) => {
|
|
15
14
|
const locale = await RouteVariants.getLocale(props);
|
|
16
15
|
const { t } = await translation('setting', locale);
|
|
@@ -21,19 +20,23 @@ export const generateMetadata = async (props: DynamicLayoutProps) => {
|
|
|
21
20
|
});
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
const SettingsLayout = ServerLayout<
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const SettingsLayout = ServerLayout<
|
|
24
|
+
LayoutProps & {
|
|
25
|
+
showLLM?: boolean;
|
|
26
|
+
}
|
|
27
|
+
>({ Desktop, Mobile });
|
|
27
28
|
|
|
28
29
|
const SettingsPage = async (props: DynamicLayoutProps) => {
|
|
29
30
|
const showLLM = serverFeatureFlags().showProvider;
|
|
30
31
|
const { showOpenAIProxyUrl, showOpenAIApiKey } = serverFeatureFlags();
|
|
31
32
|
|
|
32
33
|
return (
|
|
33
|
-
<SettingsContextProvider
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
<SettingsContextProvider
|
|
35
|
+
value={{
|
|
36
|
+
showOpenAIApiKey: showOpenAIApiKey,
|
|
37
|
+
showOpenAIProxyUrl: showOpenAIProxyUrl,
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
37
40
|
<SettingsLayout {...props} showLLM={showLLM} />
|
|
38
41
|
</SettingsContextProvider>
|
|
39
42
|
);
|
|
@@ -44,42 +44,41 @@ const ProviderItem = memo<ProviderItemProps>(
|
|
|
44
44
|
const { styles, cx } = useStyles();
|
|
45
45
|
const searchParams = useSearchParams();
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const activeKey = searchParams.get('provider');
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
49
|
+
const isCustom = source === AiProviderSourceEnum.Custom;
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
className={cx(styles.container, activeKey === id && styles.active)}
|
|
53
|
+
onClick={() => {
|
|
54
|
+
onClick(id);
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<Flexbox gap={8} horizontal>
|
|
58
|
+
{isCustom && logo ? (
|
|
59
|
+
<Avatar
|
|
60
|
+
alt={name || id}
|
|
61
|
+
avatar={logo}
|
|
62
|
+
shape={'square'}
|
|
63
|
+
size={24}
|
|
64
|
+
style={{ borderRadius: 6 }}
|
|
65
|
+
/>
|
|
66
|
+
) : (
|
|
67
|
+
<ProviderIcon provider={id} size={24} style={{ borderRadius: 6 }} type={'avatar'} />
|
|
68
|
+
)}
|
|
69
|
+
{name}
|
|
70
|
+
</Flexbox>
|
|
71
|
+
<Flexbox horizontal>
|
|
72
|
+
{enabled && (
|
|
73
|
+
<Center width={24}>
|
|
74
|
+
<Badge status="success" />
|
|
75
|
+
</Center>
|
|
76
|
+
)}
|
|
77
|
+
{/* cloud slot */}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
79
|
+
{/* cloud slot */}
|
|
80
|
+
</Flexbox>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
});
|
|
85
84
|
export default ProviderItem;
|
|
@@ -9,10 +9,8 @@ import { useAiInfraStore } from '@/store/aiInfra';
|
|
|
9
9
|
|
|
10
10
|
import ProviderItem from './Item';
|
|
11
11
|
|
|
12
|
-
const SearchResult = memo((props:{
|
|
13
|
-
onProviderSelect
|
|
14
|
-
}) => {
|
|
15
|
-
const {onProviderSelect =()=>{} } = props
|
|
12
|
+
const SearchResult = memo((props: { onProviderSelect?: (key: string) => void }) => {
|
|
13
|
+
const { onProviderSelect = () => {} } = props;
|
|
16
14
|
const { t } = useTranslation('modelProvider');
|
|
17
15
|
|
|
18
16
|
const searchKeyword = useAiInfraStore((s) => s.providerSearchKeyword);
|
|
@@ -37,7 +35,9 @@ const SearchResult = memo((props:{
|
|
|
37
35
|
{t('menu.notFound')}
|
|
38
36
|
</Flexbox>
|
|
39
37
|
) : (
|
|
40
|
-
filteredProviders.map((item) =>
|
|
38
|
+
filteredProviders.map((item) => (
|
|
39
|
+
<ProviderItem {...item} key={item.id} onClick={onProviderSelect} />
|
|
40
|
+
))
|
|
41
41
|
)}
|
|
42
42
|
</Flexbox>
|
|
43
43
|
);
|
|
@@ -5,9 +5,15 @@ import { PropsWithChildren, memo } from 'react';
|
|
|
5
5
|
import SettingContainer from '@/features/Setting/SettingContainer';
|
|
6
6
|
|
|
7
7
|
const Container = memo<PropsWithChildren>(({ children }) => {
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
return (
|
|
9
|
+
<SettingContainer
|
|
10
|
+
style={{
|
|
11
|
+
paddingBlock: 24,
|
|
12
|
+
paddingInline: 32,
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
{children}
|
|
16
|
+
</SettingContainer>
|
|
17
|
+
);
|
|
12
18
|
});
|
|
13
19
|
export default Container;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface RootLayoutProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const RootLayout = ({ children }: RootLayoutProps) => {
|
|
8
|
+
return (
|
|
9
|
+
<html lang="en" suppressHydrationWarning>
|
|
10
|
+
<body>{children}</body>
|
|
11
|
+
</html>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default RootLayout;
|