diff --git a/web/src/components/home-card.tsx b/web/src/components/home-card.tsx index 8defb4f66..d5099756c 100644 --- a/web/src/components/home-card.tsx +++ b/web/src/components/home-card.tsx @@ -29,7 +29,7 @@ export function HomeCard({ onClick?.(); }} > - +
) { + return ( + +
select
+
+ ); +} diff --git a/web/src/pages/agent/canvas/node/dropdown/accordion-operators.tsx b/web/src/pages/agent/canvas/node/dropdown/accordion-operators.tsx index f26328bbd..864e20254 100644 --- a/web/src/pages/agent/canvas/node/dropdown/accordion-operators.tsx +++ b/web/src/pages/agent/canvas/node/dropdown/accordion-operators.tsx @@ -30,7 +30,7 @@ export function AccordionOperators({ return ( @@ -75,7 +75,11 @@ export function AccordionOperators({ diff --git a/web/src/pages/agent/constant/index.tsx b/web/src/pages/agent/constant/index.tsx index 0cff21c9d..6652b527e 100644 --- a/web/src/pages/agent/constant/index.tsx +++ b/web/src/pages/agent/constant/index.tsx @@ -125,9 +125,6 @@ export const componentMenuList = [ { name: Operator.GoogleScholar, }, - { - name: Operator.DeepL, - }, { name: Operator.GitHub, }, @@ -388,11 +385,6 @@ export const initialGoogleScholarValues = { }, }; -export const initialDeepLValues = { - top_n: 5, - auth_key: 'relevance', -}; - export const initialGithubValues = { top_n: 5, query: AgentGlobals.SysQuery, @@ -723,6 +715,10 @@ export const initialPlaceholderValues = { // It's just a visual placeholder }; +export const initialDataOperationsValues = { + outputs: {}, +}; + export const CategorizeAnchorPointPositions = [ { top: 1, right: 34 }, { top: 8, right: 18 }, @@ -771,7 +767,6 @@ export const RestrictedUpstreamMap = { [Operator.Google]: [Operator.Begin, Operator.Retrieval], [Operator.Bing]: [Operator.Begin, Operator.Retrieval], [Operator.GoogleScholar]: [Operator.Begin, Operator.Retrieval], - [Operator.DeepL]: [Operator.Begin, Operator.Retrieval], [Operator.GitHub]: [Operator.Begin, Operator.Retrieval], [Operator.BaiduFanyi]: [Operator.Begin, Operator.Retrieval], [Operator.QWeather]: [Operator.Begin, Operator.Retrieval], @@ -798,7 +793,8 @@ export const RestrictedUpstreamMap = { [Operator.UserFillUp]: [Operator.Begin], [Operator.Tool]: [Operator.Begin], [Operator.Placeholder]: [Operator.Begin], - [Operator.Parser]: [Operator.Begin], + [Operator.DataOperations]: [Operator.Begin], + [Operator.Parser]: [Operator.Begin], // pipeline [Operator.Splitter]: [Operator.Begin], [Operator.HierarchicalMerger]: [Operator.Begin], [Operator.Tokenizer]: [Operator.Begin], @@ -822,7 +818,6 @@ export const NodeMap = { [Operator.Google]: 'ragNode', [Operator.Bing]: 'ragNode', [Operator.GoogleScholar]: 'ragNode', - [Operator.DeepL]: 'ragNode', [Operator.GitHub]: 'ragNode', [Operator.BaiduFanyi]: 'ragNode', [Operator.QWeather]: 'ragNode', @@ -855,6 +850,7 @@ export const NodeMap = { [Operator.Splitter]: 'splitterNode', [Operator.HierarchicalMerger]: 'splitterNode', [Operator.Extractor]: 'contextNode', + [Operator.DataOperations]: 'dataOperationsNode', }; export enum BeginQueryType { diff --git a/web/src/pages/agent/form-sheet/form-config-map.tsx b/web/src/pages/agent/form-sheet/form-config-map.tsx index f99e2eed7..79cd8cfc4 100644 --- a/web/src/pages/agent/form-sheet/form-config-map.tsx +++ b/web/src/pages/agent/form-sheet/form-config-map.tsx @@ -9,7 +9,7 @@ import BingForm from '../form/bing-form'; import CategorizeForm from '../form/categorize-form'; import CodeForm from '../form/code-form'; import CrawlerForm from '../form/crawler-form'; -import DeepLForm from '../form/deepl-form'; +import DataOperationsForm from '../form/data-operations-form'; import DuckDuckGoForm from '../form/duckduckgo-form'; import EmailForm from '../form/email-form'; import ExeSQLForm from '../form/exesql-form'; @@ -99,9 +99,6 @@ export const FormConfigMap = { [Operator.GoogleScholar]: { component: GoogleScholarForm, }, - [Operator.DeepL]: { - component: DeepLForm, - }, [Operator.GitHub]: { component: GithubForm, }, @@ -190,4 +187,7 @@ export const FormConfigMap = { [Operator.Extractor]: { component: ExtractorForm, }, + [Operator.DataOperations]: { + component: DataOperationsForm, + }, }; diff --git a/web/src/pages/agent/form/data-operations-form/index.tsx b/web/src/pages/agent/form/data-operations-form/index.tsx new file mode 100644 index 000000000..5991995f4 --- /dev/null +++ b/web/src/pages/agent/form/data-operations-form/index.tsx @@ -0,0 +1,47 @@ +import { SelectWithSearch } from '@/components/originui/select-with-search'; +import { RAGFlowFormItem } from '@/components/ragflow-form'; +import { Form } from '@/components/ui/form'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { memo } from 'react'; +import { useForm } from 'react-hook-form'; +import { useTranslation } from 'react-i18next'; +import { z } from 'zod'; +import { initialDataOperationsValues } from '../../constant'; +import { useFormValues } from '../../hooks/use-form-values'; +import { useWatchFormChange } from '../../hooks/use-watch-form-change'; +import { INextOperatorForm } from '../../interface'; +import { FormWrapper } from '../components/form-wrapper'; +import { Output } from '../components/output'; + +export const RetrievalPartialSchema = { + select_operation: z.string(), +}; + +export const FormSchema = z.object(RetrievalPartialSchema); + +function DataOperationsForm({ node }: INextOperatorForm) { + const { t } = useTranslation(); + + const defaultValues = useFormValues(initialDataOperationsValues, node); + + const form = useForm({ + defaultValues: defaultValues, + resolver: zodResolver(FormSchema), + }); + + useWatchFormChange(node?.id, form); + + return ( +
+ + + + + + + +
+ ); +} + +export default memo(DataOperationsForm); diff --git a/web/src/pages/agent/form/deepl-form/index.tsx b/web/src/pages/agent/form/deepl-form/index.tsx deleted file mode 100644 index 55240b3c1..000000000 --- a/web/src/pages/agent/form/deepl-form/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import TopNItem from '@/components/top-n-item'; -import { useTranslate } from '@/hooks/common-hooks'; -import { Form, Select } from 'antd'; -import { useBuildSortOptions } from '../../form-hooks'; -import { IOperatorForm } from '../../interface'; -import { DeepLSourceLangOptions, DeepLTargetLangOptions } from '../../options'; -import DynamicInputVariable from '../components/dynamic-input-variable'; - -const DeepLForm = ({ onValuesChange, form, node }: IOperatorForm) => { - const { t } = useTranslate('flow'); - const options = useBuildSortOptions(); - - return ( -
- - - - - - - - - - - -
- ); -}; - -export default DeepLForm; diff --git a/web/src/pages/agent/form/tool-form/constant.tsx b/web/src/pages/agent/form/tool-form/constant.tsx index fac1b8998..fc5f4e94c 100644 --- a/web/src/pages/agent/form/tool-form/constant.tsx +++ b/web/src/pages/agent/form/tool-form/constant.tsx @@ -1,6 +1,5 @@ import { Operator } from '../../constant'; import AkShareForm from '../akshare-form'; -import DeepLForm from '../deepl-form'; import ArXivForm from './arxiv-form'; import BingForm from './bing-form'; import CrawlerForm from './crawler-form'; @@ -28,7 +27,6 @@ export const ToolFormConfigMap = { [Operator.Google]: GoogleForm, [Operator.Bing]: BingForm, [Operator.GoogleScholar]: GoogleScholarForm, - [Operator.DeepL]: DeepLForm, [Operator.GitHub]: GithubForm, [Operator.ExeSQL]: ExeSQLForm, [Operator.AkShare]: AkShareForm, diff --git a/web/src/pages/agent/hooks/use-add-node.ts b/web/src/pages/agent/hooks/use-add-node.ts index 99a91dfa3..d3b2ef765 100644 --- a/web/src/pages/agent/hooks/use-add-node.ts +++ b/web/src/pages/agent/hooks/use-add-node.ts @@ -19,7 +19,7 @@ import { initialCategorizeValues, initialCodeValues, initialCrawlerValues, - initialDeepLValues, + initialDataOperationsValues, initialDuckValues, initialEmailValues, initialExeSqlValues, @@ -93,7 +93,6 @@ export const useInitializeOperatorParams = () => { [Operator.Google]: initialGoogleValues, [Operator.Bing]: initialBingValues, [Operator.GoogleScholar]: initialGoogleScholarValues, - [Operator.DeepL]: initialDeepLValues, [Operator.SearXNG]: initialSearXNGValues, [Operator.GitHub]: initialGithubValues, [Operator.BaiduFanyi]: initialBaiduFanyiValues, @@ -131,6 +130,7 @@ export const useInitializeOperatorParams = () => { sys_prompt: t('flow.prompts.system.summary'), prompts: t('flow.prompts.user.summary'), }, + [Operator.DataOperations]: initialDataOperationsValues, }; }, [llmId]); diff --git a/web/src/pages/agent/operator-icon.tsx b/web/src/pages/agent/operator-icon.tsx index b8ebc34ba..fcd17954a 100644 --- a/web/src/pages/agent/operator-icon.tsx +++ b/web/src/pages/agent/operator-icon.tsx @@ -14,7 +14,7 @@ import { ReactComponent as YahooFinanceIcon } from '@/assets/svg/yahoo-finance.s import { IconFont } from '@/components/icon-font'; import { cn } from '@/lib/utils'; -import { HousePlus } from 'lucide-react'; +import { FileCode, HousePlus } from 'lucide-react'; import { Operator } from './constant'; interface IProps { @@ -56,13 +56,18 @@ export const SVGIconMap = { [Operator.Crawler]: CrawlerIcon, }; +export const LucideIconMap = { + [Operator.DataOperations]: FileCode, +}; + const Empty = () => { return
; }; const OperatorIcon = ({ name, className }: IProps) => { - const Icon = OperatorIconMap[name as keyof typeof OperatorIconMap] || Empty; - const SvgIcon = SVGIconMap[name as keyof typeof SVGIconMap] || Empty; + const Icon = OperatorIconMap[name as keyof typeof OperatorIconMap]; + const SvgIcon = SVGIconMap[name as keyof typeof SVGIconMap]; + const LucideIcon = LucideIconMap[name as keyof typeof LucideIconMap]; if (name === Operator.Begin) { return ( @@ -77,11 +82,21 @@ const OperatorIcon = ({ name, className }: IProps) => { ); } - return typeof Icon === 'string' ? ( - - ) : ( - - ); + if (Icon) { + return ( + + ); + } + + if (LucideIcon) { + return ; + } + + if (SvgIcon) { + return ; + } + + return ; }; export default OperatorIcon;