Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

869 B
Raw Blame
import type { AgentSoulAppFeaturesConfig } from '@dify/contracts/api/console/agent/types.gen'
import type { DraftFieldUpdate } from './utils'
import { atom, useAtomValue, useSetAtom } from 'jotai'
import { agentComposerDraftAtom } from '../store'
import { resolveDraftFieldUpdate } from './utils'

export const agentComposerAppFeaturesAtom = atom(
  (get) => get(agentComposerDraftAtom).appFeatures,
  (get, set, appFeaturesUpdate: DraftFieldUpdate<AgentSoulAppFeaturesConfig | undefined>) => {
    const draft = get(agentComposerDraftAtom)

    set(agentComposerDraftAtom, {
      ...draft,
      appFeatures: resolveDraftFieldUpdate(draft.appFeatures, appFeaturesUpdate),
    })
  },
)

export function useAppFeatures() {
  return useAtomValue(agentComposerAppFeaturesAtom)
}

export function useSetAppFeatures() {
  return useSetAtom(agentComposerAppFeaturesAtom)
}