Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: support 01.AI as a new provider #1627

Merged
merged 16 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
✨ feat: add 01.AI APIKey Error Form
  • Loading branch information
MapleEve committed Mar 20, 2024
commit 774f4c6528888b1064f0c7b71ebae60d39b26097
60 changes: 60 additions & 0 deletions src/features/Conversation/Error/APIKeyForm/ZeroOne.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { ZeroOne } from '@lobehub/icons';
import { Input } from 'antd';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import { ModelProvider } from '@/libs/agent-runtime';
import { useGlobalStore } from '@/store/global';
import { modelProviderSelectors } from '@/store/global/selectors';

import { FormAction } from '../style';

const ZeroOneForm = memo(() => {
const { t } = useTranslation('error');
// const [showProxy, setShow] = useState(false);

const [apiKey, setConfig] = useGlobalStore((s) => [
modelProviderSelectors.zerooneAPIKey(s),
s.setModelProviderConfig,
]);

return (
<FormAction
avatar={<ZeroOne size={56} />}
description={t('unlock.apikey.ZeroOne.description')}
title={t('unlock.apikey.ZeroOne.title')}
>
<Input.Password
autoComplete={'new-password'}
onChange={(e) => {
setConfig(ModelProvider.ZeroOne, { apiKey: e.target.value });
}}
placeholder={'*********************************'}
type={'block'}
value={apiKey}
/>
{/*{showProxy ? (*/}
{/* <Input*/}
{/* onChange={(e) => {*/}
{/* setConfig({ endpoint: e.target.value });*/}
{/* }}*/}
{/* placeholder={'https://api.openai.com/v1'}*/}
{/* type={'block'}*/}
{/* value={proxyUrl}*/}
{/* />*/}
{/*) : (*/}
{/* <Button*/}
{/* icon={<Icon icon={Network} />}*/}
{/* onClick={() => {*/}
{/* setShow(true);*/}
{/* }}*/}
{/* type={'text'}*/}
{/* >*/}
{/* {t('unlock.apikey.addProxyUrl')}*/}
{/* </Button>*/}
{/*)}*/}
</FormAction>
);
});

export default ZeroOneForm;
7 changes: 6 additions & 1 deletion src/features/Conversation/Error/APIKeyForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import MoonshotForm from './Moonshot';
import OpenAIForm from './OpenAI';
import OpenRouterForm from './OpenRouter';
import PerplexityForm from './Perplexity';
import ZeroOneForm from './ZeroOne';
import ZhipuForm from './Zhipu';

interface APIKeyFormProps {
Expand Down Expand Up @@ -60,11 +61,15 @@ const APIKeyForm = memo<APIKeyFormProps>(({ id, provider }) => {
case ModelProvider.Groq: {
return <GroqForm />;
}

case ModelProvider.OpenRouter: {
return <OpenRouterForm />;
}

case ModelProvider.ZeroOne: {
return <ZeroOneForm />;
}

default:
case ModelProvider.OpenAI: {
return <OpenAIForm />;
Expand Down
Loading