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.4 KB
Raw Blame
import type { SegmentResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import TagInput from '@/app/components/base/tag-input'

type IKeywordsProps = {
  segInfo?: Partial<SegmentResponse> & { id: string }
  className?: string
  keywords: string[]
  onKeywordsChange: (keywords: string[]) => void
  isEditMode?: boolean
  actionType?: 'edit' | 'add' | 'view'
}

const Keywords: FC<IKeywordsProps> = ({
  segInfo,
  className,
  keywords,
  onKeywordsChange,
  isEditMode,
  actionType = 'view',
}) => {
  const { t } = useTranslation(['datasetDocuments'])
  return (
    <div className={cn('flex flex-col', className)}>
      <div className="system-xs-medium-uppercase text-text-tertiary">
        {t(($) => $['segment.keywords'], { ns: 'datasetDocuments' })}
      </div>
      <div className="flex max-h-50 w-full flex-wrap gap-1 overflow-auto text-text-tertiary">
        {!segInfo?.keywords?.length && actionType === 'view' ? (
          '-'
        ) : (
          <TagInput
            items={keywords}
            onChange={(newKeywords) => onKeywordsChange(newKeywords)}
            disableAdd={!isEditMode}
            disableRemove={!isEditMode || keywords.length === 1}
          />
        )}
      </div>
    </div>
  )
}

Keywords.displayName = 'Keywords'

export default React.memo(Keywords)