mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
feat: question guide (#1508)
* feat: question guide * fix * fix * fix * change interface * fix
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { GET, POST, DELETE, PUT } from '@/web/common/api/request';
|
||||
import type { AppDetailType, AppListItemType } from '@fastgpt/global/core/app/type.d';
|
||||
import type {
|
||||
AppDetailType,
|
||||
AppListItemType,
|
||||
AppQuestionGuideTextConfigType
|
||||
} from '@fastgpt/global/core/app/type.d';
|
||||
import type { GetAppChatLogsParams } from '@/global/core/api/appReq.d';
|
||||
import { AppUpdateParams, CreateAppParams } from '@/global/core/app/api';
|
||||
import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type';
|
||||
|
||||
/**
|
||||
* 获取模型列表
|
||||
@@ -32,3 +37,19 @@ export const putAppById = (id: string, data: AppUpdateParams) =>
|
||||
|
||||
// =================== chat logs
|
||||
export const getAppChatLogs = (data: GetAppChatLogsParams) => POST(`/core/app/getChatLogs`, data);
|
||||
|
||||
/**
|
||||
* 导入提示词库
|
||||
*/
|
||||
export const importQuestionGuides = (data: {
|
||||
appId: string;
|
||||
textList: string[];
|
||||
customURL: string;
|
||||
}) => POST(`/core/app/questionGuides/import`, data);
|
||||
|
||||
/**
|
||||
* 获取提示词库
|
||||
*/
|
||||
export const getMyQuestionGuides = (
|
||||
data: PaginationProps<{ appId: string; customURL: string; searchKey: string }>
|
||||
) => GET<PaginationResponse<string>>(`/core/app/questionGuides/list`, data);
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools, persist } from 'zustand/middleware';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
import { getMyApps, getModelById, putAppById } from '@/web/core/app/api';
|
||||
import { defaultApp } from '../constants';
|
||||
import { getMyApps, getModelById, putAppById, getMyQuestionGuides } from '@/web/core/app/api';
|
||||
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';
|
||||
import { defaultApp } from '../constants';
|
||||
|
||||
type State = {
|
||||
myApps: AppListItemType[];
|
||||
|
@@ -1,4 +1,9 @@
|
||||
import { AppSimpleEditFormType } from '@fastgpt/global/core/app/type';
|
||||
import {
|
||||
AppDetailType,
|
||||
AppQuestionGuideTextConfigType,
|
||||
AppSchema,
|
||||
AppSimpleEditFormType
|
||||
} from '@fastgpt/global/core/app/type';
|
||||
import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/index.d';
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
@@ -64,6 +69,12 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType {
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||
label: '',
|
||||
value: formData.userGuide.scheduleTrigger
|
||||
},
|
||||
{
|
||||
key: NodeInputKeyEnum.questionGuideText,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||
label: '',
|
||||
value: formData.userGuide.questionGuideText
|
||||
}
|
||||
],
|
||||
outputs: []
|
||||
@@ -757,3 +768,34 @@ export const getSystemVariables = (t: TFunction): EditorVariablePickerType[] =>
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
export const getAppQGuideCustomURL = (appDetail: AppDetailType | AppSchema): string => {
|
||||
return (
|
||||
appDetail?.modules
|
||||
.find((m) => m.flowNodeType === FlowNodeTypeEnum.systemConfig)
|
||||
?.inputs.find((i) => i.key === NodeInputKeyEnum.questionGuideText)?.value.customURL || ''
|
||||
);
|
||||
};
|
||||
|
||||
export const getNodesWithNoQGuide = (
|
||||
nodes: StoreNodeItemType[],
|
||||
questionGuideText: AppQuestionGuideTextConfigType
|
||||
): StoreNodeItemType[] => {
|
||||
return nodes.map((node) => {
|
||||
if (node.flowNodeType === FlowNodeTypeEnum.systemConfig) {
|
||||
return {
|
||||
...node,
|
||||
inputs: node.inputs.map((input) => {
|
||||
if (input.key === NodeInputKeyEnum.questionGuideText) {
|
||||
return {
|
||||
...input,
|
||||
value: { ...questionGuideText, textList: [] }
|
||||
};
|
||||
}
|
||||
return input;
|
||||
})
|
||||
};
|
||||
}
|
||||
return node;
|
||||
});
|
||||
};
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
||||
import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/index.d';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
|
||||
export function checkChatSupportSelectFileByChatModels(models: string[] = []) {
|
||||
const llmModelList = useSystemStore.getState().llmModelList;
|
||||
@@ -25,3 +26,23 @@ export function checkChatSupportSelectFileByModules(modules: StoreNodeItemType[]
|
||||
);
|
||||
return checkChatSupportSelectFileByChatModels(models);
|
||||
}
|
||||
|
||||
export function getAppQuestionGuidesByModules(modules: StoreNodeItemType[] = []) {
|
||||
const systemModule = modules.find((item) => item.flowNodeType === FlowNodeTypeEnum.systemConfig);
|
||||
const questionGuideText = systemModule?.inputs.find(
|
||||
(item) => item.key === NodeInputKeyEnum.questionGuideText
|
||||
)?.value;
|
||||
|
||||
return questionGuideText?.open ? questionGuideText?.textList : [];
|
||||
}
|
||||
|
||||
export function getAppQuestionGuidesByUserGuideModule(
|
||||
module: StoreNodeItemType,
|
||||
qGuideText: string[] = []
|
||||
) {
|
||||
const questionGuideText = module?.inputs.find(
|
||||
(item) => item.key === NodeInputKeyEnum.questionGuideText
|
||||
)?.value;
|
||||
|
||||
return questionGuideText?.open ? qGuideText : [];
|
||||
}
|
||||
|
Reference in New Issue
Block a user