perf: bill

This commit is contained in:
archer
2023-07-13 22:53:44 +08:00
parent 726de0396b
commit f3715731c4
67 changed files with 915 additions and 1254 deletions

View File

@@ -15,6 +15,8 @@ import { SystemInputEnum } from '@/constants/app';
import { streamFetch } from '@/api/fetch';
import MyTooltip from '@/components/MyTooltip';
import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/ChatBox';
import { useToast } from '@/hooks/useToast';
import { getErrText } from '@/utils/tools';
export type ChatTestComponentRef = {
resetChatTest: () => void;
@@ -34,6 +36,7 @@ const ChatTest = (
) => {
const BoxRef = useRef(null);
const ChatBoxRef = useRef<ComponentRef>(null);
const { toast } = useToast();
const isOpen = useMemo(() => modules && modules.length > 0, [modules]);
const variableModules = useMemo(
@@ -60,21 +63,30 @@ const ChatTest = (
const history = messages.slice(-historyMaxLen - 2, -2);
// 流请求,获取数据
const { responseText } = await streamFetch({
const { responseText, errMsg } = await streamFetch({
url: '/api/chat/chatTest',
data: {
history,
prompt: messages[messages.length - 2].content,
modules,
variables
variables,
appId: app._id,
appName: `调试-${app.name}`
},
onMessage: generatingMessage,
abortSignal: controller
});
if (errMsg) {
return Promise.reject({
message: errMsg,
responseText
});
}
return { responseText };
},
[modules]
[app._id, app.name, modules]
);
useOutsideClick({

View File

@@ -6,14 +6,14 @@ import { FlowModuleItemType } from '@/types/flow';
import Divider from './modules/Divider';
import Container from './modules/Container';
import RenderInput from './render/RenderInput';
import type { ClassifyQuestionAgentItemType } from '@/types/app';
import type { RecognizeIntentionAgentItemType } from '@/types/app';
import { Handle, Position } from 'reactflow';
import { customAlphabet } from 'nanoid';
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 4);
import MyIcon from '@/components/Icon';
import { FlowOutputItemTypeEnum } from '@/constants/flow';
const NodeCQNode = ({
const NodeRINode = ({
data: { moduleId, inputs, outputs, onChangeNode, ...props }
}: NodeProps<FlowModuleItemType>) => {
return (
@@ -30,7 +30,7 @@ const NodeCQNode = ({
value: agents = []
}: {
key: string;
value?: ClassifyQuestionAgentItemType[];
value?: RecognizeIntentionAgentItemType[];
}) => (
<Box>
{agents.map((item, i) => (
@@ -133,4 +133,4 @@ const NodeCQNode = ({
</NodeCard>
);
};
export default React.memo(NodeCQNode);
export default React.memo(NodeRINode);

View File

@@ -49,7 +49,7 @@ const NodeAnswer = dynamic(() => import('./components/NodeAnswer'), {
const NodeQuestionInput = dynamic(() => import('./components/NodeQuestionInput'), {
ssr: false
});
const NodeCQNode = dynamic(() => import('./components/NodeCQNode'), {
const NodeRINode = dynamic(() => import('./components/NodeRINode'), {
ssr: false
});
const NodeUserGuide = dynamic(() => import('./components/NodeUserGuide'), {
@@ -70,7 +70,7 @@ const nodeTypes = {
[FlowModuleTypeEnum.kbSearchNode]: NodeKbSearch,
[FlowModuleTypeEnum.tfSwitchNode]: NodeTFSwitch,
[FlowModuleTypeEnum.answerNode]: NodeAnswer,
[FlowModuleTypeEnum.classifyQuestionNode]: NodeCQNode
[FlowModuleTypeEnum.recognizeIntention]: NodeRINode
};
const edgeTypes = {
buttonedge: ButtonEdge