Perf workflow (#1492)
* perf: handle edge check * search model * feat: plugin input can render all input; fix: plugin default value * fix ts * feat: plugin input support required
This commit is contained in:
2
packages/global/core/chat/type.d.ts
vendored
2
packages/global/core/chat/type.d.ts
vendored
@@ -139,7 +139,7 @@ export type ChatHistoryItemType = HistoryItemType & {
|
||||
/* ------- response data ------------ */
|
||||
export type ChatHistoryItemResType = DispatchNodeResponseType & {
|
||||
nodeId: string;
|
||||
moduleType: `${FlowNodeTypeEnum}`;
|
||||
moduleType: FlowNodeTypeEnum;
|
||||
moduleName: string;
|
||||
};
|
||||
|
||||
|
||||
2
packages/global/core/workflow/api.d.ts
vendored
2
packages/global/core/workflow/api.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
import { VectorModelItemType } from '../ai/model.d';
|
||||
import { NodeInputKeyEnum } from './constants';
|
||||
|
||||
export type SelectedDatasetType = { datasetId: string; vectorModel: VectorModelItemType }[];
|
||||
export type SelectedDatasetType = { datasetId: string }[];
|
||||
|
||||
export type HttpBodyType<T = Record<string, any>> = {
|
||||
[NodeInputKeyEnum.addInputParam]: Record<string, any>;
|
||||
|
||||
@@ -36,7 +36,6 @@ export const DatasetSearchModule: FlowNodeTemplateType = {
|
||||
label: 'core.module.input.label.Select dataset',
|
||||
value: [],
|
||||
valueType: WorkflowIOValueTypeEnum.selectDataset,
|
||||
list: [],
|
||||
required: true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ import { RuntimeEdgeItemType, StoreEdgeItemType } from './edge';
|
||||
import { NextApiResponse } from 'next';
|
||||
|
||||
export type FlowNodeCommonType = {
|
||||
flowNodeType: `${FlowNodeTypeEnum}`; // render node card
|
||||
flowNodeType: FlowNodeTypeEnum; // render node card
|
||||
|
||||
avatar?: string;
|
||||
name: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from './node/constant';
|
||||
import { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from './node/constant';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
@@ -22,15 +22,9 @@ export const getHandleId = (nodeId: string, type: 'source' | 'target', key: stri
|
||||
};
|
||||
|
||||
export const checkInputIsReference = (input: FlowNodeInputItemType) => {
|
||||
const value = input.value;
|
||||
if (
|
||||
Array.isArray(value) &&
|
||||
value.length === 2 &&
|
||||
typeof value[0] === 'string' &&
|
||||
typeof value[1] === 'string'
|
||||
) {
|
||||
if (input.renderTypeList?.[input?.selectedTypeIndex || 0] === FlowNodeInputTypeEnum.reference)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { getHistories } from '../utils';
|
||||
import { datasetSearchQueryExtension } from '../../../dataset/search/utils';
|
||||
import { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
|
||||
import { checkTeamReRankPermission } from '../../../../support/permission/teamLimit';
|
||||
import { MongoDataset } from '../../../dataset/schema';
|
||||
|
||||
type DatasetSearchProps = ModuleDispatchProps<{
|
||||
[NodeInputKeyEnum.datasetSelectList]: SelectedDatasetType;
|
||||
@@ -79,7 +80,9 @@ export async function dispatchDatasetSearch(
|
||||
// console.log(concatQueries, rewriteQuery, aiExtensionResult);
|
||||
|
||||
// get vector
|
||||
const vectorModel = getVectorModel(datasets[0]?.vectorModel?.model);
|
||||
const vectorModel = getVectorModel(
|
||||
(await MongoDataset.findById(datasets[0].datasetId, 'vectorModel').lean())?.vectorModel
|
||||
);
|
||||
|
||||
// start search
|
||||
const {
|
||||
|
||||
@@ -45,7 +45,7 @@ import { getReferenceVariableValue } from '@fastgpt/global/core/workflow/runtime
|
||||
import { dispatchSystemConfig } from './init/systemConfig';
|
||||
import { dispatchUpdateVariable } from './tools/runUpdateVar';
|
||||
|
||||
const callbackMap: Record<`${FlowNodeTypeEnum}`, Function> = {
|
||||
const callbackMap: Record<FlowNodeTypeEnum, Function> = {
|
||||
[FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart,
|
||||
[FlowNodeTypeEnum.answerNode]: dispatchAnswer,
|
||||
[FlowNodeTypeEnum.chatNode]: dispatchChatCompletion,
|
||||
|
||||
36
packages/web/components/common/Input/NumberInput/index.tsx
Normal file
36
packages/web/components/common/Input/NumberInput/index.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
NumberInput,
|
||||
NumberIncrementStepper,
|
||||
NumberInputField,
|
||||
NumberInputStepper,
|
||||
NumberDecrementStepper,
|
||||
NumberInputProps
|
||||
} from '@chakra-ui/react';
|
||||
import React from 'react';
|
||||
|
||||
type Props = Omit<NumberInputProps, 'onChange'> & {
|
||||
onChange: (e: number | '') => any;
|
||||
};
|
||||
|
||||
const MyNumberInput = (props: Props) => {
|
||||
return (
|
||||
<NumberInput
|
||||
{...props}
|
||||
onChange={(e) => {
|
||||
if (isNaN(Number(e))) {
|
||||
props?.onChange('');
|
||||
} else {
|
||||
props?.onChange(Number(e));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<NumberInputField />
|
||||
<NumberInputStepper>
|
||||
<NumberIncrementStepper />
|
||||
<NumberDecrementStepper />
|
||||
</NumberInputStepper>
|
||||
</NumberInput>
|
||||
);
|
||||
};
|
||||
|
||||
export default MyNumberInput;
|
||||
@@ -67,7 +67,7 @@ const MyRightDrawer = ({
|
||||
<DrawerCloseButton position={'relative'} fontSize={'sm'} top={0} right={0} />
|
||||
</Flex>
|
||||
|
||||
<DrawerBody>
|
||||
<DrawerBody overflow={'unset'} px={props?.px}>
|
||||
{children}
|
||||
<Loading loading={isLoading} fixed={false} />
|
||||
</DrawerBody>
|
||||
|
||||
Reference in New Issue
Block a user