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

chore: update api #1851

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 41 additions & 2 deletions web/client/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,18 @@ import {
SpaceConfig,
} from '@/types/knowledge';
import { UpdatePromptParams, IPrompt, PromptParams } from '@/types/prompt';
import { IFlow, IFlowNode, IFlowResponse, IFlowUpdateParam, IFlowRefreshParams } from '@/types/flow';
import { IAgent, IApp, IAppData, ITeamModal } from '@/types/app';
import {
IFlow,
IFlowNode,
IFlowResponse,
IFlowUpdateParam,
IFlowRefreshParams,
IFlowExportParams,
IFlowImportParams,
IUploadFileRequestParams,
IUploadFileResponse,
} from '@/types/flow';
import { IAgent, IApp, IAppData } from '@/types/app';

/** App */
export const postScenes = () => {
Expand Down Expand Up @@ -289,6 +299,35 @@ export const refreshFlowNodeById = (data: IFlowRefreshParams) => {
return POST<IFlowRefreshParams, IFlowNode>('/api/v2/serve/awel/nodes/refresh', data);
};

// TODO: wait for interface update
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);
};

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

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

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

/** app */
export const addApp = (data: IApp) => {
return POST<IApp, []>('/api/v1/app/create', data);
Expand Down
27 changes: 27 additions & 0 deletions web/types/flow.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { File } from 'buffer';
import { Node } from 'reactflow';

export type FlowState = 'deployed' | 'developing' | 'initializing' | 'testing' | 'disabled' | 'running' | 'load_failed';
Expand Down Expand Up @@ -165,3 +166,29 @@ export type IFlowData = {
edges: Array<IFlowDataEdge>;
viewport: IFlowDataViewport;
};

export type IFlowExportParams = {
export_type?: 'json' | 'dbgpts';
format?: 'json' | 'file';
file_name?: string;
user_name?: string;
sys_code?: string;
};

export type IFlowImportParams = {
file: File;
save_flow?: boolean;
};

export type IUploadFileRequestParams = {
files: Array<File>;
user_name?: string;
sys_code?: string;
};

export type IUploadFileResponse = {
file_name: string;
file_id: string;
bucket: string;
uri?: string;
};
Loading