mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
4.8.1 test-fix (#1561)
This commit is contained in:
@@ -2,7 +2,6 @@ import { SseResponseEventEnum } from '@fastgpt/global/core/workflow/runtime/cons
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import type { ChatHistoryItemResType } from '@fastgpt/global/core/chat/type.d';
|
||||
import type { StartChatFnProps } from '@/components/ChatBox/type.d';
|
||||
import { getToken } from '@/web/support/user/auth';
|
||||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
import dayjs from 'dayjs';
|
||||
import {
|
||||
@@ -117,8 +116,7 @@ export const streamFetch = ({
|
||||
const requestData = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
token: getToken()
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
signal: abortCtrl.signal,
|
||||
body: JSON.stringify({
|
||||
|
@@ -4,7 +4,7 @@ import axios, {
|
||||
AxiosResponse,
|
||||
AxiosProgressEvent
|
||||
} from 'axios';
|
||||
import { clearToken, getToken } from '@/web/support/user/auth';
|
||||
import { clearToken } from '@/web/support/user/auth';
|
||||
import { TOKEN_ERROR_CODE } from '@fastgpt/global/common/error/errorCode';
|
||||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||
import { useSystemStore } from '../system/useSystemStore';
|
||||
@@ -15,6 +15,7 @@ interface ConfigType {
|
||||
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
||||
cancelToken?: AbortController;
|
||||
maxQuantity?: number;
|
||||
withCredentials?: boolean;
|
||||
}
|
||||
interface ResponseDataType {
|
||||
code: number;
|
||||
@@ -61,7 +62,6 @@ function requestFinish({ url }: { url: string }) {
|
||||
*/
|
||||
function startInterceptors(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig {
|
||||
if (config.headers) {
|
||||
config.headers.token = getToken();
|
||||
}
|
||||
|
||||
return config;
|
||||
@@ -138,7 +138,7 @@ instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err)
|
||||
function request(
|
||||
url: string,
|
||||
data: any,
|
||||
{ cancelToken, maxQuantity, ...config }: ConfigType,
|
||||
{ cancelToken, maxQuantity, withCredentials, ...config }: ConfigType,
|
||||
method: Method
|
||||
): any {
|
||||
/* 去空 */
|
||||
@@ -158,6 +158,7 @@ function request(
|
||||
data: ['POST', 'PUT'].includes(method) ? data : null,
|
||||
params: !['POST', 'PUT'].includes(method) ? data : null,
|
||||
signal: cancelToken?.signal,
|
||||
withCredentials,
|
||||
...config // 用户自定义配置,可以覆盖前面的配置
|
||||
})
|
||||
.then((res) => checkRes(res.data))
|
||||
|
@@ -1,31 +0,0 @@
|
||||
import { getToken } from '@/web/support/user/auth';
|
||||
import { hasHttps } from '@fastgpt/web/common/system/utils';
|
||||
|
||||
export const xmlDownloadFetch = async ({ url, filename }: { url: string; filename: string }) => {
|
||||
if (hasHttps()) {
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
} else {
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
token: `${getToken()}`
|
||||
}
|
||||
});
|
||||
if (!response.ok) throw new Error('Network response was not ok.');
|
||||
|
||||
const blob = await response.blob();
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none'; // 隐藏<a>元素
|
||||
a.href = downloadUrl;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click(); // 模拟用户点击
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(downloadUrl); // 清理生成的URL
|
||||
}
|
||||
};
|
8
projects/app/src/web/common/system/utils.ts
Normal file
8
projects/app/src/web/common/system/utils.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export const downloadFetch = async ({ url, filename }: { url: string; filename: string }) => {
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
};
|
@@ -5,7 +5,6 @@ import type { AppTTSConfigType } from '@fastgpt/global/core/app/type.d';
|
||||
import { TTSTypeEnum } from '@/web/core/app/constants';
|
||||
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';
|
||||
@@ -41,8 +40,7 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
|
||||
const response = await fetch('/api/core/chat/item/getSpeech', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
token: getToken()
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
signal: audioController.current.signal,
|
||||
body: JSON.stringify({
|
||||
|
@@ -701,6 +701,7 @@ export const getSystemVariables = (t: TFunction): EditorVariablePickerType[] =>
|
||||
{
|
||||
key: 'appId',
|
||||
label: t('core.module.http.AppId'),
|
||||
required: true,
|
||||
valueType: WorkflowIOValueTypeEnum.string
|
||||
},
|
||||
{
|
||||
@@ -716,11 +717,13 @@ export const getSystemVariables = (t: TFunction): EditorVariablePickerType[] =>
|
||||
{
|
||||
key: 'histories',
|
||||
label: t('core.module.http.Histories'),
|
||||
required: true,
|
||||
valueType: WorkflowIOValueTypeEnum.chatHistory
|
||||
},
|
||||
{
|
||||
key: 'cTime',
|
||||
label: t('core.module.http.Current time'),
|
||||
required: true,
|
||||
valueType: WorkflowIOValueTypeEnum.string
|
||||
}
|
||||
];
|
||||
|
@@ -26,10 +26,11 @@ export const getCountChatInputGuideTotal = (data: countChatInputGuideTotalQuery)
|
||||
export const getChatInputGuideList = (data: ChatInputGuideProps) =>
|
||||
GET<ChatInputGuideResponse>(`/core/chat/inputGuide/list`, data);
|
||||
|
||||
export const queryChatInputGuideList = (
|
||||
data: QueryChatInputGuideProps,
|
||||
url = `/core/chat/inputGuide/query`
|
||||
) => GET<QueryChatInputGuideResponse>(url, data);
|
||||
export const queryChatInputGuideList = (data: QueryChatInputGuideProps, url?: string) => {
|
||||
return GET<QueryChatInputGuideResponse>(url ?? `/core/chat/inputGuide/query`, data, {
|
||||
withCredentials: !url
|
||||
});
|
||||
};
|
||||
|
||||
export const postChatInputGuides = (data: createInputGuideBody) =>
|
||||
POST<createInputGuideResponse>(`/core/chat/inputGuide/create`, data);
|
||||
|
@@ -428,7 +428,7 @@ export const v1Workflow2V2 = (
|
||||
pluginId,
|
||||
pluginType: node.pluginType,
|
||||
parentId: node.parentId,
|
||||
version: 'v2.0',
|
||||
version: '481',
|
||||
|
||||
inputs,
|
||||
outputs
|
||||
|
@@ -157,7 +157,7 @@ export const computedNodeInputReference = ({
|
||||
|
||||
return sourceNodes;
|
||||
};
|
||||
export const getReferenceDataValueType = ({
|
||||
export const getRefData = ({
|
||||
variable,
|
||||
nodeList,
|
||||
chatConfig,
|
||||
@@ -168,16 +168,34 @@ export const getReferenceDataValueType = ({
|
||||
chatConfig: AppChatConfigType;
|
||||
t: TFunction;
|
||||
}) => {
|
||||
if (!variable) return WorkflowIOValueTypeEnum.any;
|
||||
if (!variable)
|
||||
return {
|
||||
valueType: WorkflowIOValueTypeEnum.any,
|
||||
required: false
|
||||
};
|
||||
|
||||
const node = nodeList.find((node) => node.nodeId === variable[0]);
|
||||
const systemVariables = getWorkflowGlobalVariables({ nodes: nodeList, chatConfig, t });
|
||||
|
||||
if (!node) return systemVariables.find((item) => item.key === variable?.[1])?.valueType;
|
||||
if (!node) {
|
||||
const globalVariable = systemVariables.find((item) => item.key === variable?.[1]);
|
||||
return {
|
||||
valueType: globalVariable?.valueType || WorkflowIOValueTypeEnum.any,
|
||||
required: !!globalVariable?.required
|
||||
};
|
||||
}
|
||||
|
||||
const output = node.outputs.find((item) => item.id === variable[1]);
|
||||
if (!output) return WorkflowIOValueTypeEnum.any;
|
||||
return output.valueType;
|
||||
if (!output)
|
||||
return {
|
||||
valueType: WorkflowIOValueTypeEnum.any,
|
||||
required: false
|
||||
};
|
||||
|
||||
return {
|
||||
valueType: output.valueType,
|
||||
required: !!output.required
|
||||
};
|
||||
};
|
||||
|
||||
/* Connection rules */
|
||||
|
Reference in New Issue
Block a user