mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
4.8-fix (#1305)
* fix if-else find variables (#92) * fix if-else find variables * change workflow output type * fix tooltip style * fix * 4.8 (#93) * api middleware * perf: app version histories * faq * perf: value type show * fix: ts * fix: Run the same node multiple times * feat: auto save workflow * perf: auto save workflow --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { GET, POST, DELETE, PUT } from '@/web/common/api/request';
|
||||
import type { AppDetailType, AppListItemType } from '@fastgpt/global/core/app/type.d';
|
||||
import { RequestPaging } from '@/types/index';
|
||||
import { addDays } from 'date-fns';
|
||||
import type { GetAppChatLogsParams } from '@/global/core/api/appReq.d';
|
||||
import type { CreateAppParams, AppUpdateParams } from '@fastgpt/global/core/app/api.d';
|
||||
import { AppUpdateParams, CreateAppParams } from '@/global/core/app/api';
|
||||
|
||||
/**
|
||||
* 获取模型列表
|
||||
@@ -31,32 +29,6 @@ export const getModelById = (id: string) => GET<AppDetailType>(`/core/app/detail
|
||||
*/
|
||||
export const putAppById = (id: string, data: AppUpdateParams) =>
|
||||
PUT(`/core/app/update?appId=${id}`, data);
|
||||
export const replaceAppById = (id: string, data: AppUpdateParams) =>
|
||||
PUT(`/core/app/updateTeamTasg?appId=${id}`, data);
|
||||
|
||||
// updateTeamTasg
|
||||
export const putAppTagsById = (id: string, data: AppUpdateParams) =>
|
||||
PUT(`/core/app/updateTeamTasg?appId=${id}`, data);
|
||||
/* 共享市场 */
|
||||
/**
|
||||
* 获取共享市场模型
|
||||
*/
|
||||
export const getShareModelList = (data: { searchText?: string } & RequestPaging) =>
|
||||
POST(`/core/app/share/getModels`, data);
|
||||
|
||||
/**
|
||||
* 收藏/取消收藏模型
|
||||
*/
|
||||
export const triggerModelCollection = (appId: string) =>
|
||||
POST<number>(`/core/app/share/collection?appId=${appId}`);
|
||||
|
||||
// ====================== data
|
||||
export const getAppTotalUsage = (data: { appId: string }) =>
|
||||
POST<{ date: String; total: number }[]>(`/core/app/data/totalUsage`, {
|
||||
...data,
|
||||
start: addDays(new Date(), -13),
|
||||
end: addDays(new Date(), 1)
|
||||
}).then((res) => (res.length === 0 ? [{ date: new Date(), total: 0 }] : res));
|
||||
|
||||
// =================== chat logs
|
||||
export const getAppChatLogs = (data: GetAppChatLogsParams) => POST(`/core/app/getChatLogs`, data);
|
||||
|
@@ -1,10 +1,12 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools, persist } from 'zustand/middleware';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
import { getMyApps, getModelById, putAppById, replaceAppById } from '@/web/core/app/api';
|
||||
import { getMyApps, getModelById, putAppById } from '@/web/core/app/api';
|
||||
import { defaultApp } from '@/constants/app';
|
||||
import type { AppUpdateParams } from '@fastgpt/global/core/app/api.d';
|
||||
import type { AppUpdateParams } from '@/global/core/app/api.d';
|
||||
import { AppDetailType, AppListItemType } from '@fastgpt/global/core/app/type.d';
|
||||
import { PostPublishAppProps } from '@/global/core/app/api';
|
||||
import { postPublishApp } from '../versionApi';
|
||||
|
||||
type State = {
|
||||
myApps: AppListItemType[];
|
||||
@@ -12,7 +14,7 @@ type State = {
|
||||
appDetail: AppDetailType;
|
||||
loadAppDetail: (id: string, init?: boolean) => Promise<AppDetailType>;
|
||||
updateAppDetail(appId: string, data: AppUpdateParams): Promise<void>;
|
||||
replaceAppDetail(appId: string, data: AppUpdateParams): Promise<void>;
|
||||
publishApp(appId: string, data: PostPublishAppProps): Promise<void>;
|
||||
clearAppModules(): void;
|
||||
};
|
||||
|
||||
@@ -44,19 +46,22 @@ export const useAppStore = create<State>()(
|
||||
set((state) => {
|
||||
state.appDetail = {
|
||||
...state.appDetail,
|
||||
...data
|
||||
...data,
|
||||
modules: data?.nodes || state.appDetail.modules
|
||||
};
|
||||
});
|
||||
},
|
||||
async replaceAppDetail(appId: string, data: AppUpdateParams) {
|
||||
await replaceAppById(appId, { ...get().appDetail, ...data });
|
||||
async publishApp(appId: string, data: PostPublishAppProps) {
|
||||
await postPublishApp(appId, data);
|
||||
set((state) => {
|
||||
state.appDetail = {
|
||||
...state.appDetail,
|
||||
...data
|
||||
...data,
|
||||
modules: data?.nodes || state.appDetail.modules
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
clearAppModules() {
|
||||
set((state) => {
|
||||
state.appDetail = {
|
||||
|
5
projects/app/src/web/core/app/versionApi.ts
Normal file
5
projects/app/src/web/core/app/versionApi.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { PostPublishAppProps } from '@/global/core/app/api';
|
||||
import { GET, POST, DELETE, PUT } from '@/web/common/api/request';
|
||||
|
||||
export const postPublishApp = (appId: string, data: PostPublishAppProps) =>
|
||||
POST(`/core/app/version/publish?appId=${appId}`, data);
|
@@ -15,7 +15,7 @@ import {
|
||||
FlowNodeTemplateType,
|
||||
StoreNodeItemType
|
||||
} from '@fastgpt/global/core/workflow/type';
|
||||
import { VARIABLE_NODE_ID } from './constants';
|
||||
import { VARIABLE_NODE_ID } from '@fastgpt/global/core/workflow/constants';
|
||||
import { getHandleId, splitGuideModule } from '@fastgpt/global/core/workflow/utils';
|
||||
import { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import { LLMModelTypeEnum } from '@fastgpt/global/core/ai/constants';
|
||||
|
@@ -2,34 +2,47 @@ import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants
|
||||
|
||||
export const FlowValueTypeMap = {
|
||||
[WorkflowIOValueTypeEnum.string]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#36ADEF'
|
||||
},
|
||||
label: 'core.module.valueType.string',
|
||||
label: 'string',
|
||||
value: WorkflowIOValueTypeEnum.string,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.number]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#FB7C3C'
|
||||
},
|
||||
label: 'core.module.valueType.number',
|
||||
label: 'number',
|
||||
value: WorkflowIOValueTypeEnum.number,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.boolean]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#E7D118'
|
||||
},
|
||||
label: 'core.module.valueType.boolean',
|
||||
label: 'boolean',
|
||||
value: WorkflowIOValueTypeEnum.boolean,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.object]: {
|
||||
label: 'object',
|
||||
value: WorkflowIOValueTypeEnum.object,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayString]: {
|
||||
label: 'array<string>',
|
||||
value: WorkflowIOValueTypeEnum.arrayString,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayNumber]: {
|
||||
label: 'array<number>',
|
||||
value: WorkflowIOValueTypeEnum.arrayNumber,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayBoolean]: {
|
||||
label: 'array<boolean>',
|
||||
value: WorkflowIOValueTypeEnum.arrayBoolean,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayObject]: {
|
||||
label: 'array<object>',
|
||||
value: WorkflowIOValueTypeEnum.arrayObject,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.chatHistory]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#00A9A6'
|
||||
},
|
||||
label: 'core.module.valueType.chatHistory',
|
||||
label: '历史记录',
|
||||
value: WorkflowIOValueTypeEnum.chatHistory,
|
||||
description: `{
|
||||
obj: System | Human | AI;
|
||||
@@ -37,10 +50,7 @@ export const FlowValueTypeMap = {
|
||||
}[]`
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.datasetQuote]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#A558C9'
|
||||
},
|
||||
label: 'core.module.valueType.datasetQuote',
|
||||
label: '知识库引用',
|
||||
value: WorkflowIOValueTypeEnum.datasetQuote,
|
||||
description: `{
|
||||
id: string;
|
||||
@@ -52,42 +62,22 @@ export const FlowValueTypeMap = {
|
||||
a: string
|
||||
}[]`
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.any]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#9CA2A8'
|
||||
},
|
||||
label: 'core.module.valueType.any',
|
||||
value: WorkflowIOValueTypeEnum.any,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.selectApp]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#6a6efa'
|
||||
},
|
||||
label: 'core.module.valueType.selectApp',
|
||||
label: '选择应用',
|
||||
value: WorkflowIOValueTypeEnum.selectApp,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.selectDataset]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#21ba45'
|
||||
},
|
||||
label: 'core.module.valueType.selectDataset',
|
||||
label: '选择知识库',
|
||||
value: WorkflowIOValueTypeEnum.selectDataset,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.tools]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#21ba45'
|
||||
},
|
||||
label: 'core.module.valueType.tools',
|
||||
value: WorkflowIOValueTypeEnum.tools,
|
||||
[WorkflowIOValueTypeEnum.any]: {
|
||||
label: 'any',
|
||||
value: WorkflowIOValueTypeEnum.any,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.dynamic]: {
|
||||
handlerStyle: {
|
||||
borderColor: '#9CA2A8'
|
||||
},
|
||||
label: '动态数据',
|
||||
value: WorkflowIOValueTypeEnum.any,
|
||||
description: ''
|
||||
|
@@ -1 +0,0 @@
|
||||
export const VARIABLE_NODE_ID = 'VARIABLE_NODE_ID';
|
@@ -14,7 +14,7 @@ import { EmptyNode } from '@fastgpt/global/core/workflow/template/system/emptyNo
|
||||
import { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
import { systemConfigNode2VariableNode } from './adapt';
|
||||
import { VARIABLE_NODE_ID } from './constants';
|
||||
import { VARIABLE_NODE_ID } from '@fastgpt/global/core/workflow/constants';
|
||||
import { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
|
||||
export const nodeTemplate2FlowNode = ({
|
||||
|
Reference in New Issue
Block a user