-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize the structure and naming of projects (#335)
- Loading branch information
Showing
97 changed files
with
882 additions
and
821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { KbTypeEnum } from '@/constants/dataset'; | ||
import type { RequestPaging } from '@/types'; | ||
import { TrainingModeEnum } from '@/constants/plugin'; | ||
|
||
export type PushDataProps = { | ||
kbId: string; | ||
data: DatasetItemType[]; | ||
mode: `${TrainingModeEnum}`; | ||
prompt?: string; | ||
}; | ||
export type PushDataResponse = { | ||
insertLen: number; | ||
}; | ||
|
||
export type UpdateDataPrams = { | ||
dataId: string; | ||
kbId: string; | ||
a?: string; | ||
q?: string; | ||
}; | ||
|
||
export type GetDatasetDataListProps = RequestPaging & { | ||
kbId: string; | ||
searchText: string; | ||
fileId: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { GET, POST, PUT, DELETE } from '@/api/request'; | ||
import type { DatasetDataItemType } from '@/types/core/dataset/data'; | ||
import type { | ||
PushDataProps, | ||
PushDataResponse, | ||
UpdateDataPrams, | ||
GetDatasetDataListProps | ||
} from './data.d'; | ||
import { QuoteItemType } from '@/types/chat'; | ||
import { getToken } from '@/utils/user'; | ||
import download from 'downloadjs'; | ||
|
||
/* kb data */ | ||
export const getDatasetDataList = (data: GetDatasetDataListProps) => | ||
POST(`/core/dataset/data/getDataList`, data); | ||
|
||
/** | ||
* export and download data | ||
*/ | ||
export const exportDatasetData = (data: { kbId: string }) => | ||
fetch(`/api/core/dataset/data/exportAll?kbId=${data.kbId}`, { | ||
method: 'GET', | ||
headers: { | ||
token: getToken() | ||
} | ||
}) | ||
.then(async (res) => { | ||
if (!res.ok) { | ||
const data = await res.json(); | ||
throw new Error(data?.message || 'Export failed'); | ||
} | ||
return res.blob(); | ||
}) | ||
.then((blob) => download(blob, 'dataset.csv', 'text/csv')); | ||
|
||
/** | ||
* 获取模型正在拆分数据的数量 | ||
*/ | ||
export const getTrainingData = (data: { kbId: string; init: boolean }) => | ||
POST<{ | ||
qaListLen: number; | ||
vectorListLen: number; | ||
}>(`/core/dataset/data/getTrainingData`, data); | ||
|
||
/* get length of system training queue */ | ||
export const getTrainingQueueLen = () => GET<number>(`/core/dataset/data/getQueueLen`); | ||
|
||
export const getDatasetDataItemById = (dataId: string) => | ||
GET<QuoteItemType>(`/core/dataset/data/getDataById`, { dataId }); | ||
|
||
/** | ||
* push data to training queue | ||
*/ | ||
export const postChunks2Dataset = (data: PushDataProps) => | ||
POST<PushDataResponse>(`/core/dataset/data/pushData`, data); | ||
|
||
/** | ||
* insert one data to dataset (immediately insert) | ||
*/ | ||
export const postData2Dataset = (data: { kbId: string; data: DatasetDataItemType }) => | ||
POST<string>(`/core/dataset/data/insertData`, data); | ||
|
||
/** | ||
* 更新一条数据 | ||
*/ | ||
export const putDatasetDataById = (data: UpdateDataPrams) => | ||
PUT('/core/dataset/data/updateData', data); | ||
/** | ||
* 删除一条知识库数据 | ||
*/ | ||
export const delOneDatasetDataById = (dataId: string) => | ||
DELETE(`/core/dataset/data/delDataById?dataId=${dataId}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { KbTypeEnum } from '@/constants/dataset'; | ||
import type { RequestPaging } from '@/types'; | ||
import { TrainingModeEnum } from '@/constants/plugin'; | ||
import type { SearchTestItemType } from '@/types/core/dataset'; | ||
|
||
export type DatasetUpdateParams = { | ||
id: string; | ||
parentId?: string; | ||
tags?: string; | ||
name?: string; | ||
avatar?: string; | ||
}; | ||
export type CreateDatasetParams = { | ||
parentId?: string; | ||
name: string; | ||
tags: string[]; | ||
avatar: string; | ||
vectorModel?: string; | ||
type: `${KbTypeEnum}`; | ||
}; | ||
|
||
export type DatasetUpdateParams = { | ||
id: string; | ||
parentId?: string; | ||
tags?: string; | ||
name?: string; | ||
avatar?: string; | ||
}; | ||
|
||
export type SearchTestProps = { | ||
kbId: string; | ||
text: string; | ||
}; | ||
export type SearchTestResponseType = SearchTestItemType['results']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { GET, POST, PUT, DELETE } from '@/api/request'; | ||
import type { DatasetItemType, DatasetsItemType, DatasetPathItemType } from '@/types/core/dataset'; | ||
import type { | ||
DatasetUpdateParams, | ||
CreateDatasetParams, | ||
SearchTestProps, | ||
SearchTestResponseType | ||
} from './index.d'; | ||
import { KbTypeEnum } from '@/constants/dataset'; | ||
|
||
export const getDatasets = (data: { parentId?: string; type?: `${KbTypeEnum}` }) => | ||
GET<DatasetsItemType[]>(`/core/dataset/list`, data); | ||
|
||
/** | ||
* get type=dataset list | ||
*/ | ||
export const getAllDataset = () => GET<DatasetsItemType[]>(`/core/dataset/allDataset`); | ||
|
||
export const getDatasetPaths = (parentId?: string) => | ||
GET<DatasetPathItemType[]>('/core/dataset/paths', { parentId }); | ||
|
||
export const getDatasetById = (id: string) => GET<DatasetItemType>(`/core/dataset/detail?id=${id}`); | ||
|
||
export const postCreateDataset = (data: CreateDatasetParams) => | ||
POST<string>(`/core/dataset/create`, data); | ||
|
||
export const putDatasetById = (data: DatasetUpdateParams) => PUT(`/core/dataset/update`, data); | ||
|
||
export const delDatasetById = (id: string) => DELETE(`/core/dataset/delete?id=${id}`); | ||
|
||
export const postSearchText = (data: SearchTestProps) => | ||
POST<SearchTestResponseType>(`/core/dataset/searchTest`, data); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.