import request from '@/utils/request'

export function listKnowledgeBases() {
  return request({
    url: '/admin/kb/knowledge-bases',
    method: 'get'
  })
}

export function listDocuments(params: any) {
  return request({
    url: '/admin/kb/documents',
    method: 'get',
    params
  })
}

export function uploadDocument(data: FormData) {
  return request({
    url: '/admin/kb/documents',
    method: 'post',
    data
  })
}

export function getIndexJob(jobId: string) {
  return request({
    url: `/admin/kb/index/jobs/${jobId}`,
    method: 'get'
  })
}

export function deleteDocument(docId: string) {
  return request({
    url: `/admin/kb/documents/${docId}`,
    method: 'delete'
  })
}

export function batchUploadDocuments(data: FormData) {
  return request({
    url: '/admin/kb/documents/batch-upload',
    method: 'post',
    data
  })
}

export function jsonBatchUpload(kbId: string, data: FormData) {
  return request({
    url: `/admin/kb/${kbId}/documents/json-batch`,
    method: 'post',
    data
  })
}
