// @ts-ignore
/* eslint-disable */
import request from '@repo/api-client'

/** Excel导入 POST /api/ai/faq/batch_import */
export async function postFaqBatchImport(
  body: {
    knowledge_base_id: string
    standard_question: string
    similar_questions: string[]
    negative_questions: string[]
    answers: string[]
    is_enabled: boolean
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/faq/batch_import',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 创建单个FAQ条目 POST /api/ai/faq/create */
export async function postFaqCreate(
  body: {
    knowledge_base_id: string
    standard_question: string
    similar_questions: string[]
    negative_questions: string[]
    answers: string[]
    is_enabled: boolean
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/faq/create',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 删除单个FAQ条目 POST /api/ai/faq/delete */
export async function postFaqOpenApiDelete(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<Record<string, any>>('/api/ai/faq/delete', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 详情 POST /api/ai/faq/info */
export async function postFaqInfo(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      answer_strategy: string
      answers: string[]
      chunk_id: string
      chunk_type: string
      creationTime: string
      creatorUserId: string
      id: string
      index_mode: string
      is_enabled: boolean
      is_recommended: boolean
      knowledge_base_id: string
      knowledge_id: string
      negative_questions: string[]
      similar_questions: string[]
      standard_question: string
      tag_id: string
    }
    isAuthorized: boolean
  }>('/api/ai/faq/info', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 分页列表 POST /api/ai/faq/pageList */
export async function postFaqPageList(
  body: {
    knowledge_base_id: string
    pageIndex: number
    pageSize: number
    keyword: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      currentPage: number
      hasNextPage: boolean
      hasPreviousPage: boolean
      model: {
        answer_strategy?: string
        answers?: string[]
        chunk_id?: string
        chunk_type?: string
        creationTime?: string
        creatorUserId?: string
        id?: string
        index_mode?: string
        is_enabled?: boolean
        is_recommended?: boolean
        knowledge_base_id?: string
        knowledge_id?: string
        negative_questions?: string[]
        similar_questions?: string[]
        standard_question?: string
        tag_id?: string
      }[]
      pageSize: number
      totalCount: number
      totalPages: number
    }
    isAuthorized: boolean
  }>('/api/ai/faq/pageList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 更新单个FAQ条目 POST /api/ai/faq/update */
export async function postFaqUpdate(
  body: {
    id: string
    standard_question: string
    similar_questions: string[]
    negative_questions: string[]
    answers: string[]
    is_enabled: boolean
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/faq/update',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 创建知识库 POST /api/ai/knowledge-base/create */
export async function postKnowledgeBaseCreate(
  body: {
    name: string
    description: string
    type: string
    wiki_config: {
      extraction_granularity: string
      max_pages_per_ingest: number
      synthesis_model_id: string
    }
    indexing_strategy: {
      graph_enabled: boolean
      keyword_enabled: boolean
      vector_enabled: boolean
      wiki_enabled: boolean
    }
    chunking_config: {
      chunk_size: number
      chunk_overlap: number
      separators: string[]
      parser_engine_rules: { engine: string; file_types: string[] }[]
      enable_parent_child: boolean
      parent_chunk_size: number
      child_chunk_size: number
    }
    embedding_model_id: string
    summary_model_id: string
    vlm_config: { model_id: string; enabled: boolean }
    asr_config: { model_id: string; language: string; enabled: boolean }
    storage_provider_config: { provider: string }
    storage_config: { provider: string }
    question_generation_config: { enabled: boolean; question_count: number }
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/knowledge-base/create',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 删除知识库 POST /api/ai/knowledge-base/delete */
export async function postKnowledgeBaseOpenApiDelete(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/knowledge-base/delete',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 混合搜索 (FAQ) POST /api/ai/knowledge-base/faq_hybrid_search */
export async function postKnowledgeBaseFaqHybridSearch(
  body: {
    knowledge_base_id: string
    query_text: string
    vector_threshold: number
    match_count: number
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      answer_strategy?: string
      answers?: string[]
      chunk_id?: string
      chunk_type?: string
      creationTime?: string
      creatorUserId?: string
      id?: string
      index_mode?: string
      is_enabled?: boolean
      is_recommended?: boolean
      knowledge_base_id?: string
      knowledge_id?: string
      negative_questions?: string[]
      score?: number
      similar_questions?: string[]
      standard_question?: string
      tag_id?: string
    }[]
    isAuthorized: boolean
  }>('/api/ai/knowledge-base/faq_hybrid_search', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 混合搜索 POST /api/ai/knowledge-base/hybrid_search */
export async function postKnowledgeBaseHybridSearch(
  body: {
    id: string
    query_text: string
    vector_threshold: number
    keyword_threshold: number
    match_count: number
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; result: string[]; isAuthorized: boolean }>(
    '/api/ai/knowledge-base/hybrid_search',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 根据ids，混合搜索 POST /api/ai/knowledge-base/hybrid_search_ids */
export async function postKnowledgeBaseHybridSearchIds(
  body: {
    query: string
    knowledge_base_ids: string[]
    knowledge_ids: string[]
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      chunk_index?: string
      chunk_metadata: { generated_questions: { id: string; question: string }[] }
      chunk_type?: string
      content?: string
      end_at?: number
      id?: string
      image_info?: string
      knowledge_base_id?: string
      knowledge_channel?: string
      knowledge_filename?: string
      knowledge_id?: string
      knowledge_source?: string
      knowledge_title?: string
      match_type?: number
      metadata: { base_score: string }
      parent_chunk_id?: string
      score?: number
      seq?: number
      start_at?: number
      sub_chunk_id?: string[]
    }[]
    isAuthorized: boolean
  }>('/api/ai/knowledge-base/hybrid_search_ids', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 知识库详情 POST /api/ai/knowledge-base/info */
export async function postKnowledgeBaseInfo(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      asr_config: { enabled: boolean; language: string; model_id: string }
      chunking_config: {
        child_chunk_size: number
        chunk_overlap: number
        chunk_size: number
        enable_parent_child: boolean
        parent_chunk_size: number
        parser_engine_rules: { engine: string; file_types: string[] }[]
        separators: string[]
      }
      creationTime: string
      creatorUserId: string
      description: string
      embedding_model_id: string
      faq_config: { index_mode: string; question_index_mode: string }
      id: string
      indexing_strategy: {
        graph_enabled: boolean
        keyword_enabled: boolean
        vector_enabled: boolean
        wiki_enabled: boolean
      }
      isDeleted: boolean
      is_pinned: boolean
      is_temporary: boolean
      name: string
      question_generation_config: { enabled: boolean; question_count: number }
      storage_config: { provider: string }
      storage_provider_config: { provider: string }
      summary_model_id: string
      type: string
      updateTime: string
      vlm_config: { enabled: boolean; model_id: string }
      wiki_config: {
        extraction_granularity: string
        max_pages_per_ingest: number
        synthesis_model_id: string
      }
    }
    isAuthorized: boolean
  }>('/api/ai/knowledge-base/info', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取知识库分页列表 POST /api/ai/knowledge-base/pageList */
export async function postKnowledgeBasePageList(
  body: {
    keyword: string
    type: string
    pageIndex: number
    pageSize: number
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      currentPage: number
      hasNextPage: boolean
      hasPreviousPage: boolean
      model: {
        asr_config: { enabled: boolean; language: string; model_id: string }
        chunking_config: {
          child_chunk_size: number
          chunk_overlap: number
          chunk_size: number
          enable_parent_child: boolean
          parent_chunk_size: number
          parser_engine_rules: { engine: string; file_types: string[] }[]
          separators: string[]
        }
        creationTime: string
        creatorUserId: string
        description: string
        embedding_model_id: string
        faq_config: { index_mode: string; question_index_mode: string }
        id: string
        indexing_strategy: {
          graph_enabled: boolean
          keyword_enabled: boolean
          vector_enabled: boolean
          wiki_enabled: boolean
        }
        isDeleted: boolean
        is_pinned: boolean
        is_temporary: boolean
        name: string
        question_generation_config: { enabled: boolean; question_count: number }
        storage_config: { provider: string }
        storage_provider_config: { provider: string }
        summary_model_id: string
        type: string
        updateTime: string
        vlm_config: { enabled: boolean; model_id: string }
        wiki_config: {
          extraction_granularity: string
          max_pages_per_ingest: number
          synthesis_model_id: string
        }
        extract_config: { enabled: boolean }
      }[]
      pageSize: number
      totalCount: number
      totalPages: number
    }
    isAuthorized: boolean
  }>('/api/ai/knowledge-base/pageList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 更新知识库 POST /api/ai/knowledge-base/update */
export async function postKnowledgeBaseUpdate(
  body: {
    id: string
    name: string
    description: string
    wiki_config: {
      extraction_granularity: string
      max_pages_per_ingest: number
      synthesis_model_id: string
    }
    indexing_strategy: {
      graph_enabled: boolean
      keyword_enabled: boolean
      vector_enabled: boolean
      wiki_enabled: boolean
    }
    chunking_config: {
      chunk_size: number
      chunk_overlap: number
      separators: string[]
      parser_engine_rules: { engine: string; file_types: string[] }[]
      enable_parent_child: boolean
      parent_chunk_size: number
      child_chunk_size: number
    }
    embedding_model_id: string
    summary_model_id: string
    vlm_config: { model_id: string; enabled: boolean }
    asr_config: { model_id: string; language: string; enabled: boolean }
    storage_provider_config: { provider: string }
    storage_config: { provider: string }
    question_generation_config: { enabled: boolean; question_count: number }
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/knowledge-base/update',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 创建来自文件的知识 POST /api/ai/knowledge/createWithFile */
export async function postKnowledgeCreateWithFile(
  body: {
    knowledge_base_id: string
    fileId: string
    metadata: Record<string, any>
    enable_multi_model: boolean
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/knowledge/createWithFile',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 创建自定义知识 POST /api/ai/knowledge/createWithManual */
export async function postKnowledgeCreateWithManual(
  body: {
    knowledge_base_id: string
    title: string
    content: string
    publish: boolean
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/knowledge/createWithManual',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 删除知识 POST /api/ai/knowledge/delete */
export async function postKnowledgeOpenApiDelete(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/knowledge/delete',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 获取详情 POST /api/ai/knowledge/info */
export async function postKnowledgeInfo(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      channel: string
      creationTime: string
      description: string
      embedding_model_id: string
      enable_status: string
      error_message: string
      file_hash: string
      file_name: string
      file_path: string
      file_size: number
      file_type: string
      id: string
      isDeleted: boolean
      knowledge_base_id: string
      metadata: {
        updated_at: string
        format: string
        version: number
        content: string
        status: string
      }
      parse_status: string
      source: string
      storage_size: number
      summary_status: string
      tag_id: string
      title: string
      type: string
      updateTime: string
      userId: string
    }
    isAuthorized: boolean
  }>('/api/ai/knowledge/info', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 获取知识分页列表 POST /api/ai/knowledge/pageList */
export async function postKnowledgePageList(
  body: {
    knowledge_base_id: string
    title: string
    file_type: string
    pageIndex: number
    pageSize: number
  },
  options?: { [key: string]: any }
) {
  return request<{
    isSuccess: boolean
    code: number
    result: {
      currentPage: number
      hasNextPage: boolean
      hasPreviousPage: boolean
      model: {
        channel?: string
        creationTime?: string
        description?: string
        embedding_model_id?: string
        enable_status?: string
        error_message?: string
        file_hash?: string
        file_name?: string
        file_path?: string
        file_size?: number
        file_type?: string
        id?: string
        isDeleted?: boolean
        knowledge_base_id?: string
        metadata?: Record<string, any>
        parse_status?: string
        source?: string
        storage_size?: number
        summary_status?: string
        tag_id?: string
        title?: string
        type?: string
        updateTime?: string
      }[]
      pageSize: number
      totalCount: number
      totalPages: number
    }
    isAuthorized: boolean
  }>('/api/ai/knowledge/pageList', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 重新解析知识 POST /api/ai/knowledge/reparse */
export async function postKnowledgeReparse(
  body: {
    id: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/knowledge/reparse',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}

/** 更新知识 POST /api/ai/knowledge/update */
export async function postKnowledgeUpdate(
  body: {
    id: string
    title: string
    description: string
  },
  options?: { [key: string]: any }
) {
  return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
    '/api/ai/knowledge/update',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {})
    }
  )
}
