-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: support model provider groq (#1562)
- Loading branch information
Showing
23 changed files
with
307 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Perplexity } from '@lobehub/icons'; | ||
import { Input } from 'antd'; | ||
import { useTheme } from 'antd-style'; | ||
import { memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { ModelProvider } from '@/libs/agent-runtime'; | ||
|
||
import Checker from '../components/Checker'; | ||
import ProviderConfig from '../components/ProviderConfig'; | ||
import { LLMProviderApiTokenKey, LLMProviderConfigKey } from '../const'; | ||
|
||
const providerKey = 'groq'; | ||
|
||
const GroqProvider = memo(() => { | ||
const { t } = useTranslation('setting'); | ||
|
||
const theme = useTheme(); | ||
|
||
return ( | ||
<ProviderConfig | ||
configItems={[ | ||
{ | ||
children: ( | ||
<Input.Password | ||
autoComplete={'new-password'} | ||
placeholder={t('llm.Groq.token.placeholder')} | ||
/> | ||
), | ||
desc: t('llm.Groq.token.desc'), | ||
label: t('llm.Groq.token.title'), | ||
name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey], | ||
}, | ||
{ | ||
children: <Checker model={'gemma-7b-it'} provider={ModelProvider.Groq} />, | ||
desc: t('llm.checker.desc'), | ||
label: t('llm.checker.title'), | ||
minWidth: '100%', | ||
}, | ||
]} | ||
provider={providerKey} | ||
title={ | ||
<Perplexity.Combine | ||
color={theme.isDarkMode ? theme.colorText : Perplexity.colorPrimary} | ||
size={24} | ||
/> | ||
} | ||
/> | ||
); | ||
}); | ||
|
||
export default GroqProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ModelProviderCard } from '@/types/llm'; | ||
|
||
const Groq: ModelProviderCard = { | ||
chatModels: [ | ||
{ | ||
displayName: 'LLaMA2-70b-chat', | ||
id: 'llama2-70b-4096', | ||
tokens: 4096, | ||
}, | ||
{ | ||
displayName: 'Mixtral-8x7b-Instruct-v0.1', | ||
id: 'mixtral-8x7b-32768', | ||
tokens: 32_768, | ||
}, | ||
{ | ||
displayName: 'Gemma-7b-it', | ||
id: 'gemma-7b-it', | ||
tokens: 8192, | ||
}, | ||
], | ||
id: 'groq', | ||
}; | ||
|
||
export default Groq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Groq } 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 GroqForm = memo(() => { | ||
const { t } = useTranslation('error'); | ||
// const [showProxy, setShow] = useState(false); | ||
|
||
const [apiKey, setConfig] = useGlobalStore((s) => [ | ||
modelProviderSelectors.groqAPIKey(s), | ||
s.setModelProviderConfig, | ||
]); | ||
|
||
return ( | ||
<FormAction | ||
avatar={<Groq size={56} />} | ||
description={t('unlock.apikey.Groq.description')} | ||
title={t('unlock.apikey.Groq.title')} | ||
> | ||
<Input.Password | ||
autoComplete={'new-password'} | ||
onChange={(e) => { | ||
setConfig(ModelProvider.Groq, { 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 GroqForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.