mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
4.8-preview fix (#1324)
* feishu app release (#85) * Revert "lafAccount add pat & re request when token invalid (#76)" (#77) This reverts commit 83d85dfe37adcaef4833385ea52ee79fd84720be. * perf: workflow ux * system config * feat: feishu app release * chore: sovle the conflicts files; fix the feishu entry * fix: rename Feishu interface to FeishuType * fix: fix type problem in app.ts * fix: type problem * fix: style problem --------- Co-authored-by: Archer <545436317@qq.com> * perf: publish channel code * change system variable position (#94) * perf: workflow context * perf: variable select * hide publish * perf: simple edit auto refresh * perf: simple edit data refresh * fix: target handle --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { TTSTypeEnum } from '@/constants/app';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import type { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat.d';
|
||||
import { getToken } from '@/web/support/user/auth';
|
||||
import { useMount } from 'ahooks';
|
||||
|
||||
const contentType = 'audio/mpeg';
|
||||
const splitMarker = 'SPLIT_MARKER';
|
||||
@@ -329,7 +330,7 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
|
||||
);
|
||||
|
||||
// listen audio status
|
||||
useEffect(() => {
|
||||
useMount(() => {
|
||||
const audio = new Audio();
|
||||
audioRef.current = audio;
|
||||
|
||||
@@ -357,7 +358,7 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
|
||||
audio.remove();
|
||||
window.removeEventListener('beforeunload', listen);
|
||||
};
|
||||
}, []);
|
||||
});
|
||||
|
||||
return {
|
||||
audio: audioRef.current,
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { clientInitData } from '@/web/common/system/staticData';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import type { FastGPTFeConfigsType } from '@fastgpt/global/common/system/types/index.d';
|
||||
import { change2DefaultLng, setLngStore } from '@/web/common/utils/i18n';
|
||||
import { useMemoizedFn, useMount } from 'ahooks';
|
||||
|
||||
export const useInitApp = () => {
|
||||
const router = useRouter();
|
||||
@@ -14,7 +15,7 @@ export const useInitApp = () => {
|
||||
const [scripts, setScripts] = useState<FastGPTFeConfigsType['scripts']>([]);
|
||||
const [title, setTitle] = useState(process.env.SYSTEM_NAME || 'AI');
|
||||
|
||||
const initFetch = useCallback(async () => {
|
||||
const initFetch = useMemoizedFn(async () => {
|
||||
const {
|
||||
feConfigs: { scripts, isPlus, show_git, systemTitle }
|
||||
} = await clientInitData();
|
||||
@@ -35,18 +36,18 @@ export const useInitApp = () => {
|
||||
|
||||
setScripts(scripts || []);
|
||||
setInitd();
|
||||
}, [loadGitStar, setInitd]);
|
||||
});
|
||||
|
||||
const initUserLanguage = useCallback(() => {
|
||||
const initUserLanguage = useMemoizedFn(() => {
|
||||
// get default language
|
||||
const targetLng = change2DefaultLng(i18n.language);
|
||||
if (targetLng) {
|
||||
setLngStore(targetLng);
|
||||
router.replace(router.asPath, undefined, { locale: targetLng });
|
||||
}
|
||||
}, []);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
useMount(() => {
|
||||
initFetch();
|
||||
initUserLanguage();
|
||||
|
||||
@@ -67,7 +68,7 @@ export const useInitApp = () => {
|
||||
return () => {
|
||||
window.removeEventListener('error', errorTrack);
|
||||
};
|
||||
}, []);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
hiId && localStorage.setItem('inviterId', hiId);
|
||||
|
@@ -704,7 +704,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType {
|
||||
...pluginTool.map((tool) => tool.edges).flat()
|
||||
]
|
||||
};
|
||||
console.log(config);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -724,23 +724,28 @@ export const getSystemVariables = (t: TFunction): EditorVariablePickerType[] =>
|
||||
return [
|
||||
{
|
||||
key: 'appId',
|
||||
label: t('core.module.http.AppId')
|
||||
label: t('core.module.http.AppId'),
|
||||
valueType: WorkflowIOValueTypeEnum.string
|
||||
},
|
||||
{
|
||||
key: 'chatId',
|
||||
label: t('core.module.http.ChatId')
|
||||
label: t('core.module.http.ChatId'),
|
||||
valueType: WorkflowIOValueTypeEnum.string
|
||||
},
|
||||
{
|
||||
key: 'responseChatItemId',
|
||||
label: t('core.module.http.ResponseChatItemId')
|
||||
label: t('core.module.http.ResponseChatItemId'),
|
||||
valueType: WorkflowIOValueTypeEnum.string
|
||||
},
|
||||
{
|
||||
key: 'histories',
|
||||
label: t('core.module.http.Histories')
|
||||
label: t('core.module.http.Histories'),
|
||||
valueType: WorkflowIOValueTypeEnum.chatHistory
|
||||
},
|
||||
{
|
||||
key: 'cTime',
|
||||
label: t('core.module.http.Current time')
|
||||
label: t('core.module.http.Current time'),
|
||||
valueType: WorkflowIOValueTypeEnum.string
|
||||
}
|
||||
];
|
||||
};
|
||||
|
@@ -16,7 +16,7 @@ import {
|
||||
StoreNodeItemType
|
||||
} from '@fastgpt/global/core/workflow/type';
|
||||
import { VARIABLE_NODE_ID } from '@fastgpt/global/core/workflow/constants';
|
||||
import { getHandleId, splitGuideModule } from '@fastgpt/global/core/workflow/utils';
|
||||
import { getHandleId } from '@fastgpt/global/core/workflow/utils';
|
||||
import { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import { LLMModelTypeEnum } from '@fastgpt/global/core/ai/constants';
|
||||
import {
|
||||
@@ -24,8 +24,10 @@ import {
|
||||
FlowNodeOutputItemType
|
||||
} from '@fastgpt/global/core/workflow/type/io';
|
||||
import { PluginTypeEnum } from '@fastgpt/global/core/plugin/constants';
|
||||
import { getWorkflowGlobalVariables } from './utils';
|
||||
import { TFunction } from 'next-i18next';
|
||||
|
||||
export const systemConfigNode2VariableNode = (node: FlowNodeItemType) => {
|
||||
export const getGlobalVariableNode = (nodes: FlowNodeItemType[], t: TFunction) => {
|
||||
const template: FlowNodeTemplateType = {
|
||||
id: FlowNodeTypeEnum.globalVariable,
|
||||
templateType: FlowNodeTemplateTypeEnum.other,
|
||||
@@ -41,17 +43,17 @@ export const systemConfigNode2VariableNode = (node: FlowNodeItemType) => {
|
||||
outputs: []
|
||||
};
|
||||
|
||||
const { variableModules } = splitGuideModule(node);
|
||||
const globalVariables = getWorkflowGlobalVariables(nodes, t);
|
||||
|
||||
const variableNode: FlowNodeItemType = {
|
||||
nodeId: VARIABLE_NODE_ID,
|
||||
...template,
|
||||
outputs: variableModules.map((item) => ({
|
||||
outputs: globalVariables.map((item) => ({
|
||||
id: item.key,
|
||||
type: FlowNodeOutputTypeEnum.dynamic,
|
||||
type: FlowNodeOutputTypeEnum.static,
|
||||
label: item.label,
|
||||
key: item.key,
|
||||
valueType: WorkflowIOValueTypeEnum.any
|
||||
valueType: item.valueType || WorkflowIOValueTypeEnum.any
|
||||
}))
|
||||
};
|
||||
|
||||
|
@@ -13,9 +13,17 @@ import {
|
||||
import { EmptyNode } from '@fastgpt/global/core/workflow/template/system/emptyNode';
|
||||
import { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
import { systemConfigNode2VariableNode } from './adapt';
|
||||
import { getGlobalVariableNode } from './adapt';
|
||||
import { VARIABLE_NODE_ID } from '@fastgpt/global/core/workflow/constants';
|
||||
import { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { EditorVariablePickerType } from '@fastgpt/web/components/common/Textarea/PromptEditor/type';
|
||||
import {
|
||||
formatEditorVariablePickerIcon,
|
||||
getGuideModule,
|
||||
splitGuideModule
|
||||
} from '@fastgpt/global/core/workflow/utils';
|
||||
import { getSystemVariables } from '../app/utils';
|
||||
import { TFunction } from 'next-i18next';
|
||||
|
||||
export const nodeTemplate2FlowNode = ({
|
||||
template,
|
||||
@@ -97,11 +105,13 @@ export const storeEdgesRenderEdge = ({ edge }: { edge: StoreEdgeItemType }) => {
|
||||
export const computedNodeInputReference = ({
|
||||
nodeId,
|
||||
nodes,
|
||||
edges
|
||||
edges,
|
||||
t
|
||||
}: {
|
||||
nodeId: string;
|
||||
nodes: FlowNodeItemType[];
|
||||
edges: Edge[];
|
||||
t: TFunction;
|
||||
}) => {
|
||||
// get current node
|
||||
const node = nodes.find((item) => item.nodeId === nodeId);
|
||||
@@ -126,14 +136,7 @@ export const computedNodeInputReference = ({
|
||||
};
|
||||
findSourceNode(nodeId);
|
||||
|
||||
// add system config node
|
||||
const systemConfigNode = nodes.find(
|
||||
(item) => item.flowNodeType === FlowNodeTypeEnum.systemConfig
|
||||
);
|
||||
|
||||
if (systemConfigNode) {
|
||||
sourceNodes.unshift(systemConfigNode2VariableNode(systemConfigNode));
|
||||
}
|
||||
sourceNodes.unshift(getGlobalVariableNode(nodes, t));
|
||||
|
||||
return sourceNodes;
|
||||
};
|
||||
@@ -232,3 +235,17 @@ export const filterSensitiveNodesData = (nodes: StoreNodeItemType[]) => {
|
||||
});
|
||||
return cloneNodes;
|
||||
};
|
||||
|
||||
/* get workflowStart output to global variables */
|
||||
export const getWorkflowGlobalVariables = (
|
||||
nodes: FlowNodeItemType[],
|
||||
t: TFunction
|
||||
): EditorVariablePickerType[] => {
|
||||
const globalVariables = formatEditorVariablePickerIcon(
|
||||
splitGuideModule(getGuideModule(nodes))?.variableModules || []
|
||||
);
|
||||
|
||||
const systemVariables = getSystemVariables(t);
|
||||
|
||||
return [...globalVariables, ...systemVariables];
|
||||
};
|
||||
|
@@ -1,26 +1,40 @@
|
||||
import { GET, POST, DELETE } from '@/web/common/api/request';
|
||||
import type { OutLinkEditType, OutLinkSchema } from '@fastgpt/global/support/outLink/type.d';
|
||||
|
||||
/**
|
||||
* create a shareChat
|
||||
*/
|
||||
export const createShareChat = (
|
||||
data: OutLinkEditType & {
|
||||
// create a shareChat
|
||||
export function createShareChat<T>(
|
||||
data: OutLinkEditType<T> & {
|
||||
appId: string;
|
||||
type: OutLinkSchema['type'];
|
||||
}
|
||||
) => POST<string>(`/support/outLink/create`, data);
|
||||
) {
|
||||
return POST<string>(`/support/outLink/create`, data);
|
||||
}
|
||||
|
||||
export const putShareChat = (data: OutLinkEditType) =>
|
||||
POST<string>(`/support/outLink/update`, data);
|
||||
|
||||
/**
|
||||
* get shareChat
|
||||
*/
|
||||
export const getShareChatList = (appId: string) =>
|
||||
GET<OutLinkSchema[]>(`/support/outLink/list`, { appId });
|
||||
// get shareChat
|
||||
export function getShareChatList<T>(data: { appId: string; type: OutLinkSchema<T>['type'] }) {
|
||||
return GET<OutLinkSchema<T>[]>(`/support/outLink/list`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a shareChat
|
||||
*/
|
||||
export const delShareChatById = (id: string) => DELETE(`/support/outLink/delete?id=${id}`);
|
||||
// delete a shareChat
|
||||
export function delShareChatById(id: string) {
|
||||
return DELETE(`/support/outLink/delete?id=${id}`);
|
||||
}
|
||||
|
||||
// update a shareChat
|
||||
export function updateShareChat<T>(data: OutLinkEditType<T>) {
|
||||
return POST<string>(`/support/outLink/update`, data);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * create a shareChat
|
||||
// */
|
||||
// export const createWecomLinkChat = (
|
||||
// data: OutLinkConfigEditType & {
|
||||
// appId: string;
|
||||
// type: OutLinkSchema['type'];
|
||||
// }
|
||||
// ) => POST<string>(`/support/outLink/create`, data);
|
||||
|
@@ -57,7 +57,7 @@ export const useSendCode = () => {
|
||||
}
|
||||
setCodeSending(false);
|
||||
},
|
||||
[codeCountDown, toast]
|
||||
[codeCountDown, feConfigs?.googleClientVerKey, toast]
|
||||
);
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user