-
-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
294 additions
and
89 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,106 @@ | ||
import { TextArea } from '@lobehub/ui'; | ||
import { Button, Collapse, InputNumber, Segmented, Slider } from 'antd'; | ||
import isEqual from 'fast-deep-equal'; | ||
import { useTranslation } from 'next-i18next'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
import { shallow } from 'zustand/shallow'; | ||
|
||
import { agentSelectors, useSessionStore } from '@/store/session'; | ||
import { LanguageModel } from '@/types/llm'; | ||
|
||
import { FormItem } from './FormItem'; | ||
import { useStyles } from './style'; | ||
|
||
const AgentConfig = () => { | ||
const { t } = useTranslation('common'); | ||
|
||
const { styles, theme } = useStyles(); | ||
|
||
const config = useSessionStore(agentSelectors.currentAgentConfigSafe, isEqual); | ||
|
||
const [updateAgentConfig] = useSessionStore((s) => [s.updateAgentConfig], shallow); | ||
|
||
return ( | ||
<> | ||
<Flexbox | ||
align={'center'} | ||
distribution={'space-between'} | ||
horizontal | ||
paddingBlock={12} | ||
style={{ | ||
borderBottom: `1px solid ${theme.colorBorder}`, | ||
}} | ||
> | ||
<Flexbox className={styles.profile}> {t('modelConfig')}</Flexbox> | ||
</Flexbox> | ||
<Flexbox gap={24}> | ||
<FormItem label={t('agentModel')}> | ||
<Segmented | ||
block | ||
onChange={(value) => { | ||
updateAgentConfig({ model: value as LanguageModel }); | ||
}} | ||
options={Object.values(LanguageModel).map((value) => ({ | ||
label: t(value), | ||
value, | ||
}))} | ||
size={'large'} | ||
/> | ||
</FormItem> | ||
<FormItem label={t('agentPrompt')}> | ||
<Flexbox gap={16}> | ||
<TextArea | ||
placeholder={t('agentPromptPlaceholder')} | ||
style={{ minHeight: 160 }} | ||
type={'block'} | ||
value={config.systemRole} | ||
/> | ||
<Flexbox direction={'horizontal-reverse'}> | ||
<Button type={'primary'}>{t('updatePrompt')}</Button> | ||
</Flexbox> | ||
</Flexbox> | ||
</FormItem> | ||
<Collapse | ||
activeKey={['advanceSettings']} | ||
bordered={false} | ||
className={styles.title} | ||
expandIconPosition={'end'} | ||
items={[ | ||
{ | ||
children: ( | ||
<Flexbox paddingBlock={16}> | ||
<FormItem label={t('modelTemperature')}> | ||
<Flexbox gap={16} horizontal> | ||
<Slider | ||
max={1} | ||
min={0} | ||
onChange={(value) => { | ||
updateAgentConfig({ params: { temperature: value } }); | ||
}} | ||
step={0.1} | ||
style={{ flex: 1 }} | ||
value={Number(config.params.temperature)} | ||
/> | ||
<InputNumber | ||
max={1} | ||
min={0} | ||
onChange={(value) => { | ||
if (value) updateAgentConfig({ params: { temperature: value } }); | ||
}} | ||
value={config.params.temperature} | ||
/> | ||
</Flexbox> | ||
</FormItem> | ||
</Flexbox> | ||
), | ||
key: 'advanceSettings', | ||
label: t('advanceSettings'), | ||
}, | ||
]} | ||
/> | ||
</Flexbox> | ||
</> | ||
); | ||
}; | ||
|
||
export default AgentConfig; |
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,84 @@ | ||
import { ActionIcon, Avatar, Input } from '@lobehub/ui'; | ||
import { Button } from 'antd'; | ||
import isEqual from 'fast-deep-equal'; | ||
import { LucideSparkles } from 'lucide-react'; | ||
import { useTranslation } from 'next-i18next'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
import { shallow } from 'zustand/shallow'; | ||
|
||
import { agentSelectors, useSessionStore } from '@/store/session'; | ||
|
||
import { FormItem } from './FormItem'; | ||
import { useStyles } from './style'; | ||
|
||
const AgentMeta = () => { | ||
const { t } = useTranslation('common'); | ||
|
||
const { styles, theme } = useStyles(); | ||
|
||
const metaData = useSessionStore(agentSelectors.currentAgentMeta, isEqual); | ||
|
||
const [autocompleteMeta, loading] = useSessionStore( | ||
(s) => [s.autocompleteMeta, s.autocompleteLoading], | ||
shallow, | ||
); | ||
|
||
const basic = [ | ||
{ key: 'title', label: t('agentName'), placeholder: t('agentNamePlaceholder') }, | ||
{ | ||
key: 'description', | ||
label: t('agentDescription'), | ||
placeholder: t('agentDescriptionPlaceholder'), | ||
}, | ||
// { key: 'tag', label: t('agentTag'), placeholder: t('agentTagPlaceholder') }, | ||
]; | ||
|
||
return ( | ||
<> | ||
<Flexbox | ||
align={'center'} | ||
distribution={'space-between'} | ||
horizontal | ||
paddingBlock={12} | ||
style={{ | ||
borderBottom: `1px solid ${theme.colorBorder}`, | ||
}} | ||
> | ||
<Flexbox className={styles.profile}> {t('profile')}</Flexbox> | ||
<Button size={'large'}>{t('autoGenerate')}</Button> | ||
</Flexbox> | ||
<Flexbox gap={80} horizontal style={{ marginTop: 16 }}> | ||
<Flexbox flex={1} gap={24}> | ||
{basic.map((item) => ( | ||
<FormItem key={item.key} label={item.label}> | ||
<Input | ||
placeholder={item.placeholder} | ||
suffix={ | ||
<ActionIcon | ||
icon={LucideSparkles} | ||
loading={loading[item.key as keyof typeof loading]} | ||
onClick={() => { | ||
autocompleteMeta(item.key as keyof typeof metaData); | ||
}} | ||
size={'small'} | ||
style={{ | ||
color: theme.purple, | ||
}} | ||
title={t('autoGenerate')} | ||
/> | ||
} | ||
type={'block'} | ||
value={metaData[item.key as keyof typeof metaData]} | ||
/> | ||
</FormItem> | ||
))} | ||
</Flexbox> | ||
<FormItem label={t('agentAvatar')}> | ||
<Avatar avatar={metaData.avatar} size={200} /> | ||
</FormItem> | ||
</Flexbox> | ||
</> | ||
); | ||
}; | ||
|
||
export default AgentMeta; |
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.
d95027d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
lobe-chat – ./
lobe-chat-lobehub.vercel.app
lobe-chat-git-master-lobehub.vercel.app
lobeweb-chat.vercel.app
chat.lobehub.com