Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): Unified frontend code style #1923

Merged
merged 146 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
51ff21b
feat(core): Add UI component for AWEL flow
fangyinc Jul 30, 2024
8465726
feat: Add flow2.0 examples
fangyinc Aug 5, 2024
db44f2b
feat(core): Support refresh for AWEL flow
fangyinc Aug 6, 2024
e97b63a
feat: 编排画布新增基于AWEL2.0的Select类型节点渲染
Aug 8, 2024
bde6792
style: translate comment to English
Aug 8, 2024
b96bfb1
feat: add Select type node rendering based on AWEL2.0 protocol to wor…
Dreammy23 Aug 8, 2024
2387aaf
feat(core): Add UI component for AWEL flow
fangyinc Jul 30, 2024
79fbee7
feat: Add flow2.0 examples
fangyinc Aug 5, 2024
462dee3
feat(core): Support refresh for AWEL flow
fangyinc Aug 6, 2024
3b4b34c
feat(core): Support variables for AWEL
fangyinc Aug 9, 2024
a348e6c
feat(core): Support complex variables parsing
fangyinc Aug 11, 2024
a00a9d5
feat(core): Fetch flow nodes API supports filterd by tags
fangyinc Aug 11, 2024
a70ca45
Merge branch 'awel-flow2.0' into feat/update-backend-code
Aug 12, 2024
ff87228
feat: update code of awel-flow2.0 branch (#1810)
Dreammy23 Aug 12, 2024
5193c3e
feat: add some atomic components to flow
Aug 12, 2024
6593af2
feat: add slider textarea treeSelect(80%) timePicker
Aug 12, 2024
18ea5ad
feat: Error resolution
Aug 13, 2024
be7efed
feat: add atom component to flow(textArea、treeSelect、timePiceker、slid…
Dreammy23 Aug 13, 2024
baa1691
style: optimize code of flow
Aug 13, 2024
3225a97
style: optimize code of flow (#1817)
Dreammy23 Aug 13, 2024
0d76c0e
Merge branch 'feat/sprint-web-flow' into feat/atom-component
Aug 13, 2024
9808af3
feat: optimize code
Aug 13, 2024
0b102c2
feat: add atom components to flow(select、input、checkbox、dataPicker) (…
Dreammy23 Aug 13, 2024
dfb13f4
style: update readme
Aug 13, 2024
6290666
fix: Fixed the issue where the date selection component was not effec…
Aug 13, 2024
7c5a67b
fix: fixed the issue where the datePicker component was not effective…
Dreammy23 Aug 13, 2024
f8c786e
feat: update style of canvas node
Aug 14, 2024
a07676e
feat: update style of canvas node (#1829)
Dreammy23 Aug 14, 2024
b8538c7
fix: fixed the issue of incorrect background color of canvas node in …
Aug 14, 2024
9796bf9
style: delete redundant font styles
Aug 14, 2024
145b255
fix: fixed the issue of incorrect background color of canvas node in …
Dreammy23 Aug 14, 2024
6f31c01
feat: add components (codeEditor80% updata)
yunfeng1993 Aug 14, 2024
6284f6a
feat(core): Add AWEL flow radio component
fangyinc Aug 15, 2024
2696d9a
feat: add Password component to flow
Aug 15, 2024
27ee22d
feat:Remove test code
Aug 15, 2024
c9a4668
feat: add Password component to flow (#1831)
Dreammy23 Aug 15, 2024
6a732ae
Merge branch 'awel-flow2.0' into chore/update-api
Aug 15, 2024
da29d4a
chore: update backend api (#1832)
Dreammy23 Aug 15, 2024
b264325
feat:code editor
Aug 15, 2024
b301860
fix:Attribute error
Aug 15, 2024
fa5e425
fix:Description error
Aug 15, 2024
c5ba264
feat:1、Set language 2、Remove junk code
yunfeng1993 Aug 15, 2024
dd21314
Merge branch 'feat/sprint-web-flow' into feat-sprint-web-flow-2.0
yunfeng1993 Aug 16, 2024
187cdd6
feat: add atom components to flow (upload、codeEditor) (#1834)
yunfeng1993 Aug 16, 2024
77be0e6
fix: 1、components treeSelect and Password switch locations
Aug 16, 2024
1bc6d26
fix: 1、components treeSelect and Password switch locations 2、remove c…
Dreammy23 Aug 16, 2024
6ad7199
fix: Components slider and treeSelect drag
Aug 16, 2024
ec42162
fix: Components slider and treeSelect drag (#1837)
Dreammy23 Aug 16, 2024
8563e30
feat(core): Add UI component for AWEL flow
fangyinc Jul 30, 2024
e3e08a8
feat: Add flow2.0 examples
fangyinc Aug 5, 2024
f6669d3
feat(core): Support refresh for AWEL flow
fangyinc Aug 6, 2024
125765a
feat(core): Support variables for AWEL
fangyinc Aug 9, 2024
94ef5da
feat(core): Support complex variables parsing
fangyinc Aug 11, 2024
abf1c78
feat(core): Fetch flow nodes API supports filterd by tags
fangyinc Aug 11, 2024
74f3433
feat(core): Add AWEL flow radio component
fangyinc Aug 15, 2024
58fb29b
feat(core): Add debug and export/import for AWEL flow
fangyinc Aug 17, 2024
b6d54ed
feat(core): Add file server for DB-GPT
fangyinc Aug 18, 2024
48312ed
feat(core): Add file upload operator
fangyinc Aug 18, 2024
7c241b6
fix(core): Fix upload ui component attr error
fangyinc Aug 18, 2024
3d1d275
feat(core): Add multi-instance config
fangyinc Aug 19, 2024
8ced940
feat: add Variables component to flow
Aug 19, 2024
8571ebd
Merge branch 'feat/sprint-web-flow' into feat/tags
Aug 19, 2024
59a3f37
feat: add Variables component to flow (#1839)
Dreammy23 Aug 19, 2024
5c7b938
Merge branch 'awel-flow2.0' of https://github.com/eosphoros-ai/DB-GPT…
Aug 19, 2024
fbd44b8
Merge branch 'awel-flow2.0' into chore/update-api
Aug 19, 2024
d47ecec
chore: update api (#1840)
Dreammy23 Aug 19, 2024
a731233
style: delete repeated Select component
Aug 19, 2024
d0249cb
style: delete repeated Select component (#1841)
Dreammy23 Aug 19, 2024
9394d34
feat(core): Add code editor for UI component
fangyinc Aug 19, 2024
aebb71f
Feat/sprint web flow (#1845)
yunfeng1993 Aug 19, 2024
978ffe1
feat: 1、component textArea support mouse scrolling
Aug 19, 2024
09b9523
fix: add label of component
Aug 20, 2024
861ed9e
feat: refactor NodeParamHandler component
Aug 20, 2024
bf169fa
feat: TextArea component support mouse scrolling、Slider component s…
Dreammy23 Aug 20, 2024
ca1d710
fix: add label of component (#1847)
Dreammy23 Aug 20, 2024
3270112
Merge branch 'awel-flow2.0' of https://github.com/eosphoros-ai/DB-GPT…
Aug 20, 2024
77fbe47
Merge branch 'awel-flow2.0' into chore/update-api
Aug 20, 2024
1a73f5f
chore: update api (#1848)
Dreammy23 Aug 20, 2024
5cf6070
feat: Update UI components for better user experience
Aug 20, 2024
c8fa08f
feat: update UI components for better user experience (#1850)
Dreammy23 Aug 20, 2024
37240c9
chore: update api
Aug 20, 2024
e89f4e3
chore: update api (#1851)
Dreammy23 Aug 20, 2024
74cbfb6
feat: add export/import functionality to flow canvas
Aug 20, 2024
3bb00ed
feat: refactor NodeParamHandler component
Aug 20, 2024
47b1f6a
feat: add export/import functionality to flow canvas (#1853)
Dreammy23 Aug 20, 2024
093ab9a
refactor: refactor canvasNode component to improve rendering performance
Aug 20, 2024
dd4a90d
style: remove console.log statements in NodeParamHandler component
Aug 20, 2024
ef43061
Feat: Merge branch sprint web flow (#1854)
yunfeng1993 Aug 20, 2024
4736b80
feat: Component Upload complete
Aug 20, 2024
1781d0d
feat:remove console
Aug 20, 2024
1c53621
refactor: remove unused API functions and update flow utils
Aug 20, 2024
438adac
refactor: Update canvasNode component to support parameter refreshing
Aug 20, 2024
3859ef1
feat: flow Component Upload support multiple selection
Aug 20, 2024
1cd9bb3
feat: update canvasNode component to support parameter refreshing (#1…
Dreammy23 Aug 20, 2024
132afec
feat: upload file type
Aug 20, 2024
06d7bd4
chore: Fix merge code error
fangyinc Aug 20, 2024
79aff88
feat: update upload components (#1857)
Dreammy23 Aug 20, 2024
0723cda
feat: add prefix icon support to RenderInput component
Aug 20, 2024
0585158
feat: add prefix icon support to RenderInput component (#1858)
Dreammy23 Aug 20, 2024
b4d9f90
feat: fix import typo in node-renderer/index.ts
Aug 21, 2024
ad44355
refactor: simplify code by removing unused API functions and updating…
Aug 21, 2024
3997754
feat: remove defaultValue prop from renderUpload component
Aug 21, 2024
fc4c5ee
refactor: fix import typo in node-renderer/index.ts (#1861)
Dreammy23 Aug 21, 2024
d9fe810
feat: Update console log messages in CanvasNode component
Aug 22, 2024
c7173fb
feat: Update getFlows API function to support pagination
Aug 22, 2024
4848647
feat: update getFlows API function to support pagination (#1868)
Dreammy23 Aug 22, 2024
c052a69
feat: Add support for importing and exporting flows
Aug 22, 2024
bef46d8
feat: add support for importing and exporting flows (#1869)
Dreammy23 Aug 22, 2024
e3faa25
Merge branch 'main' into chore/merge-master
Aug 27, 2024
807b13e
chore: merge main (#1894)
Dreammy23 Aug 27, 2024
a5620d9
chore: merge frontend code of dev-0.6
Aug 27, 2024
b3dc93d
chore: merge frontend code of branch dev-0.6 (#1895)
Dreammy23 Aug 27, 2024
84d335f
chore: Update npm dependency to latest stable version
Aug 27, 2024
b73e138
chore: Update npm dependency to latest stable version (#1903)
Dreammy23 Aug 27, 2024
af95bb4
feat: Add support for importing and exporting flows
Aug 27, 2024
6d3366c
chore: delete yarn.lock (#1904)
Dreammy23 Aug 27, 2024
435fbdb
feat:1、upload data transmission value 2 、 textarea value default exhi…
yunfeng1993 Aug 27, 2024
875b758
feat:upload data transmission value、change textarea value default val…
Dreammy23 Aug 27, 2024
b808075
chore: Update .gitignore to exclude /web/yarn.lock
Aug 27, 2024
3f598b8
Merge remote-tracking branch 'origin/feat/sprint-web-flow' into style…
Aug 27, 2024
32d611b
fix: Fix position offset while drag node on canvas
Aug 27, 2024
97bb8b2
fix: Fix position offset while dragging nodes on canvas
Aug 27, 2024
47777da
fix: Fix position offset while dragging nodes on canvas (#1906)
Dreammy23 Aug 27, 2024
e6b49b3
fix:1、Upload matching parameters 2、Date formatting 3、Reduced referen…
yunfeng1993 Aug 28, 2024
72e9200
fix:remove console
yunfeng1993 Aug 28, 2024
48d2ed1
fix: matching parameters of Upload component、fixed date formatting an…
Dreammy23 Aug 28, 2024
1595084
fix: import data
Aug 29, 2024
a72b34f
fix:Open the popup reset import
Aug 29, 2024
2ec490a
fix: Open the popup reset import (#1919)
Dreammy23 Aug 29, 2024
2f37a1f
chore: update lint tool
Aug 29, 2024
eb58433
chore: Remove unused file server configuration in config.py
Aug 29, 2024
2d70efa
chore: Remove unused file server configuration
Aug 29, 2024
4760c87
Merge branch 'feat/sprint-update-flow' into chore/add-eslint
Aug 29, 2024
a735c8d
chore: Remove unused file server configuration in config.py
Aug 29, 2024
8f1d6b6
chore: update lint tool (#1922)
Dreammy23 Aug 29, 2024
ec3263f
chore: remove console.log statements
Aug 29, 2024
b984439
chore: remove console.log statements (#1924)
Dreammy23 Aug 29, 2024
968c067
Merge branch 'main' into chore/merge-main
Aug 30, 2024
15a9d0c
chore: merge main (#1925)
Dreammy23 Aug 30, 2024
e7a40e4
chore: fix lint error of web floder
Aug 30, 2024
ac97dea
chore: update lint config in package.json and fix lint error of web (…
Dreammy23 Aug 30, 2024
b5fe9b3
chore: Update lint config and fix lint error in web folder
Aug 30, 2024
bb826da
chore: Fix lint error in connect.ts file
Aug 30, 2024
371dec1
fix: build error (#1928)
Dreammy23 Aug 30, 2024
9ecc124
chore: Update lint config and fix lint error in web folder
Aug 30, 2024
cd4048f
chore: update lint config in package.json antd fix lint error (#1930)
Dreammy23 Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions dbgpt/_private/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,6 @@ def __init__(self) -> None:
os.getenv("MULTI_INSTANCE", "False").lower() == "true"
)

# file server configuration
# The host of the current file server, if None, get the host automatically
self.FILE_SERVER_HOST = os.getenv("FILE_SERVER_HOST")
self.FILE_SERVER_LOCAL_STORAGE_PATH = os.getenv(
"FILE_SERVER_LOCAL_STORAGE_PATH"
)
# multi-instance flag
self.WEBSERVER_MULTI_INSTANCE = (
os.getenv("MULTI_INSTANCE", "False").lower() == "true"
)

@property
def local_db_manager(self) -> "ConnectorManager":
from dbgpt.datasource.manages import ConnectorManager
Expand Down
3 changes: 3 additions & 0 deletions web/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
build/
dist/
57 changes: 57 additions & 0 deletions web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
commonjs: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': 'error',
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
quotes: ['error', 'single', { allowTemplateLiterals: true, avoidEscape: true }],
semi: ['error', 'always'],
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
},
};
3 changes: 3 additions & 0 deletions web/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
build/
dist/
16 changes: 16 additions & 0 deletions web/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
printWidth: 120,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
jsxSingleQuote: true,
trailingComma: "all",
bracketSpacing: true,
jsxBracketSameLine: false,
arrowParens: "avoid",
plugins: [
require.resolve('prettier-plugin-organize-imports'),
require.resolve('prettier-plugin-packagejson'),
]
}
10 changes: 5 additions & 5 deletions web/app/chat-context.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { apiInterceptors, getDialogueList, getUsableModels, queryAdminList } from '@/client/api';
import { apiInterceptors, getUsableModels, queryAdminList } from '@/client/api';
import { ChatHistoryResponse, DialogueListResponse, IChatDialogueSchema } from '@/types/chat';
import { UserInfoResponse } from '@/types/userinfo';
import { getUserId } from '@/utils';
import { STORAGE_THEME_KEY } from '@/utils/constants/index';
import { useRequest } from 'ahooks';
import { useSearchParams } from 'next/navigation';
import { createContext, useEffect, useMemo, useState } from 'react';
import { createContext, useEffect, useState } from 'react';

type ThemeMode = 'dark' | 'light';

Expand Down Expand Up @@ -109,7 +109,7 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) =>
return res ?? [];
},
{
onSuccess: (data) => {
onSuccess: data => {
setAdminList(data);
},
manual: true,
Expand All @@ -120,15 +120,15 @@ const ChatContextProvider = ({ children }: { children: React.ReactElement }) =>
if (getUserId()) {
queryAdminListRun();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [queryAdminListRun, getUserId()]);

useEffect(() => {
setMode(getDefaultTheme());
try {
const dialogInfo = JSON.parse(localStorage.getItem('cur_dialog_info') || '');
setCurrentDialogInfo(dialogInfo);
} catch (error) {
} catch {
setCurrentDialogInfo({
chat_scene: '',
app_code: '',
Expand Down
5 changes: 2 additions & 3 deletions web/app/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Domain } from '@mui/icons-material';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import en from '@/locales/en';
import zh from '@/locales/zh';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';

export type I18nKeys = keyof typeof en;
interface Resources {
Expand Down
19 changes: 7 additions & 12 deletions web/client/api/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export const updateApp = (data: CreateAppParams) => {
* 应用列表
*/
export const getAppList = (data: Record<string, any>) => {
return POST<Record<string, any>, AppListResponse>(`/api/v1/app/list?page=${data.page || 1}&page_size=${data.page_size || 12}`, data);
return POST<Record<string, any>, AppListResponse>(
`/api/v1/app/list?page=${data.page || 1}&page_size=${data.page_size || 12}`,
data,
);
};
/**
* 获取创建应用agents
Expand All @@ -52,9 +55,7 @@ export const getAppStrategy = () => {
* 获取资源参数
*/
export const getResource = (data: Record<string, string>) => {
return GET<Record<string, string>, Record<string, any>[]>(
`/api/v1/app/resources/list?type=${data.type}`
);
return GET<Record<string, string>, Record<string, any>[]>(`/api/v1/app/resources/list?type=${data.type}`);
};
/**
* 创建native_app应用
Expand All @@ -80,12 +81,6 @@ export const getAppAdmins = (appCode: string) => {
/**
* 更新应用权限
*/
export const updateAppAdmins = (data: {
app_code: string;
admins: string[];
}) => {
return POST<{ app_code: string; admins: string[] }, null>(
`/api/v1/app/admins/update`,
data
);
export const updateAppAdmins = (data: { app_code: string; admins: string[] }) => {
return POST<{ app_code: string; admins: string[] }, null>(`/api/v1/app/admins/update`, data);
};
5 changes: 4 additions & 1 deletion web/client/api/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ export const cancelFeedback = (data: CancelFeedbackAddParams) => {
* 终止话题
*/
export const stopTopic = (data: StopTopicParams) => {
return POST<StopTopicParams, null>(`/api/v1/chat/topic/terminate?conv_id=${data.conv_id}&round_index=${data.round_index}`, data);
return POST<StopTopicParams, null>(
`/api/v1/chat/topic/terminate?conv_id=${data.conv_id}&round_index=${data.round_index}`,
data,
);
};
26 changes: 15 additions & 11 deletions web/client/api/evaluate/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { getUserId } from '@/utils';
import { GET, POST, DELETE } from '../index';
import type {
getDataSetsRequest,
getEvaluationsRequest,
createEvaluationsRequest,
delDataSetRequest,
delEvaluationRequest,
uploadDataSetsRequest,
createEvaluationsRequest,
downloadEvaluationRequest,
getDataSetsRequest,
getEvaluationsRequest,
getMetricsRequest,
updateDataSetRequest,
downloadEvaluationRequest,
uploadDataSetsRequest,
} from '@/types/evaluate';
import { getUserId } from '@/utils';
import { DELETE, GET, POST } from '../index';

export const getTestAuth = () => {
return GET(`/api/v1/evaluate/test_auth`);
Expand Down Expand Up @@ -100,11 +100,15 @@ export const getMetrics = (data: getMetricsRequest) => {
});
};
export const showEvaluation = (data: Partial<createEvaluationsRequest>) => {
return GET<Partial<createEvaluationsRequest>, Record<string, any>[]>(`/api/v1/evaluate/evaluation/detail/show`, data, {
headers: {
'user-id': userId,
return GET<Partial<createEvaluationsRequest>, Record<string, any>[]>(
`/api/v1/evaluate/evaluation/detail/show`,
data,
{
headers: {
'user-id': userId,
},
},
});
);
};
export const getStorageTypes = () => {
return GET<undefined, Record<string, any>>(`/api/v1/evaluate/storage/types`, undefined, {
Expand Down
23 changes: 7 additions & 16 deletions web/client/api/flow/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
IFlow,
IFlowExportParams,
IFlowImportParams,
IFlowNode,
IFlowRefreshParams,
IFlowResponse,
IFlowUpdateParam,
IFlowRefreshParams,
IFlowExportParams,
IFlowImportParams,
IUploadFileRequestParams,
IUploadFileResponse,
} from '@/types/flow';
Expand All @@ -16,7 +16,7 @@ export const addFlow = (data: IFlowUpdateParam) => {
return POST<IFlowUpdateParam, IFlow>('/api/v2/serve/awel/flows', data);
};

export const getFlows = (page?: number, page_size?: number) => {
export const getFlows = ({ page, page_size }: { page?: number; page_size?: number }) => {
return GET<any, IFlowResponse>('/api/v2/serve/awel/flows', {
page,
page_size,
Expand All @@ -40,32 +40,23 @@ export const getFlowNodes = () => {
};

export const refreshFlowNodeById = (data: IFlowRefreshParams) => {
return POST<IFlowRefreshParams, IFlowNode>(
'/api/v2/serve/awel/nodes/refresh',
data
);
return POST<IFlowRefreshParams, IFlowNode>('/api/v2/serve/awel/nodes/refresh', data);
};

export const debugFlow = (data: any) => {
return POST<any, IFlowNode>('/api/v2/serve/awel/flow/debug', data);
};

export const exportFlow = (data: IFlowExportParams) => {
return GET<IFlowExportParams, any>(
`/api/v2/serve/awel/flow/export/${data.uid}`,
data
);
return GET<IFlowExportParams, any>(`/api/v2/serve/awel/flow/export/${data.uid}`, data);
};

export const importFlow = (data: IFlowImportParams) => {
return POST<IFlowImportParams, any>('/api/v2/serve/awel/flow/import', data);
};

export const uploadFile = (data: IUploadFileRequestParams) => {
return POST<IUploadFileRequestParams, Array<IUploadFileResponse>>(
'/api/v2/serve/file/files/dbgpt',
data
);
return POST<IUploadFileRequestParams, Array<IUploadFileResponse>>('/api/v2/serve/file/files/dbgpt', data);
};

export const downloadFile = (fileId: string) => {
Expand Down
34 changes: 23 additions & 11 deletions web/client/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getUserId } from '@/utils';
import { HEADER_USER_ID_KEY } from '@/utils/constants/index';
import axios, { AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';

export type ResponseType<T = any> = {
data: T;
Expand Down Expand Up @@ -38,41 +38,53 @@ const LONG_TIME_API: string[] = [
'/personal/agent/upload',
];

ins.interceptors.request.use((request) => {
const isLongTimeApi = LONG_TIME_API.some((item) => request.url && request.url.indexOf(item) >= 0);
ins.interceptors.request.use(request => {
const isLongTimeApi = LONG_TIME_API.some(item => request.url && request.url.indexOf(item) >= 0);
if (!request.timeout) {
request.timeout = isLongTimeApi ? 60000 : 100000;
}
request.headers.set(HEADER_USER_ID_KEY, getUserId());
return request;
});

export const GET = <Params = any, Response = any, D = any>(url: string, params?: Params, config?: AxiosRequestConfig<D>) => {
export const GET = <Params = any, Response = any, D = any>(
url: string,
params?: Params,
config?: AxiosRequestConfig<D>,
) => {
return ins.get<Params, ApiResponse<Response>>(url, { params, ...config });
};

export const POST = <Data = any, Response = any, D = any>(url: string, data?: Data, config?: AxiosRequestConfig<D>) => {
return ins.post<Data, ApiResponse<Response>>(url, data, config);
};

export const PATCH = <Data = any, Response = any, D = any>(url: string, data?: Data, config?: AxiosRequestConfig<D>) => {
export const PATCH = <Data = any, Response = any, D = any>(
url: string,
data?: Data,
config?: AxiosRequestConfig<D>,
) => {
return ins.patch<Data, ApiResponse<Response>>(url, data, config);
};

export const PUT = <Data = any, Response = any, D = any>(url: string, data?: Data, config?: AxiosRequestConfig<D>) => {
return ins.put<Data, ApiResponse<Response>>(url, data, config);
};

export const DELETE = <Params = any, Response = any, D = any>(url: string, params?: Params, config?: AxiosRequestConfig<D>) => {
export const DELETE = <Params = any, Response = any, D = any>(
url: string,
params?: Params,
config?: AxiosRequestConfig<D>,
) => {
return ins.delete<Params, ApiResponse<Response>>(url, { params, ...config });
};

export * from './tools';
export * from './request';
export * from './app';
export * from './chat';
export * from './evaluate';
export * from './flow';
export * from './app';
export * from './knowledge';
export * from './user';
export * from './prompt';
export * from './evaluate';
export * from './request';
export * from './tools';
export * from './user';
Loading
Loading