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.1 KB
Raw Blame
'use client'

import { useAtomValueRawSync, useSetAtom } from 'jotai'
import { useLayoutEffect } from 'react'
import { KnowledgeModelSetupDialog } from '../components/knowledge-model-setup-dialog'
import { useKnowledgeModelSetupGuard } from '../use-knowledge-model-setup-guard'
import { documentsKnowledgeSpaceIdAtom } from './state/inputs'
import { documentModelReadyActionAtom } from './state/runtime'

export function DocumentModelRuntimeController() {
  const knowledgeSpaceId = useAtomValueRawSync(documentsKnowledgeSpaceIdAtom)
  const {
    configureModelSetup,
    ensureModelReady,
    modelReadiness,
    modelSetupDialogOpen,
    setModelSetupDialogOpen,
  } = useKnowledgeModelSetupGuard(knowledgeSpaceId)
  const setModelReadyAction = useSetAtom(documentModelReadyActionAtom)
  useLayoutEffect(() => {
    setModelReadyAction({ ensureModelReady })
  }, [ensureModelReady, setModelReadyAction])

  return (
    <KnowledgeModelSetupDialog
      open={modelSetupDialogOpen}
      readiness={modelReadiness}
      onOpenChange={setModelSetupDialogOpen}
      onConfigure={configureModelSetup}
    />
  )
}