feat: http modules

This commit is contained in:
archer
2023-08-03 11:09:57 +08:00
parent b7934ecc27
commit 952da2a06e
31 changed files with 851 additions and 176 deletions

View File

@@ -75,11 +75,17 @@ export const appModule2FlowNode = ({
const template =
ModuleTemplatesFlat.find((template) => template.flowType === item.flowType) || EmptyModule;
const concatInputs = template.inputs.concat(
item.inputs.filter(
(input) => input.label && !template.inputs.find((item) => item.key === input.key)
)
);
// replace item data
const moduleItem: FlowModuleItemType = {
...item,
...template,
inputs: template.inputs.map((templateInput) => {
inputs: concatInputs.map((templateInput) => {
// use latest inputs
const itemInput = item.inputs.find((item) => item.key === templateInput.key) || templateInput;
return {
@@ -87,7 +93,6 @@ export const appModule2FlowNode = ({
value: itemInput.value
};
}),
// 合并 template 和数据库,文案以 template 为准
outputs: item.outputs.map((output) => {
// unChange outputs
const templateOutput = template.outputs.find((item) => item.key === output.key);

View File

@@ -1,9 +1,10 @@
import type { AppModuleInputItemType, AppModuleItemType, VariableItemType } from '@/types/app';
import type { AppModuleItemType, VariableItemType } from '@/types/app';
import { chatModelList, vectorModelList } from '@/store/static';
import { FlowModuleTypeEnum, SpecialInputKeyEnum } from '@/constants/flow';
import { SystemInputEnum } from '@/constants/app';
import { TaskResponseKeyEnum } from '@/constants/chat';
import type { SelectedKbType } from '@/types/plugin';
import { FlowInputItemType } from '@/types/flow';
export type EditFormType = {
chatModel: {
@@ -64,7 +65,7 @@ export const appModules2Form = (modules: AppModuleItemType[]) => {
key
}: {
formKey: string;
inputs: AppModuleInputItemType[];
inputs: FlowInputItemType[];
key: string;
}) => {
const propertyPath = formKey.split('.');
@@ -148,7 +149,7 @@ export const appModules2Form = (modules: AppModuleItemType[]) => {
return defaultAppForm;
};
const chatModelInput = (formData: EditFormType): AppModuleInputItemType[] => [
const chatModelInput = (formData: EditFormType): FlowInputItemType[] => [
{
key: 'model',
value: formData.chatModel.model,