mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 20:27:45 +00:00
v4.5.2 (#439)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { GET, POST, PUT, DELETE } from '@/web/common/api/request';
|
||||
import { GET, POST } from '@/web/common/api/request';
|
||||
import type { CreateTrainingBillType } from '@fastgpt/global/common/bill/types/billReq.d';
|
||||
import type { PaySchema } from '@/types/mongoSchema';
|
||||
import type { PaySchema } from '@fastgpt/global/support/wallet/type.d';
|
||||
import type { PagingData, RequestPaging } from '@/types';
|
||||
import { UserBillType } from '@/types/user';
|
||||
import { delay } from '@/utils/tools';
|
||||
|
@@ -9,7 +9,7 @@ import type { CreateAppParams } from '@/types/app';
|
||||
/**
|
||||
* 获取模型列表
|
||||
*/
|
||||
export const getMyModels = () => GET<AppListItemType[]>('/app/myApps');
|
||||
export const getMyApps = () => GET<AppListItemType[]>('/app/myApps');
|
||||
|
||||
/**
|
||||
* 创建一个模型
|
||||
|
@@ -1,14 +1,15 @@
|
||||
import type { AppModuleItemType, VariableItemType } from '@/types/app';
|
||||
import type { VariableItemType } from '@/types/app';
|
||||
import { chatModelList } from '@/web/common/system/staticData';
|
||||
import type { ModuleItemType } from '@fastgpt/global/core/module/type';
|
||||
import {
|
||||
FlowInputItemTypeEnum,
|
||||
FlowModuleTypeEnum,
|
||||
FlowValueTypeEnum,
|
||||
SpecialInputKeyEnum
|
||||
} from '@/constants/flow';
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeTypeEnum,
|
||||
FlowNodeValTypeEnum,
|
||||
FlowNodeSpecialInputKeyEnum
|
||||
} from '@fastgpt/global/core/module/node/constant';
|
||||
import { SystemInputEnum } from '@/constants/app';
|
||||
import type { SelectedDatasetType } from '@/types/core/dataset';
|
||||
import type { FlowInputItemType } from '@/types/core/app/flow';
|
||||
import type { FlowNodeInputItemType } from '@fastgpt/global/core/module/node/type.d';
|
||||
import type { AIChatProps } from '@/types/core/aiChat';
|
||||
import { getGuideModule, splitGuideModule } from '@/global/core/app/modules/utils';
|
||||
|
||||
@@ -59,7 +60,7 @@ export const getDefaultAppForm = (): EditFormType => {
|
||||
};
|
||||
};
|
||||
|
||||
export const appModules2Form = (modules: AppModuleItemType[]) => {
|
||||
export const appModules2Form = (modules: ModuleItemType[]) => {
|
||||
const defaultAppForm = getDefaultAppForm();
|
||||
const updateVal = ({
|
||||
formKey,
|
||||
@@ -67,7 +68,7 @@ export const appModules2Form = (modules: AppModuleItemType[]) => {
|
||||
key
|
||||
}: {
|
||||
formKey: string;
|
||||
inputs: FlowInputItemType[];
|
||||
inputs: FlowNodeInputItemType[];
|
||||
key: string;
|
||||
}) => {
|
||||
const propertyPath = formKey.split('.');
|
||||
@@ -84,7 +85,7 @@ export const appModules2Form = (modules: AppModuleItemType[]) => {
|
||||
};
|
||||
|
||||
modules.forEach((module) => {
|
||||
if (module.flowType === FlowModuleTypeEnum.chatNode) {
|
||||
if (module.flowType === FlowNodeTypeEnum.chatNode) {
|
||||
updateVal({
|
||||
formKey: 'chatModel.model',
|
||||
inputs: module.inputs,
|
||||
@@ -115,7 +116,7 @@ export const appModules2Form = (modules: AppModuleItemType[]) => {
|
||||
inputs: module.inputs,
|
||||
key: 'quotePrompt'
|
||||
});
|
||||
} else if (module.flowType === FlowModuleTypeEnum.datasetSearchNode) {
|
||||
} else if (module.flowType === FlowNodeTypeEnum.datasetSearchNode) {
|
||||
updateVal({
|
||||
formKey: 'kb.list',
|
||||
inputs: module.inputs,
|
||||
@@ -137,9 +138,10 @@ export const appModules2Form = (modules: AppModuleItemType[]) => {
|
||||
if (emptyOutput) {
|
||||
const target = modules.find((item) => item.moduleId === emptyOutput.moduleId);
|
||||
defaultAppForm.kb.searchEmptyText =
|
||||
target?.inputs?.find((item) => item.key === SpecialInputKeyEnum.answerText)?.value || '';
|
||||
target?.inputs?.find((item) => item.key === FlowNodeSpecialInputKeyEnum.answerText)
|
||||
?.value || '';
|
||||
}
|
||||
} else if (module.flowType === FlowModuleTypeEnum.userGuide) {
|
||||
} else if (module.flowType === FlowNodeTypeEnum.userGuide) {
|
||||
const { welcomeText, variableModules, questionGuide } = splitGuideModule(
|
||||
getGuideModule(modules)
|
||||
);
|
||||
@@ -157,7 +159,7 @@ export const appModules2Form = (modules: AppModuleItemType[]) => {
|
||||
return defaultAppForm;
|
||||
};
|
||||
|
||||
const chatModelInput = (formData: EditFormType): FlowInputItemType[] => [
|
||||
const chatModelInput = (formData: EditFormType): FlowNodeInputItemType[] => [
|
||||
{
|
||||
key: 'model',
|
||||
value: formData.chatModel.model,
|
||||
@@ -232,26 +234,26 @@ const chatModelInput = (formData: EditFormType): FlowInputItemType[] => [
|
||||
connected: true
|
||||
}
|
||||
];
|
||||
const userGuideTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
const userGuideTemplate = (formData: EditFormType): ModuleItemType[] => [
|
||||
{
|
||||
name: '用户引导',
|
||||
flowType: FlowModuleTypeEnum.userGuide,
|
||||
flowType: FlowNodeTypeEnum.userGuide,
|
||||
inputs: [
|
||||
{
|
||||
key: SystemInputEnum.welcomeText,
|
||||
type: FlowInputItemTypeEnum.hidden,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '开场白',
|
||||
value: formData.guide.welcome.text
|
||||
},
|
||||
{
|
||||
key: SystemInputEnum.variables,
|
||||
type: FlowInputItemTypeEnum.hidden,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '对话框变量',
|
||||
value: formData.variables
|
||||
},
|
||||
{
|
||||
key: SystemInputEnum.questionGuide,
|
||||
type: FlowInputItemTypeEnum.hidden,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '问题引导',
|
||||
value: formData.questionGuide
|
||||
}
|
||||
@@ -264,10 +266,10 @@ const userGuideTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
moduleId: 'userGuide'
|
||||
}
|
||||
];
|
||||
const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
const simpleChatTemplate = (formData: EditFormType): ModuleItemType[] => [
|
||||
{
|
||||
name: '用户问题(对话入口)',
|
||||
flowType: FlowModuleTypeEnum.questionInput,
|
||||
flowType: FlowNodeTypeEnum.questionInput,
|
||||
inputs: [
|
||||
{
|
||||
key: 'userChatInput',
|
||||
@@ -295,7 +297,7 @@ const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
},
|
||||
{
|
||||
name: '聊天记录',
|
||||
flowType: FlowModuleTypeEnum.historyNode,
|
||||
flowType: FlowNodeTypeEnum.historyNode,
|
||||
inputs: [
|
||||
{
|
||||
key: 'maxContext',
|
||||
@@ -330,7 +332,7 @@ const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
},
|
||||
{
|
||||
name: 'AI 对话',
|
||||
flowType: FlowModuleTypeEnum.chatNode,
|
||||
flowType: FlowNodeTypeEnum.chatNode,
|
||||
inputs: chatModelInput(formData),
|
||||
showStatus: true,
|
||||
outputs: [
|
||||
@@ -357,10 +359,10 @@ const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
moduleId: 'chatModule'
|
||||
}
|
||||
];
|
||||
const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
const kbTemplate = (formData: EditFormType): ModuleItemType[] => [
|
||||
{
|
||||
name: '用户问题(对话入口)',
|
||||
flowType: FlowModuleTypeEnum.questionInput,
|
||||
flowType: FlowNodeTypeEnum.questionInput,
|
||||
inputs: [
|
||||
{
|
||||
key: 'userChatInput',
|
||||
@@ -392,7 +394,7 @@ const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
},
|
||||
{
|
||||
name: '聊天记录',
|
||||
flowType: FlowModuleTypeEnum.historyNode,
|
||||
flowType: FlowNodeTypeEnum.historyNode,
|
||||
inputs: [
|
||||
{
|
||||
key: 'maxContext',
|
||||
@@ -427,39 +429,39 @@ const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
},
|
||||
{
|
||||
name: '知识库搜索',
|
||||
flowType: FlowModuleTypeEnum.datasetSearchNode,
|
||||
flowType: FlowNodeTypeEnum.datasetSearchNode,
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
{
|
||||
key: 'datasets',
|
||||
value: formData.kb.list,
|
||||
type: FlowInputItemTypeEnum.custom,
|
||||
type: FlowNodeInputTypeEnum.custom,
|
||||
label: '关联的知识库',
|
||||
connected: true
|
||||
},
|
||||
{
|
||||
key: 'similarity',
|
||||
value: formData.kb.searchSimilarity,
|
||||
type: FlowInputItemTypeEnum.slider,
|
||||
type: FlowNodeInputTypeEnum.slider,
|
||||
label: '相似度',
|
||||
connected: true
|
||||
},
|
||||
{
|
||||
key: 'limit',
|
||||
value: formData.kb.searchLimit,
|
||||
type: FlowInputItemTypeEnum.slider,
|
||||
type: FlowNodeInputTypeEnum.slider,
|
||||
label: '单次搜索上限',
|
||||
connected: true
|
||||
},
|
||||
{
|
||||
key: 'switch',
|
||||
type: FlowInputItemTypeEnum.target,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '触发器',
|
||||
connected: false
|
||||
},
|
||||
{
|
||||
key: 'userChatInput',
|
||||
type: FlowInputItemTypeEnum.target,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '用户问题',
|
||||
connected: true
|
||||
}
|
||||
@@ -507,19 +509,19 @@ const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
? [
|
||||
{
|
||||
name: '指定回复',
|
||||
flowType: FlowModuleTypeEnum.answerNode,
|
||||
flowType: FlowNodeTypeEnum.answerNode,
|
||||
inputs: [
|
||||
{
|
||||
key: 'switch',
|
||||
type: FlowInputItemTypeEnum.target,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '触发器',
|
||||
connected: true
|
||||
},
|
||||
{
|
||||
key: SpecialInputKeyEnum.answerText,
|
||||
key: FlowNodeSpecialInputKeyEnum.answerText,
|
||||
value: formData.kb.searchEmptyText,
|
||||
type: FlowInputItemTypeEnum.textarea,
|
||||
valueType: FlowValueTypeEnum.string,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
valueType: FlowNodeValTypeEnum.string,
|
||||
label: '回复的内容',
|
||||
connected: true
|
||||
}
|
||||
@@ -535,7 +537,7 @@ const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
: []),
|
||||
{
|
||||
name: 'AI 对话',
|
||||
flowType: FlowModuleTypeEnum.chatNode,
|
||||
flowType: FlowNodeTypeEnum.chatNode,
|
||||
inputs: chatModelInput(formData),
|
||||
showStatus: true,
|
||||
outputs: [
|
||||
@@ -569,5 +571,5 @@ export const appForm2Modules = (formData: EditFormType) => {
|
||||
...(formData.kb.list.length > 0 ? kbTemplate(formData) : simpleChatTemplate(formData))
|
||||
];
|
||||
|
||||
return modules as AppModuleItemType[];
|
||||
return modules as ModuleItemType[];
|
||||
};
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools, persist } from 'zustand/middleware';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
import type { SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type';
|
||||
import type { DatasetItemType, DatasetsItemType } from '@/types/core/dataset';
|
||||
import { getAllDataset, getDatasets, getDatasetById, putDatasetById } from '@/web/core/dataset/api';
|
||||
import { defaultKbDetail } from '@/constants/dataset';
|
||||
|
19
projects/app/src/web/core/plugin/api.ts
Normal file
19
projects/app/src/web/core/plugin/api.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { GET, POST, DELETE, PUT } from '@/web/common/api/request';
|
||||
import { FlowModuleTemplateType } from '@fastgpt/global/core/module/type';
|
||||
import {
|
||||
CreateOnePluginParams,
|
||||
PluginListItemType,
|
||||
UpdatePluginParams
|
||||
} from '@fastgpt/global/core/plugin/controller';
|
||||
import { PluginItemSchema } from '@fastgpt/global/core/plugin/type';
|
||||
|
||||
export const postCreatePlugin = (data: CreateOnePluginParams) =>
|
||||
POST<string>('/core/plugin/create', data);
|
||||
export const putUpdatePlugin = (data: UpdatePluginParams) => PUT('/core/plugin/update', data);
|
||||
export const getUserPlugins = () => GET<PluginListItemType[]>('/core/plugin/list');
|
||||
export const getUserPlugs2ModuleTemplates = () =>
|
||||
GET<FlowModuleTemplateType[]>('/core/plugin/templateList');
|
||||
export const getPluginModuleDetail = (id: string) =>
|
||||
GET<FlowModuleTemplateType>('/core/plugin/moduleDetail', { id });
|
||||
export const getOnePlugin = (id: string) => GET<PluginItemSchema>('/core/plugin/detail', { id });
|
||||
export const delOnePlugin = (id: string) => DELETE('/core/plugin/delete', { id });
|
28
projects/app/src/web/core/plugin/store/plugin.ts
Normal file
28
projects/app/src/web/core/plugin/store/plugin.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
import type { FlowModuleTemplateType } from '@fastgpt/global/core/module/type';
|
||||
import { getUserPlugs2ModuleTemplates } from '../api';
|
||||
|
||||
type State = {
|
||||
pluginModuleTemplates: FlowModuleTemplateType[];
|
||||
loadPluginModuleTemplates: (init?: boolean) => Promise<FlowModuleTemplateType[]>;
|
||||
};
|
||||
|
||||
export const usePluginStore = create<State>()(
|
||||
devtools(
|
||||
immer((set, get) => ({
|
||||
pluginModuleTemplates: [],
|
||||
async loadPluginModuleTemplates(init) {
|
||||
if (!init && get().pluginModuleTemplates.length > 0) {
|
||||
return get().pluginModuleTemplates;
|
||||
}
|
||||
const templates = await getUserPlugs2ModuleTemplates();
|
||||
set((state) => {
|
||||
state.pluginModuleTemplates = templates;
|
||||
});
|
||||
return templates;
|
||||
}
|
||||
}))
|
||||
)
|
||||
);
|
@@ -4,7 +4,7 @@ import type { ResLogin, PromotionRecordType } from '@/global/support/api/userRes
|
||||
import { UserAuthTypeEnum } from '@/constants/common';
|
||||
import { UserType, UserUpdateParams } from '@/types/user';
|
||||
import type { PagingData, RequestPaging } from '@/types';
|
||||
import { informSchema } from '@/types/mongoSchema';
|
||||
import type { UserInformSchema } from '@fastgpt/global/support/user/type';
|
||||
import { OAuthEnum } from '@/constants/user';
|
||||
|
||||
export const sendAuthCode = (data: {
|
||||
@@ -71,7 +71,7 @@ export const loginOut = () => GET('/user/account/loginout');
|
||||
export const putUserInfo = (data: UserUpdateParams) => PUT('/user/account/update', data);
|
||||
|
||||
export const getInforms = (data: RequestPaging) =>
|
||||
POST<PagingData<informSchema>>(`/user/inform/list`, data);
|
||||
POST<PagingData<UserInformSchema>>(`/user/inform/list`, data);
|
||||
|
||||
export const getUnreadCount = () => GET<number>(`/user/inform/countUnread`);
|
||||
export const readInform = (id: string) => GET(`/user/inform/read`, { id });
|
||||
|
@@ -2,7 +2,7 @@ import { create } from 'zustand';
|
||||
import { devtools, persist } from 'zustand/middleware';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
import type { UserType, UserUpdateParams } from '@/types/user';
|
||||
import { getMyModels, getModelById, putAppById } from '@/web/core/app/api';
|
||||
import { getMyApps, getModelById, putAppById } from '@/web/core/app/api';
|
||||
import { formatPrice } from '@fastgpt/global/common/bill/tools';
|
||||
import { getTokenLogin, putUserInfo } from '@/web/support/user/api';
|
||||
import { defaultApp } from '@/constants/model';
|
||||
@@ -66,7 +66,7 @@ export const useUserStore = create<State>()(
|
||||
myCollectionApps: [],
|
||||
async loadMyApps(init = true) {
|
||||
if (get().myApps.length > 0 && !init) return [];
|
||||
const res = await getMyModels();
|
||||
const res = await getMyApps();
|
||||
set((state) => {
|
||||
state.myApps = res;
|
||||
});
|
||||
|
Reference in New Issue
Block a user