mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-02-07 03:21:09 +08:00
feat(agents): implement add agent functionality and migration
- Add migration for new agents structure (version 155) - Enable addAgent call in AddAgentModal - Update dependencies array with addAgent - Replace TODO comment with FIXME for model type issue
This commit is contained in:
parent
1bf63865a8
commit
941a6666e6
@ -57,7 +57,6 @@ export const AddAgentModal: React.FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const loadingRef = useRef(false)
|
||||
const { setTimeoutTimer } = useTimer()
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { addAgent } = useAgents()
|
||||
|
||||
// default values. may change to undefined.
|
||||
@ -208,14 +207,14 @@ export const AddAgentModal: React.FC = () => {
|
||||
model: form.model
|
||||
} satisfies AgentEntity
|
||||
logger.debug('Agent', agent)
|
||||
// addAgent(agent)
|
||||
addAgent(agent)
|
||||
window.toast.success(t('common.add_success'))
|
||||
loadingRef.current = false
|
||||
|
||||
setTimeoutTimer('onCreateAgent', () => EventEmitter.emit(EVENT_NAMES.SHOW_ASSISTANTS), 0)
|
||||
onClose()
|
||||
},
|
||||
[form.type, form.model, form.name, form.description, form.instructions, t, setTimeoutTimer, onClose]
|
||||
[form.type, form.model, form.name, form.description, form.instructions, addAgent, t, setTimeoutTimer, onClose]
|
||||
)
|
||||
|
||||
return (
|
||||
@ -250,7 +249,7 @@ export const AddAgentModal: React.FC = () => {
|
||||
)}
|
||||
</Select>
|
||||
<Input isRequired value={form.name} onValueChange={onNameChange} label={t('common.name')} />
|
||||
{/* Model type definition is string. It cannot be related to provider. Just mock a model now. */}
|
||||
{/* FIXME: Model type definition is string. It cannot be related to provider. Just mock a model now. */}
|
||||
<Select
|
||||
isRequired
|
||||
selectionMode="single"
|
||||
|
||||
@ -67,7 +67,7 @@ const persistedReducer = persistReducer(
|
||||
{
|
||||
key: 'cherry-studio',
|
||||
storage,
|
||||
version: 154,
|
||||
version: 155,
|
||||
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs'],
|
||||
migrate
|
||||
},
|
||||
|
||||
@ -2463,6 +2463,15 @@ const migrateConfig = {
|
||||
logger.error('migrate 154 error', error as Error)
|
||||
return state
|
||||
}
|
||||
},
|
||||
'155': (state: RootState) => {
|
||||
try {
|
||||
state.agents.agentsNew = []
|
||||
return state
|
||||
} catch (error) {
|
||||
logger.error('migrate 155 error', error as Error)
|
||||
return state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user