Skip to content

Commit

Permalink
feat(web): AWEL flow 2.0 frontend codes (#1898)
Browse files Browse the repository at this point in the history
Co-authored-by: Fangyin Cheng <[email protected]>
Co-authored-by: 谨欣 <[email protected]>
Co-authored-by: 严志勇 <[email protected]>
Co-authored-by: yanzhiyong <[email protected]>
  • Loading branch information
5 people authored Aug 28, 2024
1 parent 9502251 commit 131bc7b
Show file tree
Hide file tree
Showing 60 changed files with 2,335 additions and 2,244 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ thirdparty
#web
# dependencies
/web/node_modules
/web/yarn.lock

.idea
# next.js
Expand All @@ -184,7 +185,4 @@ thirdparty
/examples/**/*.gv
/examples/**/*.gv.pdf
/i18n/locales/**/**/*_ai_translated.po
/i18n/locales/**/**/*~

/web_new/node_modules
/web_new/.next
/i18n/locales/**/**/*~
11 changes: 11 additions & 0 deletions dbgpt/_private/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ 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
2 changes: 1 addition & 1 deletion web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ yarn install

### Usage
```sh
cp .env.example .env
cp .env.template .env
```
edit the `API_BASE_URL` to the real address

Expand Down
33 changes: 21 additions & 12 deletions web/client/api/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { AppListResponse, CreateAppParams, IAgent, IApp, NativeAppScenesResponse, StrategyResponse, TeamMode } from '@/types/app';
import { IFlowResponse } from '@/types/flow';
import {
AppListResponse,
CreateAppParams,
IAgent,
IApp,
NativeAppScenesResponse,
StrategyResponse,
TeamMode,
} from '@/types/app';

import { GET, POST } from '../index';

Expand Down Expand Up @@ -45,7 +52,9 @@ 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 @@ -61,13 +70,7 @@ export const getNativeAppScenes = () => {
export const getAppStrategyValues = (type: string) => {
return GET<string, string[]>(`/api/v1/llm-strategy/value/list?type=${type}`);
};
/**
* 创建awel_layout应用
* 获取工作流
*/
export const getFlows = ({ page, page_size }: { page: number; page_size: number }) => {
return GET<{ page: number; page_size: number }, IFlowResponse>(`/api/v1/serve/awel/flows?page=${page}&page_size=${page_size}`);
};

/**
* 查询应用权限
*/
Expand All @@ -77,6 +80,12 @@ 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
);
};
89 changes: 81 additions & 8 deletions web/client/api/flow/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,82 @@
import { IFlow, UpdateFLowAdminsParams } from '@/types/flow';
import { POST } from '../index';

/**
* 更新管理员
*/
export const updateFlowAdmins = (data: UpdateFLowAdminsParams) => {
return POST<UpdateFLowAdminsParams, IFlow>(`/api/v1/serve/awel/flow/admins`, data);
import {
IFlow,
IFlowNode,
IFlowResponse,
IFlowUpdateParam,
IFlowRefreshParams,
IFlowExportParams,
IFlowImportParams,
IUploadFileRequestParams,
IUploadFileResponse,
} from '@/types/flow';
import { DELETE, GET, POST, PUT } from '../index';

/** AWEL Flow */
export const addFlow = (data: IFlowUpdateParam) => {
return POST<IFlowUpdateParam, IFlow>('/api/v2/serve/awel/flows', data);
};

export const getFlows = (page?: number, page_size?: number) => {
return GET<any, IFlowResponse>('/api/v2/serve/awel/flows', {
page,
page_size,
});
};

export const getFlowById = (id: string) => {
return GET<null, IFlow>(`/api/v2/serve/awel/flows/${id}`);
};

export const updateFlowById = (id: string, data: IFlowUpdateParam) => {
return PUT<IFlowUpdateParam, IFlow>(`/api/v2/serve/awel/flows/${id}`, data);
};

export const deleteFlowById = (id: string) => {
return DELETE<null, null>(`/api/v2/serve/awel/flows/${id}`);
};

export const getFlowNodes = () => {
return GET<null, Array<IFlowNode>>(`/api/v2/serve/awel/nodes`);
};

export const refreshFlowNodeById = (data: IFlowRefreshParams) => {
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
);
};

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
);
};

export const downloadFile = (fileId: string) => {
return GET<null, any>(`/api/v2/serve/file/files/dbgpt/${fileId}`);
};

// TODO:wait for interface update
export const getFlowTemplateList = () => {
return GET<null, Array<any>>('/api/v2/serve/awel/flow/templates');
};

export const getFlowTemplateById = (id: string) => {
return GET<null, any>(`/api/v2/serve/awel/flow/templates/${id}`);
};
Loading

0 comments on commit 131bc7b

Please sign in to comment.