import request from '/@/utils/request';

// 数据集查询参数
export interface knowledgeQueryParams {
	keyword?: string;
	pageNum: number;
	pageSize: number;
}

// 创建知识库参数
export interface CreateknowledgeParams {
	name: string; // 必传
	description?: string; // 可选
}

// 更新知识库参数
export interface UpdateknowledgeParams {
	id: string; // 必传
	name?: string; // 可选
	description?: string; // 可选
}

// 数据集信息
export interface knowledgeInfo {
	id?: string;
	name: string;
	description?: string;
	fileCount?: number;
	totalSize?: number;
	createdAt?: string;
	updatedAt?: string;
}

// 获取知识库列表
export function listknowledges(params: knowledgeQueryParams) {
	return request({
		url: '/rag/dataset/list',
		method: 'get',
		params,
	});
}

// 创建知识库
export function createknowledge(data: CreateknowledgeParams) {
	return request({
		url: '/rag/dataset/create',
		method: 'post',
		data,
	});
}

// 更新知识库
export function updateknowledge(data: UpdateknowledgeParams) {
	return request({
		url: '/rag/dataset/update',
		method: 'put',
		data,
	});
}

// 删除知识库
export function deleteknowledge(id: string) {
	return request({
		url: '/rag/dataset/delete',
		method: 'delete',
		params: { id },
	});
}

// 获取知识库详情
export function getknowledge(id: string) {
	return request({
		url: '/rag/dataset/detail',
		method: 'get',
		params: { id },
	});
}

// 更新知识库状态
export function updateknowledgeStatus(data: { id: string; status: string }) {
	return request({
		url: '/rag/dataset/updateStatus',
		method: 'put',
		data,
	});
}
