mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-26 04:32:50 +00:00
Node rebase
This commit is contained in:
parent
1df95f4e22
commit
32ca0bfd66
|
|
@ -9,11 +9,11 @@ import { textAdaptGptResponse } from '@fastgpt/global/core/workflow/runtime/util
|
|||
import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/constants';
|
||||
import { runWorkflow } from '../../index';
|
||||
import type { DispatchToolModuleProps, RunToolResponse, ToolNodeItemType } from './type';
|
||||
import json5 from 'json5';
|
||||
import type { DispatchFlowResponse } from '../../type';
|
||||
import { GPTMessages2Chats } from '@fastgpt/global/core/chat/adapt';
|
||||
import type { AIChatItemType } from '@fastgpt/global/core/chat/type';
|
||||
import { formatToolResponse, initToolCallEdges, initToolNodes, parseToolArgs } from '../utils';
|
||||
import { formatToolResponse, parseToolArgs } from '../utils';
|
||||
import { initToolNodes, initToolCallEdges } from './utils';
|
||||
import { computedMaxToken } from '../../../../ai/utils';
|
||||
import { sliceStrStartEnd } from '@fastgpt/global/common/string/tools';
|
||||
import type { WorkflowInteractiveResponseType } from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import type { RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io';
|
||||
|
||||
export const initToolNodes = (
|
||||
nodes: RuntimeNodeItemType[],
|
||||
entryNodeIds: string[],
|
||||
startParams?: Record<string, any>
|
||||
) => {
|
||||
const updateToolInputValue = ({
|
||||
params,
|
||||
inputs
|
||||
}: {
|
||||
params: Record<string, any>;
|
||||
inputs: FlowNodeInputItemType[];
|
||||
}) => {
|
||||
return inputs.map((input) => ({
|
||||
...input,
|
||||
value: params[input.key] ?? input.value
|
||||
}));
|
||||
};
|
||||
|
||||
nodes.forEach((node) => {
|
||||
if (entryNodeIds.includes(node.nodeId)) {
|
||||
node.isEntry = true;
|
||||
node.isStart = true;
|
||||
if (startParams) {
|
||||
node.inputs = updateToolInputValue({ params: startParams, inputs: node.inputs });
|
||||
}
|
||||
} else {
|
||||
node.isStart = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
// 在原参上改变值,不修改原对象,tool workflow 中,使用的还是原对象
|
||||
export const initToolCallEdges = (edges: RuntimeEdgeItemType[], entryNodeIds: string[]) => {
|
||||
edges.forEach((edge) => {
|
||||
if (entryNodeIds.includes(edge.target)) {
|
||||
edge.status = 'active';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -50,43 +50,6 @@ export const formatToolResponse = (toolResponses: any) => {
|
|||
return toolResponses ? String(toolResponses) : 'none';
|
||||
};
|
||||
|
||||
// 在原参上改变值,不修改原对象,tool workflow 中,使用的还是原对象
|
||||
export const initToolCallEdges = (edges: RuntimeEdgeItemType[], entryNodeIds: string[]) => {
|
||||
edges.forEach((edge) => {
|
||||
if (entryNodeIds.includes(edge.target)) {
|
||||
edge.status = 'active';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const initToolNodes = (
|
||||
nodes: RuntimeNodeItemType[],
|
||||
entryNodeIds: string[],
|
||||
startParams?: Record<string, any>
|
||||
) => {
|
||||
const updateToolInputValue = ({
|
||||
params,
|
||||
inputs
|
||||
}: {
|
||||
params: Record<string, any>;
|
||||
inputs: FlowNodeInputItemType[];
|
||||
}) => {
|
||||
return inputs.map((input) => ({
|
||||
...input,
|
||||
value: params[input.key] ?? input.value
|
||||
}));
|
||||
};
|
||||
|
||||
nodes.forEach((node) => {
|
||||
if (entryNodeIds.includes(node.nodeId)) {
|
||||
node.isEntry = true;
|
||||
if (startParams) {
|
||||
node.inputs = updateToolInputValue({ params: startParams, inputs: node.inputs });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Tool call, auth add file prompt to question。
|
||||
Guide the LLM to call tool.
|
||||
|
|
|
|||
|
|
@ -26,18 +26,14 @@
|
|||
"date-fns": "2.30.0",
|
||||
"dayjs": "^1.11.7",
|
||||
"next": "14.2.32",
|
||||
"i18next": "23.16.8",
|
||||
"js-cookie": "^3.0.5",
|
||||
"lexical": "0.12.6",
|
||||
"lodash": "^4.17.21",
|
||||
"next-i18next": "15.4.2",
|
||||
"papaparse": "^5.4.1",
|
||||
"react": "18.3.1",
|
||||
"react-beautiful-dnd": "^13.1.1",
|
||||
"react-day-picker": "^8.7.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-hook-form": "7.43.1",
|
||||
"react-i18next": "14.1.2",
|
||||
"react-photo-view": "^1.2.6",
|
||||
"recharts": "^2.15.0",
|
||||
"use-context-selector": "^1.4.4",
|
||||
|
|
@ -53,5 +49,10 @@
|
|||
"@types/react": "18.3.1",
|
||||
"@types/react-beautiful-dnd": "^13.1.1",
|
||||
"@types/react-dom": "18.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"next-i18next": "15.4.2",
|
||||
"react-i18next": "14.1.2",
|
||||
"i18next": "23.16.8"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { Box, Button, Flex, HStack, IconButton } from '@chakra-ui/react';
|
||||
import React, { useState } from 'react';
|
||||
import { AppContext } from '../context';
|
||||
import { AppContext } from '../../context';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import MyMenu from '@fastgpt/web/components/common/MyMenu';
|
||||
import { type AppSchema } from '@fastgpt/global/core/app/type';
|
||||
import TagsEditModal from '../TagsEditModal';
|
||||
import TagsEditModal from '../../TagsEditModal';
|
||||
|
||||
const AppCard = () => {
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
import { useChatStore } from '@/web/core/chat/context/useChatStore';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { AppContext } from '../context';
|
||||
import { AppContext } from '../../context';
|
||||
import ChatItemContextProvider from '@/web/core/chat/context/chatItemContext';
|
||||
import ChatRecordContextProvider from '@/web/core/chat/context/chatRecordContext';
|
||||
import { Box, Button, Center, Flex, HStack } from '@chakra-ui/react';
|
||||
import { cardStyles } from '../constants';
|
||||
import { cardStyles } from '../../constants';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { type HttpToolConfigType } from '@fastgpt/global/core/app/type';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
|
@ -17,7 +17,7 @@ import { valueTypeToInputType } from '@/components/core/app/formRender/utils';
|
|||
import { getNodeInputTypeFromSchemaInputType } from '@fastgpt/global/core/app/jsonschema';
|
||||
import LabelAndFormRender from '@/components/core/app/formRender/LabelAndForm';
|
||||
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
|
||||
import ValueTypeLabel from '../WorkflowComponents/Flow/nodes/render/ValueTypeLabel';
|
||||
import ValueTypeLabel from '../../WorkflowComponents/Flow/nodes/render/ValueTypeLabel';
|
||||
import LightRowTabs from '@fastgpt/web/components/common/Tabs/LightRowTabs';
|
||||
import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
|
||||
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
import { Box, Flex } from '@chakra-ui/react';
|
||||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import styles from '../SimpleApp/styles.module.scss';
|
||||
import { cardStyles } from '../constants';
|
||||
import styles from '../FormComponent/styles.module.scss';
|
||||
import { cardStyles } from '../../constants';
|
||||
import AppCard from './AppCard';
|
||||
import ChatTest from './ChatTest';
|
||||
import MyBox from '@fastgpt/web/components/common/MyBox';
|
||||
import EditForm from './EditForm';
|
||||
import { type HttpToolConfigType } from '@fastgpt/global/core/app/type';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { AppContext } from '../context';
|
||||
import { AppContext } from '../../context';
|
||||
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
||||
|
||||
const Edit = () => {
|
||||
|
|
@ -13,7 +13,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
|||
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { AppContext } from '../context';
|
||||
import { AppContext } from '../../context';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import MyIconButton from '@fastgpt/web/components/common/Icon/button';
|
||||
import { type HttpToolConfigType } from '@fastgpt/global/core/app/type';
|
||||
|
|
@ -3,7 +3,7 @@ import FolderPath from '@/components/common/folder/Path';
|
|||
import { useTranslation } from 'next-i18next';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { AppContext } from '../context';
|
||||
import { AppContext } from '../../context';
|
||||
import { getAppFolderPath } from '@/web/core/app/api/app';
|
||||
import { useCallback } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
|
|
@ -27,7 +27,7 @@ import {
|
|||
import { useForm } from 'react-hook-form';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { AppContext } from '../context';
|
||||
import { AppContext } from '../../context';
|
||||
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
|
||||
import MySelect from '@fastgpt/web/components/common/MySelect';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
|
|
@ -22,7 +22,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
|||
import { getApiSchemaByUrl, putUpdateHttpPlugin } from '@/web/core/app/api/tool';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { AppContext } from '../context';
|
||||
import { AppContext } from '../../context';
|
||||
import HttpInput from '@fastgpt/web/components/common/Input/HttpInput';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { pathData2ToolList } from '@fastgpt/global/core/app/tool/httpTool/utils';
|
||||
|
|
@ -31,7 +31,7 @@ const MCPTools = dynamic(() => import('@/pageComponents/app/detail/Edit/MCPTools
|
|||
ssr: false,
|
||||
loading: () => <Loading fixed={false} />
|
||||
});
|
||||
const HTTPTools = dynamic(() => import('@/pageComponents/app/detail/HTTPTools'), {
|
||||
const HTTPTools = dynamic(() => import('@/pageComponents/app/detail/Edit/HTTPTools'), {
|
||||
ssr: false,
|
||||
loading: () => <Loading fixed={false} />
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue