import request from '../base/ajax'; /** * @description 创建Dify智能体, * @param {Object} data 包含创建Dify所需参数的对象 * @param {String} data.mode 模式,可选值:'advanced-chat'、'agent-chat'、'workflow' * */ export function createDify(data) { const initData = { icon_type: 'emoji', icon: '🤖', icon_background: '#FFEAD5' }; initData.mode = data.mode; initData.name = data.name; initData.description = data.description; return request({ url: `/dify/console/api/apps`, method: 'post', data: initData }); } // 删除dify智能体 export function deleteDify(id) { return request({ url: `/dify/console/api/apps/${id}`, method: 'delete' }); } /** * 编辑dify智能体 * */ export function updateDify(id, data) { return request({ url: `/dify/console/api/apps/${id}`, method: 'put', data }); } // 创建rgflow智能体 export function createRgFlow(data) { return request({ url: `/rgflow/v1/dialog/set`, method: 'post', data }); } // 删除rgflow智能体 export function deleteRgFlow(data) { return request({ url: `/rgflow/v1/dialog/rm`, method: 'post', data }); } // 头像上传 export function kbdocumentupload(data) { const config = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' // token: token, } }; return request({ url: `/rgflow/v1/document/upload`, method: 'post', data, headers: config.headers }); } // 查询模型列表 export function queryModelList() { return request({ url: `/rgflow/v1/llm/list`, method: 'get' }); } // 获取某个智能体的数据 export function getRagFlowData(id) { return request({ url: `/rgflow/v1/dialog/get?dialog_id=${id}`, method: 'get' }); } // 新增知识库 export function createKb(name) { return request({ url: `/rgflow/v1/kb/create`, method: 'post', data: { name } }); } // 查询知识库列表 export function queryKbList() { return request({ url: `/rgflow/v1/kb/list`, method: 'get' }); } // 知识库详情接口 export function queryKbdetail(params) { return request({ url: `/rgflow/v1/kb/detail`, method: 'get', params }); } // 文档列表接口 export function queryKbDocumentList(params) { return request({ url: `/rgflow/v1/document/list`, method: 'get', params }); } // 知识库删除接口 export function deleteKnow(data) { return request({ url: `/rgflow/v1/kb/rm`, method: 'post', data }); } // 文档删除接口 export function kbdocumentrm(data) { return request({ url: `/rgflow/v1/document/rm`, method: 'post', data }); } // 文档启动/取消解析接口 export function kbdocumentrun(data) { return request({ url: `/rgflow/v1/document/run`, method: 'post', data }); } // 文档启用/禁用接口 export function kbdocumentchangeStatus(data) { return request({ url: `/rgflow/v1/document/change_status`, method: 'post', data }); } // 文档下载接口 export const downloadFile = ({ url, filename, target }) => { const downloadElement = document.createElement('a'); downloadElement.style.display = 'none'; downloadElement.href = url; if (target) { downloadElement.target = '_blank'; } downloadElement.rel = 'noopener noreferrer'; if (filename) { downloadElement.download = filename; } document.body.appendChild(downloadElement); downloadElement.click(); document.body.removeChild(downloadElement); }; //启用禁用 export function changeStatus(data) { return request({ url: `/rgflow/v1/document/change_status`, method: 'post', data }); } // 文件解析方法接口 export function kbdocumentchangeparser(data) { return request({ url: `/rgflow/v1/document/change_parser`, method: 'post', data }); } // 创建解析块接口 export function achunkCreate(data) { return request({ url: `/rgflow/v1/chunk/create`, method: 'post', data }); } //解析块列表接口 export function queryChunkList(data) { return request({ url: `/rgflow/v1/chunk/list`, method: 'post', data }); } // 启用禁用接口 export function chunkSwitch(data) { return request({ url: `/rgflow/v1/chunk/switch`, method: 'post', data }); } // 删除解析块接口 export function chunkRm(data) { return request({ url: `/rgflow/v1/chunk/rm`, method: 'post', data }); } export function achunkGet(params) { return request({ url: `/rgflow/v1/chunk/get`, method: 'get', params }); } // 知识库创建接口 export function kbcreate(date) { return request({ url: `/rgflow/v1/kb/create`, method: 'post', data }); } export function achunkSet(data) { return request({ url: `/rgflow/v1/chunk/set`, method: 'post', data }); } // 测试接口 export function kbretrievalTest(data) { return request({ url: `/rgflow/v1/chunk/retrieval_test`, method: 'post', data }); } // 文档重命名接口 export function kbdocumentrename(data) { return request({ url: `/rgflow/v1/document/rename`, method: 'post', data }); } // 获取知识库管理配置嵌入模型 export function getKnowledgeBaseModel(params) { return request({ url: `/rgflow/v1/llm/my_llms`, method: 'get', params }); } // 配置接口 export function kbUpdate(data) { return request({ url: `/rgflow/v1/kb/update`, method: 'post', data }); } // 获取tenant_info export function getTenantInfo() { return request({ url: `/rgflow/v1/user/tenant_info`, method: 'get' }); }