diff --git a/web/src/hooks/flow-hooks.ts b/web/src/hooks/flow-hooks.ts index 9fb3cfe70..7d9b74bbb 100644 --- a/web/src/hooks/flow-hooks.ts +++ b/web/src/hooks/flow-hooks.ts @@ -90,3 +90,22 @@ export const useDeleteFlow = () => { return { data, loading, deleteFlow: mutateAsync }; }; + +export const useRunFlow = () => { + const { + data, + isPending: loading, + mutateAsync, + } = useMutation({ + mutationKey: ['runFlow'], + mutationFn: async (params: { id: string; dsl: DSL }) => { + const { data } = await flowService.runCanvas(params); + if (data.retcode === 0) { + message.success(i18n.t(`message.modified`)); + } + return data?.data ?? {}; + }, + }); + + return { data, loading, runFlow: mutateAsync }; +}; diff --git a/web/src/pages/flow/constant.ts b/web/src/pages/flow/constant.ts index f230a68ba..0f29c775f 100644 --- a/web/src/pages/flow/constant.ts +++ b/web/src/pages/flow/constant.ts @@ -1,5 +1,3 @@ -import { ModelVariableType } from '@/constants/knowledge'; - export enum Operator { Begin = 'Begin', Retrieval = 'Retrieval', @@ -18,8 +16,8 @@ export const initialBeginValues = { }; export const initialGenerateValues = { - parameters: ModelVariableType.Precise, - temperatureEnabled: false, + // parameters: ModelVariableType.Precise, + // temperatureEnabled: true, temperature: 0.1, top_p: 0.3, frequency_penalty: 0.7, @@ -30,3 +28,10 @@ export const initialGenerateValues = { The above is the content you need to summarize.`, cite: true, }; + +export const initialFormValuesMap = { + [Operator.Begin]: initialBeginValues, + [Operator.Retrieval]: initialRetrievalValues, + [Operator.Generate]: initialGenerateValues, + [Operator.Answer]: {}, +}; diff --git a/web/src/pages/flow/header/index.tsx b/web/src/pages/flow/header/index.tsx index 57293ffbd..b4988c4d4 100644 --- a/web/src/pages/flow/header/index.tsx +++ b/web/src/pages/flow/header/index.tsx @@ -1,10 +1,11 @@ import { Button, Flex } from 'antd'; -import { useSaveGraph } from '../hooks'; +import { useRunGraph, useSaveGraph } from '../hooks'; import styles from './index.less'; const FlowHeader = () => { const { saveGraph } = useSaveGraph(); + const { runGraph } = useRunGraph(); return ( { gap={'large'} className={styles.flowHeader} > -