import exp from 'constants';
import api from './api';
import audit from '@/pages/system/audit';
import { data } from 'react-router-dom';

// Api参数类型
export type LoginApiParams = {
    username: string,
    password: string,
    uuid: string,
    code: string | number,
};

// Api参数类型
export type JkLoginApiParams = {
    code: string,
    redirectUrl: string,
};

export type FetchAppListApiParams = {
    pageNum: number,
    pageSize: number,
    userId: string,
    typeId: any,
    projectId?: any,
    keyword?: string,
    isCollect?: string | null,
};
export type FetchAppListMyApiParams = {
    pageNum: number,
    pageSize: number,
    name: string,
};

export type FetchKnowledgeLibListApiParams = {
    pageNum: number,
    pageSize: number,
};

export type CreateOrModifyKnowledgeLibApiParams = {
    name: string,
    embeddingId: string,
    description: string,
};

export type FetchAppIndexParams = {
    pageNum: number,
    pageSize: number,
    userId: string,
    typeId: any,
    projectId: any,
    keyword: string,
};

export type CreateOrModifyApplicationApiParams = {
    id: string,
    name: string,  //应用名称
    desc: string,  //应用描述
    prompt: string, //应用提示语
    topP: string, //topP
    topK?: string, //topK
    temperature: string, //温度
    knowledge_ids: string[],
    slice_count: number,
    model: string,
    iconColor: string,
    iconType: string,
    questionList: string[],
    // knowledge_info: {
    //     model: string,
    //     knowledge_ids: string[],
    //     slice_config_type: string,
    //     recall_method: string,
    //     slice_count: number,
    //     rerank_status: number,
    //     rerank_model_name: string,
    //     show_recall_result: boolean,
    //     recall_slice_splicing_method: string,
    // },
    //questionList: string[]
};

export type FetchDocumentLibListApiParams = {
    knowledge_id: string,
    page: number,
    size: number,
}

export type ModifyDocumentApiParams = {
    id: string,
    name: string,
    url: string,
    length: number,
    sentence_size: number,
    knowledge_type: number,
    custom_separator: string[],
    embedding_stat: number,
    word_num: number,
    parse_image: number
};

export type FetchChatHistoryListApiParams = Partial<{
    appId: string,
    pageNum: number,
    pageSize: number,
}>;

export type ModifyDocumentSettingApiParams = {
    knowledgeId: string,
    documentId: string,
    setSlice: string,
    setAnalyze: string,
    setTabel: string,
};

export type FetchSliceListApiParams = {
    knowledge_id: string,
    document_id: string,
    text: string,
    pageNum: number,
    pageSize: number,
};

export type addAndModifySliceApiParams = {
    knowledgeId: string,
    sliceId: string,
    sliceText: string,
    documentId: string,
};

export type FetchAuditConfigLibListApiParams = {
    approver: string,
    pageNum: number,
    pageSize: number,
};

// Api函数类型
export type CheckTokenApi = (token: string) => Promise<any>;
export type JkLoginApi = (data: JkLoginApiParams) => Promise<any>;
export type LoginApi = (data: LoginApiParams) => Promise<any>;
export type LogoutApi = () => Promise<any>;
export type FetchAppListApi = (data: FetchAppListApiParams) => Promise<any>;
export type FetchKnowledgeLibListApi = (data: FetchKnowledgeLibListApiParams) => Promise<any>;
export type FetchEmbeddingListApi = () => Promise<any>;
export type CreateKnowledgeLibApi = (data: CreateOrModifyKnowledgeLibApiParams) => Promise<any>;
export type ModifyKnowledgeLibApi = (knowledgeId: string, data: CreateOrModifyKnowledgeLibApiParams) => Promise<any>;
export type DeleteKnowledgeLibApi = (knowledgeId: string) => Promise<any>;
export type FetchKnowledgeLibDetailApi = (knowledgeId: string) => Promise<any>;
export type FetchAppIndexApi = (data: FetchAppIndexParams) => Promise<any>;
export type FetchApplicationDetailApi = (appId: string) => Promise<any>;
export type FetchModelListApi = () => Promise<any>;
export type FetchKnowledgeApiListApi = () => Promise<any>;
export type ModifyApplicationLibApi = (appId: string, data: CreateOrModifyApplicationApiParams) => Promise<any>;
export type DeleteApplicationLibApi = (appId: string) => Promise<any>;
export type CreateApplicationLibApi = (data: CreateOrModifyApplicationApiParams) => Promise<any>;
export type uploadFileLibApi = (konwledgeId: string,data?:any) => Promise<any>;
export type FetchDocumentLibListApi = (data: FetchDocumentLibListApiParams) => Promise<any>;
export type FetchDocumentLibApi = (id: string) => Promise<any>;
export type ModifyDocumentLibApi = (id: string, data: ModifyDocumentApiParams) => Promise<any>;
export type DeleteDocumentLibApi = (id: string) => Promise<any>;
export type FetchApplicationListApi = () => Promise<any>;
export type FetchChatHistoryListApi = (data: FetchChatHistoryListApiParams) => Promise<any>;
export type ExportChatHistoryApi = (id: string) => Promise<any>;
export type FetchTakaiAppListApi = (data: FetchAppListApiParams) => Promise<any>;
export type FetchTakaiMyAppListApi = (data: FetchAppListMyApiParams) => Promise<any>;
export type FetchTakaiApplicationDetailApi = (appId: string) => Promise<any>;
export type CreateTakaiApplicationLibApi = (data: CreateOrModifyApplicationApiParams) => Promise<any>;
export type ModifyTakaiApplicationLibApi = (appId: string, data: CreateOrModifyApplicationApiParams) => Promise<any>;
export type DeleteTakaiApplicationLibApi = (appId: string) => Promise<any>;
export type FetchTakaiAppIndexApi = (data: FetchAppIndexParams) => Promise<any>;
export type FetchTakaiKnowledgeApiListApi = () => Promise<any>;
export type FetchTakaiKnowledgeLibListApi = (data: FetchKnowledgeLibListApiParams) => Promise<any>;
export type FetchTakaiKnowledgeLibDetailApi = (knowledgeId: string) => Promise<any>;
export type ModifyTakaiKnowledgeLibApi = (knowledgeId: string, data: CreateOrModifyKnowledgeLibApiParams) => Promise<any>;
export type CreateTakaiKnowledgeLibApi = (data: CreateOrModifyKnowledgeLibApiParams) => Promise<any>;
export type DeleteTakaiKnowledgeLibApi = (knowledgeId: string) => Promise<any>;
export type FetchTakaiDocumentLibListApi = (data: FetchDocumentLibListApiParams) => Promise<any>;
export type FetchTakaiDocumentLibApi = (id: string) => Promise<any>;
export type ModifyTakaiDocumentLibApi = (id: string, data: ModifyDocumentApiParams) => Promise<any>;
export type DeleteTakaiDocumentLibApi = (id: string) => Promise<any>;
export type FetchTakaiDocumentSettingLibApi = (id: string) => Promise<any>;
export type ModifyTakaiDocumentSettingLibApi = (id: string, data: ModifyDocumentSettingApiParams) => Promise<any>;
export type FetchTakaiSliceListApi = (data: FetchSliceListApiParams) => Promise<any>;
export type deleteTakaiSliceLibApi = (sliceId: string, knowledgeId: string, documentId: string) => Promise<any>;
export type FetchTakaiSliceDetailLibApi = (sliceId: string, knowledgeId: string) => Promise<any>;
export type modifyTakaiSliceInfoLibApi = (data: addAndModifySliceApiParams) => Promise<any>;
export type FetchTakaiChatHistoryListApi = (data: FetchChatHistoryListApiParams) => Promise<any>;
export type ExportTakaiChatHistoryApi = (id: string) => Promise<any>;
export type FetchTakaiApplicationListApi = (userId: string) => Promise<any>;
export type addTakaiSliceLibApi = (data: addAndModifySliceApiParams) => Promise<any>;
export type FetchTakaiAppTypeListApi = (dictType: string) => Promise<any>;
export type FetchUserInfoApi = (userId?: string) => Promise<any>;
export type FetchAuditInfoLibDetailApi = (documentId: string) => Promise<any>;
export type FetchTakaiAuditConfigLibListApi = (data: FetchAuditConfigLibListApiParams) => Promise<any>;
export type ModifyTakaiAuditDocumentLibApi = (id: string, data: ModifyDocumentApiParams) => Promise<any>;
export type AuditTakaiApplicationApi = (appId: string, userId: string) => Promise<any>;
export type FetchTakaiProjectApi = () => Promise<any>;
export type FetchUserListApi = (data: any) => Promise<any>;
export type ExportKnowledgeSliceExport = (knowledgeId: any) => Promise<any>;
export type exportDocumentSliceExport = (lis:String[]) => Promise<any>;
export type exportDocumentExport = (lis:String[]) => Promise<any>;
export type setCollectApi = (appId:string) => Promise<any>;


// token联登校验
const checkTokenApi: CheckTokenApi = async (token) => {
    return api.get(`/auth/checkToken/${token}`);
};

// 建科登录
const jkloginApi: JkLoginApi = async (data) => {
    return api.post('/jk_code_login', data);
};

// 登录 prod-api/admin/login
const loginApi: LoginApi = async (data) => {
    // return api.post('-captchaImage/dev-api/admin/login', data);
    return api.post('/auth/login', data,{
        headers:{
            isEncrypt:true
        }
    });
};
// 验证码 prod-api/captchaImage
const captchaImage = async () => {
    const url = '/auth/code';
    return api.get(url, {});
};

// 登出
const logoutApi: LogoutApi = async () => {
    return api.post('/auth/logout');
};

// 获取应用列表
const fetchAppListApi: FetchAppListApi = async (data) => {
    return api.post('/bigmodel/api/getApplicationList', data);
};

// 获取知识库列表
const fetchKnowledgeLibListApi: FetchKnowledgeLibListApi = async (data) => {
    return api.post('bigmodel/api/knowledgeList', data);
};

// 获取向量化模型列表
const fetchEmbeddingListApi: FetchEmbeddingListApi = async () => {
    return api.get('bigmodel/api/embedding');
};

// 创建知识库
const createKnowledgeLibApi: CreateKnowledgeLibApi = async (data) => {
    return api.post('bigmodel/api/createKnowledge', data);
};

// 修改知识库
const modifyKnowledgeLibApi: ModifyKnowledgeLibApi = async (knowledgeId, data) => {
    return api.put(`bigmodel/api/updateKnowledge/${knowledgeId}`, data);
};

// 删除知识库
const deleteKnowledgeLibApi: DeleteKnowledgeLibApi = async (knowledgeId) => {
    return api.delete(`bigmodel/api/delKnowledge/${knowledgeId}`);
};

// 获取知识库详情
const fetchKnowledgeLibDetailApi: FetchKnowledgeLibDetailApi = async (knowledgeId) => {
    return api.get(`bigmodel/api/detailKnowledge/${knowledgeId}`);
};

// 获取首页信息
const fetchIndexApi: FetchAppIndexApi = async (data) => {
    return api.post('/bigmodel/api/index', data);
};

// 获取应用详情
const fetchApplicationDetailApi: FetchApplicationDetailApi = async (appId) => {
    return api.get(`bigmodel/api/selectApplication/${appId}`);
};

// 模型列表
const fetchModelListApi: FetchModelListApi = async () => {
    return api.get('/bigmodel/api/model/list');
};

// 知识库列表
const fetchKnowledgeListApi: FetchKnowledgeApiListApi = async () => {
    // return api.get('/bigmodel/api/applicationList');
    return api.get('/bigmodel/api/knowledgeList');
};

// 编辑应用
const modifyApplicationLibApi: ModifyApplicationLibApi = async (appId, data) => {
    return api.put(`bigmodel/api/updateApplication/${appId}`, data);
};

// 删除应用
const deleteApplicationLibApi: DeleteApplicationLibApi = async (appId) => {
    return api.delete(`bigmodel/api/delApplication/${appId}`);
};

// 创建应用
const createApplicationLibApi: CreateApplicationLibApi = async (data) => {
    return api.post('bigmodel/api/createApplication', data);
};

// 上传知识文件
const uploadFileLibApi: uploadFileLibApi = async (konwledgeId) => {
    return api.post(`bigmodel/api/uploadDocument/${konwledgeId}`);
};

// 获取知识列表
const fetchDocumentLibListApi: FetchDocumentLibListApi = async (data) => {
    return api.post('bigmodel/api/documentList', data);
};

// 知识详情
const fetchDocumentLibApi: FetchDocumentLibApi = async (id) => {
    return api.get(`bigmodel/api/documentDetail/${id}`);
};

// 修改知识
const modifyDocumentApi: ModifyDocumentLibApi = async (id, data) => {
    return api.put(`bigmodel/api/updateDocument/${id}`, data);
};

// 删除知识文件
const deleteDocumentApi: DeleteDocumentLibApi = async (id) => {
    return api.delete(`bigmodel/api/delDocument/${id}`);
};

// 获取应用列表
const fetchApplicationListApi: FetchApplicationListApi = async () => {
    return api.get('bigmodel/api/application/list');
};

// 获取聊天记录列表
const fetchChatHistoryListApi: FetchChatHistoryListApi = async (data) => {
    return api.post('bigmodel/api/chatHistory/list', data);
};

// 导出聊天记录
const exportChatHistoryApi: ExportChatHistoryApi = async (id) => {
    return api.post(`bigmodel/api/dialog/export/${id}`, {}, { responseType: 'blob' });
};

// 获取takai应用列表
const fetchTakaiAppListApi: FetchTakaiAppListApi = async (data) => {
    return api.post('/deepseek/api/getApplicationList', data);
};
// 获取我创建的应用列表 /deepseek/api/getMyApplicationList
const fetchTakaiMyAppListApi: FetchTakaiMyAppListApi = async (data) => {
    return api.post('/deepseek/api/getMyApplicationList', data);
};

// 获取takai应用详情
const fetchTakaiApplicationDetailApi: FetchTakaiApplicationDetailApi = async (appId) => {
    return api.get(`/deepseek/api/selectApplication/${appId}`);
};

// 创建takai应用
const createTakaiApplicationLibApi: CreateTakaiApplicationLibApi = async (data) => {
    return api.post('/deepseek/api/createApplication', data);
};

// 编辑takai应用
const modifyTakaiApplicationLibApi: ModifyTakaiApplicationLibApi = async (appId, data) => {
    return api.put(`/deepseek/api/updateApplication/${appId}`, data);
};

// 删除takai应用
const deleteTakaiApplicationLibApi: DeleteTakaiApplicationLibApi = async (appId) => {
    return api.delete(`/deepseek/api/delApplication/${appId}`);
};

// 获取首页信息
const fetchTakaiIndexApi: FetchTakaiAppIndexApi = async (data) => {
    return api.post('/deepseek/api/index', data);
};

// takai知识库列表
const fetchTakaiKnowledgeListApi: FetchTakaiKnowledgeApiListApi = async () => {
    return api.get('/deepseek/api/knowledgeList');
};

// 获取takai知识库列表
const fetchTakaiKnowledgeLibListApi: FetchTakaiKnowledgeLibListApi = async (data) => {
    return api.post('/deepseek/api/getKnowledgeList', data);
};

// 获取takai知识库详情
const fetchTakaiKnowledgeLibDetailApi: FetchTakaiKnowledgeLibDetailApi = async (knowledgeId) => {
    return api.get(`/deepseek/api/detailKnowledge/${knowledgeId}`);
};

// 修改takai知识库
const modifyTakaiKnowledgeLibApi: ModifyTakaiKnowledgeLibApi = async (knowledgeId, data) => {
    return api.put(`/deepseek/api/updateKnowledge/${knowledgeId}`, data);
};

// 创建takai知识库
const createTakaiKnowledgeLibApi: CreateTakaiKnowledgeLibApi = async (data) => {
    return api.post('/deepseek/api/createKnowledge', data);
};

// 删除takai知识库
const deleteTakaiKnowledgeLibApi: DeleteTakaiKnowledgeLibApi = async (knowledgeId) => {
    return api.delete(`/deepseek/api/delKnowledge/${knowledgeId}`);
};

// 获取takai知识列表
const fetchTakaiDocumentLibListApi: FetchTakaiDocumentLibListApi = async (data) => {
    return api.post('/deepseek/api/documentList', data);
};

// takai知识详情
const fetchTakaiDocumentLibApi: FetchTakaiDocumentLibApi = async (id) => {
    return api.get(`/deepseek/api/documentDetail/${id}`);
};

// 修改takai知识
const modifyTakaiDocumentApi: ModifyTakaiDocumentLibApi = async (id, data) => {
    return api.put(`/deepseek/api/updateDocument/${id}`, data);
};

// 删除takai知识文件
const deleteTakaiDocumentApi: DeleteTakaiDocumentLibApi = async (id) => {
    return api.delete(`/deepseek/api/delDocument/${id}`);
};
// 删除takai知识文件--delUnfinishedDocument
const deleteTakaidelUnfinishedDocumentApi: DeleteTakaiDocumentLibApi = async (id) => {
    return api.delete(`/deepseek/api/delUnfinishedDocument/${id}`);
};

// takai知识配置详情
const fetchTakaiDocumentSettingLibApi: FetchTakaiDocumentSettingLibApi = async (id) => {
    return api.get(`/deepseek/api/documentSetting/${id}`);
};

// 修改takai知识配置
const modifyTakaiDocumentSettingApi: ModifyTakaiDocumentSettingLibApi = async (id, data) => {
    return api.put(`/deepseek/api/updateDocumentSetting/${id}`, data);
};

// 获取takai切片列表
const fetchTakaiSliceListApi: FetchTakaiSliceListApi = async (data) => {
    return api.post(`/deepseek/api/getSliceList`, data);
};

// 删除切片
const deleteTakaiSliceApi: deleteTakaiSliceLibApi = async (sliceId, knowledgeId, documentId) => {
    return api.delete(`/deepseek/api/deleteSlice/${sliceId}/${knowledgeId}/${documentId}`);
};

// 获取takai切片详情
const fetchTakaiSliceDetailApi: FetchTakaiSliceDetailLibApi = async (sliceId, knowledgeId) => {
    return api.get(`/deepseek/api/getSliceDetail/${sliceId}/${knowledgeId}`);
};

// 修改takai切片详情
const modifyTakaiSliceInfoApi: modifyTakaiSliceInfoLibApi = async (data) => {
    return api.put(`/deepseek/api/updateSliceInfo/`, data);
};

// 获取takai聊天记录列表
const fetchTakaiChatHistoryListApi: FetchTakaiChatHistoryListApi = async (data) => {
    return api.post('/deepseek/api/chatHistory/list', data);
};

// 导出takai聊天记录
const exportTakaiChatHistoryApi: ExportTakaiChatHistoryApi = async (id) => {
    return api.post(`/deepseek/api/dialog/export/${id}`, {}, { responseType: 'blob' });
};

// 获取takai应用列表 (下拉框)
const fetchTakaiApplicationListApi: FetchTakaiApplicationListApi = async (userId) => {
    return api.get('/deepseek/api/application/list/' + userId);
};

// 新增takai切片
const addTakaiSliceApi: addTakaiSliceLibApi = async (data) => {
    return api.post(`/deepseek/api/add/slice/`, data);
};

// takai应用类型列表
const fetchTakaiAppTypeListApi: FetchTakaiAppTypeListApi = async (dictType) => {
    return api.get(`/deepseek/api/${dictType}`);
};

const fetchUserInfoApi: FetchUserInfoApi = async () => {
    return api.get(`/system/user/getInfo`);
};
const fetchAuditInfoLibDetailApi: FetchAuditInfoLibDetailApi = async (documentId) => {
    return api.get(`/system/info/all/${documentId}`);
};


const fetchTakaiAuditConfigLibListApi: FetchTakaiAuditConfigLibListApi = async (data) => {
    return api.post('/deepseek/api/app/audit/list', data);
};

// 修改takai知识审核
const modifyTakaiAuditDocumentApi: ModifyTakaiAuditDocumentLibApi = async (id, data) => {
    return api.put(`/deepseek/api/updateDocumentAudit/${id}`, data);
};

const auditTakaiApplicationApi: AuditTakaiApplicationApi = async (appId, userId) => {
    return api.put(`/deepseek/api/audit/${appId}/${userId}`);
};

const fetchTakaiProjectApi: FetchTakaiProjectApi = async () => {
    return api.get(`/system/project/alllist?pageNum=1&pageSize=1000`);
};
// /system/user/appVipList   用户列表信息
const fetchUserListApi: FetchUserListApi = async (data: any) => {
    return api.get(`/system/user/appVipList?pageNum=${data.pageNum}&pageSize=${data.pageSize}&userName=${data.userName}&nickName=${data.nickName}&userType=${data.userType}`);
}
// start 建科新的APi
// 获取租户列表
const getTenantListApi = async (isToken: boolean) => {
    return api({
        url: '/auth/tenant/list',
        headers: {
            isToken: isToken
        },
        method: 'get'
    });
}
// 提交知识文件
const uploadDocumentApi: uploadFileLibApi = async (konwledgeId,data) => {
    return api.post(`/deepseek/api/uploadDocument/${konwledgeId}`,data);
};
// 下载知识库文件----deepseek/api/knowledgeSliceExport/{{knowledgeId}}
const exportKnowledgeSliceExport:ExportKnowledgeSliceExport = async (knowledgeId) => {
    return api.post(`/deepseek/api/knowledgeSliceExport/${knowledgeId}`, {}, { responseType: 'blob' });
};
// 中断 SSE请求 /resource/sse/close
const getSseclose = async () => {
    return api({
        url: '/resource/sse/close',
        method: 'get'
    });
}
// http://localhost:8080/deepseek/api/documentSliceExport  参数List<String> documentIds; 切片导出
const exportDocumentSliceExport:exportDocumentSliceExport = async (lis) => {
    return api.post(`/deepseek/api/documentSliceExport`, {
        documentIds:lis
    }, { responseType: 'blob' });
};
// http://localhost:8080/deepseek/api/documentExport  参数List<String> documentIds; 文件导出
const exportDocumentExport:exportDocumentExport = async (lis) => {
    return api.post(`/deepseek/api/documentExport`, {
        documentIds:lis
    }, { responseType: 'blob' });
};
// deepseek/api/pdfStream 下载PDF
const exportPdfStream:exportDocumentExport = async (lis) => {
    return api.post(`/deepseek/api/pdfStream`, {
        documentIds:lis
    }, { responseType: 'blob' });
};
// /deepseek/api/getSliceListByDocumentId/{{documentId}} 获取切片列表
const getSliceListByDocumentId = async (documentId:string)=>{
    return api({
        url: `/deepseek/api/getSliceListByDocumentId/${documentId}`,
        method: 'get'
    });
}

// POST http://localhost:8080/deepseek/api/sliceDocumentList 获取文档列表 参数name
const sliceDocumentList = async (data:any)=>{
    return api.post(`/deepseek/api/sliceDocumentList`, data);
};
// deepseek/api/quoteDocumentList 获取引用文档列表 参数 knowledge_id，knowledgeType(类型)
const getQuoteDocumentList = async (data:any)=>{
    // return api.post(`/deepseek/api/quoteDocumentList`, data);
    return api({
        url: `/deepseek/api/quoteDocumentList`,
        method: 'post',
        data
    });
};
// deepseek/api/importDocumentList 获取引用文档列表 参数 documentIds knowledgeId(类型)
const importDocumentList = async (data:any)=>{
    return api.post(`/deepseek/api/importDocumentList`, data);
};
// /deepseek/api/uploadSliceImage/${params.knowledgeId}/${params.documentId}
const uploadSliceImage = async (params:any,data:any)=>{
    return api.post(`/deepseek/api/uploadSliceImage/${params.knowledgeId}/${params.documentId}`, data);
};
// PUT http://localhost:8080/deepseek/api/updateSliceInfo 修改切片 
const setupdateSliceInfo = async (data:any) => {
    return api.put(`/deepseek/api/updateSliceInfo`, data);
};
// POST http://localhost:8080/deepseek/api/add/slice 新增切片
const addSlice = async (data:any) => {
    return api.post(`/deepseek/api/add/slice`, data);
};
// PUT http://localhost:8080/deepseek/api/updateSliceInfoList 提交--全部提交
const updateSliceInfoList = async (data:any) => {
    return api.put(`/deepseek/api/updateSliceInfoList`, data);
};
// GET http://localhost:8080/deepseek/api/getOldSliceListByDocumentId/{{documentId}} 获取初始模板切片
const getOldSliceListByDocumentId = async (documentId:string)=>{
    return api({
        url: `/deepseek/api/getOldSliceListByDocumentId/${documentId}`,
        method: 'get'
    });
}
// deepseek/api/knowledgeMarkDownFileExport/{{knowledgeId}} 下载知识库MarkDown文件
const exportKnowledgeMarkDown:ExportKnowledgeSliceExport = async (knowledgeId:string) => {
    return api.post(`/deepseek/api/knowledgeMarkDownFileExport/${knowledgeId}`, {},{ responseType: 'blob' });
};
// POST http://localhost:8080/deepseek/api/knowledgeFileExport/{{knowledgeId}} 下载知识库原文档
const exportKnowledgeFile:ExportKnowledgeSliceExport = async (knowledgeId:string) => {
    return api.post(`/deepseek/api/knowledgeFileExport/${knowledgeId}`, {},{ responseType: 'blob' });
};
// POST http://localhost:8080/deepseek/api/documentFileExport 文档列表下载文档原文件
const documentFileExport:exportDocumentExport = async (lis) => {
    return api.post(`/deepseek/api/documentFileExport`, {
        documentIds:lis
    }, { responseType: 'blob' });
};
// POST http://localhost:9080/deepseek/api/app/collect 我的收藏
const setCollectApi:setCollectApi = async (appId:string) => {
    console.log("appId",appId);
    return api.post(`/deepseek/api/app/collect`,{
        appId:appId
    });
}
// DELETE http://localhost:9080/deepseek/api/app/collect/{appId}
export const delCollectApi:setCollectApi = async (appId:string) => {
    return api.delete(`/deepseek/api/app/collect/${appId}`);
};
// 获取预设问题列表  '/deepseek/api/presets'; get请求
const getPresets = async (appId:string) => {
    return api({
        url: `/deepseek/api/presets/${appId}`,
        method: 'get'
    });
}
// DELETE http://localhost:9080/resource/oss/{ossIds} 批量删除oss文件
export const deleteOssFileApi = async (ossIds: string) => {
    return api.delete(`/resource/oss/${ossIds}`);
};
// deepseek/revise/pageList 知识库修订工具列表
export const fetchReviseToolList = async (data: any) => {
    return api.get('/deepseek/revise/pageList', { params: data });
}
// deepseek/revise/list 知识库修订工具列表不分页 
// String documentName,String sliceText,String documentId,String knowledgeId
export const fetchReviseToolAllList = async (data: any) => {
    return api.get('/deepseek/revise/list', { params: data });
}
// deepseek/revise/sliceList 知识库修订工具切片列表 String sliceText, String documentId
export const fetchReviseToolSliceList = async (data: any) => {
    return api.get('/deepseek/revise/sliceList', { params: data });
}
// revision_status.  ---- 0 未修订 1 已修订
// http://localhost:8080/deepseek/revise/reviseSlice  提交修订知识切片private String sliceId;
// private String refSliceId;
// private String revisionStatus;
export const submitReviseSliceApi = async (data: any) => {
    return api.put('/deepseek/revise/reviseSlice', data);
};
// http://localhost:8080/deepseek/api/document/checkFile 检查文件是否存在
export const checkFileApi = async (data: any) => {
    return api.post('/deepseek/api/document/checkFile', data);
}
// deepseek/api/getMarkDodnSliceByDocumentId/eb2f685c-451e-4252-b04c-bdc07au9969j 获取MarkDown切片列表
export const getMarkDodnSliceByDocumentId = async (documentId:string)=>{
    return api({
        url: `/deepseek/api/getMarkDodnSliceByDocumentId/${documentId}`,
        method: 'get'
    });
}
// deepseek/revise/reviseHistoryList 知识库修订历史记录列表 String knowledgeId,String knowledgeName,String documentName,String refDocumentName
export const fetchReviseHistoryList = async (data: any) => { 
    return api.get('/deepseek/revise/reviseHistoryList', { params: data });
}
// /deepseek/dataset/datsetExport  数据集导出
export const datasetExportApi = async (data: any) => {
    return api.post('/deepseek/dataset/datsetExport', data, { responseType: 'blob' });
};
// POST http://localhost:8080/deepseek/dataset/create 创建数据集 private String name;
// private String description;
// private Long ossId;
// private String url;
export const createDatasetApi = async (data: any) => {
    return api.post('/deepseek/dataset/create', data);
};
// http://localhost:8080/deepseek/dataset/pageList 数据集列表 --String name,String createBy,PageQuery pageQuery
export const fetchDatasetList = async (data: any) => { 
    return api.get('/deepseek/dataset/pageList', { params: data });
}
// DELETE http://localhost:8080/deepseek/dataset/delete/{{id}} 删除数据集
export const deleteDatasetApi = async (id: string) => {
    return api.delete(`/deepseek/dataset/delete/${id}`);
};
// GET http://localhost:8080/deepseek/dataset/list 数据集下拉框列表
export const fetchDatasetSelectList = async (data: any) => {
    return api.get('/deepseek/dataset/list', { params: data });
};
// POST http://localhost:8080/deepseek/evaluation/create 创建评测
export const createEvaluationApi = async (data: any) => {
    return api.post('/deepseek/evaluation/create', data);
};
// GET http://localhost:8080/deepseek/evaluation/pageList       String name, PageQuery pageQuery
export const fetchEvaluationList = async (data: any) => { 
    return api.get('/deepseek/evaluation/pageList', { params: data });
}
// DELETE http://localhost:8080/deepseek/evaluation/delete/{{taskId}} 删除评测
export const deleteEvaluationApi = async (taskId: string) => {
    return api.delete(`/deepseek/evaluation/delete/${taskId}`);
};
// /deepseek/api/editMarkDownFile private String knowledgeId; private String documentId;private String markDownText;

export const editMarkDownFileApi = async (data: any) => {
    return api.put('/deepseek/api/editMarkDownFile', data);
}
// GET http://localhost:8080/system/menu/getClientRouters 获取前端路由
export const fetchClientRouters = async () => {
    return api.get('/system/menu/getClientRouters');
};
// POST http://localhost:8080/deepseek/evaluation/taskBegin 开始评测
export const beginEvaluationApi = async (data: any) => {
    return api.post('/deepseek/evaluation/taskBegin', data);
};
// GET http://localhost:8080/system/tenant/getTenantSize
export const getTenantSize = async ()=>{
    return api.get('/system/tenant/getTenantSize');
}
// http://localhost:8080/deepseek/api/app/auditHistory/list
export const fetchAuditHistoryList = async (data: any) => {
    return api.post('/deepseek/api/app/auditHistory/list', { data: data });
}

// ==================== 审核管理相关 API ====================

// 获取审核列表
export const fetchAuditList = async (data: any) => {
    return api.post('/deepseek/api/app/audit/list', data);
};

// 获取审核统计数据
export const fetchAuditStats = async () => {
    return api.get('/deepseek/api/app/audit/stats');
};

// 审核操作（通过/拒绝）
export const auditAction = async (data: { auditId: string; action: string; opinion: string }) => {
    return api.put('/deepseek/api/app/audit/auditAction', data);
};

// 获取审核详情
export const fetchAuditDetail = async (auditId: string) => {
    return api.get(`/deepseek/api/app/audit/detail/${auditId}`);
};
// POST http://localhost:8080/deepseek/api/document/checkQuoteFile 检查引用文件是否存在
export const checkQuoteFileApi = async (data: any) => {
    return api.post('/deepseek/api/document/checkQuoteFile', data);
};
// DELETE http://localhost:8080/deepseek/api/deleteSliceList/{{knowledgeId}}/{{documentId}}
export const deleteSliceListApi = async (knowledgeId:any,documentId:any, data: any) => {
    return api.delete(`/deepseek/api/deleteSliceList/${knowledgeId}/${documentId}`,{
        data:data
    });
}
// http://localhost/dev-api/system/modelConfig/rerankList?modelType=1 获取重排模型列表
export const fetchRerankModelList = async () => {
    return api.get('/system/modelConfig/rerankList',{
        params:{
            modelType:1
        }
    });
}
// GET http://localhost:8080/system/taskHistory/list 获取评测历史列表
export const fetchTaskHistoryList = async (data: any) => {
    return api.get('/system/taskHistory/list',{
        params:{
            ...data
        }
    });
}
// GET http://localhost:8080/deepseek/overview/topData 头上面
export const fetchTopData = async () => {
    return api.get('/deepseek/overview/topData');
}

// GET http://localhost:8080/deepseek/overview/onlineUserData 活跃用户
export const fetchOnlineUserData = async (data: any) => {
    return api.get('/deepseek/overview/onlineUserData',{
        params:{
            ...data
        }
    });
}

// GET http://localhost:8080/deepseek/overview/conversationData 会话
export const fetchConversationData = async (data: any) => {
    return api.get('/deepseek/overview/conversationData',{
        params:{
            ...data
        }
    });
}

// GET http://localhost:8080/deepseek/overview/conversationDetailData 互动
export const fetchConversationDetailData = async (data: any) => {
    return api.get('/deepseek/overview/conversationDetailData',{
        params:{
            ...data
        }
    });
}

// GET http://localhost:8080/deepseek/overview/overviewTokenData token输出
export const fetchOverviewTokenData = async (data: any) => {
    return api.get('/deepseek/overview/overviewTokenData',{
        params:{
            ...data
        }
    });
}

// GET http://localhost:8080/deepseek/overview/overviewAppData RAG应用列表
export const fetchOverviewAppData = async (data: any) => {
    return api.get('/deepseek/overview/overviewAppData',{
        params:{
            ...data
        }
    });
}
// GET http://localhost:8080/deepseek/overview/overviewAppDetailData RAG应用明细
export const fetchOverviewAppDetailData = async (data: any) => {
    return api.get('/deepseek/overview/overviewAppDetailData',{
        params:{
            ...data
        }
    });
}

// GET http://localhost:8080/deepseek/overview/overviewKnowledgeData 知识库列表
export const fetchOverviewKnowledgeData = async (data: any) => {
    return api.get('/deepseek/overview/overviewKnowledgeData',{
        params:{
            ...data
        }
    });
}
// DELETE http://localhost:8080/deepseek/api/deleteSlice/{{sliceId}}/{{knowledgeId}}/{{documentId}}

// end 建科新的APi

export const apis = {
    checkToken: checkTokenApi,
    jklogin: jkloginApi,
    login: loginApi,
    captchaImage: captchaImage,
    logout: logoutApi,
    fetchAppList: fetchAppListApi,
    fetchKnowledgeLibList: fetchKnowledgeLibListApi,
    fetchEmbeddingList: fetchEmbeddingListApi,
    createKnowledgeLib: createKnowledgeLibApi,
    modifyKnowledgeLib: modifyKnowledgeLibApi,
    deleteKnowledgeLib: deleteKnowledgeLibApi,
    fetchKnowledgeLibDetail: fetchKnowledgeLibDetailApi,
    fetchIndexCount: fetchIndexApi,
    fetchApplicationDetail: fetchApplicationDetailApi,
    fetchModelList: fetchModelListApi,
    fetchKnowledgeList: fetchKnowledgeListApi,
    modifyApplicationApi: modifyApplicationLibApi,
    deleteApplicationApi: deleteApplicationLibApi,
    createApplicationApi: createApplicationLibApi,
    uploadFileLibApi: uploadFileLibApi,
    fetchDocumentLibListApi: fetchDocumentLibListApi,
    fetchDocumentDetailLibApi: fetchDocumentLibApi,
    modifyDocumentLibApi: modifyDocumentApi,
    deleteDocumentLibApi: deleteDocumentApi,
    fetchApplicationList: fetchApplicationListApi,
    fetchChatHistoryList: fetchChatHistoryListApi,
    exportChatHistory: exportChatHistoryApi,
    fetchTakaiAppList: fetchTakaiAppListApi,
    fetchTakaiApplicationDetail: fetchTakaiApplicationDetailApi,
    createTakaiApplicationApi: createTakaiApplicationLibApi,
    modifyTakaiApplicationApi: modifyTakaiApplicationLibApi,
    deleteTakaiApplicationApi: deleteTakaiApplicationLibApi,
    fetchTakaiIndexCount: fetchTakaiIndexApi,
    fetchTakaiKnowledgeList: fetchTakaiKnowledgeListApi,
    fetchTakaiKnowledgeLibList: fetchTakaiKnowledgeLibListApi,
    fetchTakaiKnowledgeLibDetail: fetchTakaiKnowledgeLibDetailApi,
    modifyTakaiKnowledgeLib: modifyTakaiKnowledgeLibApi,
    createTakaiKnowledgeLib: createTakaiKnowledgeLibApi,
    deleteTakaiKnowledgeLib: deleteTakaiKnowledgeLibApi,
    fetchTakaiDocumentLibListApi: fetchTakaiDocumentLibListApi,
    fetchTakaiDocumentDetailLibApi: fetchTakaiDocumentLibApi,
    modifyTakaiDocumentLibApi: modifyTakaiDocumentApi,
    deleteTakaiDocumentLibApi: deleteTakaiDocumentApi,
    deleteTakaidelUnfinishedDocumentLibApi: deleteTakaidelUnfinishedDocumentApi,
    fetchTakaiDocumentSettingLibApi: fetchTakaiDocumentSettingLibApi,
    modifyTakaiDocumentSettingLibApi: modifyTakaiDocumentSettingApi,
    fetchTakaiSliceList: fetchTakaiSliceListApi,
    deleteTakaiSlice: deleteTakaiSliceApi,
    fetchTakaiSliceDetail: fetchTakaiSliceDetailApi,
    modifyTakaiSliceInfo: modifyTakaiSliceInfoApi,
    fetchTakaiChatHistoryList: fetchTakaiChatHistoryListApi,
    exportTakaiChatHistory: exportTakaiChatHistoryApi,
    fetchTakaiApplicationList: fetchTakaiApplicationListApi,
    addTakaiSlice: addTakaiSliceApi,
    fetchTakaiAppTypeList: fetchTakaiAppTypeListApi,
    fetchUserInfo: fetchUserInfoApi,
    fetchAuditInfoLibDetail: fetchAuditInfoLibDetailApi,
    fetchTakaiAuditConfigLibList: fetchTakaiAuditConfigLibListApi,
    modifyTakaiAuditDocumentLibApi: modifyTakaiAuditDocumentApi,
    auditTakaiApplicationLibApi: auditTakaiApplicationApi,
    fetchTakaiProjectLibApi: fetchTakaiProjectApi,
    fetchUserListApi: fetchUserListApi,
    // start 建科新的APi
    getTenantList:getTenantListApi,
    uploadDocumentApi:uploadDocumentApi,
    exportKnowledgeSliceExport:exportKnowledgeSliceExport,
    getSseclose:getSseclose,
    exportDocumentSliceExport:exportDocumentSliceExport,
    exportDocumentExport:exportDocumentExport,
    getSliceListByDocumentId:getSliceListByDocumentId,
    sliceDocumentList:sliceDocumentList,
    exportPdfStream:exportPdfStream,
    getQuoteDocumentList:getQuoteDocumentList,
    importDocumentList:importDocumentList,
    uploadSliceImage:uploadSliceImage,
    setupdateSliceInfo:setupdateSliceInfo,
    addSlice:addSlice,
    updateSliceInfoList:updateSliceInfoList,
    getOldSliceListByDocumentId:getOldSliceListByDocumentId,
    exportKnowledgeMarkDown:exportKnowledgeMarkDown,
    exportKnowledgeFile:exportKnowledgeFile,
    documentFileExport:documentFileExport,
    fetchTakaiMyAppListApi:fetchTakaiMyAppListApi,
    setCollectApi:setCollectApi,
    delCollectApi:delCollectApi,
    getPresets:getPresets,
    deleteOssFileApi:deleteOssFileApi,
    fetchReviseToolList:fetchReviseToolList,
    fetchReviseToolAllList:fetchReviseToolAllList,
    fetchReviseToolSliceList:fetchReviseToolSliceList,
    checkFileApi:checkFileApi,
    getMarkDodnSliceByDocumentId:getMarkDodnSliceByDocumentId,
    datasetExportApi:datasetExportApi,
    createDatasetApi:createDatasetApi,
    deleteDatasetApi:deleteDatasetApi,
    fetchDatasetSelectList:fetchDatasetSelectList,
    createEvaluationApi:createEvaluationApi,
    fetchEvaluationList:fetchEvaluationList,
    deleteEvaluationApi:deleteEvaluationApi,
    editMarkDownFileApi:editMarkDownFileApi,
    fetchClientRouters:fetchClientRouters,
    beginEvaluationApi:beginEvaluationApi,
    getTenantSize:getTenantSize,
    fetchAuditHistoryList:fetchAuditHistoryList,
    checkQuoteFileApi:checkQuoteFileApi,
    deleteSliceListApi:deleteSliceListApi,
    fetchRerankModelList:fetchRerankModelList,
    fetchTaskHistoryList:fetchTaskHistoryList,
    fetchTopData:fetchTopData,
    fetchOnlineUserData:fetchOnlineUserData,
    fetchConversationData:fetchConversationData,
    fetchConversationDetailData:fetchConversationDetailData,
    fetchOverviewTokenData:fetchOverviewTokenData
    // end 建科新的APi
};
