import { get, post, put, del } from "@/utils/request";

type RequestPayload = Record<string, unknown>;
type RequestParams = Record<string, unknown>;

// 获取知识库列表
export function queryKnowledgeBasesUsingPost(params: RequestPayload) {
  return post("/api/knowledge-base/list", params);
}

// 创建知识库
export function createKnowledgeBaseUsingPost(data: RequestPayload) {
  return post("/api/knowledge-base/create", data);
}

// 获取知识库详情
export function queryKnowledgeBaseByIdUsingGet(baseId: string) {
  return get(`/api/knowledge-base/${baseId}`);
}

// 更新知识库
export function updateKnowledgeBaseByIdUsingPut(baseId: string, data: RequestPayload) {
  return put(`/api/knowledge-base/${baseId}`, data);
}

// 删除知识库
export function deleteKnowledgeBaseByIdUsingDelete(baseId: string) {
  return del(`/api/knowledge-base/${baseId}`);
}

// 获取知识生成文件列表
export function queryKnowledgeBaseFilesUsingGet(baseId: string, data: RequestParams) {
  return get(`/api/knowledge-base/${baseId}/files`, data);
}

// 全库检索知识库文件
export function queryKnowledgeBaseFilesSearchUsingGet(params: RequestParams) {
  return get("/api/knowledge-base/files/search", params);
}

// 添加文件到知识库
export function addKnowledgeBaseFilesUsingPost(baseId: string, data: RequestPayload) {
  return post(`/api/knowledge-base/${baseId}/files`, data);
}

// 删除知识生成文件
export function deleteKnowledgeBaseFileByIdUsingDelete(baseId: string, data: RequestPayload) {
  return del(`/api/knowledge-base/${baseId}/files`, data);
}

// 检索知识库内容
export function retrieveKnowledgeBaseContent(data: {
  query: string;
  topK?: number;
  threshold?: number;
  knowledgeBaseIds: string[];
}) {
  return post("/api/knowledge-base/retrieve", data);
}
