mirror of
https://github.com/langgenius/dify.git
synced 2026-08-28 18:13:21 +08:00
Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Yansong Zhang <916125788@qq.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
25 lines
839 B
TypeScript
25 lines
839 B
TypeScript
import type { AgentSkill } from '../form-state'
|
|
import type { DraftFieldUpdate } from './utils'
|
|
import { atom } from 'jotai'
|
|
import { syncSkillReferenceLabels } from '../reference-labels'
|
|
import { agentComposerDraftAtom } from '../store'
|
|
import { resolveDraftFieldUpdate } from './utils'
|
|
|
|
export const agentComposerSkillsAtom = atom<AgentSkill[], [DraftFieldUpdate<AgentSkill[]>], void>(
|
|
get => get(agentComposerDraftAtom).skills,
|
|
(get, set, skillsUpdate: DraftFieldUpdate<AgentSkill[]>) => {
|
|
const draft = get(agentComposerDraftAtom)
|
|
const skills = resolveDraftFieldUpdate(draft.skills, skillsUpdate)
|
|
|
|
set(agentComposerDraftAtom, {
|
|
...draft,
|
|
prompt: syncSkillReferenceLabels({
|
|
prompt: draft.prompt,
|
|
currentSkills: draft.skills,
|
|
nextSkills: skills,
|
|
}),
|
|
skills,
|
|
})
|
|
},
|
|
)
|