feat(settings): default assistant settings
This commit is contained in:
parent
7dc0b98f3a
commit
1d67845c69
@ -34,7 +34,7 @@ const AssistantSettingPopupContainer: React.FC<Props> = ({ assistant, resolve })
|
||||
return (
|
||||
<Modal title={assistant.name} open={open} onOk={onOk} onCancel={handleCancel} afterClose={onClose}>
|
||||
<Box mb={8}>Name</Box>
|
||||
<Input placeholder="Assistant Name" value={name} onChange={(e) => setName(e.target.value)} autoFocus />
|
||||
<Input placeholder="Assistant Name" value={name} onChange={(e) => setName(e.target.value)} />
|
||||
<Box mt={8} mb={8}>
|
||||
Description
|
||||
</Box>
|
||||
@ -43,18 +43,11 @@ const AssistantSettingPopupContainer: React.FC<Props> = ({ assistant, resolve })
|
||||
placeholder="Assistant Description"
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
autoFocus
|
||||
/>
|
||||
<Box mt={8} mb={8}>
|
||||
Prompt
|
||||
</Box>
|
||||
<TextArea
|
||||
rows={4}
|
||||
placeholder="Assistant Prompt"
|
||||
value={prompt}
|
||||
onChange={(e) => setPrompt(e.target.value)}
|
||||
autoFocus
|
||||
/>
|
||||
<TextArea rows={4} placeholder="Assistant Prompt" value={prompt} onChange={(e) => setPrompt(e.target.value)} />
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import {
|
||||
removeAllTopics as _removeAllTopics,
|
||||
removeTopic as _removeTopic,
|
||||
setModel as _setModel,
|
||||
updateDefaultAssistant as _updateDefaultAssistant,
|
||||
updateTopic as _updateTopic,
|
||||
addAssistant,
|
||||
removeAssistant,
|
||||
@ -47,6 +48,16 @@ export function useAssistant(id: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export function useDefaultAssistant() {
|
||||
const { defaultAssistant } = useAppSelector((state) => state.assistants)
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
return {
|
||||
defaultAssistant,
|
||||
updateDefaultAssistant: (assistant: Assistant) => dispatch(_updateDefaultAssistant({ assistant }))
|
||||
}
|
||||
}
|
||||
|
||||
export function useDefaultModel() {
|
||||
const { defaultModel, topicNamingModel } = useAppSelector((state) => state.llm)
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { Navbar, NavbarLeft, NavbarRight } from '@renderer/components/app/Navbar'
|
||||
import { useAssistants } from '@renderer/hooks/useAssistant'
|
||||
import { useAssistants, useDefaultAssistant } from '@renderer/hooks/useAssistant'
|
||||
import { FC, useState } from 'react'
|
||||
import styled from 'styled-components'
|
||||
import Chat from './components/Chat'
|
||||
import Assistants from './components/Assistants'
|
||||
import { uuid } from '@renderer/utils'
|
||||
import { getDefaultAssistant } from '@renderer/services/assistant'
|
||||
import { useShowRightSidebar } from '@renderer/hooks/useStore'
|
||||
import { Tooltip } from 'antd'
|
||||
import Navigation from './components/Navigation'
|
||||
@ -14,12 +13,12 @@ const HomePage: FC = () => {
|
||||
const { assistants, addAssistant } = useAssistants()
|
||||
const [activeAssistant, setActiveAssistant] = useState(assistants[0])
|
||||
const { showRightSidebar, setShowRightSidebar } = useShowRightSidebar()
|
||||
const { defaultAssistant } = useDefaultAssistant()
|
||||
|
||||
const onCreateAssistant = () => {
|
||||
const _assistant = getDefaultAssistant()
|
||||
_assistant.id = uuid()
|
||||
addAssistant(_assistant)
|
||||
setActiveAssistant(_assistant)
|
||||
const assistant = { ...defaultAssistant, id: uuid() }
|
||||
addAssistant(assistant)
|
||||
setActiveAssistant(assistant)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -1,11 +1,38 @@
|
||||
import { FC } from 'react'
|
||||
import styled from 'styled-components'
|
||||
import { SettingContainer, SettingDivider, SettingSubtitle, SettingTitle } from './components/SettingComponent'
|
||||
import { Input } from 'antd'
|
||||
import TextArea from 'antd/es/input/TextArea'
|
||||
import { useDefaultAssistant } from '@renderer/hooks/useAssistant'
|
||||
|
||||
const AssistantSettings: FC = () => {
|
||||
return <Container>Default Assistant</Container>
|
||||
const { defaultAssistant, updateDefaultAssistant } = useDefaultAssistant()
|
||||
|
||||
return (
|
||||
<SettingContainer>
|
||||
<SettingTitle>Default Assistant</SettingTitle>
|
||||
<SettingDivider />
|
||||
<SettingSubtitle>Name</SettingSubtitle>
|
||||
<Input
|
||||
placeholder="Assistant Name"
|
||||
value={defaultAssistant.name}
|
||||
onChange={(e) => updateDefaultAssistant({ ...defaultAssistant, name: e.target.value })}
|
||||
/>
|
||||
<SettingSubtitle>Description</SettingSubtitle>
|
||||
<TextArea
|
||||
rows={4}
|
||||
placeholder="Assistant Description"
|
||||
value={defaultAssistant.description}
|
||||
onChange={(e) => updateDefaultAssistant({ ...defaultAssistant, description: e.target.value })}
|
||||
/>
|
||||
<SettingSubtitle>Prompt</SettingSubtitle>
|
||||
<TextArea
|
||||
rows={4}
|
||||
placeholder="Assistant Prompt"
|
||||
value={defaultAssistant.prompt}
|
||||
onChange={(e) => updateDefaultAssistant({ ...defaultAssistant, prompt: e.target.value })}
|
||||
/>
|
||||
</SettingContainer>
|
||||
)
|
||||
}
|
||||
|
||||
const Container = styled.div`
|
||||
padding: 20px;
|
||||
`
|
||||
export default AssistantSettings
|
||||
|
||||
@ -5,10 +5,12 @@ import { Assistant, Model, Topic } from '@renderer/types'
|
||||
import { uniqBy } from 'lodash'
|
||||
|
||||
export interface AssistantsState {
|
||||
defaultAssistant: Assistant
|
||||
assistants: Assistant[]
|
||||
}
|
||||
|
||||
const initialState: AssistantsState = {
|
||||
defaultAssistant: getDefaultAssistant(),
|
||||
assistants: [getDefaultAssistant()]
|
||||
}
|
||||
|
||||
@ -16,6 +18,9 @@ const assistantsSlice = createSlice({
|
||||
name: 'assistants',
|
||||
initialState,
|
||||
reducers: {
|
||||
updateDefaultAssistant: (state, action: PayloadAction<{ assistant: Assistant }>) => {
|
||||
state.defaultAssistant = action.payload.assistant
|
||||
},
|
||||
addAssistant: (state, action: PayloadAction<Assistant>) => {
|
||||
state.assistants.push(action.payload)
|
||||
},
|
||||
@ -83,6 +88,7 @@ const assistantsSlice = createSlice({
|
||||
})
|
||||
|
||||
export const {
|
||||
updateDefaultAssistant,
|
||||
addAssistant,
|
||||
removeAssistant,
|
||||
updateAssistant,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user