import { Button } from '@langgenius/dify-ui/button' import { cn } from '@langgenius/dify-ui/cn' import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip' import { RiApps2AddLine, RiArrowRightLine, RiSparklingFill } from '@remixicon/react' import * as React from 'react' import { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { useFeatures } from '@/app/components/base/features/hooks' import VoiceSettings from '@/app/components/base/features/new-feature-panel/text-to-speech/voice-settings' import { Citations, ContentModeration, FolderUpload, LoveMessage, MessageFast, Microphone01, TextToAudio, VirtualAssistant, } from '@/app/components/base/icons/src/vender/features' type Props = Readonly<{ isChatMode?: boolean showFileUpload?: boolean disabled?: boolean onFeatureBarClick?: (state: boolean) => void hideEditEntrance?: boolean }> const FeatureBar = ({ isChatMode = true, showFileUpload = true, disabled, onFeatureBarClick, hideEditEntrance = false, }: Props) => { const { t } = useTranslation() const features = useFeatures((s) => s.features) const [modalOpen, setModalOpen] = useState(false) const noFeatureEnabled = useMemo(() => { // completion app citation is always true but not enabled for setting const data = { ...features, citation: { enabled: isChatMode ? features.citation?.enabled : false }, file: showFileUpload ? features.file! : { enabled: false }, } return !Object.values(data).some((f) => f.enabled) }, [features, isChatMode, showFileUpload]) return (
{noFeatureEnabled && (
onFeatureBarClick?.(true)} >
{t(($) => $['feature.bar.empty'], { ns: 'appDebug' })}
)} {!noFeatureEnabled && (
{!!features.moreLikeThis?.enabled && (
} /> {t(($) => $['feature.moreLikeThis.title'], { ns: 'appDebug' })} )} {!!features.opening?.enabled && (
} /> {t(($) => $['feature.conversationOpener.title'], { ns: 'appDebug' })} )} {!!features.moderation?.enabled && (
} /> {t(($) => $['feature.moderation.title'], { ns: 'appDebug' })} )} {!!features.speech2text?.enabled && ( } /> {t(($) => $['feature.speechToText.title'], { ns: 'appDebug' })} )} {!!features.text2speech?.enabled && ( } /> {t(($) => $['feature.textToSpeech.title'], { ns: 'appDebug' })} )} {showFileUpload && !!features.file?.enabled && ( } /> {t(($) => $['feature.fileUpload.title'], { ns: 'appDebug' })} )} {!!features.suggested?.enabled && ( } /> {t(($) => $['feature.suggestedQuestionsAfterAnswer.title'], { ns: 'appDebug' })} )} {isChatMode && !!features.citation?.enabled && ( } /> {t(($) => $['feature.citation.title'], { ns: 'appDebug' })} )} {isChatMode && !!features.annotationReply?.enabled && ( } /> {t(($) => $['feature.annotation.title'], { ns: 'appDebug' })} )}
{t(($) => $['feature.bar.enableText'], { ns: 'appDebug' })}
{!hideEditEntrance && ( )} )} ) } export default FeatureBar