| import React from 'react' | import React from 'react' | ||||
| type Props = {} | |||||
| const page = (props: Props) => { | |||||
| const page = () => { | |||||
| return ( | return ( | ||||
| <div>dataset detail api</div> | <div>dataset detail api</div> | ||||
| ) | ) |
| if (onSuccess) | if (onSuccess) | ||||
| onSuccess() | onSuccess() | ||||
| } | } | ||||
| catch (e: any) { | |||||
| catch { | |||||
| } | } | ||||
| setShowConfirmDelete(false) | setShowConfirmDelete(false) | ||||
| }, [dataset.id, notify, onSuccess, t]) | }, [dataset.id, notify, onSuccess, t]) |
| setAppDetail(app) | setAppDetail(app) | ||||
| mutateApps() | mutateApps() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('app.editFailed') }) | notify({ type: 'error', message: t('app.editFailed') }) | ||||
| } | } | ||||
| }, [appDetail, mutateApps, notify, setAppDetail, t]) | }, [appDetail, mutateApps, notify, setAppDetail, t]) | ||||
| onPlanInfoChanged() | onPlanInfoChanged() | ||||
| getRedirection(true, newApp, replace) | getRedirection(true, newApp, replace) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | ||||
| } | } | ||||
| } | } | ||||
| a.download = `${appDetail.name}.yml` | a.download = `${appDetail.name}.yml` | ||||
| a.click() | a.click() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('app.exportFailed') }) | notify({ type: 'error', message: t('app.exportFailed') }) | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| setSecretEnvList(list) | setSecretEnvList(list) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('app.exportFailed') }) | notify({ type: 'error', message: t('app.exportFailed') }) | ||||
| } | } | ||||
| } | } | ||||
| }) | }) | ||||
| } | } | ||||
| setShowConfirmDelete(false) | setShowConfirmDelete(false) | ||||
| }, [appDetail, mutateApps, notify, onPlanInfoChanged, replace, t]) | |||||
| }, [appDetail, mutateApps, notify, onPlanInfoChanged, replace, setAppDetail, t]) | |||||
| const { isCurrentWorkspaceEditor } = useAppContext() | const { isCurrentWorkspaceEditor } = useAppContext() | ||||
| try { | try { | ||||
| await onAdd(payload) | await onAdd(payload) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| setIsSaving(false) | setIsSaving(false) | ||||
| setList(data as AnnotationItem[]) | setList(data as AnnotationItem[]) | ||||
| setTotal(total) | setTotal(total) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| setIsLoading(false) | setIsLoading(false) |
| setHitHistoryList(data as HitHistoryItem[]) | setHitHistoryList(data as HitHistoryItem[]) | ||||
| setTotal(total) | setTotal(total) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| } | } | ||||
| setTempSetting(addDefaultValue(setting, formSchemas)) | setTempSetting(addDefaultValue(setting, formSchemas)) | ||||
| } | } | ||||
| } | } | ||||
| catch (e) { } | |||||
| catch { } | |||||
| setIsLoading(false) | setIsLoading(false) | ||||
| })() | })() | ||||
| }, [collection?.name, collection?.id, collection?.type]) | }, [collection?.name, collection?.id, collection?.type]) |
| retrieval_model_dict: retrievalConfig, | retrieval_model_dict: retrievalConfig, | ||||
| }) | }) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| } | } | ||||
| finally { | finally { |
| localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | ||||
| getRedirection(isCurrentWorkspaceEditor, { id: app.app_id!, mode }, push) | getRedirection(isCurrentWorkspaceEditor, { id: app.app_id!, mode }, push) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | ||||
| } | } | ||||
| } | } |
| localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | ||||
| getRedirection(isCurrentWorkspaceEditor, app, push) | getRedirection(isCurrentWorkspaceEditor, app, push) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | ||||
| } | } | ||||
| isCreatingRef.current = false | isCreatingRef.current = false | ||||
| onClick: () => void | onClick: () => void | ||||
| } | } | ||||
| function AppTypeCard({ icon, title, description, active, onClick }: AppTypeCardProps) { | function AppTypeCard({ icon, title, description, active, onClick }: AppTypeCardProps) { | ||||
| const { t } = useTranslation() | |||||
| return <div | return <div | ||||
| className={ | className={ | ||||
| cn(`relative box-content h-[84px] w-[191px] cursor-pointer rounded-xl | cn(`relative box-content h-[84px] w-[191px] cursor-pointer rounded-xl |
| { value: PageType.log, text: t('appLog.title') }, | { value: PageType.log, text: t('appLog.title') }, | ||||
| { value: PageType.annotation, text: t('appAnnotation.title') }, | { value: PageType.annotation, text: t('appAnnotation.title') }, | ||||
| ] | ] | ||||
| }, [appDetail]) | |||||
| }, [appDetail?.mode, t]) | |||||
| if (!appDetail) { | if (!appDetail) { | ||||
| return ( | return ( |
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| return true | return true | ||||
| } | } | ||||
| catch (err) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| return false | return false | ||||
| } | } | ||||
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| return true | return true | ||||
| } | } | ||||
| catch (err) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| return false | return false | ||||
| } | } | ||||
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| return true | return true | ||||
| } | } | ||||
| catch (err) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| return false | return false | ||||
| } | } | ||||
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| return true | return true | ||||
| } | } | ||||
| catch (err) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| return false | return false | ||||
| } | } |
| removeOriginal ? replace : push, | removeOriginal ? replace : push, | ||||
| ) | ) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | ||||
| } | } | ||||
| } | } |
| this.audioPlayers.cacheBuffers = [] | this.audioPlayers.cacheBuffers = [] | ||||
| this.audioPlayers.sourceBuffer?.abort() | this.audioPlayers.sourceBuffer?.abort() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| } | } | ||||
| this.receiveAudioData(value) | this.receiveAudioData(value) | ||||
| } | } | ||||
| } | } | ||||
| catch (error) { | |||||
| catch { | |||||
| this.isLoadData = false | this.isLoadData = false | ||||
| this.callback && this.callback('error') | this.callback && this.callback('error') | ||||
| } | } |
| setWaveformData(normalizedWaveform) | setWaveformData(normalizedWaveform) | ||||
| setIsAudioAvailable(true) | setIsAudioAvailable(true) | ||||
| } | } | ||||
| catch (error) { | |||||
| catch { | |||||
| const waveform: number[] = [] | const waveform: number[] = [] | ||||
| let prevValue = Math.random() | let prevValue = Math.random() | ||||
| try { | try { | ||||
| return JSON.parse(value)[index] | return JSON.parse(value)[index] | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| } | } | ||||
| return value | return value | ||||
| if (Array.isArray(JSON.parse(thought.tool))) | if (Array.isArray(JSON.parse(thought.tool))) | ||||
| return [JSON.parse(thought.tool), true] | return [JSON.parse(thought.tool), true] | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| return [[thought.tool], false] | return [[thought.tool], false] | ||||
| })() | })() |
| isPublicAPI: !isInstalledApp, | isPublicAPI: !isInstalledApp, | ||||
| }, | }, | ||||
| ) | ) | ||||
| }, [ | |||||
| chatList, | |||||
| handleNewConversationCompleted, | |||||
| handleSend, | |||||
| currentConversationId, | |||||
| currentConversationItem, | |||||
| newConversationInputs, | |||||
| isInstalledApp, | |||||
| appId, | |||||
| ]) | |||||
| }, [currentConversationId, currentConversationInputs, newConversationInputs, chatList, handleSend, isInstalledApp, appId, handleNewConversationCompleted]) | |||||
| const doRegenerate = useCallback((chatItem: ChatItemInTree) => { | const doRegenerate = useCallback((chatItem: ChatItemInTree) => { | ||||
| const question = chatList.find(item => item.id === chatItem.parentMessageId)! | const question = chatList.find(item => item.id === chatItem.parentMessageId)! |
| handleNewConversationInputsChange, | handleNewConversationInputsChange, | ||||
| } = useEmbeddedChatbotContext() | } = useEmbeddedChatbotContext() | ||||
| const inputsFormValue = currentConversationId ? currentConversationInputs : newConversationInputs | const inputsFormValue = currentConversationId ? currentConversationInputs : newConversationInputs | ||||
| const readonly = !!currentConversationId | |||||
| const handleFormChange = useCallback((variable: string, value: any) => { | const handleFormChange = useCallback((variable: string, value: any) => { | ||||
| setCurrentConversationInputs({ | setCurrentConversationInputs({ |
| try { | try { | ||||
| return JSON.parse(String(children).replace(/\n$/, '')) | return JSON.parse(String(children).replace(/\n$/, '')) | ||||
| } | } | ||||
| catch (error) { } | |||||
| catch { } | |||||
| } | } | ||||
| return JSON.parse('{"title":{"text":"ECharts error - Wrong JSON format."}}') | return JSON.parse('{"title":{"text":"ECharts error - Wrong JSON format."}}') | ||||
| }, [language, children]) | }, [language, children]) |
| setImagePreview(svgToDataURL(svgElement as Element)) | setImagePreview(svgToDataURL(svgElement as Element)) | ||||
| }) | }) | ||||
| } | } | ||||
| catch (error) { | |||||
| catch { | |||||
| if (svgRef.current) | if (svgRef.current) | ||||
| svgRef.current.innerHTML = '<span style="padding: 1rem;">Error rendering SVG. Wait for the image content to complete.</span>' | svgRef.current.innerHTML = '<span style="padding: 1rem;">Error rendering SVG. Wait for the image content to complete.</span>' | ||||
| } | } |
| setName('') | setName('') | ||||
| setPending(false) | setPending(false) | ||||
| } | } | ||||
| catch (e: any) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.tag.failed') }) | notify({ type: 'error', message: t('common.tag.failed') }) | ||||
| setPending(false) | setPending(false) | ||||
| } | } |
| setCreating(false) | setCreating(false) | ||||
| onCreate() | onCreate() | ||||
| } | } | ||||
| catch (e: any) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.tag.failed') }) | notify({ type: 'error', message: t('common.tag.failed') }) | ||||
| setCreating(false) | setCreating(false) | ||||
| } | } | ||||
| await bindTag(tagIDs, targetID, type) | await bindTag(tagIDs, targetID, type) | ||||
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| } | } | ||||
| catch (e: any) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| } | } | ||||
| } | } | ||||
| await unBindTag(tagID, targetID, type) | await unBindTag(tagID, targetID, type) | ||||
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| } | } | ||||
| catch (e: any) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| } | } | ||||
| } | } |
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| setName(name) | setName(name) | ||||
| } | } | ||||
| catch (e: any) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| setName(tag.name) | setName(tag.name) | ||||
| const recoverList = tagList.map((tag) => { | const recoverList = tagList.map((tag) => { | ||||
| ]) | ]) | ||||
| setPending(false) | setPending(false) | ||||
| } | } | ||||
| catch (e: any) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| setPending(false) | setPending(false) | ||||
| } | } |
| onConverted(audioResponse.text) | onConverted(audioResponse.text) | ||||
| onCancel() | onCancel() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| onConverted('') | onConverted('') | ||||
| onCancel() | onCancel() | ||||
| } | } | ||||
| if (canvasRef.current && ctxRef.current) | if (canvasRef.current && ctxRef.current) | ||||
| drawRecord() | drawRecord() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| onCancel() | onCancel() | ||||
| } | } | ||||
| } | } |
| localStorage = globalThis.localStorage | localStorage = globalThis.localStorage | ||||
| sessionStorage = globalThis.sessionStorage | sessionStorage = globalThis.sessionStorage | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| localStorage = new StorageMock() | localStorage = new StorageMock() | ||||
| sessionStorage = new StorageMock() | sessionStorage = new StorageMock() | ||||
| } | } |
| import React from 'react' | import React from 'react' | ||||
| type Props = {} | |||||
| const index = (props: Props) => { | |||||
| const index = () => { | |||||
| return ( | return ( | ||||
| <div>index</div> | <div>index</div> | ||||
| ) | ) |
| await sleep(2500) | await sleep(2500) | ||||
| await startQueryStatus() | await startQueryStatus() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| await sleep(2500) | await sleep(2500) | ||||
| await startQueryStatus() | await startQueryStatus() | ||||
| } | } |
| onHide() | onHide() | ||||
| router.push(`/datasets/${dataset.id}/documents`) | router.push(`/datasets/${dataset.id}/documents`) | ||||
| } | } | ||||
| catch (err) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('datasetCreation.stepOne.modal.failed') }) | notify({ type: 'error', message: t('datasetCreation.stepOne.modal.failed') }) | ||||
| } | } | ||||
| } | } |
| }, | }, | ||||
| } | } | ||||
| } | } | ||||
| }, [crawlOptions.limit]) | |||||
| }, [crawlOptions.limit, onCheckedCrawlResultChange]) | |||||
| const handleRun = useCallback(async (url: string) => { | const handleRun = useCallback(async (url: string) => { | ||||
| const { isValid, errorMsg } = checkValid(url) | const { isValid, errorMsg } = checkValid(url) | ||||
| finally { | finally { | ||||
| setStep(Step.finished) | setStep(Step.finished) | ||||
| } | } | ||||
| }, [checkValid, crawlOptions, onJobIdChange, t, waitForCrawlFinished]) | |||||
| }, [checkValid, crawlOptions, onCheckedCrawlResultChange, onJobIdChange, t, waitForCrawlFinished]) | |||||
| return ( | return ( | ||||
| <div> | <div> |
| await sleep(2500) | await sleep(2500) | ||||
| await startQueryStatus() | await startQueryStatus() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| await sleep(2500) | await sleep(2500) | ||||
| await startQueryStatus() | await startQueryStatus() | ||||
| } | } |
| params: { metadata: 'without' }, | params: { metadata: 'without' }, | ||||
| }) | }) | ||||
| const { data: documentMetadata, error: metadataErr, refetch: metadataMutate } = useDocumentMetadata({ | |||||
| const { data: documentMetadata } = useDocumentMetadata({ | |||||
| datasetId, | datasetId, | ||||
| documentId, | documentId, | ||||
| params: { metadata: 'only' }, | params: { metadata: 'only' }, | ||||
| } | } | ||||
| const isDetailLoading = !documentDetail && !error | const isDetailLoading = !documentDetail && !error | ||||
| const isMetadataLoading = !documentMetadata && !metadataErr | |||||
| const embedding = ['queuing', 'indexing', 'paused'].includes((documentDetail?.display_status || '').toLowerCase()) | const embedding = ['queuing', 'indexing', 'paused'].includes((documentDetail?.display_status || '').toLowerCase()) | ||||
| payload, | payload, | ||||
| isShowAll, | isShowAll, | ||||
| }) => { | }) => { | ||||
| const { id, score, content, position } = payload | |||||
| const { score, content, position } = payload | |||||
| return ( | return ( | ||||
| <div | <div | ||||
| className={!isShowAll ? 'line-clamp-2 break-all' : ''} | className={!isShowAll ? 'line-clamp-2 break-all' : ''} |
| onSuccess() | onSuccess() | ||||
| onClose() | onClose() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| } | } | ||||
| finally { | finally { |
| mutate(unstable_serialize(getKey)) | mutate(unstable_serialize(getKey)) | ||||
| } | } | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| } | } | ||||
| finally { | finally { |
| localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') | ||||
| getRedirection(isCurrentWorkspaceEditor, { id: app.app_id!, mode }, push) | getRedirection(isCurrentWorkspaceEditor, { id: app.app_id!, mode }, push) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) | ||||
| } | } | ||||
| } | } |
| langeniusVersionInfo: LangGeniusVersionResponse | langeniusVersionInfo: LangGeniusVersionResponse | ||||
| onCancel: () => void | onCancel: () => void | ||||
| } | } | ||||
| const buttonClassName = ` | |||||
| shrink-0 flex items-center h-8 px-3 rounded-lg border border-gray-200 | |||||
| text-xs text-gray-800 font-medium | |||||
| ` | |||||
| export default function AccountAbout({ | export default function AccountAbout({ | ||||
| langeniusVersionInfo, | langeniusVersionInfo, | ||||
| onCancel, | onCancel, |
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| location.assign(`${location.origin}`) | location.assign(`${location.origin}`) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.provider.saveFailed') }) | notify({ type: 'error', message: t('common.provider.saveFailed') }) | ||||
| } | } | ||||
| } | } |
| import useSWR from 'swr' | import useSWR from 'swr' | ||||
| import { useTranslation } from 'react-i18next' | |||||
| import DataSourceNotion from './data-source-notion' | import DataSourceNotion from './data-source-notion' | ||||
| import DataSourceWebsite from './data-source-website' | import DataSourceWebsite from './data-source-website' | ||||
| import { fetchDataSource } from '@/service/common' | import { fetchDataSource } from '@/service/common' | ||||
| import { DataSourceProvider } from '@/models/common' | import { DataSourceProvider } from '@/models/common' | ||||
| export default function DataSourcePage() { | export default function DataSourcePage() { | ||||
| const { t } = useTranslation() | |||||
| const { data } = useSWR({ url: 'data-source/integrates' }, fetchDataSource) | const { data } = useSWR({ url: 'data-source/integrates' }, fetchDataSource) | ||||
| const notionWorkspaces = data?.data.filter(item => item.provider === 'notion') || [] | const notionWorkspaces = data?.data.filter(item => item.provider === 'notion') || [] | ||||
| }: IEditWorkspaceModalProps) => { | }: IEditWorkspaceModalProps) => { | ||||
| const { t } = useTranslation() | const { t } = useTranslation() | ||||
| const { notify } = useContext(ToastContext) | const { notify } = useContext(ToastContext) | ||||
| const { currentWorkspace, isCurrentWorkspaceOwner, mutateCurrentWorkspace } = useAppContext() | |||||
| const { currentWorkspace, isCurrentWorkspaceOwner } = useAppContext() | |||||
| const [name, setName] = useState<string>(currentWorkspace.name) | const [name, setName] = useState<string>(currentWorkspace.name) | ||||
| const changeWorkspaceInfo = async (name: string) => { | const changeWorkspaceInfo = async (name: string) => { | ||||
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| location.assign(`${location.origin}`) | location.assign(`${location.origin}`) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| } | } | ||||
| } | } |
| onSend(invitation_results) | onSend(invitation_results) | ||||
| } | } | ||||
| } | } | ||||
| catch (e) { } | |||||
| catch { } | |||||
| } | } | ||||
| else { | else { | ||||
| notify({ type: 'error', message: t('common.members.emailInvalid') }) | notify({ type: 'error', message: t('common.members.emailInvalid') }) |
| onOperate() | onOperate() | ||||
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| } | } | ||||
| onOperate() | onOperate() | ||||
| notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| } | } |
| renderTrigger, | renderTrigger, | ||||
| readonly, | readonly, | ||||
| isInWorkflow, | isInWorkflow, | ||||
| scope = 'text-generation', | |||||
| }) => { | }) => { | ||||
| const { t } = useTranslation() | const { t } = useTranslation() | ||||
| const { isAPIKeySet } = useProviderContext() | const { isAPIKeySet } = useProviderContext() |
| }) | }) | ||||
| } | } | ||||
| } | } | ||||
| catch (error) { | |||||
| catch { | |||||
| Toast.notify({ | Toast.notify({ | ||||
| type: 'error', | type: 'error', | ||||
| message: t('plugin.error.fetchReleasesError'), | message: t('plugin.error.fetchReleasesError'), |
| try { | try { | ||||
| return idStrings ? JSON.parse(idStrings)[0] : '' | return idStrings ? JSON.parse(idStrings)[0] : '' | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| return '' | return '' | ||||
| } | } | ||||
| }, [searchParams]) | }, [searchParams]) | ||||
| try { | try { | ||||
| return info ? JSON.parse(info) : undefined | return info ? JSON.parse(info) : undefined | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| return undefined | return undefined | ||||
| } | } | ||||
| }, [searchParams]) | }, [searchParams]) |
| try { | try { | ||||
| accessTokenJson = JSON.parse(accessToken) | accessTokenJson = JSON.parse(accessToken) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| if (!accessTokenJson[sharedToken]) { | if (!accessTokenJson[sharedToken]) { | ||||
| try { | try { | ||||
| accessTokenJson = JSON.parse(accessToken) | accessTokenJson = JSON.parse(accessToken) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| try { | try { | ||||
| accessTokenJson = JSON.parse(accessToken) | accessTokenJson = JSON.parse(accessToken) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| setInit(true) | setInit(true) | ||||
| } | } | ||||
| catch (error) { | |||||
| catch { | |||||
| router.replace('/signin') | router.replace('/signin') | ||||
| } | } | ||||
| })() | })() |
| setCustomCollection(newCollection) | setCustomCollection(newCollection) | ||||
| setParamsSchemas(parameters_schema) | setParamsSchemas(parameters_schema) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| const customCollection = getCustomCollection() | const customCollection = getCustomCollection() | ||||
| const newCollection = produce(customCollection, (draft) => { | const newCollection = produce(customCollection, (draft) => { | ||||
| draft.schema_type = '' | draft.schema_type = '' | ||||
| const path = decodeURI(new URL(url).pathname) | const path = decodeURI(new URL(url).pathname) | ||||
| return path || '' | return path || '' | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| return url | return url | ||||
| } | } | ||||
| } | } |
| setCustomCollection(newCollection) | setCustomCollection(newCollection) | ||||
| setParamsSchemas(parameters_schema) | setParamsSchemas(parameters_schema) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| const customCollection = getCustomCollection() | const customCollection = getCustomCollection() | ||||
| const newCollection = produce(customCollection, (draft) => { | const newCollection = produce(customCollection, (draft) => { | ||||
| draft.schema_type = '' | draft.schema_type = '' | ||||
| const path = decodeURI(new URL(url).pathname) | const path = decodeURI(new URL(url).pathname) | ||||
| return path || '' | return path || '' | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| return url | return url | ||||
| } | } | ||||
| } | } |
| setToolList(list) | setToolList(list) | ||||
| } | } | ||||
| } | } | ||||
| catch (e) { } | |||||
| catch { } | |||||
| setIsDetailLoading(false) | setIsDetailLoading(false) | ||||
| }, [collection.name, collection.type]) | }, [collection.name, collection.type]) | ||||
| a.download = `${appDetail.name}.yml` | a.download = `${appDetail.name}.yml` | ||||
| a.click() | a.click() | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('app.exportFailed') }) | notify({ type: 'error', message: t('app.exportFailed') }) | ||||
| } | } | ||||
| finally { | finally { | ||||
| }, | }, | ||||
| } as any) | } as any) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| notify({ type: 'error', message: t('app.exportFailed') }) | notify({ type: 'error', message: t('app.exportFailed') }) | ||||
| } | } | ||||
| }, [appDetail, eventEmitter, handleExportDSL, notify, t]) | }, [appDetail, eventEmitter, handleExportDSL, notify, t]) |
| const value = formatValue(form.values[input.variable], input.type) | const value = formatValue(form.values[input.variable], input.type) | ||||
| submitData[input.variable] = value | submitData[input.variable] = value | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| parseErrorJsonField = input.variable | parseErrorJsonField = input.variable | ||||
| } | } | ||||
| }) | }) |
| try { | try { | ||||
| return JSON.stringify(value as object, null, 2) | return JSON.stringify(value as object, null, 2) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| return value as string | return value as string | ||||
| } | } | ||||
| })() | })() |
| import type { CodeNodeType } from './types' | |||||
| export const checkNodeValid = (payload: CodeNodeType) => { | |||||
| export const checkNodeValid = () => { | |||||
| return true | return true | ||||
| } | } |
| : '' | : '' | ||||
| } | } | ||||
| return '' | return '' | ||||
| }, []) | |||||
| }, [t]) | |||||
| return ( | return ( | ||||
| <div className='rounded-md bg-workflow-block-parma-bg'> | <div className='rounded-md bg-workflow-block-parma-bg'> |
| value: isArrayValue ? [value] : value, | value: isArrayValue ? [value] : value, | ||||
| } | } | ||||
| doUpdateCondition(newCondition) | doUpdateCondition(newCondition) | ||||
| }, [condition, doUpdateCondition, fileAttr]) | |||||
| }, [condition, doUpdateCondition, isArrayValue]) | |||||
| const isSelect = condition.comparison_operator && [ComparisonOperator.in, ComparisonOperator.notIn].includes(condition.comparison_operator) | const isSelect = condition.comparison_operator && [ComparisonOperator.in, ComparisonOperator.notIn].includes(condition.comparison_operator) | ||||
| const selectOptions = useMemo(() => { | const selectOptions = useMemo(() => { |
| }) | }) | ||||
| setInputs(newInputs) | setInputs(newInputs) | ||||
| updateNodeInternals(id) | updateNodeInternals(id) | ||||
| }, [inputs, setInputs]) | |||||
| }, [id, inputs, setInputs, updateNodeInternals]) | |||||
| const handleAddCondition = useCallback<HandleAddCondition>((caseId, valueSelector, varItem) => { | const handleAddCondition = useCallback<HandleAddCondition>((caseId, valueSelector, varItem) => { | ||||
| const newInputs = produce(inputs, (draft) => { | const newInputs = produce(inputs, (draft) => { |
| import type { QuestionClassifierNodeType } from './types' | |||||
| export const checkNodeValid = (payload: QuestionClassifierNodeType) => { | |||||
| export const checkNodeValid = () => { | |||||
| return true | return true | ||||
| } | } |
| try { | try { | ||||
| initialValue = JSON.parse(value) | initialValue = JSON.parse(value) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| setChatItemTree(tree) | setChatItemTree(tree) | ||||
| setThreadChatItems(getThreadMessages(tree, newAllChatItems.at(-1)?.id)) | setThreadChatItems(getThreadMessages(tree, newAllChatItems.at(-1)?.id)) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| finally { | finally { | ||||
| setFetched(true) | setFetched(true) |
| }) | }) | ||||
| setObjectValue(newObjectValue) | setObjectValue(newObjectValue) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| // ignore JSON.parse errors | // ignore JSON.parse errors | ||||
| } | } | ||||
| } | } | ||||
| const newValue = JSON.parse(content) | const newValue = JSON.parse(content) | ||||
| setValue(newValue) | setValue(newValue) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| // ignore JSON.parse errors | // ignore JSON.parse errors | ||||
| } | } | ||||
| } | } |
| } from 'react' | } from 'react' | ||||
| import { RiCloseLine } from '@remixicon/react' | import { RiCloseLine } from '@remixicon/react' | ||||
| import { useTranslation } from 'react-i18next' | |||||
| import type { GlobalVariable } from '../../types' | import type { GlobalVariable } from '../../types' | ||||
| import Item from './item' | import Item from './item' | ||||
| import { useStore } from '@/app/components/workflow/store' | import { useStore } from '@/app/components/workflow/store' | ||||
| import cn from '@/utils/classnames' | import cn from '@/utils/classnames' | ||||
| const Panel = () => { | const Panel = () => { | ||||
| const { t } = useTranslation() | |||||
| const setShowPanel = useStore(s => s.setShowGlobalVariablePanel) | const setShowPanel = useStore(s => s.setShowGlobalVariablePanel) | ||||
| const globalVariableList: GlobalVariable[] = [ | const globalVariableList: GlobalVariable[] = [ |
| catch { | catch { | ||||
| await revalidateToken() | await revalidateToken() | ||||
| } | } | ||||
| }, [password, revalidateToken, token, valid]) | |||||
| }, [confirmPassword, password, revalidateToken, searchParams, valid]) | |||||
| return ( | return ( | ||||
| <div className={ | <div className={ |
| fetchSetupStatus, | fetchSetupStatus, | ||||
| sendForgotPasswordEmail, | sendForgotPasswordEmail, | ||||
| } from '@/service/common' | } from '@/service/common' | ||||
| import type { InitValidateStatusResponse, SetupStatusResponse } from '@/models/common' | |||||
| import type { InitValidateStatusResponse } from '@/models/common' | |||||
| const accountFormSchema = z.object({ | const accountFormSchema = z.object({ | ||||
| email: z | email: z | ||||
| } | } | ||||
| useEffect(() => { | useEffect(() => { | ||||
| fetchSetupStatus().then((res: SetupStatusResponse) => { | |||||
| fetchSetupStatus().then(() => { | |||||
| fetchInitValidateStatus().then((res: InitValidateStatusResponse) => { | fetchInitValidateStatus().then((res: InitValidateStatusResponse) => { | ||||
| if (res.status === 'not_started') | if (res.status === 'not_started') | ||||
| window.location.href = '/init' | window.location.href = '/init' |
| const { translation } = await translate(sourceObj[key], null, languageKeyMap[toLanguage]) | const { translation } = await translate(sourceObj[key], null, languageKeyMap[toLanguage]) | ||||
| targetObject[key] = translation | targetObject[key] = translation | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| console.error(`Error translating ${sourceObj[key]}(${key}) to ${toLanguage}`) | console.error(`Error translating ${sourceObj[key]}(${key}) to ${toLanguage}`) | ||||
| } | } | ||||
| } | } |
| try { | try { | ||||
| bufferObj = JSON.parse(message.substring(6)) as Record<string, any>// remove data: and parse as json | bufferObj = JSON.parse(message.substring(6)) as Record<string, any>// remove data: and parse as json | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| // mute handle message cut off | // mute handle message cut off | ||||
| onData('', isFirstMessage, { | onData('', isFirstMessage, { | ||||
| conversationId: bufferObj?.conversation_id, | conversationId: bufferObj?.conversation_id, |
| try { | try { | ||||
| accessTokenJson = JSON.parse(accessToken) | accessTokenJson = JSON.parse(accessToken) | ||||
| } | } | ||||
| catch (e) { | |||||
| catch { | |||||
| } | } | ||||
| return accessTokenJson[sharedToken] | return accessTokenJson[sharedToken] |
| let isRefreshing = false | let isRefreshing = false | ||||
| function waitUntilTokenRefreshed() { | function waitUntilTokenRefreshed() { | ||||
| return new Promise<void>((resolve, reject) => { | |||||
| return new Promise<void>((resolve) => { | |||||
| function _check() { | function _check() { | ||||
| const isRefreshingSign = globalThis.localStorage.getItem(LOCAL_STORAGE_KEY) | const isRefreshingSign = globalThis.localStorage.getItem(LOCAL_STORAGE_KEY) | ||||
| if ((isRefreshingSign && isRefreshingSign === '1') || isRefreshing) { | if ((isRefreshingSign && isRefreshingSign === '1') || isRefreshing) { |
| const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${currentProvider?.provider}/models`) | const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${currentProvider?.provider}/models`) | ||||
| return !!modelId && !!modelsData.data.find(item => item.model === modelId) | return !!modelId && !!modelsData.data.find(item => item.model === modelId) | ||||
| } | } | ||||
| catch (error) { | |||||
| catch { | |||||
| return false | return false | ||||
| } | } | ||||
| }, | }, | ||||
| const response = await fetchPluginInfoFromMarketPlace({ org, name }) | const response = await fetchPluginInfoFromMarketPlace({ org, name }) | ||||
| return response.data.plugin.category === PluginTypeEnum.model ? response.data.plugin : null | return response.data.plugin.category === PluginTypeEnum.model ? response.data.plugin : null | ||||
| } | } | ||||
| catch (error) { | |||||
| catch { | |||||
| return null | return null | ||||
| } | } | ||||
| }, | }, |