feat: fetch flow (#1068)

### What problem does this PR solve?
feat: fetch flow #918 
feat: save graph

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-06-06 11:01:14 +08:00
committed by GitHub
parent b6980d8a16
commit 72c6784ff8
22 changed files with 241 additions and 90 deletions

28
web/src/utils/form.ts Normal file
View File

@ -0,0 +1,28 @@
import { variableEnabledFieldMap } from '@/constants/chat';
import omit from 'lodash/omit';
// chat model setting and generate operator
export const excludeUnEnabledVariables = (
values: any,
prefix = 'llm_setting.',
) => {
const unEnabledFields: Array<keyof typeof variableEnabledFieldMap> =
Object.keys(variableEnabledFieldMap).filter((key) => !values[key]) as Array<
keyof typeof variableEnabledFieldMap
>;
return unEnabledFields.map(
(key) => `${prefix}${variableEnabledFieldMap[key]}`,
);
};
// chat model setting and generate operator
export const removeUselessFieldsFromValues = (values: any, prefix?: string) => {
const nextValues: any = omit(values, [
...Object.keys(variableEnabledFieldMap),
'parameters',
...excludeUnEnabledVariables(values, prefix),
]);
return nextValues;
};

View File

@ -1,7 +1,10 @@
import omit from 'lodash/omit';
import { RequestMethod } from 'umi-request';
type Service<T extends string> = Record<T, (params?: any) => any>;
type Service<T extends string> = Record<
T,
(params?: any, urlAppendix?: string) => any
>;
const registerServer = <T extends string>(
opt: Record<T, { url: string; method: string }>,