| import Switch from '@/app/components/base/switch' | import Switch from '@/app/components/base/switch' | ||||
| import Toast from '@/app/components/base/toast' | import Toast from '@/app/components/base/toast' | ||||
| import Divider from '@/app/components/base/divider' | import Divider from '@/app/components/base/divider' | ||||
| import { noop } from 'lodash-es' | |||||
| type Props = { | type Props = { | ||||
| datasetConfigs: DatasetConfigs | datasetConfigs: DatasetConfigs | ||||
| onChange, | onChange, | ||||
| isInWorkflow, | isInWorkflow, | ||||
| singleRetrievalModelConfig: singleRetrievalConfig = {} as ModelConfig, | singleRetrievalModelConfig: singleRetrievalConfig = {} as ModelConfig, | ||||
| onSingleRetrievalModelChange = () => { }, | |||||
| onSingleRetrievalModelParamsChange = () => { }, | |||||
| onSingleRetrievalModelChange = noop, | |||||
| onSingleRetrievalModelParamsChange = noop, | |||||
| selectedDatasets = [], | selectedDatasets = [], | ||||
| }) => { | }) => { | ||||
| const { t } = useTranslation() | const { t } = useTranslation() |
| const isOpenAI = modelConfig.provider === 'langgenius/openai/openai' | const isOpenAI = modelConfig.provider === 'langgenius/openai/openai' | ||||
| const [collectionList, setCollectionList] = useState<Collection[]>([]) | const [collectionList, setCollectionList] = useState<Collection[]>([]) | ||||
| useEffect(() => { | |||||
| }, []) | |||||
| const [datasetConfigs, doSetDatasetConfigs] = useState<DatasetConfigs>({ | const [datasetConfigs, doSetDatasetConfigs] = useState<DatasetConfigs>({ | ||||
| retrieval_model: RETRIEVE_TYPE.multiWay, | retrieval_model: RETRIEVE_TYPE.multiWay, | ||||
| reranking_model: { | reranking_model: { |
| private audioPlayers: AudioPlayer | null = null | private audioPlayers: AudioPlayer | null = null | ||||
| private msgId: string | undefined | private msgId: string | undefined | ||||
| private constructor() { | |||||
| } | |||||
| public static getInstance(): AudioPlayerManager { | public static getInstance(): AudioPlayerManager { | ||||
| if (!AudioPlayerManager.instance) { | if (!AudioPlayerManager.instance) { | ||||
| AudioPlayerManager.instance = new AudioPlayerManager() | AudioPlayerManager.instance = new AudioPlayerManager() | ||||
| return AudioPlayerManager.instance | return AudioPlayerManager.instance | ||||
| } | } | ||||
| public getAudioPlayer(url: string, isPublic: boolean, id: string | undefined, msgContent: string | null | undefined, voice: string | undefined, callback: ((event: string) => {}) | null): AudioPlayer { | |||||
| public getAudioPlayer(url: string, isPublic: boolean, id: string | undefined, msgContent: string | null | undefined, voice: string | undefined, callback: ((event: string) => void) | null): AudioPlayer { | |||||
| if (this.msgId && this.msgId === id && this.audioPlayers) { | if (this.msgId && this.msgId === id && this.audioPlayers) { | ||||
| this.audioPlayers.setCallback(callback) | this.audioPlayers.setCallback(callback) | ||||
| return this.audioPlayers | return this.audioPlayers |
| isLoadData = false | isLoadData = false | ||||
| url: string | url: string | ||||
| isPublic: boolean | isPublic: boolean | ||||
| callback: ((event: string) => {}) | null | |||||
| callback: ((event: string) => void) | null | |||||
| constructor(streamUrl: string, isPublic: boolean, msgId: string | undefined, msgContent: string | null | undefined, voice: string | undefined, callback: ((event: string) => {}) | null) { | |||||
| constructor(streamUrl: string, isPublic: boolean, msgId: string | undefined, msgContent: string | null | undefined, voice: string | undefined, callback: ((event: string) => void) | null) { | |||||
| this.audioContext = new AudioContext() | this.audioContext = new AudioContext() | ||||
| this.msgId = msgId | this.msgId = msgId | ||||
| this.msgContent = msgContent | this.msgContent = msgContent | ||||
| }) | }) | ||||
| } | } | ||||
| public setCallback(callback: ((event: string) => {}) | null) { | |||||
| public setCallback(callback: ((event: string) => void) | null) { | |||||
| this.callback = callback | this.callback = callback | ||||
| if (callback) { | if (callback) { | ||||
| this.audio.addEventListener('ended', () => { | this.audio.addEventListener('ended', () => { | ||||
| this.audioContext.suspend() | this.audioContext.suspend() | ||||
| } | } | ||||
| private cancer() { | |||||
| } | |||||
| private receiveAudioData(unit8Array: Uint8Array) { | private receiveAudioData(unit8Array: Uint8Array) { | ||||
| if (!unit8Array) { | if (!unit8Array) { | ||||
| this.finishStream() | this.finishStream() |
| getProcessedFiles, | getProcessedFiles, | ||||
| getProcessedFilesFromResponse, | getProcessedFilesFromResponse, | ||||
| } from '@/app/components/base/file-uploader/utils' | } from '@/app/components/base/file-uploader/utils' | ||||
| import { noop } from 'lodash-es' | |||||
| type GetAbortController = (abortController: AbortController) => void | type GetAbortController = (abortController: AbortController) => void | ||||
| type SendCallback = { | type SendCallback = { | ||||
| else | else | ||||
| ttsUrl = `/apps/${params.appId}/text-to-audio` | ttsUrl = `/apps/${params.appId}/text-to-audio` | ||||
| } | } | ||||
| const player = AudioPlayerManager.getInstance().getAudioPlayer(ttsUrl, ttsIsPublic, uuidV4(), 'none', 'none', (_: any): any => { }) | |||||
| const player = AudioPlayerManager.getInstance().getAudioPlayer(ttsUrl, ttsIsPublic, uuidV4(), 'none', 'none', noop) | |||||
| ssePost( | ssePost( | ||||
| url, | url, | ||||
| { | { |
| IPaginationProps, | IPaginationProps, | ||||
| PageButtonProps, | PageButtonProps, | ||||
| } from './type' | } from './type' | ||||
| import { noop } from 'lodash-es' | |||||
| const defaultState: IPagination = { | const defaultState: IPagination = { | ||||
| currentPage: 0, | currentPage: 0, | ||||
| setCurrentPage: () => {}, | |||||
| setCurrentPage: noop, | |||||
| truncableText: '...', | truncableText: '...', | ||||
| truncableClassName: '', | truncableClassName: '', | ||||
| pages: [], | pages: [], |
| import CustomDialog from '@/app/components/base/dialog' | import CustomDialog from '@/app/components/base/dialog' | ||||
| import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem' | import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem' | ||||
| import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback' | import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback' | ||||
| import { noop } from 'lodash-es' | |||||
| const TextLabel: FC<PropsWithChildren> = (props) => { | const TextLabel: FC<PropsWithChildren> = (props) => { | ||||
| return <label className='system-sm-semibold text-text-secondary'>{props.children}</label> | return <label className='system-sm-semibold text-text-secondary'>{props.children}</label> | ||||
| </div> | </div> | ||||
| )} | )} | ||||
| </div> | </div> | ||||
| <FloatRightContainer isMobile={isMobile} isOpen={true} onClose={() => { }} footer={null}> | |||||
| <FloatRightContainer isMobile={isMobile} isOpen={true} onClose={noop} footer={null}> | |||||
| <PreviewContainer | <PreviewContainer | ||||
| header={<PreviewHeader | header={<PreviewHeader | ||||
| title={t('datasetCreation.stepTwo.preview')} | title={t('datasetCreation.stepTwo.preview')} |
| import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type' | import { extensionToFileType } from '@/app/components/datasets/hit-testing/utils/extension-to-file-type' | ||||
| import useBatchEditDocumentMetadata from '../metadata/hooks/use-batch-edit-document-metadata' | import useBatchEditDocumentMetadata from '../metadata/hooks/use-batch-edit-document-metadata' | ||||
| import EditMetadataBatchModal from '@/app/components/datasets/metadata/edit-metadata-batch/modal' | import EditMetadataBatchModal from '@/app/components/datasets/metadata/edit-metadata-batch/modal' | ||||
| import { noop } from 'lodash-es' | |||||
| export const useIndexStatus = () => { | export const useIndexStatus = () => { | ||||
| const { t } = useTranslation() | const { t } = useTranslation() | ||||
| return <div className='flex items-center' onClick={e => e.stopPropagation()}> | return <div className='flex items-center' onClick={e => e.stopPropagation()}> | ||||
| {isListScene && !embeddingAvailable && ( | {isListScene && !embeddingAvailable && ( | ||||
| <Switch defaultValue={false} onChange={() => { }} disabled={true} size='md' /> | |||||
| <Switch defaultValue={false} onChange={noop} disabled={true} size='md' /> | |||||
| )} | )} | ||||
| {isListScene && embeddingAvailable && ( | {isListScene && embeddingAvailable && ( | ||||
| <> | <> | ||||
| needsDelay | needsDelay | ||||
| > | > | ||||
| <div> | <div> | ||||
| <Switch defaultValue={false} onChange={() => { }} disabled={true} size='md' /> | |||||
| <Switch defaultValue={false} onChange={noop} disabled={true} size='md' /> | |||||
| </div> | </div> | ||||
| </Tooltip> | </Tooltip> | ||||
| : <Switch defaultValue={enabled} onChange={v => handleSwitch(v ? 'enable' : 'disable')} size='md' /> | : <Switch defaultValue={enabled} onChange={v => handleSwitch(v ? 'enable' : 'disable')} size='md' /> |
| import { useProviderContext } from '@/context/provider-context' | import { useProviderContext } from '@/context/provider-context' | ||||
| import AppsFull from '@/app/components/billing/apps-full-in-dialog' | import AppsFull from '@/app/components/billing/apps-full-in-dialog' | ||||
| import type { AppIconType } from '@/types/app' | import type { AppIconType } from '@/types/app' | ||||
| import { noop } from 'lodash-es' | |||||
| export type CreateAppModalProps = { | export type CreateAppModalProps = { | ||||
| show: boolean | show: boolean | ||||
| <> | <> | ||||
| <Modal | <Modal | ||||
| isShow={show} | isShow={show} | ||||
| onClose={() => {}} | |||||
| onClose={noop} | |||||
| className='relative !max-w-[480px] px-8' | className='relative !max-w-[480px] px-8' | ||||
| > | > | ||||
| <div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onHide}> | <div className='absolute right-4 top-4 cursor-pointer p-2' onClick={onHide}> |
| import { DataSourceType } from './types' | import { DataSourceType } from './types' | ||||
| import s from './style.module.css' | import s from './style.module.css' | ||||
| import cn from '@/utils/classnames' | import cn from '@/utils/classnames' | ||||
| import { noop } from 'lodash-es' | |||||
| export type ConfigItemType = { | export type ConfigItemType = { | ||||
| id: string | id: string | ||||
| const { t } = useTranslation() | const { t } = useTranslation() | ||||
| const isNotion = type === DataSourceType.notion | const isNotion = type === DataSourceType.notion | ||||
| const isWebsite = type === DataSourceType.website | const isWebsite = type === DataSourceType.website | ||||
| const onChangeAuthorizedPage = notionActions?.onChangeAuthorizedPage || function () { } | |||||
| const onChangeAuthorizedPage = notionActions?.onChangeAuthorizedPage || noop | |||||
| return ( | return ( | ||||
| <div className={cn(s['workspace-item'], 'mb-1 flex items-center rounded-lg bg-components-panel-on-panel-item-bg py-1 pr-1')} key={payload.id}> | <div className={cn(s['workspace-item'], 'mb-1 flex items-center rounded-lg bg-components-panel-on-panel-item-bg py-1 pr-1')} key={payload.id}> |
| import { marketplaceUrlPrefix } from '@/config' | import { marketplaceUrlPrefix } from '@/config' | ||||
| import { RiArrowRightUpLine, RiSearchLine } from '@remixicon/react' | import { RiArrowRightUpLine, RiSearchLine } from '@remixicon/react' | ||||
| // import { RiArrowRightUpLine } from '@remixicon/react' | // import { RiArrowRightUpLine } from '@remixicon/react' | ||||
| import { noop } from 'lodash-es' | |||||
| type Props = { | type Props = { | ||||
| wrapElemRef: React.RefObject<HTMLElement> | wrapElemRef: React.RefObject<HTMLElement> | ||||
| <Item | <Item | ||||
| key={index} | key={index} | ||||
| payload={item} | payload={item} | ||||
| onAction={() => { }} | |||||
| onAction={noop} | |||||
| /> | /> | ||||
| ))} | ))} | ||||
| <div className='mb-3 mt-2 flex items-center justify-center space-x-2'> | <div className='mb-3 mt-2 flex items-center justify-center space-x-2'> |
| import { useFeaturesStore } from '@/app/components/base/features/hooks' | import { useFeaturesStore } from '@/app/components/base/features/hooks' | ||||
| import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player.manager' | import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player.manager' | ||||
| import type { VersionHistory } from '@/types/workflow' | import type { VersionHistory } from '@/types/workflow' | ||||
| import { noop } from 'lodash-es' | |||||
| export const useWorkflowRun = () => { | export const useWorkflowRun = () => { | ||||
| const store = useStoreApi() | const store = useStoreApi() | ||||
| else | else | ||||
| ttsUrl = `/apps/${params.appId}/text-to-audio` | ttsUrl = `/apps/${params.appId}/text-to-audio` | ||||
| } | } | ||||
| const player = AudioPlayerManager.getInstance().getAudioPlayer(ttsUrl, ttsIsPublic, uuidV4(), 'none', 'none', (_: any): any => { }) | |||||
| const player = AudioPlayerManager.getInstance().getAudioPlayer(ttsUrl, ttsIsPublic, uuidV4(), 'none', 'none', noop) | |||||
| ssePost( | ssePost( | ||||
| url, | url, |
| import DocumentExtractorDefault from '@/app/components/workflow/nodes/document-extractor/default' | import DocumentExtractorDefault from '@/app/components/workflow/nodes/document-extractor/default' | ||||
| import LoopDefault from '@/app/components/workflow/nodes/loop/default' | import LoopDefault from '@/app/components/workflow/nodes/loop/default' | ||||
| import { ssePost } from '@/service/base' | import { ssePost } from '@/service/base' | ||||
| import { noop } from 'lodash-es' | |||||
| import { getInputVars as doGetInputVars } from '@/app/components/base/prompt-editor/constants' | import { getInputVars as doGetInputVars } from '@/app/components/base/prompt-editor/constants' | ||||
| import type { NodeTracing } from '@/types/workflow' | import type { NodeTracing } from '@/types/workflow' | ||||
| const { checkValid: checkLLMValid } = LLMDefault | const { checkValid: checkLLMValid } = LLMDefault | ||||
| getIterationSingleNodeRunUrl(isChatMode, appId!, id), | getIterationSingleNodeRunUrl(isChatMode, appId!, id), | ||||
| { body: { inputs: submitData } }, | { body: { inputs: submitData } }, | ||||
| { | { | ||||
| onWorkflowStarted: () => { | |||||
| }, | |||||
| onWorkflowStarted: noop, | |||||
| onWorkflowFinished: (params) => { | onWorkflowFinished: (params) => { | ||||
| handleNodeDataUpdate({ | handleNodeDataUpdate({ | ||||
| id, | id, | ||||
| getLoopSingleNodeRunUrl(isChatMode, appId!, id), | getLoopSingleNodeRunUrl(isChatMode, appId!, id), | ||||
| { body: { inputs: submitData } }, | { body: { inputs: submitData } }, | ||||
| { | { | ||||
| onWorkflowStarted: () => { | |||||
| }, | |||||
| onWorkflowStarted: noop, | |||||
| onWorkflowFinished: (params) => { | onWorkflowFinished: (params) => { | ||||
| handleNodeDataUpdate({ | handleNodeDataUpdate({ | ||||
| id, | id, |
| }], | }], | ||||
| } | } | ||||
| })() | })() | ||||
| export const CircleNestCircle = (() => { | |||||
| })() |
| } from 'use-context-selector' | } from 'use-context-selector' | ||||
| import type { Locale } from '@/i18n' | import type { Locale } from '@/i18n' | ||||
| import { getLanguage } from '@/i18n/language' | import { getLanguage } from '@/i18n/language' | ||||
| import { noop } from 'lodash-es' | |||||
| type II18NContext = { | type II18NContext = { | ||||
| locale: Locale | locale: Locale | ||||
| const I18NContext = createContext<II18NContext>({ | const I18NContext = createContext<II18NContext>({ | ||||
| locale: 'en-US', | locale: 'en-US', | ||||
| i18n: {}, | i18n: {}, | ||||
| setLocaleOnClient: (_lang: Locale, _reloadPage?: boolean) => { }, | |||||
| setLocaleOnClient: noop, | |||||
| }) | }) | ||||
| export const useI18N = () => useContext(I18NContext) | export const useI18N = () => useContext(I18NContext) |
| // antfu migrate to eslint-plugin-unused-imports | // antfu migrate to eslint-plugin-unused-imports | ||||
| 'unused-imports/no-unused-vars': 'warn', | 'unused-imports/no-unused-vars': 'warn', | ||||
| 'unused-imports/no-unused-imports': 'warn', | 'unused-imports/no-unused-imports': 'warn', | ||||
| // We use `import { noop } from 'lodash-es'` across `web` project | |||||
| 'no-empty-function': 'error', | |||||
| }, | }, | ||||
| languageOptions: { | languageOptions: { |