import type { FC, RefObject } from 'react' import type { InputValueTypes, TextGenerationCustomConfig, TextGenerationRunControl } from './types' import type { PromptConfig, SavedMessage, TextToSpeechConfig } from '@/models/debug' import type { SiteInfo } from '@/models/share' import type { VisionFile, VisionSettings } from '@/types/app' import type { SystemFeatures } from '@/types/feature' import { useTranslation } from 'react-i18next' import SavedItems from '@/app/components/app/text-generate/saved-items' import AppIcon from '@/app/components/base/app-icon' import Badge from '@/app/components/base/badge' import DifyLogo from '@/app/components/base/logo/dify-logo' import { appDefaultIconBackground } from '@/config' import { AccessMode } from '@/models/access-control' import { cn } from '@/utils/classnames' import TabHeader from '../../base/tab-header' import MenuDropdown from './menu-dropdown' import RunBatch from './run-batch' import RunOnce from './run-once' type TextGenerationSidebarProps = { accessMode: AccessMode allTasksRun: boolean currentTab: string customConfig: TextGenerationCustomConfig | null inputs: Record inputsRef: RefObject> isInstalledApp: boolean isPC: boolean isWorkflow: boolean onBatchSend: (data: string[][]) => void onInputsChange: (inputs: Record) => void onRemoveSavedMessage: (messageId: string) => Promise onRunOnceSend: () => void onTabChange: (tab: string) => void onVisionFilesChange: (files: VisionFile[]) => void promptConfig: PromptConfig resultExisted: boolean runControl: TextGenerationRunControl | null savedMessages: SavedMessage[] siteInfo: SiteInfo systemFeatures: SystemFeatures textToSpeechConfig: TextToSpeechConfig | null visionConfig: VisionSettings } const TextGenerationSidebar: FC = ({ accessMode, allTasksRun, currentTab, customConfig, inputs, inputsRef, isInstalledApp, isPC, isWorkflow, onBatchSend, onInputsChange, onRemoveSavedMessage, onRunOnceSend, onTabChange, onVisionFilesChange, promptConfig, resultExisted, runControl, savedMessages, siteInfo, systemFeatures, textToSpeechConfig, visionConfig, }) => { const { t } = useTranslation() return (
{siteInfo.title}
{siteInfo.description && (
{siteInfo.description}
)} , extra: savedMessages.length > 0 ? ( {savedMessages.length} ) : null, }] : []), ]} value={currentTab} onChange={onTabChange} />
{currentTab === 'saved' && ( onTabChange('create')} /> )}
{!customConfig?.remove_webapp_brand && (
{t('chat.poweredBy', { ns: 'share' })}
{systemFeatures.branding.enabled && systemFeatures.branding.workspace_logo ? logo : customConfig?.replace_webapp_logo ? logo : }
)}
) } export default TextGenerationSidebar