diff --git a/web/src/constants/agent.tsx b/web/src/constants/agent.tsx index c73fbfa60..20cd9557e 100644 --- a/web/src/constants/agent.tsx +++ b/web/src/constants/agent.tsx @@ -76,7 +76,6 @@ export enum Operator { Relevant = 'Relevant', RewriteQuestion = 'RewriteQuestion', KeywordExtract = 'KeywordExtract', - Baidu = 'Baidu', DuckDuckGo = 'DuckDuckGo', Wikipedia = 'Wikipedia', PubMed = 'PubMed', @@ -85,7 +84,6 @@ export enum Operator { Bing = 'Bing', GoogleScholar = 'GoogleScholar', GitHub = 'GitHub', - BaiduFanyi = 'BaiduFanyi', QWeather = 'QWeather', ExeSQL = 'ExeSQL', Switch = 'Switch', @@ -111,6 +109,7 @@ export enum Operator { SearXNG = 'SearXNG', Placeholder = 'Placeholder', DataOperations = 'DataOperations', + VariableAssigner = 'VariableAssigner', File = 'File', // pipeline Parser = 'Parser', Tokenizer = 'Tokenizer', diff --git a/web/src/hooks/logic-hooks/use-build-operator-options.tsx b/web/src/hooks/logic-hooks/use-build-operator-options.tsx index 52441e359..82e3ed79d 100644 --- a/web/src/hooks/logic-hooks/use-build-operator-options.tsx +++ b/web/src/hooks/logic-hooks/use-build-operator-options.tsx @@ -27,9 +27,12 @@ export function useBuildSwitchOperatorOptions( const { t } = useTranslation(); const switchOperatorOptions = useMemo(() => { - return SwitchOperatorOptions.filter((x) => - subset.some((y) => y === x.value), - ).map((x) => ({ + const filteredOptions = + subset.length > 0 + ? SwitchOperatorOptions.filter((x) => subset.some((y) => y === x.value)) + : SwitchOperatorOptions; + + return filteredOptions.map((x) => ({ value: x.value, icon: ( ) { + return ( + +
select
+
+ ); +} diff --git a/web/src/pages/agent/constant/index.tsx b/web/src/pages/agent/constant/index.tsx index 3abe3ca2c..f224e7563 100644 --- a/web/src/pages/agent/constant/index.tsx +++ b/web/src/pages/agent/constant/index.tsx @@ -66,106 +66,6 @@ export const AgentOperatorList = [ Operator.Agent, ]; -export const componentMenuList = [ - { - name: Operator.Retrieval, - }, - { - name: Operator.Categorize, - }, - { - name: Operator.Message, - }, - - { - name: Operator.RewriteQuestion, - }, - { - name: Operator.KeywordExtract, - }, - { - name: Operator.Switch, - }, - { - name: Operator.Iteration, - }, - { - name: Operator.Code, - }, - { - name: Operator.WaitingDialogue, - }, - { - name: Operator.Agent, - }, - { - name: Operator.Note, - }, - { - name: Operator.DuckDuckGo, - }, - { - name: Operator.Baidu, - }, - { - name: Operator.Wikipedia, - }, - { - name: Operator.PubMed, - }, - { - name: Operator.ArXiv, - }, - { - name: Operator.Google, - }, - { - name: Operator.Bing, - }, - { - name: Operator.GoogleScholar, - }, - { - name: Operator.GitHub, - }, - { - name: Operator.BaiduFanyi, - }, - { - name: Operator.QWeather, - }, - { - name: Operator.ExeSQL, - }, - { - name: Operator.WenCai, - }, - { - name: Operator.AkShare, - }, - { - name: Operator.YahooFinance, - }, - { - name: Operator.Jin10, - }, - { - name: Operator.TuShare, - }, - { - name: Operator.Crawler, - }, - { - name: Operator.Invoke, - }, - { - name: Operator.Email, - }, - { - name: Operator.SearXNG, - }, -]; - export const DataOperationsOperatorOptions = [ ComparisonOperator.Equal, ComparisonOperator.NotEqual, @@ -281,11 +181,6 @@ export const initialSearXNGValues = { }, }; -export const initialBaiduValues = { - top_n: 10, - ...initialQueryBaseValues, -}; - export const initialWikipediaValues = { top_n: 10, language: 'en', @@ -385,13 +280,6 @@ export const initialGithubValues = { }, }; -export const initialBaiduFanyiValues = { - appid: 'xxx', - secret_key: 'xxx', - trans_type: 'translate', - ...initialQueryBaseValues, -}; - export const initialQWeatherValues = { web_apikey: 'xxx', type: 'weather', @@ -717,6 +605,8 @@ export const initialDataOperationsValues = { }, }; +export const initialVariableAssignerValues = {}; + export const CategorizeAnchorPointPositions = [ { top: 1, right: 34 }, { top: 8, right: 18 }, @@ -757,7 +647,6 @@ export const RestrictedUpstreamMap = { Operator.Message, Operator.Relevant, ], - [Operator.Baidu]: [Operator.Begin, Operator.Retrieval], [Operator.DuckDuckGo]: [Operator.Begin, Operator.Retrieval], [Operator.Wikipedia]: [Operator.Begin, Operator.Retrieval], [Operator.PubMed]: [Operator.Begin, Operator.Retrieval], @@ -766,7 +655,6 @@ export const RestrictedUpstreamMap = { [Operator.Bing]: [Operator.Begin, Operator.Retrieval], [Operator.GoogleScholar]: [Operator.Begin, Operator.Retrieval], [Operator.GitHub]: [Operator.Begin, Operator.Retrieval], - [Operator.BaiduFanyi]: [Operator.Begin, Operator.Retrieval], [Operator.QWeather]: [Operator.Begin, Operator.Retrieval], [Operator.SearXNG]: [Operator.Begin, Operator.Retrieval], [Operator.ExeSQL]: [Operator.Begin], @@ -798,6 +686,7 @@ export const RestrictedUpstreamMap = { [Operator.Tokenizer]: [Operator.Begin], [Operator.Extractor]: [Operator.Begin], [Operator.File]: [Operator.Begin], + [Operator.VariableAssigner]: [Operator.Begin], }; export const NodeMap = { @@ -809,7 +698,6 @@ export const NodeMap = { [Operator.RewriteQuestion]: 'rewriteNode', [Operator.KeywordExtract]: 'keywordNode', [Operator.DuckDuckGo]: 'ragNode', - [Operator.Baidu]: 'ragNode', [Operator.Wikipedia]: 'ragNode', [Operator.PubMed]: 'ragNode', [Operator.ArXiv]: 'ragNode', @@ -817,7 +705,6 @@ export const NodeMap = { [Operator.Bing]: 'ragNode', [Operator.GoogleScholar]: 'ragNode', [Operator.GitHub]: 'ragNode', - [Operator.BaiduFanyi]: 'ragNode', [Operator.QWeather]: 'ragNode', [Operator.SearXNG]: 'ragNode', [Operator.ExeSQL]: 'ragNode', @@ -849,6 +736,7 @@ export const NodeMap = { [Operator.HierarchicalMerger]: 'splitterNode', [Operator.Extractor]: 'contextNode', [Operator.DataOperations]: 'dataOperationsNode', + [Operator.VariableAssigner]: 'variableAssignerNode', }; 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 79cd8cfc4..a259c8e1f 100644 --- a/web/src/pages/agent/form-sheet/form-config-map.tsx +++ b/web/src/pages/agent/form-sheet/form-config-map.tsx @@ -2,8 +2,6 @@ import { Operator } from '../constant'; import AgentForm from '../form/agent-form'; import AkShareForm from '../form/akshare-form'; import ArXivForm from '../form/arxiv-form'; -import BaiduFanyiForm from '../form/baidu-fanyi-form'; -import BaiduForm from '../form/baidu-form'; import BeginForm from '../form/begin-form'; import BingForm from '../form/bing-form'; import CategorizeForm from '../form/categorize-form'; @@ -72,9 +70,6 @@ export const FormConfigMap = { [Operator.Agent]: { component: AgentForm, }, - [Operator.Baidu]: { - component: BaiduForm, - }, [Operator.DuckDuckGo]: { component: DuckDuckGoForm, }, @@ -102,9 +97,6 @@ export const FormConfigMap = { [Operator.GitHub]: { component: GithubForm, }, - [Operator.BaiduFanyi]: { - component: BaiduFanyiForm, - }, [Operator.QWeather]: { component: QWeatherForm, }, diff --git a/web/src/pages/agent/form/baidu-fanyi-form/index.tsx b/web/src/pages/agent/form/baidu-fanyi-form/index.tsx deleted file mode 100644 index c02b3dd85..000000000 --- a/web/src/pages/agent/form/baidu-fanyi-form/index.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { useTranslate } from '@/hooks/common-hooks'; -import { Form, Input, Select } from 'antd'; -import { useMemo } from 'react'; -import { IOperatorForm } from '../../interface'; -import { - BaiduFanyiDomainOptions, - BaiduFanyiSourceLangOptions, -} from '../../options'; -import DynamicInputVariable from '../components/dynamic-input-variable'; - -const BaiduFanyiForm = ({ onValuesChange, form, node }: IOperatorForm) => { - const { t } = useTranslate('flow'); - const options = useMemo(() => { - return ['translate', 'fieldtranslate'].map((x) => ({ - value: x, - label: t(`baiduSecretKeyOptions.${x}`), - })); - }, [t]); - - const baiduFanyiOptions = useMemo(() => { - return BaiduFanyiDomainOptions.map((x) => ({ - value: x, - label: t(`baiduDomainOptions.${x}`), - })); - }, [t]); - - const baiduFanyiSourceLangOptions = useMemo(() => { - return BaiduFanyiSourceLangOptions.map((x) => ({ - value: x, - label: t(`baiduSourceLangOptions.${x}`), - })); - }, [t]); - - return ( -
- - - - - - - - - - - - {({ getFieldValue }) => - getFieldValue('trans_type') === 'fieldtranslate' && ( - - - - ) - } - - - - - - - -
- ); -}; - -export default BaiduFanyiForm; diff --git a/web/src/pages/agent/form/baidu-form/index.tsx b/web/src/pages/agent/form/baidu-form/index.tsx deleted file mode 100644 index 0861ef829..000000000 --- a/web/src/pages/agent/form/baidu-form/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { TopNFormField } from '@/components/top-n-item'; -import { Form } from '@/components/ui/form'; -import { INextOperatorForm } from '../../interface'; -import { DynamicInputVariable } from '../components/next-dynamic-input-variable'; - -const BaiduForm = ({ form, node }: INextOperatorForm) => { - return ( -
- { - e.preventDefault(); - }} - > - - -
- - ); -}; - -export default BaiduForm; diff --git a/web/src/pages/agent/hooks/use-add-node.ts b/web/src/pages/agent/hooks/use-add-node.ts index d3b2ef765..81630eb39 100644 --- a/web/src/pages/agent/hooks/use-add-node.ts +++ b/web/src/pages/agent/hooks/use-add-node.ts @@ -12,8 +12,6 @@ import { initialAgentValues, initialAkShareValues, initialArXivValues, - initialBaiduFanyiValues, - initialBaiduValues, initialBeginValues, initialBingValues, initialCategorizeValues, @@ -50,6 +48,7 @@ import { initialTokenizerValues, initialTuShareValues, initialUserFillUpValues, + initialVariableAssignerValues, initialWaitingDialogueValues, initialWenCaiValues, initialWikipediaValues, @@ -86,7 +85,6 @@ export const useInitializeOperatorParams = () => { llm_id: llmId, }, [Operator.DuckDuckGo]: initialDuckValues, - [Operator.Baidu]: initialBaiduValues, [Operator.Wikipedia]: initialWikipediaValues, [Operator.PubMed]: initialPubMedValues, [Operator.ArXiv]: initialArXivValues, @@ -95,7 +93,6 @@ export const useInitializeOperatorParams = () => { [Operator.GoogleScholar]: initialGoogleScholarValues, [Operator.SearXNG]: initialSearXNGValues, [Operator.GitHub]: initialGithubValues, - [Operator.BaiduFanyi]: initialBaiduFanyiValues, [Operator.QWeather]: initialQWeatherValues, [Operator.ExeSQL]: initialExeSqlValues, [Operator.Switch]: initialSwitchValues, @@ -131,6 +128,7 @@ export const useInitializeOperatorParams = () => { prompts: t('flow.prompts.user.summary'), }, [Operator.DataOperations]: initialDataOperationsValues, + [Operator.VariableAssigner]: initialVariableAssignerValues, }; }, [llmId]); diff --git a/web/src/pages/agent/operator-icon.tsx b/web/src/pages/agent/operator-icon.tsx index fcd17954a..6a0ae7f7d 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 { FileCode, HousePlus } from 'lucide-react'; +import { Equal, FileCode, HousePlus } from 'lucide-react'; import { Operator } from './constant'; interface IProps { @@ -58,6 +58,7 @@ export const SVGIconMap = { export const LucideIconMap = { [Operator.DataOperations]: FileCode, + [Operator.VariableAssigner]: Equal, }; const Empty = () => { diff --git a/web/src/pages/next-chats/chat/app-settings/metadata-filter-conditions.tsx b/web/src/pages/next-chats/chat/app-settings/metadata-filter-conditions.tsx deleted file mode 100644 index 136cfdc57..000000000 --- a/web/src/pages/next-chats/chat/app-settings/metadata-filter-conditions.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import { SelectWithSearch } from '@/components/originui/select-with-search'; -import { Button } from '@/components/ui/button'; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from '@/components/ui/dropdown-menu'; -import { - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '@/components/ui/form'; -import { Input } from '@/components/ui/input'; -import { Separator } from '@/components/ui/separator'; -import { SwitchOperatorOptions } from '@/constants/agent'; -import { useBuildSwitchOperatorOptions } from '@/hooks/logic-hooks/use-build-operator-options'; -import { useFetchKnowledgeMetadata } from '@/hooks/use-knowledge-request'; -import { Plus, X } from 'lucide-react'; -import { useCallback } from 'react'; -import { useFieldArray, useFormContext } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; - -export function MetadataFilterConditions({ kbIds }: { kbIds: string[] }) { - const { t } = useTranslation(); - const form = useFormContext(); - const name = 'meta_data_filter.manual'; - const metadata = useFetchKnowledgeMetadata(kbIds); - - const switchOperatorOptions = useBuildSwitchOperatorOptions(); - - const { fields, remove, append } = useFieldArray({ - name, - control: form.control, - }); - - const add = useCallback( - (key: string) => () => { - append({ - key, - value: '', - op: SwitchOperatorOptions[0].value, - }); - }, - [append], - ); - - return ( -
-
- {t('chat.conditions')} - - - - - - {Object.keys(metadata.data).map((key, idx) => { - return ( - - {key} - - ); - })} - - -
-
- {fields.map((field, index) => { - const typeField = `${name}.${index}.key`; - return ( -
- ( - - - - - - - )} - /> - - ( - - - - - - - )} - /> - - ( - - - - - - - )} - /> - -
- ); - })} -
-
- ); -}