Skip to content

Commit

Permalink
chore: merge frontend code of branch dev-0.6 (#1895)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreammy23 authored Aug 27, 2024
2 parents 807b13e + a5620d9 commit b3dc93d
Show file tree
Hide file tree
Showing 43 changed files with 9,297 additions and 2,537 deletions.
1 change: 0 additions & 1 deletion web/app/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Domain } from '@mui/icons-material';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import en from '@/locales/en';
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}`);
};
78 changes: 2 additions & 76 deletions web/client/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
PostAgentPluginResponse,
PostAgentQueryParams,
} from '@/types/agent';
import { GetAppInfoParams, IApp } from '@/types/app';
import {
ChatHistoryResponse,
DialogueListResponse,
Expand Down Expand Up @@ -46,26 +47,14 @@ import {
ISyncBatchResponse,
SpaceConfig,
} from '@/types/knowledge';
import {
IFlow,
IFlowNode,
IFlowResponse,
IFlowUpdateParam,
IFlowRefreshParams,
IFlowExportParams,
IFlowImportParams,
IUploadFileRequestParams,
IUploadFileResponse,
} from '@/types/flow';
import { GetAppInfoParams, IApp, IAgent, IAppData } from '@/types/app';
import {
BaseModelParams,
IModelData,
StartModelParams,
SupportModel,
} from '@/types/model';
import { AxiosRequestConfig } from 'axios';
import { DELETE, GET, POST, PUT } from '.';
import { GET, POST } from '.';

/** App */
export const postScenes = () => {
Expand Down Expand Up @@ -380,69 +369,6 @@ export const postChatFeedBackForm = ({

/** prompt */

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

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

/** app */

export const collectApp = (data: Record<string, string>) => {
Expand Down
2 changes: 1 addition & 1 deletion web/components/chat/completion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const Completion = ({ messages, onSubmit }: Props) => {
question={showMessages?.filter((e) => e?.role === 'human' && e?.order === content.order)[0]?.context}
knowledge_space={spaceNameOriginal || dbParam || ''}
/>
<Tooltip title={t('copy')}>
<Tooltip title={t('Copy_Btn')}>
<Button
onClick={() => onCopyContext(content?.context)}
slots={{ root: IconButton }}
Expand Down
2 changes: 1 addition & 1 deletion web/components/database/form-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button, Form, Input, InputNumber, Modal, Select, Spin, Tooltip, message
import { useEffect, useMemo, useState } from 'react';
import { addOmcDB, apiInterceptors, getSupportDBList, postDbAdd, postDbEdit, postDbTestConnect } from '@/client/api';
import { DBOption, DBType, DbListResponse, PostDbParams } from '@/types/db';
import { isFileDb } from '@/pages/database';
import { isFileDb } from '@/pages/construct/database';
import { useTranslation } from 'react-i18next';
import { useDebounceFn } from 'ahooks';

Expand Down
Loading

0 comments on commit b3dc93d

Please sign in to comment.