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.

1.6 KB
Raw Blame
import type { EditorResource } from './resource'
import { atom } from 'jotai'
import { atomWithLazy } from 'jotai/utils'
import { isChatflow } from './resource'

export const editorResourceAtom = atomWithLazy<EditorResource>(() => {
  throw new Error('EditorResourceScope is required for the workflow editor')
})

export const editorResourceKindAtom = atom((get) => get(editorResourceAtom).kind)
export const editorCollaborationEnabledAtom = atom((get) => {
  const resource = get(editorResourceAtom)
  return resource.kind === 'app' && resource.collaborationEnabled
})
export const editorAppIdAtom = atom((get) => {
  const resource = get(editorResourceAtom)
  return resource.kind === 'app' ? resource.appId : undefined
})
export const editorPipelineIdAtom = atom((get) => {
  const resource = get(editorResourceAtom)
  return resource.kind === 'knowledge-pipeline' ? resource.pipelineId : undefined
})

export const isChatflowAtom = atom((get) => isChatflow(get(editorResourceAtom)))

export const workflowAppIdentityAtom = atom((get) => {
  const resource = get(editorResourceAtom)
  if (resource.kind !== 'app') throw new Error('This operation requires a workflow app editor')
  return resource
})

export const knowledgePipelineIdentityAtom = atom((get) => {
  const resource = get(editorResourceAtom)
  if (resource.kind !== 'knowledge-pipeline')
    throw new Error('This operation requires a knowledge pipeline editor')
  return resource
})

export const snippetIdentityAtom = atom((get) => {
  const resource = get(editorResourceAtom)
  if (resource.kind !== 'snippet') throw new Error('This operation requires a snippet editor')
  return resource
})