mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
V4.6.5-alpha (#609)
This commit is contained in:
@@ -10,7 +10,7 @@ export async function createQuestionGuide({
|
||||
messages: ChatMessageItemType[];
|
||||
model: string;
|
||||
}) {
|
||||
const ai = getAIApi(undefined, 48000);
|
||||
const ai = getAIApi(undefined, 480000);
|
||||
const data = await ai.chat.completions.create({
|
||||
model: model,
|
||||
temperature: 0,
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import { MongoPlugin } from './schema';
|
||||
import { FlowModuleTemplateType } from '@fastgpt/global/core/module/type';
|
||||
import { FlowNodeTypeEnum } from '@fastgpt/global/core/module/node/constant';
|
||||
import { formatPluginToPreviewModule } from '@fastgpt/global/core/module/utils';
|
||||
import { PluginType2TemplateTypeMap, PluginTypeEnum } from '@fastgpt/global/core/plugin/constants';
|
||||
import { plugin2ModuleIO } from '@fastgpt/global/core/module/utils';
|
||||
import { PluginSourceEnum } from '@fastgpt/global/core/plugin/constants';
|
||||
import type { PluginTemplateType } from '@fastgpt/global/core/plugin/type.d';
|
||||
import { ModuleTemplateTypeEnum } from '@fastgpt/global/core/module/constants';
|
||||
|
||||
/*
|
||||
plugin id rule:
|
||||
@@ -14,84 +15,71 @@ import type { PluginTemplateType } from '@fastgpt/global/core/plugin/type.d';
|
||||
|
||||
export async function splitCombinePluginId(id: string) {
|
||||
const splitRes = id.split('-');
|
||||
if (splitRes.length === 1 && id.length === 24) {
|
||||
if (splitRes.length === 1) {
|
||||
return {
|
||||
type: PluginTypeEnum.personal,
|
||||
source: PluginSourceEnum.personal,
|
||||
pluginId: id
|
||||
};
|
||||
}
|
||||
|
||||
const [type, pluginId] = id.split('-') as [`${PluginTypeEnum}`, string];
|
||||
if (!type || !pluginId) return Promise.reject('pluginId not found');
|
||||
const [source, pluginId] = id.split('-') as [`${PluginSourceEnum}`, string];
|
||||
if (!source || !pluginId) return Promise.reject('pluginId not found');
|
||||
|
||||
return { type, pluginId: id };
|
||||
return { source, pluginId: id };
|
||||
}
|
||||
|
||||
const getPluginTemplateById = async (id: string): Promise<PluginTemplateType> => {
|
||||
const { source, pluginId } = await splitCombinePluginId(id);
|
||||
if (source === PluginSourceEnum.community) {
|
||||
const item = global.communityPlugins?.find((plugin) => plugin.id === pluginId);
|
||||
if (!item) return Promise.reject('plugin not found');
|
||||
|
||||
return item;
|
||||
}
|
||||
if (source === PluginSourceEnum.personal) {
|
||||
const item = await MongoPlugin.findById(id).lean();
|
||||
if (!item) return Promise.reject('plugin not found');
|
||||
return {
|
||||
id: String(item._id),
|
||||
name: item.name,
|
||||
avatar: item.avatar,
|
||||
intro: item.intro,
|
||||
source: PluginSourceEnum.personal,
|
||||
modules: item.modules,
|
||||
templateType: ModuleTemplateTypeEnum.personalPlugin
|
||||
};
|
||||
}
|
||||
return Promise.reject('plugin not found');
|
||||
};
|
||||
|
||||
/* format plugin modules to plugin preview module */
|
||||
export async function getPluginPreviewModule({
|
||||
id
|
||||
}: {
|
||||
id: string;
|
||||
}): Promise<FlowModuleTemplateType> {
|
||||
// classify
|
||||
const { type, pluginId } = await splitCombinePluginId(id);
|
||||
const plugin = await getPluginTemplateById(id);
|
||||
|
||||
const plugin = await (async () => {
|
||||
if (type === PluginTypeEnum.community) {
|
||||
return global.communityPlugins?.find((plugin) => plugin.id === pluginId);
|
||||
}
|
||||
if (type === PluginTypeEnum.personal) {
|
||||
const item = await MongoPlugin.findById(id);
|
||||
if (!item) return undefined;
|
||||
return {
|
||||
id: String(item._id),
|
||||
name: item.name,
|
||||
avatar: item.avatar,
|
||||
intro: item.intro,
|
||||
type: PluginTypeEnum.personal,
|
||||
modules: item.modules
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
if (!plugin) return Promise.reject('plugin not found');
|
||||
return {
|
||||
id: plugin.id,
|
||||
templateType: PluginType2TemplateTypeMap[plugin.type],
|
||||
templateType: plugin.templateType,
|
||||
flowType: FlowNodeTypeEnum.pluginModule,
|
||||
avatar: plugin.avatar,
|
||||
name: plugin.name,
|
||||
intro: plugin.intro,
|
||||
showStatus: true,
|
||||
...formatPluginToPreviewModule(plugin.id, plugin.modules)
|
||||
...plugin2ModuleIO(plugin.id, plugin.modules)
|
||||
};
|
||||
}
|
||||
|
||||
/* run plugin time */
|
||||
export async function getPluginRuntimeById(id: string): Promise<PluginTemplateType> {
|
||||
const { type, pluginId } = await splitCombinePluginId(id);
|
||||
|
||||
const plugin = await (async () => {
|
||||
if (type === PluginTypeEnum.community) {
|
||||
return global.communityPlugins?.find((plugin) => plugin.id === pluginId);
|
||||
}
|
||||
if (type === PluginTypeEnum.personal) {
|
||||
const item = await MongoPlugin.findById(id);
|
||||
if (!item) return undefined;
|
||||
return {
|
||||
id: String(item._id),
|
||||
name: item.name,
|
||||
avatar: item.avatar,
|
||||
intro: item.intro,
|
||||
type: PluginTypeEnum.personal,
|
||||
modules: item.modules
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
if (!plugin) return Promise.reject('plugin not found');
|
||||
const plugin = await getPluginTemplateById(id);
|
||||
|
||||
return {
|
||||
id: plugin.id,
|
||||
type: plugin.type,
|
||||
source: plugin.source,
|
||||
templateType: plugin.templateType,
|
||||
name: plugin.name,
|
||||
avatar: plugin.avatar,
|
||||
intro: plugin.intro,
|
||||
|
Reference in New Issue
Block a user