Skip to content

Commit

Permalink
4.8.15 test (labring#3246)
Browse files Browse the repository at this point in the history
* o1 config

* perf: system plugin code
  • Loading branch information
c121914yu committed Nov 27, 2024
1 parent d0a9ffd commit 3930191
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 82 deletions.
8 changes: 2 additions & 6 deletions docSite/content/zh-cn/docs/development/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ weight: 708
"customExtractPrompt": "",
"defaultSystemChatPrompt": "",
"defaultConfig": {
"temperature": 1,
"max_tokens": null,
"stream": false
"temperature": 1
}
},
{
Expand All @@ -122,9 +120,7 @@ weight: 708
"customExtractPrompt": "",
"defaultSystemChatPrompt": "",
"defaultConfig": {
"temperature": 1,
"max_tokens": null,
"stream": false
"temperature": 1
}
}
],
Expand Down
12 changes: 2 additions & 10 deletions docSite/content/zh-cn/docs/development/upgrading/4811.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ weight: 813
"customExtractPrompt": "",
"defaultSystemChatPrompt": "",
"defaultConfig": {
"temperature": 1,
"stream": false
},
"fieldMap": {
"max_tokens": "max_completion_tokens"
"temperature": 1
}
},
{
Expand All @@ -67,11 +63,7 @@ weight: 813
"customExtractPrompt": "",
"defaultSystemChatPrompt": "",
"defaultConfig": {
"temperature": 1,
"stream": false
},
"fieldMap": {
"max_tokens": "max_completion_tokens"
"temperature": 1
}
}
```
Expand Down
1 change: 0 additions & 1 deletion packages/global/core/plugin/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ export type PluginRuntimeType = {
edges: StoreEdgeItemType[];
currentCost?: number;
hasTokenFee?: boolean;
pluginOrder?: number;
};
71 changes: 21 additions & 50 deletions packages/service/core/app/plugin/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,28 @@ const getSystemPluginTemplateById = async (
const item = getSystemPluginTemplates().find((plugin) => plugin.id === pluginId);
if (!item) return Promise.reject('plugin not found');

return cloneDeep(item);
const plugin = cloneDeep(item);

if (plugin.associatedPluginId) {
// TODO: check is system plugin

const app = await MongoApp.findById(plugin.associatedPluginId).lean();
if (!app) return Promise.reject('plugin not found');

const version = await getAppLatestVersion(plugin.associatedPluginId, app);
if (!version.versionId) return Promise.reject('App version not found');

plugin.workflow = {
nodes: version.nodes,
edges: version.edges,
chatConfig: version.chatConfig
};
}

return plugin;
};

/* format plugin modules to plugin preview module */
/* Format plugin to workflow preview node data */
export async function getChildAppPreviewNode({
id
}: {
Expand Down Expand Up @@ -86,20 +104,6 @@ export async function getChildAppPreviewNode({
}
})();

if (app.associatedPluginId) {
const item = await MongoApp.findById(app.associatedPluginId).lean();
if (!item) return Promise.reject('plugin not found');

const version = await getAppLatestVersion(app.associatedPluginId, item);

if (!version.versionId) return Promise.reject('App version not found');
app.workflow = {
nodes: version.nodes,
edges: version.edges,
chatConfig: version.chatConfig
};
}

const isPlugin = !!app.workflow.nodes.find(
(node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput
);
Expand Down Expand Up @@ -167,38 +171,6 @@ export async function getChildAppRuntimeById(
hasTokenFee: false,
pluginOrder: 0
};
} else if (source === PluginSourceEnum.commercial) {
const pluginTemplate = getSystemPluginTemplates().find((plugin) => plugin.id === pluginId);
if (!pluginTemplate?.associatedPluginId) return Promise.reject('plugin not found');

const item = await MongoApp.findById(pluginTemplate.associatedPluginId).lean();
if (!item) return Promise.reject('plugin not found');

const version = await getAppVersionById({
appId: pluginTemplate.associatedPluginId,
versionId,
app: item
});

return {
id: String(item._id),
teamId: String(item.teamId),
name: item.name,
avatar: item.avatar,
intro: item.intro,
showStatus: true,
workflow: {
nodes: version.nodes,
edges: version.edges,
chatConfig: version.chatConfig
},
templateType: FlowNodeTemplateTypeEnum.teamApp,
version: pluginTemplate.version,
originCost: pluginTemplate.originCost,
currentCost: pluginTemplate.currentCost,
hasTokenFee: pluginTemplate.hasTokenFee,
pluginOrder: pluginTemplate.pluginOrder
};
} else {
return getSystemPluginTemplateById(pluginId);
}
Expand All @@ -213,7 +185,6 @@ export async function getChildAppRuntimeById(
currentCost: app.currentCost,
nodes: app.workflow.nodes,
edges: app.workflow.edges,
hasTokenFee: app.hasTokenFee,
pluginOrder: app.pluginOrder
hasTokenFee: app.hasTokenFee
};
}
2 changes: 2 additions & 0 deletions packages/service/support/permission/app/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const authPluginByTmbId = async ({

return app;
}

// commercial custom plugin already checked in "getSystemPluginTemplateById"
};

export const authAppByTmbId = async ({
Expand Down
12 changes: 2 additions & 10 deletions projects/app/data/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@
"customExtractPrompt": "",
"defaultSystemChatPrompt": "",
"defaultConfig": {
"temperature": 1,
"stream": false
},
"fieldMap": {
"max_tokens": "max_completion_tokens"
"temperature": 1
}
},
{
Expand All @@ -109,11 +105,7 @@
"customExtractPrompt": "",
"defaultSystemChatPrompt": "",
"defaultConfig": {
"temperature": 1,
"stream": false
},
"fieldMap": {
"max_tokens": "max_completion_tokens"
"temperature": 1
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/components/Layout/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Navbar = ({ unread }: { unread: number }) => {
);

const itemStyles: BoxProps & LinkProps = {
my: 3,
my: 2,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import { LoopStartNode } from '@fastgpt/global/core/workflow/template/system/loo
import { LoopEndNode } from '@fastgpt/global/core/workflow/template/system/loop/loopEnd';
import { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
import { WorkflowNodeEdgeContext } from '../context/workflowInitContext';
import { defaultGroup } from '@/pages/toolkit';
import CostTooltip from '@/components/core/app/plugin/CostTooltip';

type ModuleTemplateListProps = {
Expand Down Expand Up @@ -306,7 +305,7 @@ const NodeTemplatesModal = ({ isOpen, onClose }: ModuleTemplateListProps) => {
{/* Search */}
{(templateType === TemplateTypeEnum.teamPlugin ||
templateType === TemplateTypeEnum.systemPlugin) && (
<Flex mt={2} alignItems={'center'} h={10}>
<Flex mt={2} alignItems={'center'} h={8}>
<InputGroup mr={4} h={'full'}>
<InputLeftElement h={'full'} alignItems={'center'} display={'flex'}>
<MyIcon name={'common/searchLight'} w={'16px'} color={'myGray.500'} ml={3} />
Expand Down Expand Up @@ -440,8 +439,7 @@ const RenderList = React.memo(function RenderList({
list: copy.filter((item) => item.list.length > 0)
}
];
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [templates, parentId]);
}, [type, templates, pluginGroups]);

const onAddNode = useCallback(
async ({
Expand Down

0 comments on commit 3930191

Please sign in to comment.