import { get, post, put, del } from '../../http'

/**
 * @description: 删除QA
 * @param {*} params
 * @return {*}
 */
export const submitRemoveQA = async (id: Record<string, any>) => {
  return await del(`/modelData/${id}`)
}

/**
 * @description: 使用QA
 * @param {*} params
 * @return {*}
 */
export const submitUseQA = async (id: Record<string, any>) => {
  return await post<any>(`/modelData/reuse/${id}`)
}

/**
 * @description: 召回QA
 * @param {*} params
 * @return {*}
 */
export const submitReCallQA = async (id: Record<string, any>) => {
  return await post<any>(`/modelData/recall/${id}`)
}

/**
 * @description: 查询QA详细信息
 * @param {*} params
 * @return {*}
 */
export const getDetailQA = async (id: Record<string, any>) => {
  return await get<any>(`/modelData/${id}`)
}

/**
 * @description: AI生成同义句
 * @param {*} params
 * @return {*}
 */
export const getAiGenerateQA = async (data: Record<string, any>) => {
  return await post<any>('/modelData/generate', { ...data, type: 0 })
}

/**
 * @description: 添加QA
 * @param {*} params
 * @return {*}
 */
export const submitAddQA = async (data: Record<string, any>) => {
  return await post<any>('/modelData', { ...data, type: 0 })
}

/**
 * @description: 更改QA信息
 * @param {*} params
 * @return {*}
 */
export const submitUpdataQA = async (params: Record<string, any>) => {
  return await put('/modelData', { ...params, type: 0 })
}

/**
 * @description: 获取模型下召回的QA
 * @param {*} params
 * @return {*}
 */
export const getModelRecallQAList = async (params: Record<string, any>) => {
  const url = `/modelData/recall/${params.modelId}`
  return await post(url, null, { params: { ...params, type: 0 } })
}

/**
 * @description: 获取模型下的QA
 * @param {*} params
 * @return {*}
 */
export const getModelQAList = async (params: Record<string, any>) => {
  return await get<any>('/modelData/list', {
    params: { ...params, type: 0 },
  })
}

/**
 * @description: 获取模型下的QA
 * @param {*} params
 * @return {*}
 */
export const getTemplateUrl = async () => {
  return await get<any>('/model/getTemplateUrl', {
    params: { type: 0 },
  })
}

/**
 * @description: 获取模型下的QA
 * @param {*} params
 * @return {*}
 */
export const leadOutErrMsg = async (data: Record<string, any>) => {
  return await post(
    '/model/exportErrorList',
    { ...data, type: 0 },
    { responseType: 'blob' },
  )
}

/**
 * @description: 训练模型
 * @param {*} params
 * @return {*}
 */
export const getTrainData = async (id: Record<string, any>) => {
  return await post<any>(`/model/trainData/${id}`)
}

/**
 * @description: 获取模型列表
 * @param {*} params
 * @return {*}
 */
export const getModelList = async (params: Record<string, any>) => {
  return await get<any>('/model/list', {
    params: { ...params, type: 0 },
  })
}

/**
 * @description: 文件导入批量新增型数据
 * @param {*} params
 * @return {*}
 */
export const importModelSave = async (
  id: string,
  data: Record<string, any>,
) => {
  return await post<any>(`/model/importSave/${id}`, data, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })
}

/**
 * @description: 新建模型列表
 * @param {*} params
 * @return {*}
 */
export const createModel = async (data: Record<string, any>) => {
  return await post<any>('/model', data, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })
}
