| ) | ) | ||||
| const configuredProviderPanel = () => { | const configuredProviderPanel = () => { | ||||
| const configuredPanels: any[] = [] | |||||
| const configuredPanels: JSX.Element[] = [] | |||||
| if (langSmithConfig) | if (langSmithConfig) | ||||
| configuredPanels.push(langSmithPanel) | configuredPanels.push(langSmithPanel) | ||||
| } | } | ||||
| const moreProviderPanel = () => { | const moreProviderPanel = () => { | ||||
| const notConfiguredPanels: any[] = [] | |||||
| const notConfiguredPanels: JSX.Element[] = [] | |||||
| if (!langSmithConfig) | if (!langSmithConfig) | ||||
| notConfiguredPanels.push(langSmithPanel) | notConfiguredPanels.push(langSmithPanel) |
| formattingChangedDispatcher() | formattingChangedDispatcher() | ||||
| } | } | ||||
| const handleToolAuthSetting = (value: any) => { | |||||
| const handleToolAuthSetting = (value: AgentToolWithMoreInfo) => { | |||||
| const newModelConfig = produce(modelConfig, (draft) => { | const newModelConfig = produce(modelConfig, (draft) => { | ||||
| const tool = (draft.agentConfig.tools).find((item: any) => item.provider_id === value?.collection?.id && item.tool_name === value?.tool_name) | const tool = (draft.agentConfig.tools).find((item: any) => item.provider_id === value?.collection?.id && item.tool_name === value?.tool_name) | ||||
| if (tool) | if (tool) | ||||
| } | } | ||||
| headerRight={ | headerRight={ | ||||
| <div className='flex items-center'> | <div className='flex items-center'> | ||||
| <div className='text-xs font-normal leading-[18px] text-text-tertiary'>{tools.filter((item: any) => !!item.enabled).length}/{tools.length} {t('appDebug.agent.tools.enabled')}</div> | |||||
| <div className='text-xs font-normal leading-[18px] text-text-tertiary'>{tools.filter(item => !!item.enabled).length}/{tools.length} {t('appDebug.agent.tools.enabled')}</div> | |||||
| {tools.length < MAX_TOOLS_NUM && ( | {tools.length < MAX_TOOLS_NUM && ( | ||||
| <> | <> | ||||
| <div className='ml-3 mr-1 h-3.5 w-px bg-divider-regular'></div> | <div className='ml-3 mr-1 h-3.5 w-px bg-divider-regular'></div> | ||||
| {isShowSettingTool && ( | {isShowSettingTool && ( | ||||
| <SettingBuiltInTool | <SettingBuiltInTool | ||||
| toolName={currentTool?.tool_name as string} | toolName={currentTool?.tool_name as string} | ||||
| setting={currentTool?.tool_parameters as any} | |||||
| setting={currentTool?.tool_parameters} | |||||
| collection={currentTool?.collection as Collection} | collection={currentTool?.collection as Collection} | ||||
| isBuiltIn={currentTool?.collection?.type === CollectionType.builtIn} | isBuiltIn={currentTool?.collection?.type === CollectionType.builtIn} | ||||
| isModel={currentTool?.collection?.type === CollectionType.model} | isModel={currentTool?.collection?.type === CollectionType.model} | ||||
| type: 'success', | type: 'success', | ||||
| message: t('common.api.actionSuccess'), | message: t('common.api.actionSuccess'), | ||||
| }) | }) | ||||
| handleToolAuthSetting(currentTool as any) | |||||
| handleToolAuthSetting(currentTool) | |||||
| setShowSettingAuth(false) | setShowSettingAuth(false) | ||||
| }} | }} | ||||
| /> | /> |
| const [tools, setTools] = useState<Tool[]>([]) | const [tools, setTools] = useState<Tool[]>([]) | ||||
| const currTool = tools.find(tool => tool.name === toolName) | const currTool = tools.find(tool => tool.name === toolName) | ||||
| const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : [] | const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : [] | ||||
| const infoSchemas = formSchemas.filter((item: any) => item.form === 'llm') | |||||
| const settingSchemas = formSchemas.filter((item: any) => item.form !== 'llm') | |||||
| const infoSchemas = formSchemas.filter(item => item.form === 'llm') | |||||
| const settingSchemas = formSchemas.filter(item => item.form !== 'llm') | |||||
| const hasSetting = settingSchemas.length > 0 | const hasSetting = settingSchemas.length > 0 | ||||
| const [tempSetting, setTempSetting] = useState(setting) | const [tempSetting, setTempSetting] = useState(setting) | ||||
| const [currType, setCurrType] = useState('info') | const [currType, setCurrType] = useState('info') | ||||
| const isValid = (() => { | const isValid = (() => { | ||||
| let valid = true | let valid = true | ||||
| settingSchemas.forEach((item: any) => { | |||||
| settingSchemas.forEach((item) => { | |||||
| if (item.required && !tempSetting[item.name]) | if (item.required && !tempSetting[item.name]) | ||||
| valid = false | valid = false | ||||
| }) | }) | ||||
| <div className=''> | <div className=''> | ||||
| {infoSchemas.length > 0 && ( | {infoSchemas.length > 0 && ( | ||||
| <div className='space-y-1 py-2'> | <div className='space-y-1 py-2'> | ||||
| {infoSchemas.map((item: any, index) => ( | |||||
| {infoSchemas.map((item, index) => ( | |||||
| <div key={index} className='py-1'> | <div key={index} className='py-1'> | ||||
| <div className='flex items-center gap-2'> | <div className='flex items-center gap-2'> | ||||
| <div className='code-sm-semibold text-text-secondary'>{item.label[language]}</div> | <div className='code-sm-semibold text-text-secondary'>{item.label[language]}</div> | ||||
| <Form | <Form | ||||
| value={tempSetting} | value={tempSetting} | ||||
| onChange={setTempSetting} | onChange={setTempSetting} | ||||
| formSchemas={settingSchemas as any} | |||||
| formSchemas={settingSchemas} | |||||
| isEditMode={false} | isEditMode={false} | ||||
| showOnVariableMap={{}} | showOnVariableMap={{}} | ||||
| validating={false} | validating={false} |
| provider={model?.provider} | provider={model?.provider} | ||||
| completionParams={model?.completion_params} | completionParams={model?.completion_params} | ||||
| modelId={model?.name} | modelId={model?.name} | ||||
| setModel={onSingleRetrievalModelChange as any} | |||||
| onCompletionParamsChange={onSingleRetrievalModelParamsChange as any} | |||||
| setModel={onSingleRetrievalModelChange} | |||||
| onCompletionParamsChange={onSingleRetrievalModelParamsChange} | |||||
| hideDebugWithMultipleModel | hideDebugWithMultipleModel | ||||
| debugWithMultipleModel={false} | debugWithMultipleModel={false} | ||||
| /> | /> |
| import ModelIcon from '@/app/components/header/account-setting/model-provider-page/model-icon' | import ModelIcon from '@/app/components/header/account-setting/model-provider-page/model-icon' | ||||
| import ModelName from '@/app/components/header/account-setting/model-provider-page/model-name' | import ModelName from '@/app/components/header/account-setting/model-provider-page/model-name' | ||||
| import { | import { | ||||
| type FormValue, | |||||
| MODEL_STATUS_TEXT, | MODEL_STATUS_TEXT, | ||||
| ModelStatusEnum, | ModelStatusEnum, | ||||
| } from '@/app/components/header/account-setting/model-provider-page/declarations' | } from '@/app/components/header/account-setting/model-provider-page/declarations' | ||||
| } | } | ||||
| onMultipleModelConfigsChange(true, newModelConfigs) | onMultipleModelConfigsChange(true, newModelConfigs) | ||||
| } | } | ||||
| const handleParamsChange = (params: any) => { | |||||
| const handleParamsChange = (params: FormValue) => { | |||||
| const newModelConfigs = [...multipleModelConfigs] | const newModelConfigs = [...multipleModelConfigs] | ||||
| newModelConfigs[index] = { | newModelConfigs[index] = { | ||||
| ...newModelConfigs[index], | ...newModelConfigs[index], |
| }, [modelModeType]) | }, [modelModeType]) | ||||
| const [dataSets, setDataSets] = useState<DataSet[]>([]) | const [dataSets, setDataSets] = useState<DataSet[]>([]) | ||||
| const contextVar = modelConfig.configs.prompt_variables.find((item: any) => item.is_context_var)?.key | |||||
| const contextVar = modelConfig.configs.prompt_variables.find(item => item.is_context_var)?.key | |||||
| const hasSetContextVar = !!contextVar | const hasSetContextVar = !!contextVar | ||||
| const [isShowSelectDataSet, { setTrue: showSelectDataSet, setFalse: hideSelectDataSet }] = useBoolean(false) | const [isShowSelectDataSet, { setTrue: showSelectDataSet, setFalse: hideSelectDataSet }] = useBoolean(false) | ||||
| const selectedIds = dataSets.map(item => item.id) | const selectedIds = dataSets.map(item => item.id) | ||||
| formattingChangedDispatcher() | formattingChangedDispatcher() | ||||
| let newDatasets = data | let newDatasets = data | ||||
| if (data.find(item => !item.name)) { // has not loaded selected dataset | if (data.find(item => !item.name)) { // has not loaded selected dataset | ||||
| const newSelected = produce(data, (draft: any) => { | |||||
| const newSelected = produce(data, (draft) => { | |||||
| data.forEach((item, index) => { | data.forEach((item, index) => { | ||||
| if (!item.name) { // not fetched database | if (!item.name) { // not fetched database | ||||
| const newItem = dataSets.find(i => i.id === item.id) | const newItem = dataSets.find(i => i.id === item.id) | ||||
| if (modelConfig.chat_prompt_config && modelConfig.chat_prompt_config.prompt.length > 0) | if (modelConfig.chat_prompt_config && modelConfig.chat_prompt_config.prompt.length > 0) | ||||
| setChatPromptConfig(modelConfig.chat_prompt_config) | setChatPromptConfig(modelConfig.chat_prompt_config) | ||||
| else | else | ||||
| setChatPromptConfig(clone(DEFAULT_CHAT_PROMPT_CONFIG) as any) | |||||
| setChatPromptConfig(clone(DEFAULT_CHAT_PROMPT_CONFIG)) | |||||
| setCompletionPromptConfig(modelConfig.completion_prompt_config || clone(DEFAULT_COMPLETION_PROMPT_CONFIG) as any) | setCompletionPromptConfig(modelConfig.completion_prompt_config || clone(DEFAULT_COMPLETION_PROMPT_CONFIG) as any) | ||||
| setCanReturnToSimpleMode(false) | setCanReturnToSimpleMode(false) | ||||
| } | } |
| } | } | ||||
| const onClear = () => { | const onClear = () => { | ||||
| const newInputs: Record<string, any> = {} | |||||
| const newInputs: Inputs = {} | |||||
| promptVariables.forEach((item) => { | promptVariables.forEach((item) => { | ||||
| newInputs[item.key] = '' | newInputs[item.key] = '' | ||||
| }) | }) |
| const [list, setList] = useState<AgentIteration[]>([]) | const [list, setList] = useState<AgentIteration[]>([]) | ||||
| const tools = useMemo(() => { | const tools = useMemo(() => { | ||||
| const res = uniq(flatten(runDetail?.iterations.map((iteration: any) => { | |||||
| const res = uniq(flatten(runDetail?.iterations.map((iteration) => { | |||||
| return iteration.tool_calls.map((tool: any) => tool.tool_name).filter(Boolean) | return iteration.tool_calls.map((tool: any) => tool.tool_name).filter(Boolean) | ||||
| })).filter(Boolean)) | })).filter(Boolean)) | ||||
| return res | return res |
| const params = useParams() | const params = useParams() | ||||
| const pathname = usePathname() | const pathname = usePathname() | ||||
| const audio_finished_call = (event: string): any => { | |||||
| const audio_finished_call = (event: string): void => { | |||||
| switch (event) { | switch (event) { | ||||
| case 'ended': | case 'ended': | ||||
| setAudioState('ended') | setAudioState('ended') |
| responseItem.workflowProcess!.tracing!.push({ | responseItem.workflowProcess!.tracing!.push({ | ||||
| ...iterationStartedData, | ...iterationStartedData, | ||||
| status: WorkflowRunningStatus.Running, | status: WorkflowRunningStatus.Running, | ||||
| } as any) | |||||
| }) | |||||
| updateCurrentQAOnTree({ | updateCurrentQAOnTree({ | ||||
| placeholderQuestionId, | placeholderQuestionId, | ||||
| questionItem, | questionItem, | ||||
| ...tracing[iterationIndex], | ...tracing[iterationIndex], | ||||
| ...iterationFinishedData, | ...iterationFinishedData, | ||||
| status: WorkflowRunningStatus.Succeeded, | status: WorkflowRunningStatus.Succeeded, | ||||
| } as any | |||||
| } | |||||
| updateCurrentQAOnTree({ | updateCurrentQAOnTree({ | ||||
| placeholderQuestionId, | placeholderQuestionId, | ||||
| responseItem.workflowProcess!.tracing!.push({ | responseItem.workflowProcess!.tracing!.push({ | ||||
| ...nodeStartedData, | ...nodeStartedData, | ||||
| status: WorkflowRunningStatus.Running, | status: WorkflowRunningStatus.Running, | ||||
| } as any) | |||||
| }) | |||||
| updateCurrentQAOnTree({ | updateCurrentQAOnTree({ | ||||
| placeholderQuestionId, | placeholderQuestionId, | ||||
| questionItem, | questionItem, | ||||
| responseItem.workflowProcess!.tracing!.push({ | responseItem.workflowProcess!.tracing!.push({ | ||||
| ...loopStartedData, | ...loopStartedData, | ||||
| status: WorkflowRunningStatus.Running, | status: WorkflowRunningStatus.Running, | ||||
| } as any) | |||||
| }) | |||||
| updateCurrentQAOnTree({ | updateCurrentQAOnTree({ | ||||
| placeholderQuestionId, | placeholderQuestionId, | ||||
| questionItem, | questionItem, | ||||
| ...tracing[loopIndex], | ...tracing[loopIndex], | ||||
| ...loopFinishedData, | ...loopFinishedData, | ||||
| status: WorkflowRunningStatus.Succeeded, | status: WorkflowRunningStatus.Succeeded, | ||||
| } as any | |||||
| } | |||||
| updateCurrentQAOnTree({ | updateCurrentQAOnTree({ | ||||
| placeholderQuestionId, | placeholderQuestionId, |
| import ConfigParamModal from '@/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal' | import ConfigParamModal from '@/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal' | ||||
| import AnnotationFullModal from '@/app/components/billing/annotation-full/modal' | import AnnotationFullModal from '@/app/components/billing/annotation-full/modal' | ||||
| import { ANNOTATION_DEFAULT } from '@/config' | import { ANNOTATION_DEFAULT } from '@/config' | ||||
| import type { AnnotationReplyConfig } from '@/models/debug' | |||||
| type Props = { | type Props = { | ||||
| disabled?: boolean | disabled?: boolean | ||||
| const featuresStore = useFeaturesStore() | const featuresStore = useFeaturesStore() | ||||
| const annotationReply = useFeatures(s => s.features.annotationReply) | const annotationReply = useFeatures(s => s.features.annotationReply) | ||||
| const updateAnnotationReply = useCallback((newConfig: any) => { | |||||
| const updateAnnotationReply = useCallback((newConfig: AnnotationReplyConfig) => { | |||||
| const { | const { | ||||
| features, | features, | ||||
| setFeatures, | setFeatures, |
| } | } | ||||
| }, []) | }, []) | ||||
| const transformListener = useCallback((textNode: any) => { | |||||
| const transformListener = useCallback((textNode: CustomTextNode) => { | |||||
| resetReg() | resetReg() | ||||
| return decoratorTransform(textNode, getMatch, createWorkflowVariableBlockNode) | return decoratorTransform(textNode, getMatch, createWorkflowVariableBlockNode) | ||||
| }, [createWorkflowVariableBlockNode, getMatch]) | }, [createWorkflowVariableBlockNode, getMatch]) |
| import type { ReactNode } from 'react' | |||||
| import React from 'react' | import React from 'react' | ||||
| import { act, render, screen, waitFor } from '@testing-library/react' | import { act, render, screen, waitFor } from '@testing-library/react' | ||||
| import Toast, { ToastProvider, useToastContext } from '.' | import Toast, { ToastProvider, useToastContext } from '.' | ||||
| const CustomToastContext = React.createContext({ notify: noop, close: undefined }) | const CustomToastContext = React.createContext({ notify: noop, close: undefined }) | ||||
| // Create a wrapper component using the custom context | // Create a wrapper component using the custom context | ||||
| const Wrapper = ({ children }: any) => ( | |||||
| const Wrapper = ({ children }: { children: ReactNode }) => ( | |||||
| <CustomToastContext.Provider value={{ notify: noop, close: undefined }}> | <CustomToastContext.Provider value={{ notify: noop, close: undefined }}> | ||||
| {children} | {children} | ||||
| </CustomToastContext.Provider> | </CustomToastContext.Provider> |
| import cn from '@/utils/classnames' | import cn from '@/utils/classnames' | ||||
| import Divider from '@/app/components/base/divider' | import Divider from '@/app/components/base/divider' | ||||
| import { ToastContext } from '@/app/components/base/toast' | import { ToastContext } from '@/app/components/base/toast' | ||||
| import type { IndexingStatusResponse } from '@/models/datasets' | |||||
| import { ProcessMode, type ProcessRuleResponse } from '@/models/datasets' | import { ProcessMode, type ProcessRuleResponse } from '@/models/datasets' | ||||
| import type { CommonResponse } from '@/models/common' | import type { CommonResponse } from '@/models/common' | ||||
| import { asyncRunSafe, sleep } from '@/utils' | import { asyncRunSafe, sleep } from '@/utils' | ||||
| const localDatasetId = dstId ?? datasetId | const localDatasetId = dstId ?? datasetId | ||||
| const localDocumentId = docId ?? documentId | const localDocumentId = docId ?? documentId | ||||
| const [indexingStatusDetail, setIndexingStatusDetail] = useState<any>(null) | |||||
| const [indexingStatusDetail, setIndexingStatusDetail] = useState<IndexingStatusResponse | null>(null) | |||||
| const fetchIndexingStatus = async () => { | const fetchIndexingStatus = async () => { | ||||
| const status = await doFetchIndexingStatus({ datasetId: localDatasetId, documentId: localDocumentId }) | const status = await doFetchIndexingStatus({ datasetId: localDatasetId, documentId: localDocumentId }) | ||||
| setIndexingStatusDetail(status) | setIndexingStatusDetail(status) |
| import type { ChangeEvent } from 'react' | |||||
| import React, { useState } from 'react' | import React, { useState } from 'react' | ||||
| import { useTranslation } from 'react-i18next' | import { useTranslation } from 'react-i18next' | ||||
| import { | import { | ||||
| setIsSettingsOpen(false) | setIsSettingsOpen(false) | ||||
| } | } | ||||
| function handleTextChange(event: any) { | |||||
| function handleTextChange(event: ChangeEvent<HTMLTextAreaElement>) { | |||||
| setText(event.target.value) | setText(event.target.value) | ||||
| } | } | ||||
| { | { | ||||
| isShowInstallFromMarketplace && ( | isShowInstallFromMarketplace && ( | ||||
| <InstallFromMarketplace | <InstallFromMarketplace | ||||
| manifest={plugin as any} | |||||
| manifest={plugin} | |||||
| uniqueIdentifier={plugin.latest_package_identifier} | uniqueIdentifier={plugin.latest_package_identifier} | ||||
| onClose={hideInstallFromMarketplace} | onClose={hideInstallFromMarketplace} | ||||
| onSuccess={hideInstallFromMarketplace} | onSuccess={hideInstallFromMarketplace} |
| Toast.notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | Toast.notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) | ||||
| }, | }, | ||||
| }) | }) | ||||
| const handleUpdate = (state: any) => updateEndpoint({ | |||||
| const handleUpdate = (state: Record<string, any>) => updateEndpoint({ | |||||
| endpointID, | endpointID, | ||||
| state, | state, | ||||
| }) | }) |
| }, | }, | ||||
| }) | }) | ||||
| const handleCreate = (state: any) => createEndpoint({ | |||||
| const handleCreate = (state: Record<string, any>) => createEndpoint({ | |||||
| pluginUniqueID, | pluginUniqueID, | ||||
| state, | state, | ||||
| }) | }) |
| popupClassName='!w-[387px]' | popupClassName='!w-[387px]' | ||||
| isAdvancedMode | isAdvancedMode | ||||
| isInWorkflow | isInWorkflow | ||||
| value={varInput as any} | |||||
| value={varInput} | |||||
| setModel={handleModelChange(variable)} | setModel={handleModelChange(variable)} | ||||
| scope={scope} | scope={scope} | ||||
| /> | /> |
| { | { | ||||
| isShowInstallFromMarketplace && ( | isShowInstallFromMarketplace && ( | ||||
| <InstallFromMarketplace | <InstallFromMarketplace | ||||
| manifest={payload as any} | |||||
| manifest={payload} | |||||
| uniqueIdentifier={payload.latest_package_identifier} | uniqueIdentifier={payload.latest_package_identifier} | ||||
| onClose={hideInstallFromMarketplace} | onClose={hideInstallFromMarketplace} | ||||
| onSuccess={() => hideInstallFromMarketplace()} | onSuccess={() => hideInstallFromMarketplace()} |
| ...data, | ...data, | ||||
| status: NodeRunningStatus.Running, | status: NodeRunningStatus.Running, | ||||
| expand: true, | expand: true, | ||||
| } as any) | |||||
| }) | |||||
| })) | })) | ||||
| }, | }, | ||||
| onIterationNext: () => { | onIterationNext: () => { | ||||
| draft.tracing[iterationsIndex] = { | draft.tracing[iterationsIndex] = { | ||||
| ...data, | ...data, | ||||
| expand: !!data.error, | expand: !!data.error, | ||||
| } as any | |||||
| } | |||||
| })) | })) | ||||
| }, | }, | ||||
| onLoopStart: ({ data }) => { | onLoopStart: ({ data }) => { | ||||
| ...data, | ...data, | ||||
| status: NodeRunningStatus.Running, | status: NodeRunningStatus.Running, | ||||
| expand: true, | expand: true, | ||||
| } as any) | |||||
| }) | |||||
| })) | })) | ||||
| }, | }, | ||||
| onLoopNext: () => { | onLoopNext: () => { | ||||
| draft.tracing[loopsIndex] = { | draft.tracing[loopsIndex] = { | ||||
| ...data, | ...data, | ||||
| expand: !!data.error, | expand: !!data.error, | ||||
| } as any | |||||
| } | |||||
| })) | })) | ||||
| }, | }, | ||||
| onNodeStarted: ({ data }) => { | onNodeStarted: ({ data }) => { | ||||
| ...data, | ...data, | ||||
| status: NodeRunningStatus.Running, | status: NodeRunningStatus.Running, | ||||
| expand: true, | expand: true, | ||||
| } as any) | |||||
| }) | |||||
| })) | })) | ||||
| }, | }, | ||||
| onNodeFinished: ({ data }) => { | onNodeFinished: ({ data }) => { | ||||
| : {}), | : {}), | ||||
| ...data, | ...data, | ||||
| expand: !!data.error, | expand: !!data.error, | ||||
| } as any | |||||
| } | |||||
| } | } | ||||
| })) | })) | ||||
| }, | }, |
| } | } | ||||
| export const getPlainValue = (value: Record<string, any>) => { | export const getPlainValue = (value: Record<string, any>) => { | ||||
| const plainValue = { ...value } as any | |||||
| const plainValue = { ...value } | |||||
| Object.keys(plainValue).forEach((key) => { | Object.keys(plainValue).forEach((key) => { | ||||
| plainValue[key] = value[key].value | plainValue[key] = value[key].value | ||||
| }) | }) |
| } | } | ||||
| } | } | ||||
| */ | */ | ||||
| const { letters, groups: withLetterAndGroupViewToolsData } = groupItems(tools, tool => (tool as any).label[language][0]) | |||||
| const { letters, groups: withLetterAndGroupViewToolsData } = groupItems(tools, tool => tool.label[language][0]) | |||||
| const treeViewToolsData = useMemo(() => { | const treeViewToolsData = useMemo(() => { | ||||
| const result: Record<string, ToolWithProvider[]> = {} | const result: Record<string, ToolWithProvider[]> = {} | ||||
| Object.keys(withLetterAndGroupViewToolsData).forEach((letter) => { | Object.keys(withLetterAndGroupViewToolsData).forEach((letter) => { |
| incomeEdges.forEach((edge) => { | incomeEdges.forEach((edge) => { | ||||
| edge.data = { | edge.data = { | ||||
| ...edge.data, | ...edge.data, | ||||
| _targetRunningStatus: data.status as any, | |||||
| _targetRunningStatus: data.status, | |||||
| } | } | ||||
| }) | }) | ||||
| }) | }) |
| incomeEdges.forEach((edge) => { | incomeEdges.forEach((edge) => { | ||||
| edge.data = { | edge.data = { | ||||
| ...edge.data, | ...edge.data, | ||||
| _targetRunningStatus: data.status as any, | |||||
| _targetRunningStatus: data.status, | |||||
| } | } | ||||
| }) | }) | ||||
| }) | }) |
| incomeEdges.forEach((edge) => { | incomeEdges.forEach((edge) => { | ||||
| edge.data = { | edge.data = { | ||||
| ...edge.data, | ...edge.data, | ||||
| _targetRunningStatus: data.status as any, | |||||
| _targetRunningStatus: data.status, | |||||
| } | } | ||||
| }) | }) | ||||
| }) | }) |
| required: true, | required: true, | ||||
| }], | }], | ||||
| values: { files }, | values: { files }, | ||||
| onChange: keyValue => setFiles((keyValue as any).files), | |||||
| onChange: keyValue => setFiles(keyValue.files), | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| runningStatus={runningStatus} | runningStatus={runningStatus} |
| required: false, | required: false, | ||||
| }], | }], | ||||
| values: { [iteratorInputKey]: iterator }, | values: { [iteratorInputKey]: iterator }, | ||||
| onChange: keyValue => setIterator((keyValue as any)[iteratorInputKey]), | |||||
| onChange: keyValue => setIterator(keyValue[iteratorInputKey]), | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| runningStatus={runningStatus} | runningStatus={runningStatus} |
| model: configs.reranking_model?.reranking_model_name, | model: configs.reranking_model?.reranking_model_name, | ||||
| }), | }), | ||||
| reranking_mode: configs.reranking_mode, | reranking_mode: configs.reranking_mode, | ||||
| weights: configs.weights as any, | |||||
| weights: configs.weights, | |||||
| reranking_enable: configs.reranking_enable, | reranking_enable: configs.reranking_enable, | ||||
| }) | }) | ||||
| }, [onMultipleRetrievalConfigChange, payload.retrieval_mode, validRerankDefaultProvider, validRerankDefaultModel, onRetrievalModeChange]) | }, [onMultipleRetrievalConfigChange, payload.retrieval_mode, validRerankDefaultProvider, validRerankDefaultModel, onRetrievalModeChange]) |
| required: true, | required: true, | ||||
| }], | }], | ||||
| values: { query }, | values: { query }, | ||||
| onChange: keyValue => setQuery((keyValue as any).query), | |||||
| onChange: keyValue => setQuery(keyValue.query), | |||||
| }, | }, | ||||
| ]} | ]} | ||||
| runningStatus={runningStatus} | runningStatus={runningStatus} |
| required: false, | required: false, | ||||
| }], | }], | ||||
| values: { '#context#': contexts }, | values: { '#context#': contexts }, | ||||
| onChange: keyValue => setContexts((keyValue as any)['#context#']), | |||||
| onChange: keyValue => setContexts(keyValue['#context#']), | |||||
| }, | }, | ||||
| ) | ) | ||||
| } | } |
| })() | })() | ||||
| const currCollection = currentTools.find(item => canFindTool(item.id, provider_id)) | const currCollection = currentTools.find(item => canFindTool(item.id, provider_id)) | ||||
| const currTool = currCollection?.tools.find(tool => tool.name === tool_name) | const currTool = currCollection?.tools.find(tool => tool.name === tool_name) | ||||
| const toExactParams = (currTool?.parameters || []).filter((item: any) => item.form === 'llm') | |||||
| const toExactParams = (currTool?.parameters || []).filter(item => item.form === 'llm') | |||||
| const formattedParams = toParmExactParams(toExactParams, language) | const formattedParams = toParmExactParams(toExactParams, language) | ||||
| onImport(formattedParams) | onImport(formattedParams) | ||||
| }, [buildInTools, customTools, language, onImport, workflowTools]) | }, [buildInTools, customTools, language, onImport, workflowTools]) |
| required: false, | required: false, | ||||
| }], | }], | ||||
| values: { '#files#': visionFiles }, | values: { '#files#': visionFiles }, | ||||
| onChange: keyValue => setVisionFiles((keyValue as any)['#files#']), | |||||
| onChange: keyValue => setVisionFiles(keyValue['#files#']), | |||||
| }, | }, | ||||
| ) | ) | ||||
| } | } |
| <ResultText | <ResultText | ||||
| isRunning={workflowRunningData?.result?.status === WorkflowRunningStatus.Running || !workflowRunningData?.result} | isRunning={workflowRunningData?.result?.status === WorkflowRunningStatus.Running || !workflowRunningData?.result} | ||||
| outputs={workflowRunningData?.resultText} | outputs={workflowRunningData?.resultText} | ||||
| allFiles={workflowRunningData?.result?.files as any} | |||||
| allFiles={workflowRunningData?.result?.files} | |||||
| error={workflowRunningData?.result?.error} | error={workflowRunningData?.result?.error} | ||||
| onClick={() => switchTab('DETAIL')} | onClick={() => switchTab('DETAIL')} | ||||
| /> | /> |
| const [startNode, loopNode, ...loops] = list | const [startNode, loopNode, ...loops] = list | ||||
| const result = format(list as any, noop) | const result = format(list as any, noop) | ||||
| test('result should have no nodes in loop node', () => { | test('result should have no nodes in loop node', () => { | ||||
| expect((result as any).find((item: any) => !!item.execution_metadata?.loop_id)).toBeUndefined() | |||||
| expect(result.find(item => !!item.execution_metadata?.loop_id)).toBeUndefined() | |||||
| }) | }) | ||||
| test('loop should put nodes in details', () => { | test('loop should put nodes in details', () => { | ||||
| expect(result as any).toEqual([ | |||||
| expect(result).toEqual([ | |||||
| startNode, | startNode, | ||||
| { | { | ||||
| ...loopNode, | ...loopNode, |
| const [startNode, retryNode, ...retryDetail] = steps | const [startNode, retryNode, ...retryDetail] = steps | ||||
| const result = format(steps as any) | const result = format(steps as any) | ||||
| test('should have no retry status nodes', () => { | test('should have no retry status nodes', () => { | ||||
| expect(result.find(item => (item as any).status === 'retry')).toBeUndefined() | |||||
| expect(result.find(item => item.status === 'retry')).toBeUndefined() | |||||
| }) | }) | ||||
| test('should put retry nodes in retryDetail', () => { | test('should put retry nodes in retryDetail', () => { | ||||
| expect(result).toEqual([ | expect(result).toEqual([ |
| const currCollection = currentTools.find(item => canFindTool(item.id, provider_id)) | const currCollection = currentTools.find(item => canFindTool(item.id, provider_id)) | ||||
| const currTool = currCollection?.tools.find(tool => tool.name === tool_name) | const currTool = currCollection?.tools.find(tool => tool.name === tool_name) | ||||
| const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : [] | const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : [] | ||||
| const toolInputVarSchema = formSchemas.filter((item: any) => item.form === 'llm') | |||||
| const toolSettingSchema = formSchemas.filter((item: any) => item.form !== 'llm') | |||||
| const toolInputVarSchema = formSchemas.filter(item => item.form === 'llm') | |||||
| const toolSettingSchema = formSchemas.filter(item => item.form !== 'llm') | |||||
| return { | return { | ||||
| toolInputsSchema: (() => { | toolInputsSchema: (() => { |
| import type { ChangeEventHandler } from 'react' | |||||
| import { | import { | ||||
| useCallback, | useCallback, | ||||
| useRef, | useRef, | ||||
| }) | }) | ||||
| }, [querySchoolsWithDebounced, handleUpdateSchools]) | }, [querySchoolsWithDebounced, handleUpdateSchools]) | ||||
| const handleValueChange = useCallback((e: any) => { | |||||
| const handleValueChange: ChangeEventHandler<HTMLInputElement> = useCallback((e) => { | |||||
| setOpen(true) | setOpen(true) | ||||
| setSchools([]) | setSchools([]) | ||||
| pageRef.current = 0 | pageRef.current = 0 |
| }) | }) | ||||
| describe('getTextWidthWithCanvas', () => { | describe('getTextWidthWithCanvas', () => { | ||||
| let originalCreateElement: any | |||||
| let originalCreateElement: typeof document.createElement | |||||
| beforeEach(() => { | beforeEach(() => { | ||||
| // Store original implementation | // Store original implementation | ||||
| }) | }) | ||||
| describe('removeSpecificQueryParam', () => { | describe('removeSpecificQueryParam', () => { | ||||
| let originalLocation: any | |||||
| let originalReplaceState: any | |||||
| let originalLocation: Location | |||||
| let originalReplaceState: typeof window.history.replaceState | |||||
| beforeEach(() => { | beforeEach(() => { | ||||
| originalLocation = window.location | originalLocation = window.location |