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.

2.0 KB
Raw Blame
'use client'

import type { AgentSoulConfig } from '@dify/contracts/api/console/agent/types.gen'
import type { AgentConfigureConversationIds, AgentConfigureRightPanelMode } from '../../state'
import { useAgentPreviewSoulConfig } from '../../hooks'
import { AgentBuildChat } from './build-chat'
import { AgentPreviewChat } from './preview-chat'

export function AgentConfigureRightPanelChat({
  agentSoulConfig,
  conversationIds,
  mode,
  onConversationComplete,
  onConversationIdChange,
  ...props
}: Omit<
  Parameters<typeof AgentPreviewChat>[0],
  'agentSoulConfig' | 'conversationId' | 'onConversationComplete' | 'onConversationIdChange'
> & {
  agentSoulConfig?: AgentSoulConfig
  conversationIds: AgentConfigureConversationIds
  mode: AgentConfigureRightPanelMode
  onConversationComplete?: (
    mode: AgentConfigureRightPanelMode,
    conversationId: string,
    workflowRunId?: string,
  ) => void
  onConversationIdChange: (mode: AgentConfigureRightPanelMode, conversationId: string) => void
}) {
  const previewAgentSoulConfig = useAgentPreviewSoulConfig(agentSoulConfig)
  const conversationId = conversationIds[mode]
  const handleConversationIdChange = (newConversationId: string) => {
    onConversationIdChange(mode, newConversationId)
  }
  const handleConversationComplete = (completedConversationId: string, workflowRunId?: string) => {
    onConversationComplete?.(mode, completedConversationId, workflowRunId)
  }

  return mode === 'build' ? (
    <AgentBuildChat
      {...props}
      conversationId={conversationId}
      agentSoulConfig={previewAgentSoulConfig}
      onConversationComplete={handleConversationComplete}
      onConversationIdChange={handleConversationIdChange}
    />
  ) : (
    <AgentPreviewChat
      {...props}
      inputAutoFocus={false}
      conversationId={conversationId}
      agentSoulConfig={previewAgentSoulConfig}
      onConversationComplete={handleConversationComplete}
      onConversationIdChange={handleConversationIdChange}
    />
  )
}