fix: type

This commit is contained in:
lyzno1 2025-10-30 18:11:52 +08:00
parent bc95678c5e
commit 99fac21bdb
No known key found for this signature in database
8 changed files with 37 additions and 15 deletions

View File

@ -110,7 +110,7 @@ const Configuration: FC = () => {
const pathname = usePathname()
const matched = pathname.match(/\/app\/([^/]+)/)
const appId = (matched?.length && matched[1]) ? matched[1] : ''
const [mode, setMode] = useState<AppModeEnum>()
const [mode, setMode] = useState<AppModeEnum>(AppModeEnum.CHAT)
const [publishedConfig, setPublishedConfig] = useState<PublishConfig | null>(null)
const [conversationId, setConversationId] = useState<string | null>('')
@ -705,8 +705,7 @@ const Configuration: FC = () => {
provider: currentRerankProvider?.provider,
model: currentRerankModel?.model,
})
setDatasetConfigs({
retrieval_model: RETRIEVE_TYPE.multiWay,
const datasetConfigsToSet = {
...modelConfig.dataset_configs,
...retrievalConfig,
...(retrievalConfig.reranking_model ? {
@ -715,7 +714,9 @@ const Configuration: FC = () => {
reranking_provider_name: correctModelProvider(retrievalConfig.reranking_model.provider),
},
} : {}),
} as DatasetConfigs)
} as DatasetConfigs
datasetConfigsToSet.retrieval_model = datasetConfigsToSet.retrieval_model ?? RETRIEVE_TYPE.multiWay
setDatasetConfigs(datasetConfigsToSet)
setHasFetchedDetail(true)
})()
}, [appId])

View File

@ -1,7 +1,22 @@
import { create } from 'zustand'
import type { PluginDetail } from '../types'
import type {
ParametersSchema,
PluginDeclaration,
PluginDetail,
PluginTriggerSubscriptionConstructor,
} from '../types'
export type SimpleDetail = Pick<PluginDetail, 'plugin_id' | 'declaration' | 'name' | 'plugin_unique_identifier' | 'id'> & { provider: string }
type TriggerDeclarationSummary = {
subscription_schema?: ParametersSchema[]
subscription_constructor?: PluginTriggerSubscriptionConstructor | null
}
export type SimpleDetail = Pick<PluginDetail, 'plugin_id' | 'name' | 'plugin_unique_identifier' | 'id'> & {
provider: string
declaration: Partial<Omit<PluginDeclaration, 'trigger'>> & {
trigger?: TriggerDeclarationSummary
}
}
type Shape = {
detail: SimpleDetail | undefined

View File

@ -139,7 +139,7 @@ export const CommonCreateModal = ({ onClose, createType, builder }: Props) => {
const { mutate: buildSubscription, isPending: isBuilding } = useBuildTriggerSubscription()
const { mutate: updateBuilder } = useUpdateTriggerSubscriptionBuilder()
const manualPropertiesSchema = detail?.declaration.trigger.subscription_schema || [] // manual
const manualPropertiesSchema = detail?.declaration?.trigger?.subscription_schema || [] // manual
const manualPropertiesFormRef = React.useRef<FormRefObject>(null)
const subscriptionFormRef = React.useRef<FormRefObject>(null)

View File

@ -297,14 +297,14 @@ const BasePanel: FC<BasePanelProps> = ({
const { setDetail } = usePluginStore()
useEffect(() => {
if (currentTriggerPlugin) {
if (currentTriggerPlugin?.subscription_constructor) {
setDetail({
name: currentTriggerPlugin.label[language],
plugin_id: currentTriggerPlugin.plugin_id || '',
plugin_unique_identifier: currentTriggerPlugin.plugin_unique_identifier || '',
id: currentTriggerPlugin.id,
provider: currentTriggerPlugin.name,
declaration: {
tool: undefined,
// @ts-expect-error just remain the necessary fields
trigger: {
subscription_schema: currentTriggerPlugin.subscription_schema || [],
subscription_constructor: currentTriggerPlugin.subscription_constructor,
@ -312,7 +312,7 @@ const BasePanel: FC<BasePanelProps> = ({
},
})
}
}, [currentTriggerPlugin, setDetail])
}, [currentTriggerPlugin, language, setDetail])
const dataSourceList = useStore(s => s.dataSourceList)

View File

@ -22,6 +22,7 @@ import Switch from '@/app/components/base/switch'
import { RiAlertFill, RiQuestionLine } from '@remixicon/react'
import { fetchAndMergeValidCompletionParams } from '@/utils/completion-params'
import Toast from '@/app/components/base/toast'
import { ModelModeType } from '@/types/app'
const i18nPrefix = 'workflow.nodes.llm'
@ -94,6 +95,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
}
})()
}, [inputs.model.completion_params])
const modelMode = (model?.mode as ModelModeType | undefined) ?? ModelModeType.chat
return (
<div className='mt-2'>
@ -106,7 +108,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
popupClassName='!w-[387px]'
isInWorkflow
isAdvancedMode={true}
mode={model?.mode}
mode={modelMode}
provider={model?.provider}
completionParams={model?.completion_params}
modelId={model?.name}

View File

@ -19,6 +19,7 @@ import type { NodePanelProps } from '@/app/components/workflow/types'
import Tooltip from '@/app/components/base/tooltip'
import { VarType } from '@/app/components/workflow/types'
import { FieldCollapse } from '@/app/components/workflow/nodes/_base/components/collapse'
import { ModelModeType } from '@/types/app'
const i18nPrefix = 'workflow.nodes.parameterExtractor'
const i18nCommonPrefix = 'workflow.common'
@ -55,6 +56,7 @@ const Panel: FC<NodePanelProps<ParameterExtractorNodeType>> = ({
} = useConfig(id, data)
const model = inputs.model
const modelMode = (model?.mode as ModelModeType | undefined) ?? ModelModeType.chat
return (
<div className='pt-2'>
@ -67,7 +69,7 @@ const Panel: FC<NodePanelProps<ParameterExtractorNodeType>> = ({
popupClassName='!w-[387px]'
isInWorkflow
isAdvancedMode={true}
mode={model?.mode}
mode={modelMode}
provider={model?.provider}
completionParams={model?.completion_params}
modelId={model?.name}

View File

@ -13,6 +13,7 @@ import type { NodePanelProps } from '@/app/components/workflow/types'
import Split from '@/app/components/workflow/nodes/_base/components/split'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
import { FieldCollapse } from '@/app/components/workflow/nodes/_base/components/collapse'
import { ModelModeType } from '@/types/app'
const i18nPrefix = 'workflow.nodes.questionClassifiers'
@ -44,6 +45,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
} = useConfig(id, data)
const model = inputs.model
const modelMode = (model?.mode as ModelModeType | undefined) ?? ModelModeType.chat
return (
<div className='pt-2'>
@ -56,7 +58,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
popupClassName='!w-[387px]'
isInWorkflow
isAdvancedMode={true}
mode={model?.mode}
mode={modelMode}
provider={model?.provider}
completionParams={model.completion_params}
modelId={model.name}

View File

@ -52,7 +52,7 @@ const Panel = () => {
// is workflow
...((isWorkflowPage && !isChatMode) ? [{
name: 'timestamp',
value_type: 'integer' as const,
value_type: 'number' as const,
description: t('workflow.globalVar.fieldsDescription.triggerTimestamp'),
}] : []),
]