Skip to content

Commit

Permalink
add provider detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Dec 23, 2024
1 parent a586561 commit 09c2bf0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/app/(main)/settings/provider/ProviderList/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ const ProviderCard = memo<ProviderCardProps>(({ id, description, name }) => {
style={{ color: theme.colorText }}
title={name}
/>
{/*<SyncSwitch value={enabled} />*/}
<Switch checked={enabled} size={'small'} />
</Flexbox>
{description && (
Expand Down
6 changes: 3 additions & 3 deletions src/app/(main)/settings/provider/ProviderMenu/All.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Link from 'next/link';
import { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import { useStyles } from './Item';

const All = memo(() => {
const { styles } = useStyles();
return (
<Flexbox className={styles.container} gap={8} horizontal>
<Link className={styles.container} href={'/settings/provider'}>
全部
</Flexbox>
</Link>
);
});
export default All;
2 changes: 1 addition & 1 deletion src/app/(main)/settings/provider/ProviderMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ProviderItem from './Item';

const ProviderMenu = () => {
return (
<Flexbox padding={8} style={{ overflow: 'scroll' }} width={320}>
<Flexbox padding={8} style={{ overflow: 'scroll' }} width={260}>
<All />
{DEFAULT_MODEL_PROVIDER_LIST.map((item) => (
<ProviderItem {...item} key={item.id} />
Expand Down
12 changes: 11 additions & 1 deletion src/app/(main)/settings/provider/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
import { PagePropsWithId } from '@/types/next';

import ProviderConfig from '../components/ProviderConfig';

const Page = async (props: PagePropsWithId) => {
const params = await props.params;

return <div> {params.id}</div>;
const card = DEFAULT_MODEL_PROVIDER_LIST.find((v) => v.id === params.id);
if (!card) return <div>not found</div>;

return (
<div>
<ProviderConfig {...card} />
</div>
);
};

export default Page;
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ import {
LLMProviderApiTokenKey,
LLMProviderBaseUrlKey,
LLMProviderConfigKey,
LLMProviderModelListKey,
} from '@/app/(main)/settings/llm/const';
import { FORM_STYLE } from '@/const/layoutTokens';
import { AES_GCM_URL, BASE_PROVIDER_DOC_URL } from '@/const/url';
import { isServerMode } from '@/const/version';
import { useUserStore } from '@/store/user';
import { keyVaultsConfigSelectors, modelConfigSelectors } from '@/store/user/selectors';
import { ModelProviderCard } from '@/types/llm';
import { GlobalLLMProviderKey } from '@/types/user/settings';

import Checker from '../Checker';
import ProviderModelListSelect from '../ProviderModelList';

const useStyles = createStyles(({ css, prefixCls, responsive, token }) => ({
aceGcm: css`
Expand Down Expand Up @@ -89,7 +86,7 @@ export interface ProviderConfigProps extends Omit<ModelProviderCard, 'id' | 'cha
className?: string;
extra?: ReactNode;
hideSwitch?: boolean;
id: GlobalLLMProviderKey;
id: string;
modelList?: {
azureDeployName?: boolean;
notFoundContent?: ReactNode;
Expand Down Expand Up @@ -206,20 +203,20 @@ const ProviderConfig = memo<ProviderConfigProps>(
label: t('llm.fetchOnClient.title'),
minWidth: undefined,
},
{
children: (
<ProviderModelListSelect
notFoundContent={modelList?.notFoundContent}
placeholder={modelList?.placeholder ?? t('llm.modelList.placeholder')}
provider={id}
showAzureDeployName={modelList?.azureDeployName}
showModelFetcher={modelList?.showModelFetcher}
/>
),
desc: t('llm.modelList.desc'),
label: t('llm.modelList.title'),
name: [LLMProviderConfigKey, id, LLMProviderModelListKey],
},
// {
// children: (
// <ProviderModelListSelect
// notFoundContent={modelList?.notFoundContent}
// placeholder={modelList?.placeholder ?? t('llm.modelList.placeholder')}
// provider={id}
// showAzureDeployName={modelList?.azureDeployName}
// showModelFetcher={modelList?.showModelFetcher}
// />
// ),
// desc: t('llm.modelList.desc'),
// label: t('llm.modelList.title'),
// name: [LLMProviderConfigKey, id, LLMProviderModelListKey],
// },
showChecker
? (checkerItem ?? {
children: <Checker model={checkModel!} provider={id} />,
Expand All @@ -231,14 +228,10 @@ const ProviderConfig = memo<ProviderConfigProps>(
showAceGcm && isServerMode && aceGcmItem,
].filter(Boolean) as FormItemProps[];

/* ↓ cloud slot ↓ */

/* ↑ cloud slot ↑ */

const model: ItemGroup = {
children: formItems,

defaultActive: canDeactivate ? enabled : undefined,
defaultActive: true,

extra: (
<Flexbox align={'center'} gap={8} horizontal>
Expand Down Expand Up @@ -283,8 +276,10 @@ const ProviderConfig = memo<ProviderConfigProps>(
<Form
className={cx(styles.form, className)}
form={form}
items={[model]}
onValuesChange={debounce(setSettings, 100)}
variant={'pure'}
// items={formItems}
items={[model]}
{...FORM_STYLE}
/>
);
Expand Down

0 comments on commit 09c2bf0

Please sign in to comment.