diff --git a/front/.env b/front/.env index f96e2ee..e5d9612 100644 --- a/front/.env +++ b/front/.env @@ -1,7 +1,7 @@ FRONTEND_DEPLOY_STAGE=DEVELOPMENT NEXT_PUBLIC_EDITION=SELF_HOSTED -FRONTEND_CORE_API=https://10.210.0.49:5025/console/api -FRONTEND_APP_API=https://10.210.0.49:5025/api +FRONTEND_CORE_API=https://112.111.7.69:30382/console/api +FRONTEND_APP_API=https://112.111.7.69:30382/api # SENTRY NEXT_PUBLIC_SENTRY_DSN= diff --git a/front/.env.example b/front/.env.example index f96e2ee..e5d9612 100644 --- a/front/.env.example +++ b/front/.env.example @@ -1,7 +1,7 @@ FRONTEND_DEPLOY_STAGE=DEVELOPMENT NEXT_PUBLIC_EDITION=SELF_HOSTED -FRONTEND_CORE_API=https://10.210.0.49:5025/console/api -FRONTEND_APP_API=https://10.210.0.49:5025/api +FRONTEND_CORE_API=https://112.111.7.69:30382/console/api +FRONTEND_APP_API=https://112.111.7.69:30382/api # SENTRY NEXT_PUBLIC_SENTRY_DSN= diff --git a/front/app/(anotherLayout)/user/group/pageAiModel.tsx b/front/app/(anotherLayout)/user/group/pageAiModel.tsx index 49a9d29..168464d 100644 --- a/front/app/(anotherLayout)/user/group/pageAiModel.tsx +++ b/front/app/(anotherLayout)/user/group/pageAiModel.tsx @@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react' import { Modal, Select, Table, message } from 'antd' import PageAiCascader from './pageAiCascader' import { getModelInfo, getModelListNew } from '@/infrastructure/api/modelWarehouse' -import { getAdjustList } from '@/infrastructure/api/prompt' +import { Service } from '@/infrastructure/api/generated' type ModelItemType = { id: string model_type: string @@ -67,7 +67,6 @@ type CascaderOptionType = { const AiModel: React.FC = ({ open, onCancel, onOk, currentRecord }) => { const [selectedServices, setSelectedServices] = useState>({}) const [selectedModels, setSelectedModels] = useState>({}) - const [cascaderOptions, setCascaderOptions] = useState([]) const [cloudServiceOptions, setCloudServiceOptions] = useState([]) const [platformServiceOptions, setPlatformServiceOptions] = useState([]) const [modelData, setModelData] = useState([]) @@ -121,7 +120,6 @@ const AiModel: React.FC = ({ open, onCancel, onOk, currentRecord } } // 平台服务 const fetchPlatformData = async () => { - const url = '/infer-service/list' const param: any = { page: 1, per_page: 9999, @@ -129,14 +127,11 @@ const AiModel: React.FC = ({ open, onCancel, onOk, currentRecord } tenant: workspaceId, } try { - const res: any = await getAdjustList({ - url, - body: param, - }) + const res: any = await Service.postInferServiceList(param) - // 处理平台服务数据 - 数据在 res.result.result 中 - if (res?.result?.result && Array.isArray(res.result.result)) { - const filteredResult = res.result.result.filter((item: any) => item.online_count > 0) + // 处理平台服务数据 - 数据在 res.data.result 中 + if (res?.data?.result && Array.isArray(res.data.result)) { + const filteredResult = res.data.result.filter((item: any) => item.online_count > 0) const options = filteredResult.map((item: any, index: number) => { const option = { value: item.id ? `${item.id}` : `service_${index}`, @@ -198,7 +193,6 @@ const AiModel: React.FC = ({ open, onCancel, onOk, currentRecord } const resetData = () => { setSelectedServices({}) setSelectedModels({}) - setCascaderOptions([]) setCloudServiceOptions([]) setPlatformServiceOptions([]) setModelData([]) diff --git a/front/app/(appLayout)/datasets/datasetManager/EnhanceModal.tsx b/front/app/(appLayout)/datasets/datasetManager/EnhanceModal.tsx index a1e2a0d..4ada11b 100644 --- a/front/app/(appLayout)/datasets/datasetManager/EnhanceModal.tsx +++ b/front/app/(appLayout)/datasets/datasetManager/EnhanceModal.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react' import { Form, Input, Modal, Select } from 'antd' -import { createKnowledgeBase, updateKnowledgeBase } from '@/infrastructure/api/knowledgeBase' -import Toast from '@/app/components/base/flash-notice' +import { Service } from '@/infrastructure/api/generated' +import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' import { categoryItems } from '@/shared/utils' const EnhanceModal = (props: any) => { @@ -11,13 +11,13 @@ const EnhanceModal = (props: any) => { const handleOk = async () => { form.validateFields().then((values) => { if (data) { - updateKnowledgeBase({ url: '/kb/update', body: { ...data, ...values } }).then((res) => { - Toast.notify({ type: 'success', message: '更新成功' }) + Service.postKbUpdate({ ...data, ...values }).then((res: any) => { + Toast.notify({ type: ToastTypeEnum.Success, message: '更新成功' }) onSuccess(res.id, 'edit') }) } else { - createKnowledgeBase({ url: '/kb/create', body: values }).then((res) => { + Service.postKbCreate(values).then((res: any) => { onSuccess(res.id, 'create') onSuccess(res.id) }) diff --git a/front/app/(appLayout)/datasets/datasetManager/[id]/DataModal.tsx b/front/app/(appLayout)/datasets/datasetManager/[id]/DataModal.tsx index 1db65b8..3b1c9c2 100644 --- a/front/app/(appLayout)/datasets/datasetManager/[id]/DataModal.tsx +++ b/front/app/(appLayout)/datasets/datasetManager/[id]/DataModal.tsx @@ -1,7 +1,7 @@ -import React, { useEffect, useState } from 'react' +import React, { useCallback, useEffect, useState } from 'react' import { Form, Input, Modal, Radio, Select } from 'antd' -import { getScriptList, handleFile } from '@/infrastructure/api/knowledgeBase' -import Toast from '@/app/components/base/flash-notice' +import { Service } from '@/infrastructure/api/generated' +import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' import { tagList } from '@/app/components/tagSelect/ClassifyMode' import { bindTags } from '@/infrastructure/api/tagManage' import { noOnlySpacesRule } from '@/shared/utils' @@ -59,7 +59,7 @@ const CleanModal = (props: any) => { setLoading(true) const values = await form.validateFields() if (data) { - const { version, script_agent, data_set_script_id, agent, script_type, ...rest } = values + const { version: _version, script_agent, data_set_script_id, agent, script_type, ...rest } = values // 构造请求参数 const requestData = { @@ -77,11 +77,8 @@ const CleanModal = (props: any) => { requestData.data_set_script_id = agent } - const res: any = await handleFile({ - url: '/data/version/clean_or_augment', - body: requestData, - }) - Toast.notify({ type: 'success', message: '操作成功' }) + const res: any = await Service.postDataVersionCleanOrAugment(requestData) + Toast.notify({ type: ToastTypeEnum.Success, message: '操作成功' }) onSuccess(res.id, 'edit') } } @@ -94,7 +91,7 @@ const CleanModal = (props: any) => { if (err instanceof Response && err.status === 423) return - Toast.notify({ type: 'error', message: '操作失败,请重试' }) + Toast.notify({ type: ToastTypeEnum.Error, message: '操作失败,请重试' }) } finally { setLoading(false) @@ -108,14 +105,14 @@ const CleanModal = (props: any) => { } // 清空所有数据 - const clearAllData = () => { + const clearAllData = useCallback(() => { form.resetFields() setProcessType('') setProcessMethod('') setScriptList([]) setAgentList([]) setLoading(false) - } + }, [form]) const getScriptListData = async (scriptType: string) => { if (!scriptType) { @@ -123,7 +120,7 @@ const CleanModal = (props: any) => { return } try { - const res: any = await getScriptList({ url: '/script/list_by_type', options: { params: { script_type: scriptType } } }) + const res: any = await Service.getScriptListByType(scriptType) setScriptList(res.map(item => ({ label: item.name, value: item.id }))) } catch (error) { @@ -192,7 +189,7 @@ const CleanModal = (props: any) => { else { data && form.setFieldsValue(data) } - }, [visible, data, form]) + }, [visible, data, form, clearAllData]) return ( diff --git a/front/app/(appLayout)/datasets/scriptManager/page.tsx b/front/app/(appLayout)/datasets/scriptManager/page.tsx index db31b30..5a62965 100644 --- a/front/app/(appLayout)/datasets/scriptManager/page.tsx +++ b/front/app/(appLayout)/datasets/scriptManager/page.tsx @@ -12,7 +12,7 @@ import CreatorSelect from '@/app/components/tagSelect/creatorSelect' import ClassifyMode, { tagList } from '@/app/components/tagSelect/ClassifyMode' import Iconfont from '@/app/components/base/iconFont' import useAuthPermissions from '@/shared/hooks/use-radio-auth' -import { createPrompt, deletePrompt } from '@/infrastructure/api/prompt' +import { Service } from '@/infrastructure/api/generated' import { getDatasetListNew } from '@/infrastructure/api/data' import { API_PREFIX } from '@/app-specs' const { Dragger } = Upload @@ -112,8 +112,7 @@ const ScriptManage = () => { } const handleDelete = async (e, id: any) => { e.stopPropagation() - const url = '/script/delete' - const res: any = await deletePrompt({ url, body: { script_id: id } }) + const res: any = await Service.postScriptDelete({ script_id: Number(id) }) if (res.code === 200) { message.success('删除成功') setPageOption({ ...pageOption, page: 1 }) @@ -135,19 +134,13 @@ const ScriptManage = () => { setIsView(false) return } - let gUrl = '' - if (isEdit) - gUrl = '/script/update' - else - gUrl = '/script/create' - form.validateFields().then(async (values) => { setBtnLoading(true) try { - const res: any = await createPrompt({ - url: gUrl, - body: { ...values, icon: '' }, - }) + const submitValues = { ...values, icon: '' } + const res: any = isEdit + ? await Service.postScriptUpdate(submitValues) + : await Service.postScriptCreate(submitValues) if (res?.name) { message.success('保存成功') form.resetFields() @@ -354,7 +347,7 @@ const ScriptManage = () => { - {loading && !list?.length + {(loading && !list?.length) ?
@@ -449,7 +442,7 @@ const ScriptManage = () => { { validator: (_, value) => { if (value && value.trim() === '') - return Promise.reject('简介不能为空格') + return Promise.reject(new Error('简介不能为空格')) return Promise.resolve() }, diff --git a/front/app/(appLayout)/inferenceService/platform/page.module.scss b/front/app/(appLayout)/inferenceService/platform/page.module.scss index abdd368..2fa22c7 100644 --- a/front/app/(appLayout)/inferenceService/platform/page.module.scss +++ b/front/app/(appLayout)/inferenceService/platform/page.module.scss @@ -4,7 +4,6 @@ // padding-top: 1.5625vw; height: auto; // overflow-x: scroll; - .panelSty { :global(.ant-collapse-header) { background: #FFF !important; diff --git a/front/app/(appLayout)/inferenceService/platform/page.tsx b/front/app/(appLayout)/inferenceService/platform/page.tsx index ceec392..a9ed419 100644 --- a/front/app/(appLayout)/inferenceService/platform/page.tsx +++ b/front/app/(appLayout)/inferenceService/platform/page.tsx @@ -1,5 +1,5 @@ 'use client' -import React, { useEffect, useRef, useState } from 'react' +import React, { useCallback, useEffect, useRef, useState } from 'react' import { Button, Collapse, Empty, Form, Input, Modal, Pagination, Popconfirm, Select, Spin, Tag, Tooltip, message } from 'antd' import { MinusCircleOutlined, PlusCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons' import { useUpdateEffect } from 'ahooks' @@ -9,7 +9,7 @@ import ClassifyMode from '@/app/components/tagSelect/ClassifyMode' import CreatorSelect from '@/app/components/tagSelect/creatorSelect' import useRadioAuth from '@/shared/hooks/use-radio-auth' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' -import { createPrompt, deletePrompt, getAdjustList, getPromptList } from '@/infrastructure/api/prompt' +import { Service } from '@/infrastructure/api/generated' const { Panel } = Collapse const showText: any = { @@ -43,7 +43,6 @@ const formItemLayoutWithOutLabel = { const InferenceService = () => { const [form] = Form.useForm() const authRadio = useRadioAuth() - const [authValue, setAuthValue] = useState(authRadio.is_self_space ? 'mine' : 'group') const [info, setInfo] = useState({}) const [testInfo, setTestInfo] = useState({}) const [title, setTitle] = useState('新建模型服务') @@ -68,8 +67,7 @@ const InferenceService = () => { // 添加轮询相关的引用 const pollingTimer = useRef(null) - const getList = async (page, search_name = '') => { - const url = '/infer-service/list' + const getList = useCallback(async (page, search_name = '') => { const param: any = { page, per_page: 10, @@ -79,12 +77,9 @@ const InferenceService = () => { } setLoading(true) try { - const res: any = await getAdjustList({ - url, - body: param, - }) + const res: any = await Service.postInferServiceList(param) if (res?.result) { - const { result = [], total } = res?.result + const { result = [], total } = res.result setList(result) setTotal(total) } @@ -92,33 +87,33 @@ const InferenceService = () => { finally { setLoading(false) } - } + }, [creator, sName, selectLabels]) // 检查是否有启动中的服务 - const hasStartingServices = () => { + const hasStartingServices = useCallback(() => { const startingStatuses = ['Done', 'InQueue', 'Running', 'Pending'] return list.some((item: any) => item.services?.some((service: any) => startingStatuses.includes(service.status)), ) - } + }, [list]) // 启动轮询 - const startPolling = () => { + const startPolling = useCallback(() => { if (pollingTimer.current) clearInterval(pollingTimer.current) pollingTimer.current = setInterval(() => { getList(pageOption.page, searchVal) }, 15000) // 15秒轮询 - } + }, [getList, pageOption.page, searchVal]) // 停止轮询 - const stopPolling = () => { + const stopPolling = useCallback(() => { if (pollingTimer.current) { clearInterval(pollingTimer.current) pollingTimer.current = null } - } + }, []) // 检查并管理轮询状态 useEffect(() => { @@ -131,51 +126,43 @@ const InferenceService = () => { return () => { stopPolling() } - }, [list, pageOption.page, searchVal]) + }, [hasStartingServices, startPolling, stopPolling]) - const getModelList = async () => { - const url = '/infer-service/model/list' + const getModelList = useCallback(async () => { const param: any = { model_type: 'local', model_kind: modelType, qtype: 'already', } try { - const res: any = await getPromptList({ - url, - options: { params: param }, - }) + const res: any = await Service.getInferServiceModelList( + param.model_type, + param.model_kind, + param.qtype, + ) if (res) setModelList(res) } finally { setLoading(false) } - } + }, [modelType]) useEffect(() => { getList(pageOption.page, '') - }, [pageOption.page]) + }, [getList, pageOption.page]) useUpdateEffect(() => { getList(1, '') - }, [sName, creator, selectLabels]) + }, [creator, getList, sName, selectLabels]) useEffect(() => { getModelList() - }, [modelType]) - - const altChange = ({ target: { value } }: any) => { - setAuthValue(value) - setSName('') - setSearchVal('') - setPageOption({ ...pageOption, page: 1 }) - } + }, [getModelList]) const handleDelete = async (e, id: any) => { e.stopPropagation() - const url = '/infer-service/service/delete' - const res: any = await deletePrompt({ url, body: { service_id: id } }) + const res: any = await Service.postInferServiceServiceDelete({ service_id: id }) if (res) { message.success('删除成功') setPageOption({ ...pageOption, page: 1 }) @@ -191,20 +178,12 @@ const InferenceService = () => { } const submitFormValues = async (values: any) => { - let gUrl = '' - if (isEdit) - gUrl = '/infer-service/service/create' - - else - gUrl = '/infer-service/group/create' - setBtnLoading(true) try { - const res: any = await createPrompt({ - url: gUrl, - body: values, - }) + const res: any = isEdit + ? await Service.postInferServiceServiceCreate(values) + : await Service.postInferServiceGroupCreate(values) if (res) { message.success('保存成功') form.resetFields() @@ -284,13 +263,11 @@ const InferenceService = () => { const clickStartStopA = async (e, id, flag) => { e.stopPropagation() const params = { group_id: id } - const url = flag === 'start' ? '/infer-service/group/start' : '/infer-service/group/close' setLoading(true) try { - const res = await createPrompt({ - url, - body: params, - }) + const res = flag === 'start' + ? await Service.postInferServiceGroupStart(params) + : await Service.postInferServiceGroupClose(params) if (res) { Toast.notify({ type: ToastTypeEnum.Success, message: '操作成功' }) refreshList() @@ -307,13 +284,11 @@ const InferenceService = () => { const clickStartStop = async (e, id, flag) => { e.stopPropagation() const params = { service_id: id } - const url = flag === 'start' ? '/infer-service/service/start' : '/infer-service/service/stop' setLoading(true) try { - const res = await createPrompt({ - url, - body: params, - }) + const res = flag === 'start' + ? await Service.postInferServiceServiceStart(params) + : await Service.postInferServiceServiceStop(params) if (res) { if ((res as any).status === 0) { Toast.notify({ type: ToastTypeEnum.Success, message: '操作成功' }) diff --git a/front/app/(appLayout)/modelWarehouse/layout.tsx b/front/app/(appLayout)/modelWarehouse/layout.tsx index 0c2ec27..391d0e1 100644 --- a/front/app/(appLayout)/modelWarehouse/layout.tsx +++ b/front/app/(appLayout)/modelWarehouse/layout.tsx @@ -17,28 +17,26 @@ const ModelWarehouseLayout = ({ children }: ModelWarehouseLayoutProps) => { useEffect(() => { const pathName = window.location.pathname - if (/\/modelWarehouse\/modelTest(?:\/.*)?$/.test(pathName)) { + if (/\/modelWarehouse\/modelTest(?:\/.*)?$/.test(pathName)) setCurrentType('modelTest') - } else if (/\/modelWarehouse(?:\/modelManage)?(?:\/.*)?$/.test(pathName)) { + else if (/\/modelWarehouse(?:\/modelManage)?(?:\/.*)?$/.test(pathName)) setCurrentType('modelManage') - } }, [currentPathname]) const processNavigation = (type: string) => { setCurrentType(type) - if (type === 'modelManage') { + if (type === 'modelManage') navigationRouter.replace('/modelWarehouse/modelManage') - } else { + else navigationRouter.replace('/modelWarehouse/modelTest') - } } const renderMenuItem = (type: string, iconType: string, label: string) => { const isActive = currentType === type - + return ( -
processNavigation(type)} >
diff --git a/front/app/(appLayout)/modelWarehouse/modelManage/CreateModule.tsx b/front/app/(appLayout)/modelWarehouse/modelManage/CreateModule.tsx index 867c519..08cda15 100644 --- a/front/app/(appLayout)/modelWarehouse/modelManage/CreateModule.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelManage/CreateModule.tsx @@ -7,13 +7,11 @@ import type { RcFile } from 'antd/es/upload/interface' import pLimit from 'p-limit' import { useDebounceFn } from 'ahooks' import styles from './page.module.scss' -import { API_PREFIX } from '@/app-specs' import useRadioAuth from '@/shared/hooks/use-radio-auth' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' -import { checkName, createModel, uploadMerge } from '@/infrastructure/api/modelWarehouse' // uploadChunk, +import { Service } from '@/infrastructure/api/generated' import { noOnlySpacesRule } from '@/shared/utils' import TagSelect from '@/app/components/tagSelect' -import { bindTags, deleteFile, getTagList } from '@/infrastructure/api/tagManage' import { useModalContext } from '@/shared/hooks/modal-context' import Iconfont from '@/app/components/base/iconFont' import IconModal from '@/app/components/iconModal' @@ -40,7 +38,6 @@ const CreateModal = (props: any) => { const [iconModal, setIconModal] = useState(false) const [form] = Form.useForm() - const token = localStorage.getItem('console_token') const authRadio = useRadioAuth() // 清理所有上传任务和进度数据的公共函数 @@ -79,14 +76,25 @@ const CreateModal = (props: any) => { const { run: handleOk } = useDebounceFn(async () => { form.validateFields().then((values) => { - createModel({ url: '/mh/create', body: { ...data, ...values, model_list: JSON.stringify(values.model_list) } }).then((res) => { + const createBody: any = { ...data, ...values, model_list: JSON.stringify(values.model_list) } + if (createBody.model_from === 'huggingface') + createBody.model_from = 'hf' + if (createBody.model_from === 'modelscope') + createBody.model_from = 'ms' + Service.postMhCreate(createBody).then((res: any) => { Toast.notify({ type: ToastTypeEnum.Success, message: '添加成功' }) setType('local') form.resetFields() setModelFrom(undefined) - bindTags({ url: 'tags/bindings/update', body: { type: 'model', tag_names: values?.tag_names, target_id: res?.id } }).then(() => { + Service.postTagsBindingsUpdate({ + type: 'model', + tag_names: values?.tag_names || [], + target_id: String(res?.id), + }).then(() => { onSuccess() }) + }).catch((err) => { + Toast.notify({ type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '添加失败' }) }) }).catch((err) => { console.error(err) @@ -110,25 +118,28 @@ const CreateModal = (props: any) => { }, [visible, data, form]) const getList = async () => { - enum EType { - 'OnlineLLM' = 'llm', - 'Embedding' = 'embedding', - 'reranker' = 'reranker', + const typeMap: Record = { + OnlineLLM: 'llm', + Embedding: 'embedding', + reranker: 'reranker', } if (!modelKind) return - const res: any = await getTagList({ url: '/brands', options: { params: { type: EType[modelKind] } } }) + const brandType = typeMap[modelKind] + if (!brandType) + return + const res = await Service.getBrands(brandType) if (res) setTags(res) } const getmodels = async () => { - const res: any = await getTagList({ url: '/mh/online_model_support_list', options: { params: {} } }) + const res = await Service.getMhOnlineModelSupportList() if (res) setModels(res) } const getExistModels = async () => { - const res: any = await getTagList({ url: '/mh/exist_model_list', options: { params: {} } }) + const res = await Service.getMhExistModelList() if (res) setExistModels(res) } @@ -176,73 +187,33 @@ const CreateModal = (props: any) => { } else if (info.file.status === 'done') { setLoading(false) - form.setFieldValue('model_icon', info.file.response.file_path) + form.setFieldValue('model_icon', info.file.response?.file_path) + } + else { + setLoading(false) } - - else { setLoading(false) } } - const requestEvent = ({ url, formData, options, onSuccess, onFail, onProgress }) => { - const xhr = new XMLHttpRequest() - const accessToken = localStorage.getItem('console_token') || '' - const taskKey = `${options.uid}-${options.chunkId}` - - // 保存XMLHttpRequest引用 - selfRef.current.activeXHRs[taskKey] = xhr - - xhr.open('POST', url, true) - // xhr.setRequestHeader('Content-Type', 'multipart/form-data') - xhr.setRequestHeader('Authorization', `Bearer ${accessToken}`) - xhr.onreadystatechange = () => { - if (xhr.readyState === 4) { - // 请求完成后移除引用 - delete selfRef.current.activeXHRs[taskKey] - - // 检查请求是否被中止,如果被中止则不处理响应 - if (xhr.status === 0) { - // 请求被中止,不需要处理 - return - } - - if (xhr.status === 200) { - try { - onSuccess && onSuccess(JSON.parse(xhr.response)) - } - catch (error) { - console.error('JSON parse error:', error) - onFail && onFail({ - ...options, - response: { error: 'Invalid response format' }, - }) - } - } - else { - try { - onFail && onFail({ - ...options, - response: JSON.parse(xhr.response), - }) - } - catch (error) { - onFail && onFail({ - ...options, - response: { error: 'Request failed' }, - }) - } - } - } - } - xhr.upload.addEventListener('progress', (event) => { - if (event.lengthComputable) { - onProgress && onProgress({ - ...options, - percent: event.loaded / event.total, + const iconUploadProps: UploadProps = { + name: 'file', + accept: '.jpg,.png,.jpeg', + listType: 'picture-card', + className: 'avatar-uploader', + maxCount: 1, + showUploadList: false, + beforeUpload, + onChange: handleIconChange, + customRequest: async ({ file, onSuccess, onError }) => { + try { + const res = await Service.postMhUploadIcon({ + file: (file instanceof Blob ? file : new Blob([file])) as Blob, }) + onSuccess?.(res) } - }) - - xhr.send(formData) - return xhr + catch (err) { + onError?.(err as Error) + } + }, } const getActualUploadTasks = () => { @@ -293,8 +264,8 @@ const CreateModal = (props: any) => { } }) - deleteFile({ url: '/mh/delete_uploaded_file', body: { file_dir: uniqueId, filename: (file as RcFile).name } }).then((res) => { - message.success(res.message || '删除成功') + Service.postMhDeleteUploadedFile({ file_dir: uniqueId, filename: (file as RcFile).name }).then((res) => { + message.success(res?.message || '删除成功') // 删除文件后清空 model_dir 字段 form.setFieldValue('model_dir', '') @@ -349,104 +320,67 @@ const CreateModal = (props: any) => { formData.append('file_dir', uniqueId) chunkQueue.push( - limit(() => new Promise((resolve) => { - requestEvent({ - url: `${API_PREFIX}/mh/upload/chunk`, - formData, - options: { name: (file as RcFile).name, uid: (file as RcFile).uid, chunkId: `chunk-${i}` }, - onSuccess: (res) => { - resolve(res) - }, - onFail: ({ uid, chunkId, response }) => { - const { uploadTasks } = selfRef.current - const failTasks = uploadTasks[`${uid}-${chunkId}`] - - // 检查是否是权限错误 - if (response && (response.code === 'no_perm' || response.status === 403)) { - message.error(response.message || '没有权限,上传失败') - - // 清理所有上传任务和进度数据 - clearAllUploadData() - onClose() - return - } - - if (failTasks) { - selfRef.current.uploadTasks[`${uid}-${chunkId}`] = { - ...failTasks, - stateTag: '上传失败', - } + limit(() => new Promise((resolve, reject) => { + const uid = (file as RcFile).uid + const chunkId = `chunk-${i}` + const taskKey = `${uid}-${chunkId}` + Service.postMhUploadChunk({ + file: chunk as Blob, + file_name: (file as RcFile).name, + chunk_number: i, + total_chunks: totalChunks, + file_dir: uniqueId, + }).then(() => { + selfRef.current.uploadTasks[taskKey] = { + uid, + name: (file as RcFile).name, + progress: 1, + } + const { actualIds, actualInfo } = getActualUploadTasks() + const progressList = actualIds.map((val) => { + let _item: any = {} + let totalProgress = 0 + if (actualInfo[val]?.length > 0) { + actualInfo[val].forEach((v: any) => { + totalProgress += Number(v.progress || 0) + }) + totalProgress = (totalProgress / actualInfo[val].length * 100) + const currentMaxProgress = selfRef.current.maxProgress[val] || 0 + const displayProgress = Math.min(totalProgress, 99) + selfRef.current.maxProgress[val] = Math.max(currentMaxProgress, displayProgress) + _item = { ...actualInfo[val][0], progress: selfRef.current.maxProgress[val].toFixed(2), icon: } } - const { actualIds, actualInfo } = getActualUploadTasks() - const progressList = actualIds.map((val) => { - let _item: any = {} - if (actualInfo[val]?.length > 0) { - const { stateTag } = actualInfo[val].find(v => v.stateTag) || {} - _item = { ...actualInfo[val][0] } - - if (stateTag) - _item.stateTag = stateTag - } - return _item - }) - runProgressMonitor({ list: progressList }) - }, - onProgress: ({ uid, name, chunkId, percent }) => { - const taskKey = `${uid}-${chunkId}` - const existingProgress = selfRef.current.uploadTasks[taskKey]?.progress || 0 - - // 只有当新进度大于已有进度时才更新 - if (percent > existingProgress) { - selfRef.current.uploadTasks[taskKey] = { - uid, - name, - progress: percent, - } + return _item + }) + runProgressMonitor({ list: progressList }) + resolve() + }).catch((err: any) => { + const response = err?.body || err + if (response?.code === 'no_perm' || response?.status === 403) { + message.error(response?.message || '没有权限,上传失败') + clearAllUploadData() + onClose() + return + } + selfRef.current.uploadTasks[taskKey] = { + uid, + name: (file as RcFile).name, + progress: 0, + stateTag: '上传失败', + } + const { actualIds, actualInfo } = getActualUploadTasks() + const progressList = actualIds.map((val) => { + let _item: any = {} + if (actualInfo[val]?.length > 0) { + const { stateTag } = actualInfo[val].find((v: any) => v.stateTag) || {} + _item = { ...actualInfo[val][0], stateTag } } - - const { actualIds, actualInfo } = getActualUploadTasks() - - const progressList = actualIds.map((val) => { - let _item: any = {} - let totalProgress: any = 0 - if (actualInfo[val]?.length > 0) { - actualInfo[val].forEach((v: any) => { - totalProgress = (Number(totalProgress) + Number(v.progress)) - }) - totalProgress = (totalProgress / actualInfo[val].length * 100).toFixed(2) - - // 只有回退超过20%时才允许回退,小于20%的回退保持历史最高进度 - const currentMaxProgress = selfRef.current.maxProgress[val] || 0 - const calculatedProgress = Number(totalProgress) - const progressDiff = currentMaxProgress - calculatedProgress - - if (calculatedProgress >= currentMaxProgress) { - // 进度增长,正常更新 - // 如果已经是100%,保持100%;否则限制为99%(除非真正完成) - const displayProgress = (currentMaxProgress === 100) ? 100 : Math.min(calculatedProgress, 99) - selfRef.current.maxProgress[val] = displayProgress - totalProgress = displayProgress.toFixed(2) - } - else if (progressDiff > 20) { - // 超过20%的回退,允许回退 - // 但如果之前已经是100%,保持100% - const displayProgress = (currentMaxProgress === 100) ? 100 : Math.min(calculatedProgress, 99) - totalProgress = displayProgress.toFixed(2) - } - else { - // 20%以内的回退,保持历史最高进度 - totalProgress = currentMaxProgress.toFixed(2) - } - - _item = { ...actualInfo[val][0], progress: totalProgress, icon: } - } - return _item - }) - - runProgressMonitor({ list: progressList }) - }, + return _item + }) + runProgressMonitor({ list: progressList }) + reject(err) }) - }).then(() => { }, () => { })), + })), ) } @@ -455,12 +389,9 @@ const CreateModal = (props: any) => { await Promise.all(chunkQueue) // 通知后端合并文件 - await uploadMerge({ - url: '/mh/upload/merge', - body: { - filename: (file as RcFile).name, - file_dir: uniqueId, - }, + await Service.postMhUploadMerge({ + filename: (file as RcFile).name, + file_dir: uniqueId, }) // 上传真正完成,设置进度为100% @@ -532,8 +463,8 @@ const CreateModal = (props: any) => { if (value && value.trim() === '') return reject(new Error('输入不能仅包含空格')) - checkName({ url: '/mh/check/model_name', body: { model_name: value } }).then((res) => { - if (res.code == 200) + Service.postMhCheckModelName({ model_name: value }).then((res) => { + if (res?.code === 200) resolve(true) else reject(new Error('模型名字重复')) @@ -544,8 +475,8 @@ const CreateModal = (props: any) => { } const isNameUniqueB = (rule: any, value: string) => { return new Promise((resolve, reject) => { - checkName({ url: '/mh/check/model_name', body: { model_name: value, model_from: 'existModel' } }).then((res) => { - if (res.code == 200) + Service.postMhCheckModelName({ model_name: value, model_from: 'existModel' }).then((res) => { + if (res?.code === 200) resolve(true) else reject(new Error('该模型下已添加')) @@ -576,20 +507,7 @@ const CreateModal = (props: any) => { name="model_icon" label="图标" > - + {form.getFieldValue('model_icon') ? avatar : uploadButton} diff --git a/front/app/(appLayout)/modelWarehouse/modelManage/EditModel.tsx b/front/app/(appLayout)/modelWarehouse/modelManage/EditModel.tsx index 5c888ea..35d10f3 100644 --- a/front/app/(appLayout)/modelWarehouse/modelManage/EditModel.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelManage/EditModel.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react' import { Form, Input, Modal } from 'antd' -import { editModel } from '@/infrastructure/api/modelWarehouse' -import Toast from '@/app/components/base/flash-notice' +import { Service } from '@/infrastructure/api/generated' +import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' const ModalList = (props: any) => { const { visible, onClose, onSuccess, data } = props @@ -11,10 +11,15 @@ const ModalList = (props: any) => { }, [visible, data]) const handleOk = () => { form.validateFields().then((values) => { - editModel({ url: '/mh/update', body: { ...values, model_id: data.id } }).then(() => { - Toast.notify({ type: 'success', message: '设置成功' }) + Service.postMhUpdate({ + api_key: values.api_key, + model_id: String(data.id), + }).then(() => { + Toast.notify({ type: ToastTypeEnum.Success, message: '设置成功' }) onSuccess() form.resetFields() + }).catch((err: any) => { + Toast.notify({ type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '设置失败' }) }) }) } diff --git a/front/app/(appLayout)/modelWarehouse/modelManage/ModelListModal.tsx b/front/app/(appLayout)/modelWarehouse/modelManage/ModelListModal.tsx index ddeb39b..a10d641 100644 --- a/front/app/(appLayout)/modelWarehouse/modelManage/ModelListModal.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelManage/ModelListModal.tsx @@ -28,11 +28,11 @@ const ModelListModal = (componentProps: ModelListModalProps) => { } return ( - {renderModelList()} diff --git a/front/app/(appLayout)/modelWarehouse/modelManage/[id]/AddModal.tsx b/front/app/(appLayout)/modelWarehouse/modelManage/[id]/AddModal.tsx index bff4b3b..5e20c66 100644 --- a/front/app/(appLayout)/modelWarehouse/modelManage/[id]/AddModal.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelManage/[id]/AddModal.tsx @@ -5,12 +5,9 @@ import type { RcFile } from 'antd/es/upload/interface' import { ExclamationCircleOutlined, InboxOutlined } from '@ant-design/icons' // , QuestionCircleOutlined import { v4 as uuid4 } from 'uuid' import pLimit from 'p-limit' -import { createModel } from '@/infrastructure/api/modelAdjust' -import Toast from '@/app/components/base/flash-notice' +import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' +import { Service } from '@/infrastructure/api/generated' import { useModalContext } from '@/shared/hooks/modal-context' -import { API_PREFIX } from '@/app-specs' -import { getTagList } from '@/infrastructure/api/tagManage' -import { uploadMerge } from '@/infrastructure/api/modelWarehouse' // uploadChunk, import Iconfont from '@/app/components/base/iconFont' const { Dragger } = Upload @@ -27,14 +24,19 @@ const AddModal = (props: any) => { const [modelFrom, setModelFrom] = useState() const [modelPath, setModelPath] = useState('') const [existModels, setExistModels] = useState([]) - const handleOk = async () => { + const handleOk = () => { form.validateFields().then((values) => { - createModel({ url: '/mh/create_finetune', body: { ...values, model_type: 'local', base_model_id: id } }).then(() => { - Toast.notify({ type: 'success', message: '导入成功' }) + const body: any = { ...values, model_type: 'local', base_model_id: Number(id) } + if (body.model_from === 'huggingface') + body.model_from = 'hf' + if (body.model_from === 'modelscope') + body.model_from = 'ms' + Service.postMhCreateFinetune(body).then(() => { + Toast.notify({ type: ToastTypeEnum.Success, message: '导入成功' }) form.resetFields() onSuccess() - }).catch((err) => { - console.error(err) + }).catch((err: any) => { + Toast.notify({ type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '导入失败' }) }) }) } @@ -54,45 +56,13 @@ const AddModal = (props: any) => { setModelPath(options?.path) } const getExistModels = async () => { - const res: any = await getTagList({ url: '/mh/exist_model_list', options: { params: {} } }) + const res = await Service.getMhExistModelList() if (res) setExistModels(res) } useEffect(() => { visible && getExistModels() }, [visible]) - const requestEvent = ({ url, formData, options, onSuccess, onFail, onProgress }) => { - const xhr = new XMLHttpRequest() - const accessToken = localStorage.getItem('console_token') || '' - - xhr.open('POST', url, true) - // xhr.setRequestHeader('Content-Type', 'multipart/form-data') - xhr.setRequestHeader('Authorization', `Bearer ${accessToken}`) - xhr.onreadystatechange = () => { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - onSuccess && onSuccess(JSON.parse(xhr.response)) - } - else { - onFail && onFail({ - ...options, - response: JSON.parse(xhr.response), - }) - } - } - } - xhr.upload.addEventListener('progress', (event) => { - if (event.lengthComputable) { - onProgress && onProgress({ - ...options, - percent: event.loaded / event.total, - }) - } - }) - - xhr.send(formData) - } - const getActualUploadTasks = () => { const { uploadTasks } = selfRef.current const cacheData = {} @@ -108,7 +78,7 @@ const AddModal = (props: any) => { const uploadProps: UploadProps = { name: 'file', multiple: true, - customRequest: async ({ file, onProgress, onSuccess, onError }) => { + customRequest: async ({ file, onSuccess, onError }) => { const totalChunks = Math.ceil((file as RcFile).size / CHUNK_SIZE) const chunkQueue: any = [] const limit = pLimit(MAX_CONCURRENT_UPLOADS) @@ -117,83 +87,66 @@ const AddModal = (props: any) => { const start = i * CHUNK_SIZE const end = Math.min((file as RcFile).size, start + CHUNK_SIZE) const chunk = file.slice(start, end) - const formData = new FormData() - - formData.append('file', chunk) - formData.append('file_name', (file as RcFile).name) - formData.append('chunk_number', `${i}`) - formData.append('total_chunks', `${totalChunks}`) - formData.append('file_dir', uniqueId) - + const uid = (file as RcFile).uid + const chunkId = `chunk-${i}` + const taskKey = `${uid}-${chunkId}` chunkQueue.push( - limit(() => new Promise((resolve, reject) => { - requestEvent({ - url: `${API_PREFIX}/mh/upload/chunk`, - formData, - options: { name: (file as RcFile).name, uid: (file as RcFile).uid, chunkId: `chunk-${i}` }, - onSuccess: (res) => { - resolve(res) - }, - onFail: ({ uid, name, chunkId }) => { - const { uploadTasks } = selfRef.current - const failTasks = uploadTasks[`${uid}-${chunkId}`] - if (failTasks) { - selfRef.current.uploadTasks[`${uid}-${chunkId}`] = { - ...failTasks, - stateTag: '上传失败', - } + limit(() => new Promise((resolve, reject) => { + Service.postMhUploadChunk({ + file: chunk as Blob, + file_name: (file as RcFile).name, + chunk_number: i, + total_chunks: totalChunks, + file_dir: uniqueId, + }).then(() => { + selfRef.current.uploadTasks[taskKey] = { + uid, + name: (file as RcFile).name, + progress: 100, + } + const { actualIds, actualInfo } = getActualUploadTasks() + const progressList = actualIds.map((val) => { + let _item: any = {} + let totalProgress = 0 + if (actualInfo[val]?.length > 0) { + actualInfo[val].forEach((v: any) => { + totalProgress += Number(v.progress || 0) + }) + totalProgress = (totalProgress / actualInfo[val].length) + _item = { ...actualInfo[val][0], progress: totalProgress.toFixed(2), icon: } } - const { actualIds, actualInfo } = getActualUploadTasks() - const progressList = actualIds.map((val) => { - let _item: any = {} - if (actualInfo[val]?.length > 0) { - const { stateTag } = actualInfo[val].find(v => v.stateTag) || {} - _item = { ...actualInfo[val][0] } - - if (stateTag) - _item.stateTag = stateTag - } - return _item - }) - runProgressMonitor({ list: progressList }) - }, - onProgress: ({ uid, name, chunkId, percent }) => { - selfRef.current.uploadTasks[`${uid}-${chunkId}`] = { - uid, - name, - progress: percent, + return _item + }) + runProgressMonitor({ list: progressList }) + resolve() + }).catch(() => { + selfRef.current.uploadTasks[taskKey] = { + uid, + name: (file as RcFile).name, + progress: 0, + stateTag: '上传失败', + } + const { actualIds, actualInfo } = getActualUploadTasks() + const progressList = actualIds.map((val) => { + let _item: any = {} + if (actualInfo[val]?.length > 0) { + const { stateTag } = actualInfo[val].find((v: any) => v.stateTag) || {} + _item = { ...actualInfo[val][0], stateTag } } - - const { actualIds, actualInfo } = getActualUploadTasks() - - const progressList = actualIds.map((val) => { - let _item: any = {} - let totalProgress: any = 0 - if (actualInfo[val]?.length > 0) { - actualInfo[val].forEach((v: any) => { - totalProgress = (Number(totalProgress) + Number(v.progress)) - }) - totalProgress = (totalProgress / actualInfo[val].length * 100).toFixed(2) - _item = { ...actualInfo[val][0], progress: totalProgress, icon: } - } - return _item - }) - - runProgressMonitor({ list: progressList }) - }, + return _item + }) + runProgressMonitor({ list: progressList }) + reject(new Error('上传失败')) }) - }).then(() => { }, () => { })), + })), ) } try { await Promise.all(chunkQueue) - await uploadMerge({ - url: '/mh/upload/merge', - body: { - filename: (file as RcFile).name, - file_dir: uniqueId, - }, + await Service.postMhUploadMerge({ + filename: (file as RcFile).name, + file_dir: uniqueId, }) onSuccess && onSuccess('Upload complete') @@ -203,7 +156,7 @@ const AddModal = (props: any) => { onError && onError(error) } }, - beforeUpload: (file) => { + beforeUpload: () => { oepnProgressMonitor({ title: '模型上传' }) return true }, diff --git a/front/app/(appLayout)/modelWarehouse/modelManage/[id]/AddModelList.tsx b/front/app/(appLayout)/modelWarehouse/modelManage/[id]/AddModelList.tsx index 745d835..af9a511 100644 --- a/front/app/(appLayout)/modelWarehouse/modelManage/[id]/AddModelList.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelManage/[id]/AddModelList.tsx @@ -1,45 +1,39 @@ import React, { useEffect, useState } from 'react' import { Button, Form, Input, Modal, Select, Space } from 'antd' import { DeleteOutlined, PlusOutlined } from '@ant-design/icons' -import Toast from '@/app/components/base/flash-notice' -import { getTagList, updateList } from '@/infrastructure/api/tagManage' +import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' +import { Service } from '@/infrastructure/api/generated' const { Option } = Select -enum EKind { - 'OnlineLLM' = 'llm_list', - 'Embedding' = 'embedding_list', - 'reranker' = 'rerank_list', -} + const AddModal = (props: any) => { const { visible, onClose, id, baseInfo, getInfo, qtype, isMine } = props const [form] = Form.useForm() - const [temps, setTemps] = useState([]) const [origin, setOrigin] = useState([]) - const getmodels = async () => { - const res: any = await getTagList({ url: '/mh/online_model_support_list', options: { params: {} } }) - if (res) - setTemps(res[baseInfo?.model_brand][EKind[baseInfo?.model_kind]]) - } - useEffect(() => { - visible && getmodels() - }, [visible]) - const fixData = (data) => { + + const fixData = (data: any) => { return data?.map((item) => { return { ...item, can_finetune: item?.can_finetune ? 1 : 0 } }) } useEffect(() => { setOrigin(fixData(baseInfo?.model_list)) - }, [visible, baseInfo.model_list]) - const handleOk = async () => { + }, [visible, baseInfo?.model_list]) + const handleOk = () => { form.validateFields().then((values) => { - updateList({ url: '/mh/update_online_model_list', body: { ...values, qtype, namespace: isMine } }).then(() => { - Toast.notify({ type: 'success', message: '操作成功' }) - // form.resetFields() + Service.postMhUpdateOnlineModelList( + { + base_model_id: Number(id), + model_list: fixData(values.model_list), + namespace: isMine, + } as any, + qtype || 'already', + ).then(() => { + Toast.notify({ type: ToastTypeEnum.Success, message: '操作成功' }) onClose() getInfo() - }).catch((err) => { - console.error(err) + }).catch((err: any) => { + Toast.notify({ type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '操作失败' }) }) }) } @@ -49,11 +43,6 @@ const AddModal = (props: any) => { form.resetFields() } - const onModelKeyChange = (value, option, index) => { - const temp = form.getFieldValue('model_list') - temp[index].can_finetune = option.support_finetune ? 1 : 0 - form.setFieldValue('model_list', temp) - } return ( { {(fields, { add, remove }) => ( <> - {fields.map(({ key, name, ...restField }, index) => ( + {fields.map(({ key, name, ...restField }) => ( { rules={[{ required: true, message: '请选择模型' }]} > - {/* */} { existModel: '已有模型导入', } return ( - + {/* */} {baseInfo?.model_name && } diff --git a/front/app/(appLayout)/modelWarehouse/modelManage/[id]/page.tsx b/front/app/(appLayout)/modelWarehouse/modelManage/[id]/page.tsx index 7a0c7df..7062777 100644 --- a/front/app/(appLayout)/modelWarehouse/modelManage/[id]/page.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelManage/[id]/page.tsx @@ -9,8 +9,7 @@ import DrawInfo from './DrawInfo' import AddModal from './AddModal' import AddModelList from './AddModelList' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' -import { getModelInfo, reDown } from '@/infrastructure/api/modelWarehouse' -import { deleteModel, getModelList } from '@/infrastructure/api/modelAdjust' +import { Service } from '@/infrastructure/api/generated' import { useApplicationContext } from '@/shared/hooks/app-context' import { usePermitCheck } from '@/app/components/app/permit-check' @@ -50,10 +49,16 @@ const ModelDetail = (req) => { } const getTableData = ({ current, pageSize }): Promise => { - return getModelList({ url: '/mh/finetune_model_page', body: { page: current, page_size: pageSize, model_id: id, online_model_id: type, qtype, namespace: isMine } }).then((res) => { + return Service.postMhFinetuneModelPage({ + page: current, + page_size: pageSize, + model_id: String(id), + online_model_id: type, + qtype: qtype as 'mine' | 'group' | 'builtin' | 'already', + }).then((res) => { return { - total: res.total, - list: res.data, + total: res?.total ?? 0, + list: res?.data ?? [], } }) } @@ -69,7 +74,7 @@ const ModelDetail = (req) => { manual: true, }) const getInfo = () => { - getModelInfo({ url: `mh/model_info/${id}`, options: { params: { qtype, namespace: isMine } } }).then((res) => { + Service.getMhModelInfo(Number(id), qtype || 'mine', isMine || 'already').then((res) => { setBaseInfo(res) if (res?.models?.length > 0) setType(res?.models[0]?.id) @@ -81,18 +86,21 @@ const ModelDetail = (req) => { getInfo() }, [id]) const handleDelete = async (record) => { - const res = await deleteModel({ url: `/mh/delete_finetune_model/${id}/${record?.id}` }) - if (res) { + try { + await Service.deleteMhDeleteFinetuneModel(Number(id), Number(record?.id)) Toast.notify({ type: ToastTypeEnum.Success, message: '删除成功' }) search.submit() } + catch (err: any) { + Toast.notify({ type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '删除失败' }) + } } const reDownload = () => { - reDown({ url: `/mh/retry_download/${id}` }).then((res) => { - if (res) { - Toast.notify({ type: ToastTypeEnum.Success, message: '操作成功' }) - getInfo() - } + Service.getMhRetryDownload(Number(id)).then(() => { + Toast.notify({ type: ToastTypeEnum.Success, message: '操作成功' }) + getInfo() + }).catch((err: any) => { + Toast.notify({ type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '操作失败' }) }) } const handleAddSuccess = () => { diff --git a/front/app/(appLayout)/modelWarehouse/modelManage/page.tsx b/front/app/(appLayout)/modelWarehouse/modelManage/page.tsx index b833a12..e3c5a44 100644 --- a/front/app/(appLayout)/modelWarehouse/modelManage/page.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelManage/page.tsx @@ -12,7 +12,7 @@ import styles from './page.module.scss' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' import HoverGuide from '@/app/components/base/hover-tip-pro' import IconFont from '@/app/components/base/iconFont' -import { deleteModel, getModelListNew } from '@/infrastructure/api/modelWarehouse' +import { Service } from '@/infrastructure/api/generated' import { useApplicationContext } from '@/shared/hooks/app-context' import { usePermitCheck } from '@/app/components/app/permit-check' import TagMode from '@/app/components/tagSelect/TagMode' @@ -20,9 +20,9 @@ import useRadioAuth from '@/shared/hooks/use-radio-auth' import useValidateSpace from '@/shared/hooks/use-validate-space' import { pageCache } from '@/shared/utils' -const TagContainer = ({ tags }) => { - const wrapperRef = useRef(null) - const [visibleTags, setVisibleTags] = useState([]) +const TagContainer = ({ tags }: { tags: string[] }) => { + const wrapperRef = useRef(null) + const [visibleTags, setVisibleTags] = useState([]) useLayoutEffect(() => { const calculateVisibleTags = () => { @@ -79,7 +79,7 @@ const ModelWarehouse = () => { const [kind, setKind] = React.useState('all') const { validate } = useValidateSpace() - const [list, setList] = useState([]) + const [list, setList] = useState([]) const [showModelList, setShowModelList] = useState(false) const [showCreateModule, setShowCreateModule] = useState(false) const [showEditModule, setShowEditModule] = useState(false) @@ -98,8 +98,18 @@ const ModelWarehouse = () => { const getCardList = useCallback(async () => { setLoading(true) try { - const res = await getModelListNew({ url: '/mh/list', body: { page: '1', page_size: '9999', model_type: type === 'all' ? '' : type, model_kind: kind === 'all' ? '' : kind, status: dValue, search_tags: selectTags?.map(item => item?.name), available: tValue === 'all' ? -1 : tValue, search_name: sName } }) - setList(res.data) + const res = await Service.postMhList({ + page: 1, + page_size: 9999, + model_type: type === 'all' ? '' : type, + model_kind: kind === 'all' ? '' : kind, + status: dValue, + search_tags: selectTags?.map((item: any) => item?.name), + available: tValue === 'all' ? -1 : tValue, + search_name: sName, + qtype: category as 'mine' | 'group' | 'builtin' | 'already', + }) + setList(res?.data || []) } finally { setLoading(false) } }, [type, category, sName, sValue, tValue, kind, dValue, selectTags]) @@ -110,9 +120,14 @@ const ModelWarehouse = () => { } const handleDelete = async (item: any, e) => { e.stopPropagation() - await deleteModel({ url: '/mh/delete', body: { model_id: item.id, qtype: category, namespace: isMine } }) - Toast.notify({ type: ToastTypeEnum.Success, message: '删除成功' }) - getCardList() + try { + await Service.postMhDelete({ model_id: String(item.id) }, category) + Toast.notify({ type: ToastTypeEnum.Success, message: '删除成功' }) + getCardList() + } + catch (err: any) { + Toast.notify({ type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '删除失败' }) + } } const onChange = ({ target: { value } }: RadioChangeEvent) => { pageCache.setTab({ name: pageCache.category.modelKind, key: value }) @@ -250,7 +265,7 @@ const ModelWarehouse = () => {
- {list && list.length > 0 + {(list && list.length > 0) ? ( {list.map((item: any) => ( @@ -318,7 +333,7 @@ const ModelWarehouse = () => { title="提示" description="是否确认删除" onConfirm={e => handleDelete(item, e)} - onCancel={e => e.stopPropagation()} + onCancel={e => e?.stopPropagation()} okText="是" cancelText="否" > diff --git a/front/app/(appLayout)/modelWarehouse/modelTest/[id]/aiDimension/page.tsx b/front/app/(appLayout)/modelWarehouse/modelTest/[id]/aiDimension/page.tsx index 375f1a8..5b618d3 100644 --- a/front/app/(appLayout)/modelWarehouse/modelTest/[id]/aiDimension/page.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelTest/[id]/aiDimension/page.tsx @@ -7,7 +7,7 @@ import Link from 'next/link' import InfoTitle from '../../../components/InfoTitle' import styles from './index.module.scss' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' -import { getAdjustInfo, getResultInfo, saveChoose } from '@/infrastructure/api/modelTest' +import { Service } from '@/infrastructure/api/generated' const Dimension = (req) => { const { id } = req.params @@ -22,47 +22,53 @@ const Dimension = (req) => { // 获取参数值 const option_select_id = searchParams.get('option_id') const getInfo = useCallback(() => { - getAdjustInfo({ url: `/model_evalution/task_info/${id}` }).then((res) => { + Service.getModelEvalutionTaskInfo(Number(id)).then((res) => { setBaseInfo(res?.result?.task_info) }) }, [id]) - const getLeftInfo = () => { + const getLeftInfo = useCallback(() => { setSpinning(true) - getResultInfo({ url: `/model_evalution/evaluation_data/${id}`, options: { params: { page } } }).then((res) => { - setResultInfo(res?.result?.data) - setMaxPage(res?.result?.total_pages || 1) - if (res?.result?.data?.evaluations.length > 0) - form.setFieldValue('evaluations', res?.result?.data?.evaluations) + const optionId = (option_select_id && option_select_id !== 'view') ? Number(option_select_id) : undefined + Service.getModelEvalutionEvaluationData(Number(id), page, optionId).then((res) => { + const data = res?.result?.data ?? res?.result + setResultInfo(data) + setMaxPage(res?.result?.total_pages ?? 1) + if (data?.evaluations?.length > 0) + form.setFieldValue('evaluations', data.evaluations) }).finally(() => { setSpinning(false) }) - } + }, [id, page, option_select_id, form]) - const getRightInfo = () => { - getAdjustInfo({ url: `/model_evalution/get_evaluation_dimensions/${id}` }).then((res) => { + const getRightInfo = useCallback(() => { + Service.getModelEvalutionGetEvaluationDimensions(Number(id)).then((res) => { setRightInfo(res?.result) }) - } + }, [id]) useEffect(() => { getInfo() }, [getInfo]) useEffect(() => { getLeftInfo() - }, [page]) + }, [getLeftInfo]) useEffect(() => { getRightInfo() - }, []) + }, [getRightInfo]) const handleOk = () => { form.validateFields().then((values) => { - saveChoose({ url: '/model_evalution/evaluate_save', body: { ...values, task_id: +id, data_id: resultInfo?.id } }).then((res) => { - if (res.status === 500) { + Service.postModelEvalutionEvaluateSave({ + ...values, + task_id: Number(id), + data_id: resultInfo?.id, + }).then((res: any) => { + if (res?.status === 500 || res?.code === 500) { Toast.notify({ - type: ToastTypeEnum.Error, message: res?.message, + type: ToastTypeEnum.Error, message: res?.message || '保存失败', }) } - if (res?.status === 0) { + else { Toast.notify({ type: ToastTypeEnum.Success, message: '保存成功', }) @@ -73,6 +79,10 @@ const Dimension = (req) => { form.resetFields() } } + }).catch((err: any) => { + Toast.notify({ + type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '保存失败', + }) }) }) } diff --git a/front/app/(appLayout)/modelWarehouse/modelTest/[id]/dimension/page.tsx b/front/app/(appLayout)/modelWarehouse/modelTest/[id]/dimension/page.tsx index 2a6d269..68be39f 100644 --- a/front/app/(appLayout)/modelWarehouse/modelTest/[id]/dimension/page.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelTest/[id]/dimension/page.tsx @@ -8,7 +8,7 @@ import Link from 'next/link' import InfoTitle from '../../../components/InfoTitle' import styles from './index.module.scss' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' -import { getAdjustInfo, getResultInfo, saveChoose } from '@/infrastructure/api/modelTest' +import { Service } from '@/infrastructure/api/generated' const Dimension = (req) => { const { id } = req.params @@ -24,25 +24,27 @@ const Dimension = (req) => { // 获取参数值 const option_select_id = searchParams.get('option_id') const getInfo = useCallback(() => { - getAdjustInfo({ url: `/model_evalution/task_info/${id}` }).then((res) => { + Service.getModelEvalutionTaskInfo(Number(id)).then((res) => { setBaseInfo(res?.result?.task_info) }) }, [id]) const getLeftInfo = () => { setSpinning(true) - getResultInfo({ url: `/model_evalution/evaluation_data/${id}`, options: { params: { page, option_select_id: option_select_id === 'view' ? '' : option_select_id } } }).then((res) => { - setResultInfo(res?.result?.data) - setMaxPage(res?.result?.total_pages || 1) - if (res?.result?.data?.evaluations.length > 0) - form.setFieldValue('evaluations', res?.result?.data?.evaluations) + const optionId = (option_select_id && option_select_id !== 'view') ? Number(option_select_id) : undefined + Service.getModelEvalutionEvaluationData(Number(id), page, optionId).then((res) => { + const data = res?.result?.data ?? res?.result + setResultInfo(data) + setMaxPage(res?.result?.total_pages ?? 1) + if (data?.evaluations?.length > 0) + form.setFieldValue('evaluations', data.evaluations) }).finally(() => { setSpinning(false) }) } const getRightInfo = () => { - getAdjustInfo({ url: `/model_evalution/get_evaluation_dimensions/${id}` }).then((res) => { + Service.getModelEvalutionGetEvaluationDimensions(Number(id)).then((res) => { setRightInfo(res?.result) }) } @@ -61,13 +63,17 @@ const Dimension = (req) => { } const handleOk = () => { form.validateFields().then((values) => { - saveChoose({ url: '/model_evalution/evaluate_save', body: { ...values, task_id: +id, data_id: resultInfo?.id } }).then((res) => { - if (res.status === 500) { + Service.postModelEvalutionEvaluateSave({ + ...values, + task_id: Number(id), + data_id: resultInfo?.id, + }).then((res: any) => { + if (res?.status === 500 || res?.code === 500) { Toast.notify({ - type: ToastTypeEnum.Error, message: res?.message, + type: ToastTypeEnum.Error, message: res?.message || '保存失败', }) } - if (res?.status === 0) { + else { Toast.notify({ type: ToastTypeEnum.Success, message: '保存成功', }) @@ -78,6 +84,10 @@ const Dimension = (req) => { form.resetFields() } } + }).catch((err: any) => { + Toast.notify({ + type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '保存失败', + }) }) }) } diff --git a/front/app/(appLayout)/modelWarehouse/modelTest/[id]/testReport/page.tsx b/front/app/(appLayout)/modelWarehouse/modelTest/[id]/testReport/page.tsx index ad67d13..ca9683c 100644 --- a/front/app/(appLayout)/modelWarehouse/modelTest/[id]/testReport/page.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelTest/[id]/testReport/page.tsx @@ -5,14 +5,14 @@ import { useRouter } from 'next/navigation' import Link from 'next/link' import InfoTitle from '../../../components/InfoTitle' import styles from './index.module.scss' -import { getAdjustInfo } from '@/infrastructure/api/modelAdjust' +import { Service } from '@/infrastructure/api/generated' const Dimension = (req) => { const { id } = req.params const router = useRouter() const [reportInfo, setReportInfo] = useState({}) const getReportInfo = useCallback(() => { - getAdjustInfo({ url: `/model_evalution/evaluation_summary/${id}` }).then((res) => { + Service.getModelEvalutionEvaluationSummary(Number(id)).then((res) => { setReportInfo(res?.result) }) }, [id]) diff --git a/front/app/(appLayout)/modelWarehouse/modelTest/[id]/testResult/page.tsx b/front/app/(appLayout)/modelWarehouse/modelTest/[id]/testResult/page.tsx index 65636ef..f492223 100644 --- a/front/app/(appLayout)/modelWarehouse/modelTest/[id]/testResult/page.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelTest/[id]/testResult/page.tsx @@ -5,14 +5,18 @@ import Link from 'next/link' import InfoTitle from '../../../components/InfoTitle' import styles from './index.module.scss' -import { getAdjustInfo } from '@/infrastructure/api/modelAdjust' +import { Service } from '@/infrastructure/api/generated' const TestResult = (req) => { const { id } = req.params const [baseInfo, setBaseInfo] = useState({}) const getInfo = useCallback(() => { - getAdjustInfo({ url: `/finetune/detail/${id}` }).then((res) => { - setBaseInfo(res) + Service.getModelEvalutionTaskInfo(Number(id)).then((res) => { + const taskInfo = res?.result?.task_info + setBaseInfo({ + ...taskInfo, + created_from_info: taskInfo?.username, + }) }) }, [id]) diff --git a/front/app/(appLayout)/modelWarehouse/modelTest/create/page.tsx b/front/app/(appLayout)/modelWarehouse/modelTest/create/page.tsx index f748c5e..88b65a1 100644 --- a/front/app/(appLayout)/modelWarehouse/modelTest/create/page.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelTest/create/page.tsx @@ -9,7 +9,7 @@ import InfoTitle from '../../../modelAdjust/components/InfoTitle' import ModelTreeSelect from '../../components/modelTreeSelect' import styles from './index.module.scss' import Iconfont from '@/app/components/base/iconFont' -import { createModel, getBaseModelList, getModelListDraw } from '@/infrastructure/api/modelAdjust' +import { Service } from '@/infrastructure/api/generated' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' import { noOnlySpacesRule } from '@/shared/utils' @@ -31,27 +31,20 @@ const templateMap = [ ] const ModelTestCreate = () => { const router = useRouter() - const token = localStorage.getItem('console_token') const [baseForm] = Form.useForm() const [options] = useState([{ option_name: '', option_value: '' }, { option_name: '', option_value: '' }, { option_name: '', option_value: '' }]) const [roundData] = useState([{ dimension_name: '', dimension_description: '' }]) const [aiRoundData] = useState([{ dimension_name: '', dimension_description: '', ai_base_score: '', choose_num: 3 }]) const [aiOptions] = useState([{ option_name: '' }, { option_name: '' }, { option_name: '' }]) - const [modelList, setModelList] = useState([]) - const [datasetList, setDatasetList] = useState([]) + const [modelList, setModelList] = useState([]) + const [datasetList, setDatasetList] = useState([]) const [evaluation_type, setDatasetType] = useState('online') const [testType, setTestType] = useState('manual') const getMList = async () => { - const res: any = await getModelListDraw({ - url: '/infer-service/list/draw', - body: { - qtype: 'already', - available: 1, - model_kind: 'localLLM', - }, - }) + const res: any = await Service.getInferServiceListDraw('localLLM') if (res) { - const temp: any = res?.result?.result?.map((item) => { + const result = res?.result?.result || res?.data?.result + const temp: any = result?.map((item) => { const serviceId = item?.services?.[0]?.id return { @@ -67,9 +60,9 @@ const ModelTestCreate = () => { } } const getDataset = async () => { - const res: any = await getBaseModelList({ url: '/model_evalution/all_online_datasets', options: {} }) + const res = await Service.getModelEvalutionAllOnlineDatasets() if (res) - setDatasetList(res?.result) + setDatasetList(res?.result || []) } useEffect(() => { getMList() @@ -94,20 +87,17 @@ const ModelTestCreate = () => { if (ai_evaluator_name?.[1]) values.ai_evaluator_name = ai_evaluator_name[1] - createModel({ url: '/model_evalution/create_task', body: { ...values } }).then((res) => { - if (res.status === 500 || res.status === 400) { - Toast.notify({ - type: ToastTypeEnum.Error, message: res?.message, - }) - } - else { - Toast.notify({ - type: ToastTypeEnum.Success, message: '创建成功', - }) - setTimeout(() => { - router.push('/modelWarehouse/modelTest') - }, 1000) - } + Service.postModelEvalutionCreateTask({ ...values }).then((_res) => { + Toast.notify({ + type: ToastTypeEnum.Success, message: '创建成功', + }) + setTimeout(() => { + router.push('/modelWarehouse/modelTest') + }, 1000) + }).catch((err: any) => { + Toast.notify({ + type: ToastTypeEnum.Error, message: err?.body?.message || err?.message || '创建失败', + }) }) }) } @@ -159,10 +149,25 @@ const ModelTestCreate = () => { } const uploadProps: any = { name: 'files', - action: '/console/api/model_evalution/upload_dataset', - headers: { Authorization: `Bearer ${token}` }, accept: ['.json', '.xlsx', '.xls', '.csv', '.zip', '.gz', 'tar'], multiple: true, + customRequest: async ({ file, onSuccess, onError }) => { + const rawFile = file as any + const originFile = rawFile?.originFileObj || rawFile + try { + const res = await Service.postModelEvalutionUploadDataset({ + files: originFile, + }) + onSuccess?.({ + status: 0, + result: res?.result, + }) + } + catch (err: any) { + onError?.(err) + message.error(err?.body?.message || err?.message || `${rawFile?.name || '文件'} 上传失败`) + } + }, onChange: (info) => { const { file, fileList } = info // 更新文件列表,过滤掉上传失败的文件 @@ -306,7 +311,41 @@ const ModelTestCreate = () => {
1. 为json、csv、xlsx格式文件或包含上述文件类型的tar.gz、zip压缩包文件上传
2.文件大小在1G以内
3.模板示例:{templateMap.map((item, index) => { - return {item.name} + return { + e.preventDefault() + try { + const res = await Service.getModelEvalutionEvaluationDatasettplDownload(item.url as 'json' | 'csv' | 'xlsx') + const blob = res instanceof Blob + ? res + : new Blob( + [ + typeof res === 'string' + ? res + : JSON.stringify(res, null, 2), + ], + { + type: item.url === 'csv' + ? 'text/csv;charset=utf-8' + : 'application/json;charset=utf-8', + }, + ) + const url = window.URL.createObjectURL(blob) + const a = document.createElement('a') + a.href = url + a.download = `${item.name}模板.${item.url}` + document.body.appendChild(a) + a.click() + window.URL.revokeObjectURL(url) + document.body.removeChild(a) + } + catch (err) { + message.error('下载模板失败') + } + }} + >{item.name} })}
)} rules={[{ required: true, message: '请上传文件' }]} diff --git a/front/app/(appLayout)/modelWarehouse/modelTest/page.tsx b/front/app/(appLayout)/modelWarehouse/modelTest/page.tsx index 1daf8e2..cc3f8ec 100644 --- a/front/app/(appLayout)/modelWarehouse/modelTest/page.tsx +++ b/front/app/(appLayout)/modelWarehouse/modelTest/page.tsx @@ -7,9 +7,8 @@ import { useAntdTable } from 'ahooks' import { useRouter } from 'next/navigation' import styles from './index.module.scss' import useRadioAuth from '@/shared/hooks/use-radio-auth' -import Toast from '@/app/components/base/flash-notice' -import { deleteTest, getTestList } from '@/infrastructure/api/modelTest' -import { apiPrefix } from '@/app-specs' +import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' +import { Service } from '@/infrastructure/api/generated' type DataType = { key: string @@ -42,17 +41,12 @@ const ModelAdjust = () => { const pollTimerRef = useRef(null) const getTableData = ({ current, pageSize }, formData): Promise => { - return getTestList({ - url: '/model_evalution/list', - options: { - params: { - page: current, - per_page: pageSize, - keyword: formData.name || '', - qtype: authValue, - } as any, - }, - }) + return Service.getModelEvalutionList( + current, + pageSize, + formData.name || '', + authValue, + ) .then((res: any) => { return { total: res?.result?.total, @@ -115,16 +109,10 @@ const ModelAdjust = () => { const handleDownload = async (record) => { const token = window.localStorage.getItem('console_token') try { - const response = await fetch(`${apiPrefix}/model_evalution/evaluation_summary_download/${record?.id}?token=${token}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - - if (!response.ok) - throw new Error(`下载失败: ${response.status}`) - - const blob = await response.blob() + const blob = await Service.getModelEvalutionEvaluationSummaryDownload( + record?.id, + token || undefined, + ) const url = window.URL.createObjectURL(blob) const a = document.createElement('a') a.href = url @@ -136,14 +124,14 @@ const ModelAdjust = () => { } catch (error) { console.error('下载出错:', error) - Toast.notify({ type: 'error', message: '下载失败,请稍后重试' }) + Toast.notify({ type: ToastTypeEnum.Error, message: '下载失败,请稍后重试' }) } } const handleDelete = async (record) => { - const res = await deleteTest({ url: `/model_evalution/delete_task/${record?.id}` }) + const res = await Service.postModelEvalutionDeleteTask(record?.id) if (res) { - Toast.notify({ type: 'success', message: '删除成功' }) + Toast.notify({ type: ToastTypeEnum.Success, message: '删除成功' }) search.submit() } } diff --git a/front/app/(appLayout)/prompt/page.tsx b/front/app/(appLayout)/prompt/page.tsx index 8aae3c3..762105d 100644 --- a/front/app/(appLayout)/prompt/page.tsx +++ b/front/app/(appLayout)/prompt/page.tsx @@ -9,39 +9,33 @@ import style from './page.module.scss' import Iconfont from '@/app/components/base/iconFont' import useRadioAuth from '@/shared/hooks/use-radio-auth' import TagSelect from '@/app/components/tagSelect' -import { bindTags } from '@/infrastructure/api/tagManage' import TagMode from '@/app/components/tagSelect/TagMode' import CreatorSelect from '@/app/components/tagSelect/creatorSelect' import { useApplicationContext } from '@/shared/hooks/app-context' -import { createPrompt, deletePrompt, getAdjustList, getPromptDetail } from '@/infrastructure/api/prompt' -import { pageCache } from '@/shared/utils' +import { PromptService, Service } from '@/infrastructure/api/generated' import AIPromptModal from '@/app/components/AIPromptModal' import { usePermitContext } from '@/shared/hooks/permit-context' const Prompt = () => { const [form] = Form.useForm() const authRadio = useRadioAuth() - const [value, setValue] = useState(pageCache.getTab({ name: pageCache.category.promptBelong }) || 'prompt') const { statusAi } = usePermitContext() const [id, setId] = useState('') const [title, setTitle] = useState('新建Prompt') const [isEdit, setIsEdit] = useState(false) const [isView, setIsView] = useState(false) - const [isCopy, setIsCopy] = useState(false) const [isModalOpen, setIsModalOpen] = useState(false) - const [icon, setIcon] = useState(p1) + const [icon] = useState(p1) const [list, setList] = useState([]) const [btnLoading, setBtnLoading] = useState(false) const [loading, setLoading] = useState(false) const [haveMore, setHaveMore] = useState(true) const [pageOption, setPageOption] = useState({ page: 1, per_page: 16 }) - const [promptType, setPromptType] = useState<'string' | 'dict'>('string') const [searchVal, setSearchVal] = useState('') const [sName, setSName] = useState('') const [creator, setCreator] = useState([]) as any const [selectTags, setSelectTags] = useState([]) as any const [refreshFlag, setRefreshFlag] = useState(false) const [tagSelectKey, setTagSelectKey] = useState(0) - const isPrompt = value == 'prompt' const selectRef: any = useRef() const { userSpecified } = useApplicationContext() const [isAIModalOpen, setIsAIModalOpen] = useState(false) @@ -53,27 +47,23 @@ const Prompt = () => { }, [isModalOpen]) const getList = async (flag: any, page) => { - const url = isPrompt ? '/prompt/list' : '/prompt-template/list' - const param: any = { - ...pageOption, - page, - per_page: 16, - search_tags: selectTags?.map(item => item.name), - user_id: creator, - search_name: sName, - } setLoading(true) try { - const res: any = await getAdjustList({ - url, - body: param, + const res = await PromptService.postPromptList({ + page, + per_page: 16, + search_tags: selectTags?.map(item => item.name), + user_id: Array.isArray(creator) ? creator : (creator ? [creator] : []), + search_name: sName, }) - if (res?.result) { - const { templates = [], next_page, prompts = [] } = res?.result + const data = res?.data ?? (res as any)?.result + if (data) { + const prompts = data.prompts ?? [] + const next_page = data.next_page if (flag === 1) - setList([...templates, ...prompts]) + setList(prompts) else - setList([...list, ...templates, ...prompts]) + setList([...list, ...prompts]) if (!next_page) setHaveMore(false) @@ -81,6 +71,9 @@ const Prompt = () => { setHaveMore(true) } } + catch (error) { + console.error('获取列表失败:', error) + } finally { setLoading(false) } @@ -91,7 +84,7 @@ const Prompt = () => { useUpdateEffect(() => { getList(1, 1) - }, [value, sName, creator, selectTags, refreshFlag]) + }, [sName, creator, selectTags, refreshFlag]) const syncSystemContentFromForm = () => { setSystemContent(form.getFieldValue('system') || '') } @@ -100,33 +93,42 @@ const Prompt = () => { e.stopPropagation() setIsView(false) setIsEdit(true) - setIsCopy(false) setId(item?.id) - setTitle(isPrompt ? '编辑Prompt' : '编辑Prompt 模版') - const url = isPrompt ? `/prompt/${item?.id}` : `/prompt-template/${item?.id}` - const res: any = await getPromptDetail({ url }) - if (res?.status === 0) { - const { result } = res + setTitle('编辑Prompt') + setTagSelectKey(prev => prev + 1) + setIsModalOpen(true) + try { + const id = item?.id != null ? Number(item.id) : item?.id + if (id == null || Number.isNaN(id)) { + message.warning('无法获取该 Prompt 的 ID') + return + } + const res: any = await PromptService.getPrompt(id) + const resultData = res?.data ?? res?.result + if (!resultData) { + message.warning('获取详情失败,请重试') + return + } const currentData: any = { - name: result?.name, - describe: result?.describe, - content: result?.content, - tag_names: item?.tags, + name: resultData?.name, + describe: resultData?.describe, + content: resultData?.content, + tag_names: item?.tags ?? [], } - // 解析角色内容 try { - currentData.system = JSON.parse(result?.content)?.find((item: any) => item.role === 'system')?.content?.trim() || '' - currentData.user = JSON.parse(result?.content)?.find((item: any) => item.role === 'user')?.content?.trim() || '' + currentData.system = JSON.parse(resultData?.content || '[]')?.find((x: any) => x.role === 'system')?.content?.trim() || '' + currentData.user = JSON.parse(resultData?.content || '[]')?.find((x: any) => x.role === 'user')?.content?.trim() || '' } - catch (error) { + catch { currentData.system = '' currentData.user = '' } - form.setFieldsValue({ - ...currentData, - }) + form.setFieldsValue({ ...currentData }) syncSystemContentFromForm() - setIsModalOpen(true) + } + catch (err) { + console.error('获取详情失败:', err) + message.error('获取详情失败,请重试') } } @@ -134,26 +136,24 @@ const Prompt = () => { e.stopPropagation() setIsView(false) setIsEdit(false) - setIsCopy(true) setId('') - setTitle(isPrompt ? '复制Prompt' : '复制Prompt 模版') - const url = isPrompt ? `/prompt/${item?.id}` : `/prompt-template/${item?.id}` - const res: any = await getPromptDetail({ url }) - if (res?.status === 0) { - const { result } = res + setTitle('复制Prompt') + try { + const res: any = await PromptService.getPrompt(Number(item?.id)) + const result = res?.data ?? res?.result + if (!result) + return let systemContent = '' let userContent = '' - try { const contentArray = JSON.parse(result?.content || '[]') - systemContent = contentArray.find((item: any) => item.role === 'system')?.content?.trim() || '' - userContent = contentArray.find((item: any) => item.role === 'user')?.content?.trim() || '' + systemContent = contentArray.find((x: any) => x.role === 'system')?.content?.trim() || '' + userContent = contentArray.find((x: any) => x.role === 'user')?.content?.trim() || '' } - catch (error) { + catch { systemContent = '' userContent = '' } - const currentData = { name: `${result?.name}`, describe: result?.describe, @@ -162,68 +162,69 @@ const Prompt = () => { user: userContent, tag_names: item?.tags, } - form.setFieldsValue(currentData) setSystemContent(systemContent) setIsModalOpen(true) } + catch (err) { + console.error('获取详情失败:', err) + } } const viewDetail = async (item: any) => { setIsView(true) setIsEdit(false) - setIsCopy(false) setId(item?.id) - setTitle(isPrompt ? '查看Prompt' : '查看Prompt 模版') - const url = isPrompt ? `/prompt/${item?.id}` : `/prompt-template/${item?.id}` - const res: any = await getPromptDetail({ url }) - if (res?.status === 0) { - const { result } = res - + setTitle('查看Prompt') + try { + const res: any = await PromptService.getPrompt(Number(item?.id)) + const result = res?.data ?? res?.result + if (!result) + return const currentData: any = { name: result?.name, describe: result?.describe, content: result?.content, - tag_names: item?.tags, + tag_names: item?.tags ?? [], } - - // 解析角色内容 try { - currentData.system = JSON.parse(result?.content)?.find((item: any) => item.role === 'system')?.content?.trim() || '' - currentData.user = JSON.parse(result?.content)?.find((item: any) => item.role === 'user')?.content?.trim() || '' + currentData.system = JSON.parse(result?.content || '[]')?.find((x: any) => x.role === 'system')?.content?.trim() || '' + currentData.user = JSON.parse(result?.content || '[]')?.find((x: any) => x.role === 'user')?.content?.trim() || '' } - catch (error) { + catch { currentData.system = '' currentData.user = '' } - - form.setFieldsValue({ - ...currentData, - }) + form.setFieldsValue({ ...currentData }) syncSystemContentFromForm() setIsModalOpen(true) } + catch (err) { + console.error('获取详情失败:', err) + } } const handleDelete = async (e, id: any) => { e.stopPropagation() - const url = isPrompt ? `/prompt/delete/${id}` : `/prompt-template/delete/${id}` - const res: any = await deletePrompt({ url, body: {} }) - if (res.status === 0) { - message.success('删除成功') - setPageOption({ ...pageOption, page: 1 }) - setList([]) - getList(1, 1) - // 重新获取标签 - selectRef.current.getList() + try { + const res: any = await PromptService.postPromptDelete(Number(id)) + const ok = res?.status === 0 || res?.code === 0 || res?.code === 200 + if (ok) { + message.success('删除成功') + setPageOption(prev => ({ ...prev, page: 1 })) + setList([]) + await getList(1, 1) + selectRef.current?.getList() + } + } + catch (err) { + console.error('删除失败:', err) } } const handleCreatePrompt = () => { setIsEdit(false) setIsView(false) - setIsCopy(false) - // isPrompt && getOriginList() - isPrompt && setPromptType('string') - setTitle(isPrompt ? '新建Prompt' : '新建Prompt 模版') + setId('') + setTitle('新建Prompt') form.resetFields() setSystemContent('') setIsModalOpen(true) @@ -235,17 +236,9 @@ const Prompt = () => { setIsView(false) return } - let gUrl = '' - if (isEdit) - gUrl = isPrompt ? `/prompt/${id}` : `/prompt-template/${id}` - else - gUrl = isPrompt ? '/prompt' : '/prompt-template' - form.validateFields().then(async (values) => { setBtnLoading(true) - const params = { ...values } - // 始终使用角色格式 params.content = JSON.stringify([ { role: 'system', content: params.system || '' }, { role: 'user', content: params.user || '' }, @@ -254,21 +247,32 @@ const Prompt = () => { delete params.user try { - const res: any = await createPrompt({ - url: gUrl, - body: params, - }) - if (res.status == 0) { + const body = { name: params.name, describe: params.describe, content: params.content, category: params.category } + const res: any = isEdit + ? await PromptService.postPrompt1(Number(id), body) + : await PromptService.postPrompt(body) + const ok = res?.status === 0 + if (ok) { message.success('保存成功') - form.resetFields() - await bindTags({ url: 'tags/bindings/update', body: { type: isPrompt ? 'prompt' : 'prompt_template', tag_names: params?.tag_names, target_id: isEdit ? id : res?.result?.id } }) setIsModalOpen(false) - setPageOption({ ...pageOption, page: 1 }) - selectRef.current.getList() + form.resetFields() + setSystemContent('') + setPageOption(prev => ({ ...prev, page: 1 })) setList([]) - getList(1, 1) if (!isEdit) setHaveMore(true) + const targetId = isEdit ? String(id) : String(res?.result?.id) + try { + await Service.postTagsBindingsUpdate({ + type: 'prompt', + tag_names: params?.tag_names ?? [], + target_id: targetId, + }) + } + finally { + selectRef.current?.getList() + await getList(1, 1) + } } } finally { @@ -325,7 +329,7 @@ const Prompt = () => {
- +
@@ -405,7 +409,7 @@ const Prompt = () => { { noStyle > {/* TagSelect内部已自带Form.Item */} - { + { await selectRef.current.getList() }} onTagsDeleted={() => { // 当标签被删除时,清空筛选状态 diff --git a/front/app/(appLayout)/resourceBase/dataBase/detail/create/editableTable.tsx b/front/app/(appLayout)/resourceBase/dataBase/detail/create/editableTable.tsx index e0c0ba3..cccc3fe 100644 --- a/front/app/(appLayout)/resourceBase/dataBase/detail/create/editableTable.tsx +++ b/front/app/(appLayout)/resourceBase/dataBase/detail/create/editableTable.tsx @@ -4,7 +4,7 @@ import { Button, Cascader, Form, Input, InputNumber, Popconfirm, Select, Table, import { InfoCircleOutlined } from '@ant-design/icons' import { COLUMN_DICT, DATA_TYPE_DICT, booleanTypeOptions, dataTypeOptions, defaultAddVal, handleTableCellValue } from '../utils' -import { getDataBaseTableStructureByName } from '@/infrastructure/api/database' +import { Service } from '@/infrastructure/api/generated' type FormInstance = GetRef> @@ -12,7 +12,7 @@ const EditableContext = React.createContext | null>(null) type EditableRowProps = { index: number } -const EditableRow: React.FC = ({ index, ...props }) => { +const EditableRow: React.FC = ({ index: _index, ...props }) => { const [form] = Form.useForm() return (
@@ -64,16 +64,17 @@ const EditableCell: React.FC> = ({ inputRef.current?.focus() }, [editing]) + const unionKeyValue = record?.[COLUMN_DICT.UNION_KEY] useEffect(() => { - if (record?.[COLUMN_DICT.UNION_KEY]) + if (unionKeyValue) setDisableDataType(true) else setDisableDataType(false) - }, [record?.[COLUMN_DICT.UNION_KEY]]) + }, [unionKeyValue]) const loadData = (selectedOptions: any[]) => { const targetOption = selectedOptions[selectedOptions.length - 1] - getDataBaseTableStructureByName({ database_id, table_name: targetOption.name }) + Service.getDatabaseTableName(Number(database_id), targetOption.name) .then((res: any) => { const temp = res.data.columns.filter(el => (el.is_primary_key || el.is_unique)) targetOption.children = temp.map(el => ({ ...el, label: el.name, value: el.name })) @@ -143,7 +144,7 @@ const EditableCell: React.FC> = ({ } } for (const key in values) { - if (values.hasOwnProperty(key) && values[key] === '') + if (Object.prototype.hasOwnProperty.call(values, key) && values[key] === '') values[key] = null } handleSave({ ...record, ...values }) @@ -209,7 +210,6 @@ const EditableCell: React.FC> = ({ || (selectedTypeValue === DATA_TYPE_DICT.INT && selectedTypeValue === DATA_TYPE_DICT.NUMERIC) )) ? { const [form] = Form.useForm() - const [formVal, setFormVal] = useState([]) + const [_formVal, setFormVal] = useState([]) const { back } = useRouter() const searchParams = useSearchParams() const id = searchParams.get('id') - const { data: tableList } = useRequest(() => getDataBaseTable({ database_id: id, page: 1, limit: 10000 }).then((res: any) => res.data.map(el => ({ ...el, label: el.name, value: el.name, isLeaf: false })))) + const { data: tableList } = useRequest(() => + Service.getDatabaseTableList(Number(id), 1, 10000, '') + .then((res: any) => + res.data.map(el => ({ ...el, label: el.name, value: el.name, isLeaf: false })), + ), + ) const handleTableSubmit = async (tableData) => { const formValues = await form.validateFields() @@ -30,7 +35,6 @@ const DatabaseDetailCreateContent = () => { } const submitData = { ...formValues, - database_id: id, columns: tableData.map((el: any) => { const { foreign_key_info, ...rest } = el return (foreign_key_info && foreign_key_info[1]) @@ -45,12 +49,12 @@ const DatabaseDetailCreateContent = () => { : rest }), } - await createDatabaseTable(submitData) + await Service.postDatabaseTable(Number(id), submitData) message.success('创建成功') back() } - const onFormFinish = async (val) => { + const onFormFinish = async (_val) => { // 这个函数现在主要用于处理基础信息的验证 // 实际提交由handleTableSubmit处理 } diff --git a/front/app/(appLayout)/resourceBase/dataBase/detail/editTableData/editableTable.tsx b/front/app/(appLayout)/resourceBase/dataBase/detail/editTableData/editableTable.tsx index 6fe9b21..e6e81ac 100644 --- a/front/app/(appLayout)/resourceBase/dataBase/detail/editTableData/editableTable.tsx +++ b/front/app/(appLayout)/resourceBase/dataBase/detail/editTableData/editableTable.tsx @@ -9,7 +9,7 @@ import { useToggle } from 'ahooks' import { DATA_TYPE_DICT, handleTableCellValue, handleTableData, isNumberType } from '../utils' import useValidateSpace from '@/shared/hooks/use-validate-space' -import { downloadTemplate } from '@/infrastructure/api/database' +import { Service } from '@/infrastructure/api/generated' import { prefixUrl } from '@/shared/utils' const { Dragger } = Upload @@ -21,7 +21,7 @@ type EditableRowProps = { index: number } -const EditableRow: React.FC = ({ index, ...props }) => { +const EditableRow: React.FC = ({ index: _index, ...props }) => { const [form] = Form.useForm() return ( @@ -42,7 +42,7 @@ type EditableCellProps = { } const EditableCell: React.FC> = ({ - title, + title: _title, editable, children, dataIndex, @@ -98,7 +98,7 @@ const EditableCell: React.FC> = ({ onPressEnter={save} onBlur={save} placeholder="请输入" - max={isNumericType ? 9999999999 : isBigIntType ? 9999999999999999999 : Number.MAX_SAFE_INTEGER} + max={isNumericType ? 9999999999 : Number.MAX_SAFE_INTEGER} style={{ width: '100%' }} precision={isNumericType ? 4 : 0} stringMode={isBigIntType} @@ -235,7 +235,7 @@ const EditableTable = (props: any) => { {el.name} , dataIndex: el.name, - onCell: (record: any, index, r) => { + onCell: (record: any, index, _r) => { return { record, editable: true, @@ -295,12 +295,12 @@ const EditableTable = (props: any) => { message.error(`${info.file.name} file upload failed.`) } }, - onDrop(e) { + onDrop(_e) { }, } const handleDownloadTemplate = () => { - downloadTemplate({ database_id, table_id }).then((res: any) => { + Service.getDatabaseImport(Number(database_id), Number(table_id)).then((res: any) => { // 创建一个链接元素 const link = document.createElement('a') link.href = URL.createObjectURL(res) // 创建 Blob URL diff --git a/front/app/(appLayout)/resourceBase/dataBase/detail/editTableData/page.tsx b/front/app/(appLayout)/resourceBase/dataBase/detail/editTableData/page.tsx index 342f414..26b2c82 100644 --- a/front/app/(appLayout)/resourceBase/dataBase/detail/editTableData/page.tsx +++ b/front/app/(appLayout)/resourceBase/dataBase/detail/editTableData/page.tsx @@ -12,7 +12,7 @@ import { handleTableData } from '../utils' import style from '../index.module.scss' import EditableTable from './editableTable' -import { getDataBaseSubTableList, updateDatabaseTable } from '@/infrastructure/api/database' +import { Service } from '@/infrastructure/api/generated' const EditTableDataContent = () => { const searchParams = useSearchParams() @@ -22,12 +22,29 @@ const EditTableDataContent = () => { const database_id = searchParams.get('database_id') const table_id = searchParams.get('table_id') - const requestInstance = useRequest(() => getDataBaseSubTableList({ database_id, table_id, page: 1, limit: 99999 }), { - onSuccess: (res) => { - if (res) - setFormVal(handleTableData(res.data)) + const requestInstance = useRequest( + () => { + const databaseId = Number(database_id) + const tableId = Number(table_id) + return Promise.all([ + Service.getDatabaseTable(databaseId, tableId), + Service.getDatabaseTableData(databaseId, tableId, 1, 99999), + ]).then(([tableRes, dataRes]) => ({ + columns: tableRes?.data ?? {}, + data: dataRes?.data ?? [], + })) }, - }) + { + onSuccess: (res) => { + if (res) + setFormVal(handleTableData(res.data)) + }, + onError: (err: any) => { + const errMsg = err?.body?.message || err?.message || '获取表数据失败' + message.error(errMsg) + }, + }, + ) const onFormFinish = async () => { // 需要额外处理 update_items add_items delete_items 等字段 const add_items: any = [] @@ -66,15 +83,19 @@ const EditTableDataContent = () => { if (!temp) delete_items.push(el) }) - await updateDatabaseTable({ - database_id, - table_id, - add_items, - update_items, - delete_items, - }) - message.success('编辑数据库表成功') - back() + try { + await Service.putDatabaseTableData(Number(database_id), Number(table_id), { + add_items, + update_items, + delete_items, + }) + message.success('编辑数据库表成功') + back() + } + catch (err: any) { + const errMsg = err?.body?.message || err?.message || '编辑数据库表失败' + message.error(errMsg) + } } return ( diff --git a/front/app/(appLayout)/resourceBase/dataBase/detail/editTableStructure/editableTable.tsx b/front/app/(appLayout)/resourceBase/dataBase/detail/editTableStructure/editableTable.tsx index 04ef09c..c221976 100644 --- a/front/app/(appLayout)/resourceBase/dataBase/detail/editTableStructure/editableTable.tsx +++ b/front/app/(appLayout)/resourceBase/dataBase/detail/editTableStructure/editableTable.tsx @@ -7,7 +7,7 @@ import { import { InfoCircleOutlined } from '@ant-design/icons' import { isEmpty } from 'lodash' import { COLUMN_DICT, booleanTypeOptions, dataTypeOptions, defaultAddVal, handleTableCellValue } from '../utils' -import { getDataBaseTableStructureByName } from '@/infrastructure/api/database' +import { Service } from '@/infrastructure/api/generated' type FormInstance = GetRef> @@ -17,7 +17,7 @@ type EditableRowProps = { index: number } -const EditableRow: React.FC = ({ index, ...props }) => { +const EditableRow: React.FC = ({ index: _index, ...props }) => { const [form] = Form.useForm() return ( @@ -68,12 +68,13 @@ const EditableCell: React.FC> = ({ inputRef.current?.focus() }, [editing]) + const unionKeyValue = record?.[COLUMN_DICT.UNION_KEY] useEffect(() => { - if (record?.[COLUMN_DICT.UNION_KEY]) + if (unionKeyValue) setDisableDataType(true) else setDisableDataType(false) - }, [record?.[COLUMN_DICT.UNION_KEY]]) + }, [unionKeyValue]) const toggleEdit = () => { setEditing(!editing) @@ -97,7 +98,7 @@ const EditableCell: React.FC> = ({ const loadData = (selectedOptions: any[]) => { const targetOption = selectedOptions[selectedOptions.length - 1] - getDataBaseTableStructureByName({ database_id, table_name: targetOption.name }) + Service.getDatabaseTableName(Number(database_id), targetOption.name) .then((res: any) => { const temp = res.data.columns.filter(el => (el.is_primary_key || el.is_unique)) targetOption.children = temp.map(el => ({ ...el, label: el.name, value: el.name })) diff --git a/front/app/(appLayout)/resourceBase/dataBase/detail/editTableStructure/page.tsx b/front/app/(appLayout)/resourceBase/dataBase/detail/editTableStructure/page.tsx index 6269dcf..d7c29d0 100644 --- a/front/app/(appLayout)/resourceBase/dataBase/detail/editTableStructure/page.tsx +++ b/front/app/(appLayout)/resourceBase/dataBase/detail/editTableStructure/page.tsx @@ -8,7 +8,7 @@ import Link from 'next/link' import { useRequest } from 'ahooks' import style from '../index.module.scss' import EditableTable from './editableTable' -import { editTableStructure, getDataBaseSubTableList, getDataBaseTable } from '@/infrastructure/api/database' +import { Service } from '@/infrastructure/api/generated' const EditTableStructureContent = () => { const searchParams = useSearchParams() @@ -18,13 +18,23 @@ const EditTableStructureContent = () => { const database_id = searchParams.get('database_id') const table_id = searchParams.get('table_id') - const { data: tableList } = useRequest(() => getDataBaseTable({ database_id, page: 1, limit: 10000 }).then((res: any) => res.data.filter(el => el.id !== Number(table_id)).map(el => ({ ...el, label: el.name, value: el.name, isLeaf: false })))) - const { data } = useRequest(() => getDataBaseSubTableList({ database_id, table_id }), { - onSuccess: (res) => { - if (res) - setFormVal(res.columns.columns) + const { data: tableList } = useRequest(() => + Service.getDatabaseTableList(Number(database_id), 1, 10000, '') + .then((res: any) => + res.data + .filter(el => el.id !== Number(table_id)) + .map(el => ({ ...el, label: el.name, value: el.name, isLeaf: false })), + ), + ) + const { data } = useRequest( + () => Service.getDatabaseTable(Number(database_id), Number(table_id)).then(res => res.data), + { + onSuccess: (res) => { + if (res) + setFormVal(res.columns ?? []) + }, }, - }) + ) const onFormFinish = async (val) => { if (formVal.length === 0) { @@ -33,10 +43,8 @@ const EditTableStructureContent = () => { } const submitData = { - ...val, - database_id, - table_id, - ...data.columns, + table_name: val.table_name ?? data.table_name, + comment: val.comment ?? data.comment, columns: formVal.map((el: any) => { const { foreign_key_info, __order, ...rest } = el return (foreign_key_info && foreign_key_info[1]) @@ -51,7 +59,7 @@ const EditTableStructureContent = () => { : rest }), } - await editTableStructure(submitData) + await Service.putDatabaseTable(Number(database_id), Number(table_id), submitData) message.success('更新成功') back() } @@ -75,7 +83,7 @@ const EditTableStructureContent = () => { layout="vertical" form={form} onFinish={onFormFinish} - initialValues={data ? data.columns : {}} + initialValues={data ? { table_name: data.table_name, comment: data.comment } : {}} > @@ -89,7 +97,12 @@ const EditTableStructureContent = () => { 数据表结构
- ({ ...el, __order: i }))} tableList={tableList} database_id={database_id} /> + ({ ...el, __order: i }))} + tableList={tableList} + database_id={database_id} + /> }
diff --git a/front/app/(appLayout)/resourceBase/dataBase/detail/individualTableDetail/page.tsx b/front/app/(appLayout)/resourceBase/dataBase/detail/individualTableDetail/page.tsx index 19dc22b..51f12b5 100644 --- a/front/app/(appLayout)/resourceBase/dataBase/detail/individualTableDetail/page.tsx +++ b/front/app/(appLayout)/resourceBase/dataBase/detail/individualTableDetail/page.tsx @@ -8,7 +8,7 @@ import Image from 'next/image' import { useAntdTable } from 'ahooks' import style from '../index.module.scss' import DatabaseIcon from '@/public/images/resource-base/database.png' -import { getDataBaseSubTableList } from '@/infrastructure/api/database' +import { Service } from '@/infrastructure/api/generated' const { Column } = Table @@ -24,32 +24,30 @@ const DatabaseDetailContent = () => { const { back } = useRouter() const getTableData = ({ current, pageSize }): Promise => { - return getDataBaseSubTableList({ - database_id: searchParams.get('database_id'), - table_id: searchParams.get('table_id'), - page: current, - limit: pageSize, - }).then((res: any) => { - // 设置表格的列信息 - if (res.columns) { - // 设置数据库表信息 + const databaseId = Number(searchParams.get('database_id')) + const tableId = Number(searchParams.get('table_id')) + return Promise.all([ + Service.getDatabaseTable(databaseId, tableId), + Service.getDatabaseTableData(databaseId, tableId, current, pageSize), + ]).then(([tableRes, dataRes]) => { + const tableInfo = tableRes?.data + if (tableInfo) { setDatabaseTableInfo({ - table_name: res.columns.table_name, - comment: res.columns.comment, + table_name: tableInfo.table_name, + comment: tableInfo.comment, }) - // 处理列信息 - const columnsArray = res.columns.columns || [] + const columnsArray = tableInfo.columns || [] const columns = columnsArray.map((col: any) => ({ - name: col.name || col.column_name, - comment: col.comment || col.column_comment || col.name || col.column_name, + name: col.name || (col as any).column_name, + comment: col.comment || (col as any).column_comment || col.name || (col as any).column_name, })) setTableColumns(columns) } return { - total: res.total, - list: res.data, + total: dataRes?.total ?? 0, + list: dataRes?.data ?? [], } }) } diff --git a/front/app/(appLayout)/resourceBase/dataBase/detail/page.tsx b/front/app/(appLayout)/resourceBase/dataBase/detail/page.tsx index ad45191..38d18a4 100644 --- a/front/app/(appLayout)/resourceBase/dataBase/detail/page.tsx +++ b/front/app/(appLayout)/resourceBase/dataBase/detail/page.tsx @@ -14,7 +14,7 @@ import Image from 'next/image' import { useAntdTable } from 'ahooks' import dayjs from 'dayjs' -import { deleteDatabaseTable, getDataBaseTable } from '@/infrastructure/api/database' +import { Service } from '@/infrastructure/api/generated' import useValidateSpace from '@/shared/hooks/use-validate-space' import DatabaseIcon from '@/public/images/resource-base/database.png' @@ -30,16 +30,12 @@ const DatabaseDetailContent = () => { const [form] = Form.useForm() const getTableData = ({ current, pageSize }, formData): Promise => { - const obj = {} - for (const key in formData) { - if (formData[key]) - obj[key] = formData[key] - } - return getDataBaseTable({ database_id: id, page: current, limit: pageSize, ...obj }) + const tableName = formData?.table_name ?? '' + return Service.getDatabaseTableList(Number(id), current, pageSize, tableName) .then((res: any) => { return { - total: res.total, - list: res.data, + total: res?.total ?? 0, + list: res?.data ?? [], } }) } @@ -50,7 +46,7 @@ const DatabaseDetailContent = () => { }) const handleDelete = (data) => { - deleteDatabaseTable({ database_id: id, table_id: data.id }).then(() => { + Service.deleteDatabaseTable(Number(id), data.id).then(() => { message.success('删除成功') refresh() }) diff --git a/front/app/(appLayout)/resourceBase/dataBase/page.tsx b/front/app/(appLayout)/resourceBase/dataBase/page.tsx index 5251b0c..c31a0b0 100644 --- a/front/app/(appLayout)/resourceBase/dataBase/page.tsx +++ b/front/app/(appLayout)/resourceBase/dataBase/page.tsx @@ -6,11 +6,10 @@ import { useAntdTable, useToggle, useUpdateEffect } from 'ahooks' import { useRouter } from 'next/navigation' import dayjs from 'dayjs' import CreatorSelect from '@/app/components/tagSelect/creatorSelect' -import { createDatabase, deleteDatabase, getDataBaseList } from '@/infrastructure/api/database' +import { Service } from '@/infrastructure/api/generated' import useRadioAuth from '@/shared/hooks/use-radio-auth' import { useApplicationContext } from '@/shared/hooks/app-context' import { noOnlySpacesRule } from '@/shared/utils' -const { Search } = Input const { Column } = Table const Database = () => { const { userSpecified } = useApplicationContext() @@ -24,13 +23,17 @@ const Database = () => { const [searchVal, setSearchVal] = useState('') const [sName, setSName] = useState('') const getTableData = ({ current, pageSize }): Promise => { - return getDataBaseList('/database/list/page', { page: current, limit: pageSize, db_name: sName, user_id: creator }) - .then((res: any) => { - return { - total: res.total, - list: res.data, - } - }) + return Service.postDatabaseListPage({ + page: current, + limit: pageSize, + db_name: sName, + user_id: creator, + }).then((res: any) => { + return { + total: res?.total ?? 0, + list: res?.data ?? [], + } + }) } const { tableProps, search, pagination, refresh, loading } = useAntdTable(getTableData, { defaultPageSize: 10, @@ -42,7 +45,7 @@ const Database = () => { const onSubmit = async (values: any) => { try { setSubmitting(true) - await createDatabase(values) + await Service.postDatabase(values) message.success('创建数据库成功') toggle() refresh() @@ -57,7 +60,7 @@ const Database = () => { } const handleDelete = async (record) => { - const res = await deleteDatabase(record?.id) + const res = await Service.deleteDatabase(record?.id) if (res) { message.success('删除成功') search.submit() diff --git a/front/app/(appLayout)/resourceBase/knowledgeBase/InfoModal.tsx b/front/app/(appLayout)/resourceBase/knowledgeBase/InfoModal.tsx index 4e81736..a26cd97 100644 --- a/front/app/(appLayout)/resourceBase/knowledgeBase/InfoModal.tsx +++ b/front/app/(appLayout)/resourceBase/knowledgeBase/InfoModal.tsx @@ -1,10 +1,9 @@ import React, { useEffect } from 'react' -import { Form, Input, Modal } from 'antd' -import { createKnowledgeBase, updateKnowledgeBase } from '@/infrastructure/api/knowledgeBase' -import Toast from '@/app/components/base/flash-notice' +import { Form, Input, Modal, message } from 'antd' +import { Service } from '@/infrastructure/api/generated' +import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' import { noOnlySpacesRule } from '@/shared/utils' import TagSelect from '@/app/components/tagSelect' -import { bindTags } from '@/infrastructure/api/tagManage' const CreateModal = (props: any) => { const { visible, onClose, onSuccess, data, gettaglist } = props @@ -12,22 +11,43 @@ const CreateModal = (props: any) => { const handleOk = async () => { gettaglist() - form.validateFields().then((values) => { - if (data) { - updateKnowledgeBase({ url: '/kb/update', body: { ...data, ...values } }).then((res) => { - Toast.notify({ type: 'success', message: '更新成功' }) - bindTags({ url: 'tags/bindings/update', body: { type: 'knowledgebase', tag_names: values?.tags, target_id: res?.id } }).then(() => { - onSuccess(res.id, 'edit') + form.validateFields().then(async (values) => { + try { + if (data) { + const res = await Service.postKbUpdate({ + id: data.id, + name: values.name, + description: values.description, }) - }) - } - else { - createKnowledgeBase({ url: '/kb/create', body: values }).then((res) => { - bindTags({ url: 'tags/bindings/update', body: { type: 'knowledgebase', tag_names: values?.tags, target_id: res?.id } }).then(() => { - onSuccess(res.id, 'create') - onSuccess(res.id) + const id = res.data?.id ?? (data as any).id + await Service.postTagsBindingsUpdate({ + type: 'knowledgebase', + tag_names: values?.tags ?? [], + target_id: id, + }) + Toast.notify({ type: ToastTypeEnum.Success, message: '更新知识库成功' }) + onSuccess(id, 'edit') + } + else { + const res = await Service.postKbCreate({ + name: values.name, + description: values.description, }) - }) + const id = res.data?.id ?? (res as any)?.id + if (!id) { + message.error('创建知识库失败:缺少ID') + return + } + await Service.postTagsBindingsUpdate({ + type: 'knowledgebase', + tag_names: values?.tags ?? [], + target_id: id, + }) + onSuccess(id, 'create') + } + } + catch (err) { + console.error(err) } }).catch((err) => { console.error(err) diff --git a/front/app/(appLayout)/resourceBase/knowledgeBase/UploadModule.tsx b/front/app/(appLayout)/resourceBase/knowledgeBase/UploadModule.tsx index e236f07..b632bc1 100644 --- a/front/app/(appLayout)/resourceBase/knowledgeBase/UploadModule.tsx +++ b/front/app/(appLayout)/resourceBase/knowledgeBase/UploadModule.tsx @@ -2,7 +2,7 @@ import React, { useRef, useState } from 'react' import { InboxOutlined } from '@ant-design/icons' import type { GetProp, UploadFile, UploadProps } from 'antd' import { Form, Modal, Upload } from 'antd' -import { addFile } from '@/infrastructure/api/knowledgeBase' // , uploadData +import { Service } from '@/infrastructure/api/generated' import { API_PREFIX } from '@/app-specs' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' import { useModalContext } from '@/shared/hooks/modal-context' @@ -92,7 +92,7 @@ const UploadModal = (props: any) => { const nextFileData = fileList.find((item: any) => item.uid === uid) if (!nextFileData) { const file_ids = Object.values(selfRef.current.uploadTasks).map((item: any) => item.serverId) || [] - Promise.resolve(addFile({ url: '/kb/file/add', body: { knowledge_base_id: id, file_ids } })).then(() => { + Promise.resolve(Service.postKbFileAdd({ knowledge_base_id: id, file_ids })).then(() => { Toast.notify({ type: ToastTypeEnum.Success, message: '上传成功' }) successEvent() setFileList([]) diff --git a/front/app/(appLayout)/resourceBase/knowledgeBase/detail/page.tsx b/front/app/(appLayout)/resourceBase/knowledgeBase/detail/page.tsx index 4fb600a..e4e77e4 100644 --- a/front/app/(appLayout)/resourceBase/knowledgeBase/detail/page.tsx +++ b/front/app/(appLayout)/resourceBase/knowledgeBase/detail/page.tsx @@ -11,11 +11,9 @@ import { useMount } from 'ahooks' import Link from 'next/link' import UploadModule from '../UploadModule' import styles from './index.module.scss' -import { API_PREFIX } from '@/app-specs' import ModalCooperation from '@/app/components/app/picker-user/ModalCooperation' -import { deleteFile, getFileList } from '@/infrastructure/api/knowledgeBase' +import { Service } from '@/infrastructure/api/generated' import { useApplicationContext } from '@/shared/hooks/app-context' -import { getJoins } from '@/infrastructure/api/apps' import { usePermitCheck } from '@/app/components/app/permit-check' import useValidateSpace from '@/shared/hooks/use-validate-space' @@ -23,11 +21,10 @@ type TableRowSelection = TableProps['rowSelection' const { Search } = Input type DataType = { - key: string - name: string - age: number - address: string - tags: string[] + id?: string + name?: string + file_type?: string + updated_at?: string } const KnowledgeBaseDetailContent = () => { @@ -53,11 +50,10 @@ const KnowledgeBaseDetailContent = () => { const [form] = Form.useForm() const getData = useCallback(async () => { - getFileList({ url: '/kb/file/list', options: { params: { file_name: fileName, knowledge_base_id: id, page: current, page_size: pageSize } } }).then((res) => { - setInfo(res.knowledge_base_info) - setData(res.data) - setTotal(res.total) - }) + const res = await Service.getKbFileList(id, current, pageSize, fileName) + setInfo(res.knowledge_base_info) + setData(res.data ?? []) + setTotal(res.total ?? 0) }, [current, fileName, pageSize, id]) useEffect(() => { @@ -67,46 +63,32 @@ const KnowledgeBaseDetailContent = () => { } }, [state]) - const handleDelete = (data) => { - deleteFile({ url: '/kb/file/delete', body: { file_ids: [data.id] } }).then(() => { - // Toast.notify({ type: 'success', message: '删除成功' }) - message.success('删除成功') - getData() - }) + const handleDelete = async (recordData) => { + await Service.postKbFileDelete({ file_ids: [String(recordData.id)] }) + message.success('删除成功') + getData() } const handleJumpDetail = (data) => { window.open(`/resourceBase/knowledgeBase/preview?id=${data.id}`, '_blank') } - const reqDownload = ({ file_ids, filename }) => { - const token = localStorage.getItem('console_token') - fetch(`${API_PREFIX}/kb/download`, - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${token}`, - }, - body: JSON.stringify({ file_ids }), - }) - .then((response) => { - if (!response.ok) - throw new Error('网络错误,请稍后再试。') - return response.blob() - }) - .then((blob) => { - const url = window.URL.createObjectURL(blob) - const a = document.createElement('a') - a.href = url - a.download = filename - document.body.appendChild(a) - a.click() - a.remove() - window.URL.revokeObjectURL(url) - }) - .catch((error) => { - console.error('handleDownload:', error) + const reqDownload = async ({ file_ids, filename }) => { + try { + const blob = await Service.postKbDownload({ + file_ids: file_ids.map((id: any) => Number(id)), }) + const url = window.URL.createObjectURL(blob) + const a = document.createElement('a') + a.href = url + a.download = filename + document.body.appendChild(a) + a.click() + a.remove() + window.URL.revokeObjectURL(url) + } + catch (error) { + console.error('handleDownload:', error) + } } const handleDownload = (recordData) => { @@ -156,9 +138,8 @@ const KnowledgeBaseDetailContent = () => { ] useEffect(() => { - // 获取协作数据 - getJoins({ url: '/workspaces/coop/joins', options: { params: { target_type: 'knowledgebase' } } }).then((res) => { - setJoins(res.data) + Service.getWorkspacesCoopJoins('knowledge_base').then((res) => { + setJoins(res.data ?? []) }) }, []) @@ -202,17 +183,20 @@ const KnowledgeBaseDetailContent = () => { onChange: onSelectChange, } - const batchDelete = () => { - deleteFile({ url: '/kb/file/delete', body: { file_ids: selectedRowKeys } }).then(() => { - // Toast.notify({ type: 'success', message: '删除成功' }) + const batchDelete = async () => { + try { + await Service.postKbFileDelete({ file_ids: selectedRowKeys.map(key => String(key)) }) message.success('删除成功') getData() setOpen(false) - setConfirmLoading(false) setSelectedRowKeys([]) - }).catch(() => { + } + catch { + // ignore + } + finally { setConfirmLoading(false) - }) + } } const batchDownload = () => { @@ -336,7 +320,7 @@ const KnowledgeBaseDetailContent = () => { { validator: (_, value) => { if (value && value.trim() === '') - return Promise.reject('文件夹名称不能为空格') + return Promise.reject(new Error('文件夹名称不能为空格')) return Promise.resolve() }, diff --git a/front/app/(appLayout)/resourceBase/knowledgeBase/page.tsx b/front/app/(appLayout)/resourceBase/knowledgeBase/page.tsx index 0005720..3b88a30 100644 --- a/front/app/(appLayout)/resourceBase/knowledgeBase/page.tsx +++ b/front/app/(appLayout)/resourceBase/knowledgeBase/page.tsx @@ -7,15 +7,14 @@ import { ReadOutlined } from '@ant-design/icons' import styles from './page.module.scss' import InfoModal from './InfoModal' import UploadModule from './UploadModule' -import { deleteKnowledgeBase, getKnowledgeBaseList } from '@/infrastructure/api/knowledgeBase' -import Toast from '@/app/components/base/flash-notice' +import { Service } from '@/infrastructure/api/generated' import Iconfont from '@/app/components/base/iconFont' import TagMode from '@/app/components/tagSelect/TagMode' import CreatorSelect from '@/app/components/tagSelect/creatorSelect' import useRadioAuth from '@/shared/hooks/use-radio-auth' import { useApplicationContext } from '@/shared/hooks/app-context' -import { pageCache } from '@/shared/utils' import ReferenceResultModal from '@/app/components/referenceResultModal' +import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' const KnowledgeBase = () => { const router = useRouter() @@ -23,7 +22,6 @@ const KnowledgeBase = () => { const authRadio = useRadioAuth() const [list, setList] = useState([]) const [data, setData] = useState({}) - const [type, setType] = useState(pageCache.getTab({ name: pageCache.category.knowledgeBase }) || 'mine') const [id, setId] = useState('') const [infoModuleVisible, setInfoModuleVisible] = useState(false) const [uploadModuleVisible, setUploadModuleVisible] = useState(false) @@ -38,13 +36,19 @@ const KnowledgeBase = () => { const [refType] = useState<'kb'>('kb') const getCardList = async () => { - const res: any = await getKnowledgeBaseList({ url: '/kb/list', body: { page: '1', page_size: '999', search_tags: selectTags.map(item => item.name), search_name: sName, user_id: creator } }) - setList(res.data) + const res = await Service.postKbList({ + page: 1, + page_size: 999, + search_tags: selectTags.map(item => item.name), + search_name: sName, + user_id: creator, + }) + setList(res.data ?? []) } const handleDelete = async (item: any, e) => { e.stopPropagation() - await deleteKnowledgeBase({ url: '/kb/delete', body: { id: item.id } }) - Toast.notify({ type: 'success', message: '删除成功' }) + await Service.postKbDelete({ id: item.id }) + Toast.notify({ type: ToastTypeEnum.Success, message: '删除成功' }) getCardList() } const handleInfoSuccess = (id: string, type: 'create' | 'edit') => { diff --git a/front/app/(appLayout)/resourceBase/knowledgeBase/preview/page.tsx b/front/app/(appLayout)/resourceBase/knowledgeBase/preview/page.tsx index c3d30b2..12f1290 100644 --- a/front/app/(appLayout)/resourceBase/knowledgeBase/preview/page.tsx +++ b/front/app/(appLayout)/resourceBase/knowledgeBase/preview/page.tsx @@ -1,13 +1,13 @@ 'use client' -import React, { Suspense, useEffect, useState } from 'react' +import React, { Suspense, useCallback, useEffect, useState } from 'react' import { useSearchParams } from 'next/navigation' import styles from './page.module.scss' import PreviewTxt from '@/app/components/preview/previewTxt' import PreviewDoc from '@/app/components/preview/previewDoc' import PreviewExcel from '@/app/components/preview/previewExcel' import PreviewPdf from '@/app/components/preview/previewPdf' -import { getFilePathById } from '@/infrastructure/api/knowledgeBase' +import { Service } from '@/infrastructure/api/generated' import PreviewJson from '@/app/components/preview/previewJSON' import PreviewMD from '@/app/components/preview/previewMD' import PreviewHtml from '@/app/components/preview/previewHTML' @@ -22,8 +22,16 @@ const PreviewPageContent = () => { const fileUrl = path.replace('/app', '/static') const suffix = type.split('.').pop() - if (suffix === 'txt') { return
} - else if (suffix === 'docx') { return } + if (suffix === 'txt') { + return ( +
+ +
+ ) + } + else if (suffix === 'docx') { + return + } else if (suffix === 'doc') { return
暂不支持.doc文件预览
@@ -31,12 +39,32 @@ const PreviewPageContent = () => { 下载文件
} - else if (suffix === 'xlsx' || suffix === 'xls' || suffix === 'csv') { return } - else if (suffix === 'pdf') { return } - else if (suffix === 'md') { return
} - else if (suffix === 'json') { return
} - else if (suffix === 'html') { return } - else if (suffix === 'pptx') { return } + else if (suffix === 'xlsx' || suffix === 'xls' || suffix === 'csv') { + return + } + else if (suffix === 'pdf') { + return + } + else if (suffix === 'md') { + return ( +
+ +
+ ) + } + else if (suffix === 'json') { + return ( +
+ +
+ ) + } + else if (suffix === 'html') { + return + } + else if (suffix === 'pptx') { + return + } else if (suffix === 'ppt') { return
暂不支持.ppt文件预览
@@ -52,19 +80,19 @@ const PreviewPageContent = () => {
} } - const getPath = async () => { + const getPath = useCallback(async () => { try { - const res = await getFilePathById({ url: '/kb/file/get', body: { file_id: seachParams.get('id') } }) as any + const res = await Service.postKbFileGet({ file_id: seachParams.get('id') || '' }) as any setPath(res.file_path) setType(res.file_type) } catch (error) { console.error('获取文件路径失败:', error) } - } + }, [seachParams]) useEffect(() => { getPath() - }, []) + }, [getPath]) return (
diff --git a/front/app/(appLayout)/tools/Mcp/page.tsx b/front/app/(appLayout)/tools/Mcp/page.tsx index 5ff8e6c..9bea133 100644 --- a/front/app/(appLayout)/tools/Mcp/page.tsx +++ b/front/app/(appLayout)/tools/Mcp/page.tsx @@ -218,6 +218,8 @@ const McpToolPageContent = () => { onFinish: (payload: any) => { if (payload && payload.flow_type === 'mcp') { message.success('同步成功') + setCanProceed(true) + setSyncStatus('success') try { const finishData = (payload && typeof payload.data === 'string') ? payload.data diff --git a/front/app/(appLayout)/tools/components/editor/baseModelAI.tsx b/front/app/(appLayout)/tools/components/editor/baseModelAI.tsx index b30c405..53fa2ca 100644 --- a/front/app/(appLayout)/tools/components/editor/baseModelAI.tsx +++ b/front/app/(appLayout)/tools/components/editor/baseModelAI.tsx @@ -5,7 +5,7 @@ import { v4 as uuidv4 } from 'uuid' import { Button, Input, Modal, Spin, message } from 'antd' import styles from './basModelAi.module.scss' import Icon from '@/app/components/base/iconFont' -import { createCodeAI } from '@/infrastructure/api/prompt' +import { Service } from '@/infrastructure/api/generated' import type { CodeAIResponse, ParamData } from '@/core/data/common' type Props = { @@ -18,7 +18,7 @@ type Props = { const BaseModelAI: FC = ({ isOpen, onClose, - value, + value: _value, onGenerated, }) => { const [isGenerated, setIsGenerated] = useState(false) @@ -52,13 +52,10 @@ const BaseModelAI: FC = ({ setInputLanguage('') setIsParam(undefined) - const res = await createCodeAI({ - url: '/apps/workflows/code_assistant', - body: { - query: inputText, - session: sessionId, - }, - }) as unknown as CodeAIResponse + const res = await Service.postAppsWorkflowsCodeAssistant({ + prompt: inputText, + session: sessionId, + } as any) as unknown as CodeAIResponse // 检查返回的 session 是否匹配 if (res.session && res.session !== sessionId) { diff --git a/front/app/(appLayout)/tools/pageDrawer.tsx b/front/app/(appLayout)/tools/pageDrawer.tsx index 1e334dd..b627358 100644 --- a/front/app/(appLayout)/tools/pageDrawer.tsx +++ b/front/app/(appLayout)/tools/pageDrawer.tsx @@ -231,6 +231,8 @@ const PageDrawer = (props: any) => { onFinish: async (payload: any) => { if (payload && payload.flow_type === 'mcp') { message.success('同步成功') + setCanProceed(true) + setSyncStatus('success') try { const finishData = (payload && typeof payload.data === 'string') ? payload.data diff --git a/front/app/components/AIPromptModal/index.tsx b/front/app/components/AIPromptModal/index.tsx index c46d5c3..f1f16c4 100644 --- a/front/app/components/AIPromptModal/index.tsx +++ b/front/app/components/AIPromptModal/index.tsx @@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid' import { Button, Input, Modal, Spin, message } from 'antd' import styles from './index.module.scss' import Icon from '@/app/components/base/iconFont' -import { createPromptAI } from '@/infrastructure/api//prompt' +import { Service } from '@/infrastructure/api/generated' type AIPromptModalProps = { open: boolean @@ -123,11 +123,9 @@ const AIPromptModal: React.FC = ({ open, onClose, onConfirm try { setLoading(true) setLastQuery(inputContent) - const res: any = await createPromptAI({ - body: { - query: inputContent, - session: currentSessionId, - }, + const res: any = await Service.postAppsWorkflowsPromptAssistant({ + prompt: inputContent, + session: currentSessionId, }) // 验证响应是否有效 @@ -163,11 +161,9 @@ const AIPromptModal: React.FC = ({ open, onClose, onConfirm try { setLoading(true) - const res: any = await createPromptAI({ - body: { - query: lastQuery, - session: currentSessionId, - }, + const res: any = await Service.postAppsWorkflowsPromptAssistant({ + prompt: lastQuery, + session: currentSessionId, }) // 验证响应是否有效 diff --git a/front/app/components/taskStream/board/asset-dashboard/components/core-asset-dash.tsx b/front/app/components/taskStream/board/asset-dashboard/components/core-asset-dash.tsx index ef9192b..f853594 100644 --- a/front/app/components/taskStream/board/asset-dashboard/components/core-asset-dash.tsx +++ b/front/app/components/taskStream/board/asset-dashboard/components/core-asset-dash.tsx @@ -169,9 +169,9 @@ const ResourcePanelBase: FC = ({
-
+
{renderResourceIcon()} diff --git a/front/app/components/taskStream/driveFlow/result-panel.tsx b/front/app/components/taskStream/driveFlow/result-panel.tsx index c1ce57b..0153b8c 100644 --- a/front/app/components/taskStream/driveFlow/result-panel.tsx +++ b/front/app/components/taskStream/driveFlow/result-panel.tsx @@ -74,7 +74,7 @@ const ExecutionResult: FC = ({ const containsInputFiles = input_files && input_files.length > 0 const containsProcessData = process_record && process_record.length > 0 const containsOutputs = outputs && status !== 'running' - const displayRunningOutput = !outputs && status === 'running' + const isRunning = status === 'running' return (
@@ -121,17 +121,30 @@ const ExecutionResult: FC = ({ /> )} - {displayRunningOutput && ( - {'输出'.toLocaleUpperCase()}
} - language={currentLanguage.json} - value={outputs} - beautifyJSON - /> + {/* 运行中时显示流式输出 */} + {isRunning && ( + <> + {(outputs && varOutputs && varOutputs.length > 0) + ? ( + + ) + : ( + {'输出'.toLocaleUpperCase()}
} + language={currentLanguage.json} + value={outputs || ''} + beautifyJSON + /> + )} + )} + {/* 完成时显示最终输出 */} {containsOutputs && ( = ({ const [isGenerating, setIsGenerating] = useState(false) const [inputText, setInputText] = useState('') const [generatedCode, setGeneratedCode] = useState('') - const abortControllerRef = useRef(null) + const requestRef = useRef | null>(null) const handleCancel = () => { // 取消正在进行的请求 - if (abortControllerRef.current) { - abortControllerRef.current.abort() - abortControllerRef.current = null - } + requestRef.current?.cancel() + requestRef.current = null setInputText('') setGeneratedCode('') @@ -47,32 +45,24 @@ const CodeAiModal: FC = ({ } // 如果之前有请求正在进行,先取消它 - if (abortControllerRef.current) - abortControllerRef.current.abort() - - // 创建新的AbortController - abortControllerRef.current = new AbortController() + requestRef.current?.cancel() setIsGenerating(true) try { - // 调用真实的AI API生成代码 - const res = await createCodeAI({ - url: '/apps/workflows/code_assistant', - body: { - query: inputText, - }, - }, { - getAbortController: (controller) => { - abortControllerRef.current = controller - }, - }) as unknown as CodeAIResponse + const request = Service.postAppsWorkflowsCodeAssistant({ + prompt: inputText, + code: currentCode, + language, + }) + requestRef.current = request + const res = await request as unknown as CodeAIResponse const generatedCode = res.message setGeneratedCode(generatedCode) } catch (error) { // 检查是否是取消请求导致的错误 - if (error instanceof Error && error.name === 'AbortError') + if (error instanceof CancelError) return console.error('代码生成失败:', error) @@ -80,7 +70,7 @@ const CodeAiModal: FC = ({ } finally { setIsGenerating(false) - abortControllerRef.current = null + requestRef.current = null } } diff --git a/front/app/components/taskStream/elements/_foundation/components/form/field-item/db-handler/table_meta_data/internal_db_panel/index.tsx b/front/app/components/taskStream/elements/_foundation/components/form/field-item/db-handler/table_meta_data/internal_db_panel/index.tsx index 8ecb128..4c8b99e 100644 --- a/front/app/components/taskStream/elements/_foundation/components/form/field-item/db-handler/table_meta_data/internal_db_panel/index.tsx +++ b/front/app/components/taskStream/elements/_foundation/components/form/field-item/db-handler/table_meta_data/internal_db_panel/index.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react' import { Form, Input, Modal, Select, Table } from 'antd' import { useRequest } from 'ahooks' -import { getDataBaseTable, getDataBaseTableStructureByName } from '@/infrastructure/api//database' +import { Service } from '@/infrastructure/api/generated' type TableEditModalProps = { type: 'add' | 'edit' @@ -17,10 +17,10 @@ const TableEditModal: React.FC = (props: TableEditModalProps) => { const { database_id, type, visible, record, setVisible, onOk } = props const [form] = Form.useForm() const [dataSource, setDataSource] = useState([]) - const [page, setPage] = useState(1) + const [_page, setPage] = useState(1) const [selectedKeys, setSelectedKeys] = useState([]) const { data } = useRequest(() => - getDataBaseTable({ database_id, page: 1, limit: 999999 }) + Service.getDatabaseTableList(Number(database_id), 1, 999999, '') .then((res: any) => ({ ...res, data: res.data.map(el => ({ ...el, label: el.name, value: el.name })) })), { refreshDeps: [database_id], @@ -41,7 +41,7 @@ const TableEditModal: React.FC = (props: TableEditModalProps) => { setSelectedKeys([]) } } - }, [visible, record]) + }, [visible, record, form]) const handleOk = () => { form.validateFields().then(async (values) => { @@ -88,7 +88,7 @@ const TableEditModal: React.FC = (props: TableEditModalProps) => { ] const handleSingleDatabaseTable = async (e) => { - const res: any = await getDataBaseTableStructureByName({ database_id, table_name: e, page: 1, limit: 99999 }) + const res: any = await Service.getDatabaseTableName(Number(database_id), e) setDataSource(res.data.columns) const allKeys = res.data.columns.map((_, index) => index.toString()) setSelectedKeys(allKeys) diff --git a/front/app/components/taskStream/elements/utility/panel.tsx b/front/app/components/taskStream/elements/utility/panel.tsx index dddee8b..07d9940 100644 --- a/front/app/components/taskStream/elements/utility/panel.tsx +++ b/front/app/components/taskStream/elements/utility/panel.tsx @@ -12,7 +12,7 @@ import ResultPanel from '@/app/components/taskStream/driveFlow/result-panel' import Split from '@/app/components/taskStream/elements/_foundation/components/divider' import { fetchApiToolInfo, fetchToolFieldList } from '@/infrastructure/api//workflow' import { generateNameReadOnlyShape } from '@/infrastructure/api//universeNodes/universe_default_config' - +import { list2Json } from '@/app/components/taskStream/elements/_foundation/components/form/field-item/netOps/kvPair/kvPairEdit/helpers' const baseTypeOptionsMap = { 'boolean': 'bool', 'array': 'list', @@ -156,17 +156,17 @@ const Panel: FC> = ({ })) const newApiHeadersData = { ...(newFormData.payload__headers || {}), - ...list2Json(formattedHeaderParams || [], 'key', 'value'), + ...list2Json(formattedHeaderParams || [], [{ key: 'key' }, { key: 'value' }]), } newFormData = { ...newFormData, - payload__params: list2Json(formattedQueryParams, 'key', 'value'), + payload__params: list2Json(formattedQueryParams, [{ key: 'key' }, { key: 'value' }]), payload__params_data: formattedQueryParams.map((item: any) => ({ id: uuid4(), key: item?.key, value: item?.value, })), - payload__body: JSON.stringify(list2Json(formattedBodyParams, 'key', 'value'), null, 2), + payload__body: JSON.stringify(list2Json(formattedBodyParams, [{ key: 'key' }, { key: 'value' }]), null, 2), payload__headers: { ...newApiHeadersData }, payload__headers_data: Object.entries(newApiHeadersData || {}).map(item => ({ id: uuid4(), @@ -227,12 +227,6 @@ const Panel: FC> = ({ } }, [data, handleFieldChange]) - if (isLoading) { - return
- -
- } - // 使用 useMemo 缓存 form 对象,避免 BeforeRunForm 不必要的重新渲染 const beforeRunFormConfig = useMemo(() => ({ inputs: varInputs, @@ -241,6 +235,12 @@ const Panel: FC> = ({ onChange: setInputVarValues, }), [varInputs, varOutputs, inputVarValues, setInputVarValues]) + if (isLoading) { + return
+ +
+ } + return (
{ const { showSingleRun, - hideSingleExecution, + concealSingleRun, toShapeInputs, toShapeOutputs, executionStatus, @@ -46,8 +46,8 @@ const useToolConfig = (nodeId: string, nodePayload: ToolNodeType) => { const hideSingleExecutionAndReset = useCallback(() => { setInputVariableValues({}) sessionStorage.removeItem('executionInputData') - hideSingleExecution() - }, [setInputVariableValues, hideSingleExecution]) + concealSingleRun() + }, [setInputVariableValues, concealSingleRun]) return { readOnly: isReadOnly, diff --git a/front/app/components/taskStream/logicHandlers/flowCore.ts b/front/app/components/taskStream/logicHandlers/flowCore.ts index d09c66d..ab5f027 100644 --- a/front/app/components/taskStream/logicHandlers/flowCore.ts +++ b/front/app/components/taskStream/logicHandlers/flowCore.ts @@ -712,17 +712,47 @@ export const useWorkflowInit = () => { function formatRespondedResources(data: any[]) { return data?.map((resource) => { - return ({ + // 确定资源的分类 + let categorization = resource.mixed + ? ResourceClassificationEnum.Custom + : (resource?.categorization || resource?.data?.categorization) + // 如果没有 categorization,根据 type 推断 + if (!categorization) { + const resourceType = resource?.type || resource?.data?.type || resource?.payload__kind + // 内置资源类型 + const builtInTypes = ['document', 'server', 'web', 'sql_manager', 'Document', 'Server', 'Web', 'SqlManager'] + if (builtInTypes.includes(resourceType)) + categorization = ResourceClassificationEnum.Internal + // 工具资源类型 + else if (resourceType === 'tool' || resourceType === 'mcp' || resourceType === 'Tool' || resourceType === 'MCP') + categorization = ResourceClassificationEnum.Tool + // 默认为自定义资源 + else + categorization = ResourceClassificationEnum.Custom + } + + // 确定资源类型 + const resourceType = resource.mixed ? CustomResourceEnum.Custom : (resource.type || resource?.data?.type) + + // 构建资源数据对象 + const resourceData = resource?.data || {} + const resourceId = resource?.id || resourceData?.id + + return { ...resource, - categorization: resource.mixed ? ResourceClassificationEnum.Custom : (resource?.categorization || resource?.data?.categorization), - type: resource.mixed ? CustomResourceEnum.Custom : resource.type, + id: resourceId, + categorization, + type: resourceType, data: { - ...resource?.data, - categorization: resource.mixed ? ResourceClassificationEnum.Custom : (resource?.categorization || resource?.data?.categorization), - id: resource?.id || resource?.data?.id, + ...resourceData, + ...resource, // 将顶层字段也合并到 data 中 + categorization, + id: resourceId, selected: false, + title: resourceData?.title || resource?.title, + desc: resourceData?.desc || resource?.desc || resourceData?.description || resource?.description, }, - }) + } }) || [] } diff --git a/front/app/components/taskStream/store.ts b/front/app/components/taskStream/store.ts index 54ceb3f..a7dda3d 100644 --- a/front/app/components/taskStream/store.ts +++ b/front/app/components/taskStream/store.ts @@ -204,7 +204,7 @@ export const createWorkflowStore = () => { setIsRestoring: isRestoring => set(() => ({ isRestoring })), debouncedSyncWorkflowDraft: debounce((syncWorkflowDraft) => { syncWorkflowDraft() - }, 5000), + }, 8000), buildInTools: [], setBuildInTools: buildInTools => set(() => ({ buildInTools })), customTools: [], diff --git a/front/infrastructure/api/database.ts b/front/infrastructure/api/database.ts deleted file mode 100644 index 0e90010..0000000 --- a/front/infrastructure/api/database.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { del, get, post, put } from './base' -const prefixUrl = 'database' - -export const deleteDatabase = (database_id) => { - return del(`${prefixUrl}/${database_id}`) -} - -export const deleteDatabaseTable = ({ database_id, table_id }) => { - return del(`${prefixUrl}/${database_id}/table/${table_id}`) -} - -export const downloadTemplate = ({ database_id, table_id }) => { - return get(`${prefixUrl}/import/${database_id}/${table_id}`, { - headers: - new Headers({ - 'Content-Type': 'application/octet-stream', - }), - }) -} - -export const getDataBaseList = (url, body) => - post(url, { body }) - -export const getDataBaseTable = ({ database_id, ...rest }) => - get(`${prefixUrl}/${database_id}/table/list`, { params: rest }) - -export const getDataBaseSubTableList = ({ database_id, table_id, ...rest }) => - get(`${prefixUrl}/${database_id}/table_data/${table_id}`, { params: rest }) - -export const getDataBaseTableStructureByName = ({ database_id, table_name, ...rest }) => - get(`${prefixUrl}/${database_id}/table_name/${table_name}`, { params: rest }) - -export const createDatabase = body => - post(prefixUrl, { body }) - -export const createDatabaseTable = body => - post(`${prefixUrl}/${body.database_id}/table`, { body }) - -export const updateDatabaseTable = ({ database_id, table_id, ...rest }) => - put(`${prefixUrl}/${database_id}/table_data/${table_id}`, { body: rest }) - -export const editTableStructure = ({ database_id, table_id, ...rest }) => - put(`${prefixUrl}/${database_id}/table/${table_id}`, { body: rest }) diff --git a/front/infrastructure/api/generated/USAGE_EXAMPLES.md b/front/infrastructure/api/generated/USAGE_EXAMPLES.md new file mode 100644 index 0000000..1624989 --- /dev/null +++ b/front/infrastructure/api/generated/USAGE_EXAMPLES.md @@ -0,0 +1,183 @@ +# 使用示例 + +本文档展示如何使用自动生成的 API 接口。 + +## 基本使用 + +### 1. 认证相关接口 (AuthService) + +```typescript +import { AuthService } from '@/infrastructure/api/generated'; + +// 获取当前用户资料 +const profile = await AuthService.getAccountProfile(); +console.log('用户资料:', profile); + +// 修改密码 +await AuthService.postAccountPassword({ + new_password: 'newPassword123', + repeat_new_password: 'newPassword123', + password: 'oldPassword123' // 可选 +}); + +// 更新用户信息 +await AuthService.postAccountUpdate({ + name: '新用户名', + email: 'newemail@example.com', + phone: '13800138000' +}); +``` + +### 2. API Key 管理 (ApiKeyService) + +```typescript +import { ApiKeyService } from '@/infrastructure/api/generated'; + +// 获取所有 API Key +const apiKeys = await ApiKeyService.getApikey(); +console.log('API Keys:', apiKeys); + +// 创建新的 API Key +const newKey = await ApiKeyService.postApikey({ + name: '我的API Key', + description: '用于测试的API Key' +}); +console.log('新创建的 Key:', newKey); + +// 删除 API Key +await ApiKeyService.deleteApikey({ + id: 123 +}); + +// 更新 API Key 状态 +await ApiKeyService.putApikey({ + id: 123, + status: 'active' // 或 'inactive' +}); +``` + +### 3. 错误处理 + +生成的接口使用 `CancelablePromise`,支持请求取消和错误处理: + +```typescript +import { AuthService, ApiError } from '@/infrastructure/api/generated'; + +try { + const result = await AuthService.getAccountProfile(); + console.log('成功:', result); +} catch (error) { + if (error instanceof ApiError) { + console.error('API错误:', error.message); + console.error('状态码:', error.status); + console.error('响应体:', error.body); + } else { + console.error('其他错误:', error); + } +} +``` + +### 4. 取消请求 + +```typescript +import { AuthService, CancelError } from '@/infrastructure/api/generated'; + +const promise = AuthService.getAccountProfile(); + +// 取消请求 +setTimeout(() => { + promise.cancel(); +}, 1000); + +try { + const result = await promise; + console.log('结果:', result); +} catch (error) { + if (error instanceof CancelError) { + console.log('请求已取消'); + } +} +``` + +### 5. 在 React 组件中使用 + +```typescript +import { useState, useEffect } from 'react'; +import { AuthService } from '@/infrastructure/api/generated'; + +function UserProfile() { + const [profile, setProfile] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + let cancelled = false; + + const loadProfile = async () => { + try { + setLoading(true); + const result = await AuthService.getAccountProfile(); + if (!cancelled) { + setProfile(result); + setError(null); + } + } catch (err) { + if (!cancelled) { + setError(err); + } + } finally { + if (!cancelled) { + setLoading(false); + } + } + }; + + loadProfile(); + + return () => { + cancelled = true; + }; + }, []); + + if (loading) return
加载中...
; + if (error) return
错误: {error.message}
; + return
{JSON.stringify(profile)}
; +} +``` + +### 6. 使用 SWR 进行数据获取 + +```typescript +import useSWR from 'swr'; +import { AuthService } from '@/infrastructure/api/generated'; + +function useUserProfile() { + const { data, error, isLoading } = useSWR( + 'user-profile', + () => AuthService.getAccountProfile() + ); + + return { + profile: data, + isLoading, + isError: error + }; +} + +// 在组件中使用 +function MyComponent() { + const { profile, isLoading, isError } = useUserProfile(); + + if (isLoading) return
加载中...
; + if (isError) return
加载失败
; + return
{profile?.name}
; +} +``` + +## 注意事项 + +1. 所有接口方法都是静态方法,直接通过类名调用 +2. 返回的是 `CancelablePromise`,可以使用 `.cancel()` 取消请求 +3. 错误会抛出 `ApiError` 异常,需要适当处理 +4. 认证 token 会自动从 localStorage 获取,无需手动设置 + diff --git a/front/infrastructure/api/generated/core/ApiError.ts b/front/infrastructure/api/generated/core/ApiError.ts new file mode 100644 index 0000000..ec7b16a --- /dev/null +++ b/front/infrastructure/api/generated/core/ApiError.ts @@ -0,0 +1,25 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; + +export class ApiError extends Error { + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + public readonly request: ApiRequestOptions; + + constructor(request: ApiRequestOptions, response: ApiResult, message: string) { + super(message); + + this.name = 'ApiError'; + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + this.request = request; + } +} diff --git a/front/infrastructure/api/generated/core/ApiRequestOptions.ts b/front/infrastructure/api/generated/core/ApiRequestOptions.ts new file mode 100644 index 0000000..93143c3 --- /dev/null +++ b/front/infrastructure/api/generated/core/ApiRequestOptions.ts @@ -0,0 +1,17 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiRequestOptions = { + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly url: string; + readonly path?: Record; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}; diff --git a/front/infrastructure/api/generated/core/ApiResult.ts b/front/infrastructure/api/generated/core/ApiResult.ts new file mode 100644 index 0000000..ee1126e --- /dev/null +++ b/front/infrastructure/api/generated/core/ApiResult.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type ApiResult = { + readonly url: string; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly body: any; +}; diff --git a/front/infrastructure/api/generated/core/CancelablePromise.ts b/front/infrastructure/api/generated/core/CancelablePromise.ts new file mode 100644 index 0000000..d70de92 --- /dev/null +++ b/front/infrastructure/api/generated/core/CancelablePromise.ts @@ -0,0 +1,131 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export class CancelError extends Error { + + constructor(message: string) { + super(message); + this.name = 'CancelError'; + } + + public get isCancelled(): boolean { + return true; + } +} + +export interface OnCancel { + readonly isResolved: boolean; + readonly isRejected: boolean; + readonly isCancelled: boolean; + + (cancelHandler: () => void): void; +} + +export class CancelablePromise implements Promise { + #isResolved: boolean; + #isRejected: boolean; + #isCancelled: boolean; + readonly #cancelHandlers: (() => void)[]; + readonly #promise: Promise; + #resolve?: (value: T | PromiseLike) => void; + #reject?: (reason?: any) => void; + + constructor( + executor: ( + resolve: (value: T | PromiseLike) => void, + reject: (reason?: any) => void, + onCancel: OnCancel + ) => void + ) { + this.#isResolved = false; + this.#isRejected = false; + this.#isCancelled = false; + this.#cancelHandlers = []; + this.#promise = new Promise((resolve, reject) => { + this.#resolve = resolve; + this.#reject = reject; + + const onResolve = (value: T | PromiseLike): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isResolved = true; + if (this.#resolve) this.#resolve(value); + }; + + const onReject = (reason?: any): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isRejected = true; + if (this.#reject) this.#reject(reason); + }; + + const onCancel = (cancelHandler: () => void): void => { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#cancelHandlers.push(cancelHandler); + }; + + Object.defineProperty(onCancel, 'isResolved', { + get: (): boolean => this.#isResolved, + }); + + Object.defineProperty(onCancel, 'isRejected', { + get: (): boolean => this.#isRejected, + }); + + Object.defineProperty(onCancel, 'isCancelled', { + get: (): boolean => this.#isCancelled, + }); + + return executor(onResolve, onReject, onCancel as OnCancel); + }); + } + + get [Symbol.toStringTag]() { + return "Cancellable Promise"; + } + + public then( + onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, + onRejected?: ((reason: any) => TResult2 | PromiseLike) | null + ): Promise { + return this.#promise.then(onFulfilled, onRejected); + } + + public catch( + onRejected?: ((reason: any) => TResult | PromiseLike) | null + ): Promise { + return this.#promise.catch(onRejected); + } + + public finally(onFinally?: (() => void) | null): Promise { + return this.#promise.finally(onFinally); + } + + public cancel(): void { + if (this.#isResolved || this.#isRejected || this.#isCancelled) { + return; + } + this.#isCancelled = true; + if (this.#cancelHandlers.length) { + try { + for (const cancelHandler of this.#cancelHandlers) { + cancelHandler(); + } + } catch (error) { + console.warn('Cancellation threw an error', error); + return; + } + } + this.#cancelHandlers.length = 0; + if (this.#reject) this.#reject(new CancelError('Request aborted')); + } + + public get isCancelled(): boolean { + return this.#isCancelled; + } +} diff --git a/front/infrastructure/api/generated/core/OpenAPI.ts b/front/infrastructure/api/generated/core/OpenAPI.ts new file mode 100644 index 0000000..72869fb --- /dev/null +++ b/front/infrastructure/api/generated/core/OpenAPI.ts @@ -0,0 +1,85 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { ApiRequestOptions } from './ApiRequestOptions'; +import { API_PREFIX } from '@/app-specs'; + +type Resolver = (options: ApiRequestOptions) => Promise; +type Headers = Record; + +export type OpenAPIConfig = { + BASE: string; + VERSION: string; + WITH_CREDENTIALS: boolean; + CREDENTIALS: 'include' | 'omit' | 'same-origin'; + TOKEN?: string | Resolver | undefined; + USERNAME?: string | Resolver | undefined; + PASSWORD?: string | Resolver | undefined; + HEADERS?: Headers | Resolver | undefined; + ENCODE_PATH?: ((path: string) => string) | undefined; +}; + +// 获取BASE URL,优先使用环境变量或DOM中的配置 +const getBaseUrl = (): string => { + // 优先从环境变量读取完整 BASE URL + if (process.env.NEXT_PUBLIC_API_BASE_URL) { + return process.env.NEXT_PUBLIC_API_BASE_URL; + } + + // 从环境变量读取各个配置项 + const envHost = process.env.NEXT_PUBLIC_API_HOST; + const envPort = process.env.NEXT_PUBLIC_API_PORT; + const envPrefix = process.env.NEXT_PUBLIC_API_PREFIX; + const envHttps = process.env.NEXT_PUBLIC_API_HTTPS === 'true'; + + // 如果配置了环境变量,使用环境变量构建 URL + if (envHost || envPort || envPrefix) { + const protocol = envHttps ? 'https' : 'http'; + const host = envHost || (typeof window !== 'undefined' ? window.location.hostname : 'localhost'); + const port = envPort ? parseInt(envPort, 10) : (envHttps ? 443 : 80); + const prefix = envPrefix || '/console/api'; + + // 如果是标准端口(80/443),不显示端口号 + const portStr = ((envHttps && port === 443) || (!envHttps && port === 80)) ? '' : `:${port}`; + + return `${protocol}://${host}${portStr}${prefix}`; + } + + // 浏览器环境:从DOM获取 + if (typeof window !== 'undefined') { + const apiBaseUrl = window.document?.body?.getAttribute('data-api-base-url'); + if (apiBaseUrl) { + return apiBaseUrl; + } + } + + // 使用API_PREFIX,如果是相对路径则使用当前origin + if (API_PREFIX.startsWith('http')) { + return API_PREFIX; + } + if (typeof window !== 'undefined') { + return `${window.location.origin}${API_PREFIX}`; + } + return API_PREFIX; +}; + +// 获取认证token,与项目现有的AuthManager保持一致 +const getAuthToken = (): string => { + if (typeof window !== 'undefined' && window.localStorage) { + return window.localStorage.getItem('console_token') || ''; + } + return ''; +}; + +export const OpenAPI: OpenAPIConfig = { + BASE: getBaseUrl(), + VERSION: '1.0.0', + WITH_CREDENTIALS: true, + CREDENTIALS: 'include', + TOKEN: getAuthToken, + USERNAME: undefined, + PASSWORD: undefined, + HEADERS: undefined, + ENCODE_PATH: undefined, +}; diff --git a/front/infrastructure/api/generated/core/request.ts b/front/infrastructure/api/generated/core/request.ts new file mode 100644 index 0000000..9465136 --- /dev/null +++ b/front/infrastructure/api/generated/core/request.ts @@ -0,0 +1,364 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import { ApiError } from './ApiError'; +import type { ApiRequestOptions } from './ApiRequestOptions'; +import type { ApiResult } from './ApiResult'; +import { CancelablePromise } from './CancelablePromise'; +import type { OnCancel } from './CancelablePromise'; +import type { OpenAPIConfig } from './OpenAPI'; + +export const isDefined = (value: T | null | undefined): value is Exclude => { + return value !== undefined && value !== null; +}; + +export const isString = (value: any): value is string => { + return typeof value === 'string'; +}; + +export const isStringWithValue = (value: any): value is string => { + return isString(value) && value !== ''; +}; + +export const isBlob = (value: any): value is Blob => { + return ( + typeof value === 'object' && + typeof value.type === 'string' && + typeof value.stream === 'function' && + typeof value.arrayBuffer === 'function' && + typeof value.constructor === 'function' && + typeof value.constructor.name === 'string' && + /^(Blob|File)$/.test(value.constructor.name) && + /^(Blob|File)$/.test(value[Symbol.toStringTag]) + ); +}; + +export const isFormData = (value: any): value is FormData => { + return value instanceof FormData; +}; + +export const base64 = (str: string): string => { + try { + return btoa(str); + } catch (err) { + // @ts-ignore + return Buffer.from(str).toString('base64'); + } +}; + +export const getQueryString = (params: Record): string => { + const qs: string[] = []; + + const append = (key: string, value: any) => { + qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); + }; + + const process = (key: string, value: any) => { + if (isDefined(value)) { + if (Array.isArray(value)) { + value.forEach(v => { + process(key, v); + }); + } else if (typeof value === 'object') { + Object.entries(value).forEach(([k, v]) => { + process(`${key}[${k}]`, v); + }); + } else { + append(key, value); + } + } + }; + + Object.entries(params).forEach(([key, value]) => { + process(key, value); + }); + + if (qs.length > 0) { + return `?${qs.join('&')}`; + } + + return ''; +}; + +const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { + const encoder = config.ENCODE_PATH || encodeURI; + + const path = options.url + .replace('{api-version}', config.VERSION) + .replace(/{(.*?)}/g, (substring: string, group: string) => { + if (options.path?.hasOwnProperty(group)) { + return encoder(String(options.path[group])); + } + return substring; + }); + + const url = `${config.BASE}${path}`; + if (options.query) { + return `${url}${getQueryString(options.query)}`; + } + return url; +}; + +export const getFormData = (options: ApiRequestOptions): FormData | undefined => { + if (options.formData) { + const formData = new FormData(); + + const process = (key: string, value: any) => { + if (isString(value) || isBlob(value)) { + formData.append(key, value); + } else { + formData.append(key, JSON.stringify(value)); + } + }; + + Object.entries(options.formData) + .filter(([_, value]) => isDefined(value)) + .forEach(([key, value]) => { + if (Array.isArray(value)) { + value.forEach(v => process(key, v)); + } else { + process(key, value); + } + }); + + return formData; + } + return undefined; +}; + +type Resolver = (options: ApiRequestOptions) => Promise; + +export const resolve = async (options: ApiRequestOptions, resolver?: T | Resolver): Promise => { + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; +}; + +export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { + const [token, username, password, additionalHeaders] = await Promise.all([ + resolve(options, config.TOKEN), + resolve(options, config.USERNAME), + resolve(options, config.PASSWORD), + resolve(options, config.HEADERS), + ]); + + const headers = Object.entries({ + Accept: 'application/json', + ...additionalHeaders, + ...options.headers, + }) + .filter(([_, value]) => isDefined(value)) + .reduce((headers, [key, value]) => ({ + ...headers, + [key]: String(value), + }), {} as Record); + + if (isStringWithValue(token)) { + headers['Authorization'] = `Bearer ${token}`; + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = base64(`${username}:${password}`); + headers['Authorization'] = `Basic ${credentials}`; + } + + if (options.body !== undefined) { + if (options.mediaType) { + headers['Content-Type'] = options.mediaType; + } else if (isBlob(options.body)) { + headers['Content-Type'] = options.body.type || 'application/octet-stream'; + } else if (isString(options.body)) { + headers['Content-Type'] = 'text/plain'; + } else if (!isFormData(options.body)) { + headers['Content-Type'] = 'application/json'; + } + } + + return new Headers(headers); +}; + +export const getRequestBody = (options: ApiRequestOptions): any => { + if (options.body !== undefined) { + if (options.mediaType?.includes('/json')) { + return JSON.stringify(options.body) + } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { + return options.body; + } else { + return JSON.stringify(options.body); + } + } + return undefined; +}; + +export const sendRequest = async ( + config: OpenAPIConfig, + options: ApiRequestOptions, + url: string, + body: any, + formData: FormData | undefined, + headers: Headers, + onCancel: OnCancel +): Promise => { + const controller = new AbortController(); + + const request: RequestInit = { + headers, + body: body ?? formData, + method: options.method, + signal: controller.signal, + }; + + if (config.WITH_CREDENTIALS) { + request.credentials = config.CREDENTIALS; + } + + onCancel(() => controller.abort()); + + return await fetch(url, request); +}; + +export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => { + if (responseHeader) { + const content = response.headers.get(responseHeader); + if (isString(content)) { + return content; + } + } + return undefined; +}; + +export const getResponseBody = async (response: Response): Promise => { + if (response.status !== 204) { + try { + const contentType = response.headers.get('Content-Type'); + const contentDisposition = response.headers.get('Content-Disposition'); + const isAttachment = !!contentDisposition && contentDisposition.toLowerCase().includes('attachment'); + if (isAttachment) { + return await response.blob(); + } + if (contentType) { + const lowerType = contentType.toLowerCase(); + const jsonTypes = ['application/json', 'application/problem+json'] + const isJSON = jsonTypes.some(type => lowerType.startsWith(type)); + if (isJSON) { + return await response.json(); + } + const isBinary = lowerType.startsWith('application/octet-stream') + || lowerType.startsWith('application/zip') + || lowerType.startsWith('application/pdf') + || lowerType.startsWith('application/vnd') + || lowerType.startsWith('application/msword') + || lowerType.startsWith('application/vnd.openxmlformats-officedocument'); + if (isBinary) { + return await response.blob(); + } + return await response.text(); + } + } catch (error) { + console.error(error); + } + } + return undefined; +}; + +export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => { + const notifyError = (message: string) => { + if (!message) { + return; + } + if (typeof window === 'undefined') { + return; + } + import('antd') + .then(({ message: antdMessage }) => antdMessage.error(message)) + .catch(() => undefined); + }; + + const resolveErrorMessage = (): string => { + const body = result.body as any; + if (body?.message) { + return body.message; + } + if (body?.detail) { + return body.detail; + } + if (typeof body === 'string' && body.trim()) { + return body; + } + return ''; + }; + + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + notifyError(resolveErrorMessage() || error); + throw new ApiError(options, result, error); + } + + if (!result.ok) { + const errorStatus = result.status ?? 'unknown'; + const errorStatusText = result.statusText ?? 'unknown'; + const errorBody = (() => { + try { + return JSON.stringify(result.body, null, 2); + } catch (e) { + return undefined; + } + })(); + + notifyError(resolveErrorMessage() || errorStatusText || 'Request Error'); + throw new ApiError(options, result, + `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` + ); + } +}; + +/** + * Request method + * @param config The OpenAPI configuration object + * @param options The request options from the service + * @returns CancelablePromise + * @throws ApiError + */ +export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { + return new CancelablePromise(async (resolve, reject, onCancel) => { + try { + const url = getUrl(config, options); + const formData = getFormData(options); + const body = getRequestBody(options); + const headers = await getHeaders(config, options); + + if (!onCancel.isCancelled) { + const response = await sendRequest(config, options, url, body, formData, headers, onCancel); + const responseBody = await getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: responseHeader ?? responseBody, + }; + + catchErrorCodes(options, result); + + resolve(result.body); + } + } catch (error) { + reject(error); + } + }); +}; diff --git a/front/infrastructure/api/generated/index.ts b/front/infrastructure/api/generated/index.ts new file mode 100644 index 0000000..e7e4d8e --- /dev/null +++ b/front/infrastructure/api/generated/index.ts @@ -0,0 +1,16 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export { ApiError } from './core/ApiError'; +export { CancelablePromise, CancelError } from './core/CancelablePromise'; +export { OpenAPI } from './core/OpenAPI'; +export type { OpenAPIConfig } from './core/OpenAPI'; + +export { Service } from './services/Service'; +export { ApiKeyService } from './services/ApiKeyService'; +export { AuthService } from './services/AuthService'; +export { ConversationService } from './services/ConversationService'; +export { CostAuditService } from './services/CostAuditService'; +export { McpService } from './services/McpService'; +export { PromptService } from './services/PromptService'; diff --git a/front/infrastructure/api/generated/services/ApiKeyService.ts b/front/infrastructure/api/generated/services/ApiKeyService.ts new file mode 100644 index 0000000..de6b6ce --- /dev/null +++ b/front/infrastructure/api/generated/services/ApiKeyService.ts @@ -0,0 +1,206 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class ApiKeyService { + /** + * 删除指定的API Key。 + * + * Args: + * id (int, required): 要删除的API Key的ID + * + * Returns: + * dict: 删除操作的结果 + * + * Raises: + * CommonError: 当API Key不存在或不属于当前用户时抛出 + * 删除指定的 API Key + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static deleteApikey( + requestBody: { + /** + * API Key ID + */ + id: number; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/apikey', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取当前用户的所有API Key列表。 + * + * Returns: + * dict: 包含API Key详细信息的字典,使用apikey_detail_fields格式化 + * + * Raises: + * CommonError: 当查询失败时抛出 + * 获取当前用户的所有 API Key 列表 + * @returns any 成功 + * @throws ApiError + */ + public static getApikey(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apikey', + errors: { + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建新的API Key。 + * + * Args: + * description (str, optional): API Key的描述信息 + * expire_date (str, optional): 过期时间,格式为YYYY-MM-DD + * tenant_id (str, required): 空间ID,多个空间ID用逗号分隔 + * + * Returns: + * dict: 新创建的API Key详细信息 + * + * Raises: + * CommonError: 当参数验证失败或创建失败时抛出 + * 创建新的 API Key + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postApikey( + requestBody: { + /** + * API Key 描述 + */ + description?: string; + /** + * 过期日期,格式:YYYY-MM-DD + */ + expire_date?: string; + /** + * 空间ID,多个空间ID用逗号分隔 + */ + tenant_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apikey', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新API Key的状态。 + * + * Args: + * id (int, required): 要更新的API Key的ID + * status (str, required): 新的状态,可选值:active, disabled, deleted, expired + * + * Returns: + * dict: 更新后的API Key详细信息 + * + * Raises: + * CommonError: 当API Key不存在、不属于当前用户或状态转换不允许时抛出 + * 更新 API Key 的状态(active, disabled, deleted, expired) + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static putApikey( + requestBody: { + /** + * API Key ID + */ + id: number; + /** + * 状态:active, disabled, deleted, expired + */ + status: 'active' | 'disabled' | 'deleted' | 'expired'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/apikey', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 使用API Key与指定应用进行对话。 + * + * Args: + * app_id (str): 应用ID + * inputs (list, required): 输入内容列表 + * mode (str, optional): 运行模式,默认为"publish" + * files (list, optional): 文件列表,可为空 + * + * Returns: + * dict: 对话结果数据 + * + * Raises: + * CommonError: 当API Key验证失败、应用不存在或服务未开启时抛出 + * 使用 API Key 与指定应用进行对话 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postApikeyChat( + appId: string, + requestBody: { + /** + * 文件列表,可为空 + */ + files?: Array; + /** + * 输入内容列表 + */ + inputs: Array; + /** + * 运行模式,默认为 publish + */ + mode?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apikey/chat/{app_id}', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } +} diff --git a/front/infrastructure/api/generated/services/AuthService.ts b/front/infrastructure/api/generated/services/AuthService.ts new file mode 100644 index 0000000..6eefe1d --- /dev/null +++ b/front/infrastructure/api/generated/services/AuthService.ts @@ -0,0 +1,780 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class AuthService { + /** + * 管理员添加用户。 + * + * 允许管理员创建新用户账号,不需要短信验证码。 + * 只有具有管理员权限的用户才能调用此接口。 + * + * Returns: + * dict: 包含创建成功结果和用户ID的字典 + * + * Raises: + * ValueError: 当非管理员调用或输入信息无效时抛出 + * 管理员创建新用户账号,不需要短信验证码 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAccountAddUser( + requestBody: { + /** + * 确认密码 + */ + confirm_password: string; + /** + * 邮箱(可选) + */ + email?: string; + /** + * 用户名 + */ + name: string; + /** + * 密码 + */ + password: string; + /** + * 手机号(可选) + */ + phone?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/account/add_user', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 修改用户密码。 + * + * 允许用户修改自己的登录密码,需要提供当前密码进行验证。 + * 修改成功后记录密码变更日志。 + * + * Returns: + * dict: 密码修改成功的结果字典 + * + * Raises: + * ValueError: 当新密码确认不一致或当前密码验证失败时抛出 + * 修改当前用户的登录密码 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAccountPassword( + requestBody: { + /** + * 新密码 + */ + new_password: string; + /** + * 当前密码(可选) + */ + password?: string; + /** + * 确认新密码 + */ + repeat_new_password: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/account/password', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取当前用户资料信息。 + * + * 返回当前登录用户的详细信息以及当前租户信息和权限角色。 + * 包括用户基本信息、租户状态、用户在租户中的角色等。 + * + * Returns: + * dict: 包含用户信息和租户信息的字典 + * 获取当前登录用户的详细信息和租户信息 + * @returns any 成功 + * @throws ApiError + */ + public static getAccountProfile(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/account/profile', + errors: { + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新用户基本信息。 + * + * 允许用户修改姓名、邮箱、手机号等基本信息。 + * 会验证信息格式和唯一性约束,修改成功后记录更新日志。 + * + * Returns: + * dict: 用户信息更新成功的结果字典 + * + * Raises: + * ValueError: 当输入格式无效或违反唯一性约束时抛出 + * 更新当前用户的基本信息(姓名、邮箱、手机号) + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAccountUpdate( + requestBody: { + /** + * 邮箱(可选) + */ + email?: string; + /** + * 用户名(可选) + */ + name?: string; + /** + * 手机号(可选) + */ + phone?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/account/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 校验用户信息唯一性。 + * + * 验证用户名、手机号或邮箱是否已被其他用户使用。 + * 用于注册前的重复性检查。 + * + * Returns: + * dict: 包含验证结果的字典,success表示可用,failed表示已存在 + * + * Note: + * 即使验证失败也不会抛出异常,而是返回包含错误信息的字典 + * 验证用户名、手机号或邮箱是否已被使用 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAccountValidateExist( + requestBody: { + /** + * 邮箱(可选) + */ + email?: string; + /** + * 用户名(可选) + */ + name?: string; + /** + * 手机号(可选) + */ + phone?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/account/validate_exist', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 发送密码重置邮件。 + * + * 向用户注册邮箱发送包含重置链接的邮件。在调试模式下, + * 响应中会包含重置令牌用于测试目的。 + * + * Request Body: + * email (str): 用户注册邮箱地址 + * + * Returns: + * dict: 包含操作结果的字典 + * - result (str): 操作结果状态 + * - token (str, optional): 调试模式下的重置令牌 + * + * Raises: + * InvalidEmailError: 邮箱格式无效 + * ValueError: 邮箱未注册 + * + * Example: + * POST /forgot-password + * { + * "email": "user@example.com" + * } + * 向用户注册邮箱发送包含重置链接的邮件 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postForgotPassword( + requestBody: { + /** + * 用户邮箱 + */ + email: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/forgot-password', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 管理员强制重置用户密码。 + * + * 允许具有管理员权限的用户为任意指定用户重置密码, + * 无需密码重置令牌。操作会被详细记录在审计日志中。 + * + * Request Body: + * name (str): 目标用户名 + * new_password (str): 新密码 + * password_confirm (str): 新密码确认 + * + * Returns: + * dict: 包含操作结果的字典 + * - result (str): 操作结果状态 + * + * Raises: + * PasswordMismatchError: 密码确认不一致 + * ValueError: 权限不足、用户不存在或密码强度不足 + * + * Example: + * POST /forgot-password/admin-resets + * { + * "name": "target_user", + * "new_password": "new_secure_password", + * "password_confirm": "new_secure_password" + * } + * 管理员强制重置指定用户的密码 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postForgotPasswordAdminResets( + requestBody: { + /** + * 目标用户名 + */ + name: string; + /** + * 新密码 + */ + new_password: string; + /** + * 确认新密码 + */ + password_confirm: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/forgot-password/admin-resets', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 重置用户密码。 + * + * 使用有效的重置令牌更新用户密码。验证新密码的强度和一致性, + * 生成新的密码哈希,更新数据库并记录操作日志。 + * + * Request Body: + * token (str): 密码重置令牌(管理员重置时可为特殊值) + * new_password (str): 新密码 + * password_confirm (str): 新密码确认 + * + * Returns: + * dict: 包含操作结果的字典 + * - result (str): 操作结果状态 + * + * Raises: + * PasswordMismatchError: 密码确认不一致 + * InvalidTokenError: 令牌无效或已过期 + * ValueError: 密码强度不足或其他验证错误 + * + * Example: + * POST /forgot-password/resets + * { + * "token": "reset_token_string", + * "new_password": "new_secure_password", + * "password_confirm": "new_secure_password" + * } + * 使用有效的重置令牌更新用户密码 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postForgotPasswordResets( + requestBody: { + /** + * 新密码 + */ + new_password: string; + /** + * 确认新密码 + */ + password_confirm: string; + /** + * 密码重置令牌 + */ + token: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/forgot-password/resets', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 验证密码重置令牌的有效性。 + * + * 检查用户提供的重置令牌是否有效且未过期。 + * 返回令牌状态和关联的邮箱地址。 + * + * Request Body: + * token (str): 密码重置令牌 + * + * Returns: + * dict: 包含验证结果的字典 + * - is_valid (bool): 令牌是否有效 + * - email (str or None): 关联的邮箱地址 + * + * Example: + * POST /forgot-password/validity + * { + * "token": "reset_token_string" + * } + * 验证密码重置令牌的有效性 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postForgotPasswordValidity( + requestBody: { + /** + * 密码重置令牌 + */ + token: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/forgot-password/validity', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 进行 ECDH 密钥交换 + * + * 请求格式: + * { + * "frontend_public_key": "Base64编码的前端公钥" + * } + * + * 响应格式: + * { + * "backend_public_key": "Base64编码的后端公钥", + * "session_id": "会话ID(UUID)", + * "expires_in": 300, + * "algorithm": "ECDH-P256 + AES-256-GCM" + * } + * + * Returns: + * dict: 包含后端公钥和会话 ID 的字典 + * + * Raises: + * ValueError: 当前端公钥格式错误时抛出 + * 进行 ECDH 密钥交换,获取会话密钥用于数据加密 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postKeyExchange( + requestBody: { + /** + * 前端公钥(Base64编码) + */ + frontend_public_key: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/key_exchange', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 用户密码登录。 + * + * 接收 encrypted_data 和 session_id 参数,使用 ECDH 会话密钥解密。 + * 请求数据应包含:name 或 email 或 phone(至少一个),以及 password + * + * 使用用户名/邮箱和密码进行身份验证并登录系统。 + * 验证成功后记录登录日志并返回访问令牌。 + * + * Returns: + * dict: 包含登录成功结果和访问令牌的字典 + * + * Raises: + * ValueError: 当身份验证失败时抛出 + * 使用用户名/邮箱/手机号和密码进行登录 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postLogin( + requestBody: { + /** + * 加密后的登录数据(Base64编码) + */ + encrypted_data: string; + /** + * 会话ID(从密钥交换接口获取) + */ + session_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/login', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 短信验证码登录。 + * + * 接收 encrypted_data 和 session_id 参数,使用 ECDH 会话密钥解密。 + * 请求数据应包含:phone, verify_code + * + * 使用手机号和短信验证码进行身份验证并登录系统。 + * 如果用户账号不存在,会缓存验证码用于后续注册流程。 + * + * Returns: + * dict: 包含登录成功结果和访问令牌的字典 + * + * Raises: + * ValueError: 当验证码验证失败或用户认证失败时抛出 + * 使用手机号和短信验证码进行登录 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postLoginSms( + requestBody: { + /** + * 加密后的登录数据(Base64编码) + */ + encrypted_data: string; + /** + * 会话ID(从密钥交换接口获取) + */ + session_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/login_sms', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 用户退出登录。 + * + * 注销当前用户会话,删除访问令牌并记录退出日志。 + * + * Returns: + * dict: 退出成功的结果字典 + * 注销当前用户会话 + * @returns any 成功 + * @throws ApiError + */ + public static getLogout(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/logout', + errors: { + 401: `未授权`, + }, + }); + } + /** + * 处理OAuth回调请求。 + * + * 处理OAuth授权完成后的回调,获取用户信息并进行登录或绑定流程。 + * 如果用户账号不存在或未绑定手机号,将跳转到手机绑定页面。 + * 如果账号已存在,则直接登录并返回访问令牌。 + * + * Args: + * provider (str): OAuth提供商名称(如'github') + * + * Returns: + * Response: 重定向响应,跳转到绑定页面或登录成功页面 + * + * Raises: + * ValueError: 当提供商不存在时抛出 + * HTTPError: 当OAuth授权失败时抛出 + * 处理 OAuth 授权完成后的回调请求 + * @param provider OAuth 提供商名称 + * @param code OAuth 授权码 + * @returns any 成功 + * @throws ApiError + */ + public static getOauthAuthorize( + provider: 'github', + code: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/oauth/authorize/{provider}', + path: { + 'provider': provider, + }, + query: { + 'code': code, + }, + errors: { + 302: `重定向到绑定页面或登录成功页面`, + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 完成OAuth账号与手机号绑定。 + * + * 处理OAuth账号绑定手机号的请求,验证短信验证码后创建或关联账号。 + * 支持以下场景: + * 1. 手机号已存在账号:直接关联 + * 2. 邮箱已存在账号:更新手机号 + * 3. 全新用户:创建新账号 + * + * Args: + * provider (str): OAuth提供商名称(如'github') + * + * Returns: + * dict: 包含登录成功结果和访问令牌的字典 + * + * Raises: + * ValueError: 当提供商不存在、信息过期或验证码错误时抛出 + * 完成 OAuth 账号与手机号的绑定 + * @param provider OAuth 提供商名称 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postOauthAuthorize( + provider: 'github', + requestBody: { + /** + * OAuth 用户ID + */ + openid: string; + /** + * 手机号 + */ + phone: string; + /** + * 短信验证码 + */ + verify_code: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/oauth/authorize/{provider}', + path: { + 'provider': provider, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 启动OAuth登录流程。 + * + * 生成OAuth授权URL并重定向用户到OAuth提供商的授权页面。 + * + * Args: + * provider (str): OAuth提供商名称(如'github') + * + * Returns: + * Response: 重定向响应,跳转到OAuth授权页面 + * + * Raises: + * ValueError: 当提供商不存在或配置无效时抛出 + * 启动 OAuth 登录流程,重定向到 OAuth 提供商授权页面 + * @param provider OAuth 提供商名称 + * @returns any 成功 + * @throws ApiError + */ + public static getOauthLogin( + provider: 'github', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/oauth/login/{provider}', + path: { + 'provider': provider, + }, + errors: { + 302: `重定向到 OAuth 授权页面`, + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 注册新用户账号。 + * + * 接收 encrypted_data 和 session_id 参数,使用 ECDH 会话密钥解密。 + * 请求数据应包含:name, email, phone, password, confirm_password, verify_code + * + * Returns: + * dict: 登录成功后的令牌信息 + * + * Raises: + * ValueError: 当输入信息无效或密码不一致时抛出 + * 注册新用户账号,需要提供加密后的用户信息和短信验证码 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postRegister( + requestBody: { + /** + * 加密后的注册数据(Base64编码) + */ + encrypted_data: string; + /** + * 会话ID(从密钥交换接口获取) + */ + session_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/register', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 发送短信验证码。 + * + * 根据指定的操作类型向手机号发送短信验证码。 + * 支持的操作类型包括:login、register、reset、relate。 + * + * Returns: + * dict: 发送成功的结果字典 + * + * Raises: + * ValueError: 当发送频率过快或其他验证失败时抛出 + * 向指定手机号发送短信验证码 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postSendsms( + requestBody: { + /** + * 操作类型 + */ + operation: 'login' | 'register' | 'reset' | 'relate'; + /** + * 手机号 + */ + phone: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/sendsms', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + } diff --git a/front/infrastructure/api/generated/services/ConversationService.ts b/front/infrastructure/api/generated/services/ConversationService.ts new file mode 100644 index 0000000..bd7716c --- /dev/null +++ b/front/infrastructure/api/generated/services/ConversationService.ts @@ -0,0 +1,254 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class ConversationService { + /** + * 对对话的结果进行反馈。 + * + * Args: + * app_id (str): 应用ID + * sessionid (str, required): 会话ID + * speak_id (int, required): 对话消息ID + * is_satisfied (bool, required): 是否满意 + * user_feedback (str, required): 用户反馈内容 + * + * Returns: + * dict: 反馈结果 + * + * Raises: + * Exception: 当反馈处理失败时抛出 + * 对对话结果进行用户反馈 + * @param appId 应用ID + * @param authorization 认证令牌,格式: Bearer 或直接 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postConversationFeedback( + appId: string, + authorization: string, + requestBody: { + /** + * 是否满意 + */ + is_satisfied: boolean; + /** + * 会话ID + */ + sessionid: string; + /** + * 对话消息ID + */ + speak_id: number; + /** + * 用户反馈内容 + */ + user_feedback: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/conversation/{app_id}/feedback', + path: { + 'app_id': appId, + }, + headers: { + 'Authorization': authorization, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 获取某个会话的历史记录。 + * + * Args: + * app_id (str): 应用ID + * sessionid (str, required): 会话ID + * start_id (int, optional): 起始消息ID + * + * Returns: + * dict: 包含历史记录的字典 + * + * Raises: + * Exception: 当获取历史记录失败时抛出 + * 获取指定会话的历史对话记录 + * @param appId 应用ID + * @param sessionid 会话ID + * @param authorization 认证令牌,格式: Bearer 或直接 + * @param startId 起始消息ID,用于分页 + * @returns any 成功 + * @throws ApiError + */ + public static getConversationHistory( + appId: string, + sessionid: string, + authorization: string, + startId?: number, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/conversation/{app_id}/history', + path: { + 'app_id': appId, + }, + headers: { + 'Authorization': authorization, + }, + query: { + 'sessionid': sessionid, + 'start_id': startId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 换取用户信息。 + * + * Args: + * app_id (str): 应用ID + * + * Returns: + * dict: 包含认证令牌的字典 + * + * Raises: + * Exception: 当初始化失败时抛出 + * 初始化用户身份并获取认证令牌,用于后续对话接口的认证 + * @param appId 应用ID + * @param tempToken 临时令牌(可选) + * @param token 认证令牌(可选) + * @returns any 成功 + * @throws ApiError + */ + public static getConversationInit( + appId: string, + tempToken?: string, + token?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/conversation/{app_id}/init', + path: { + 'app_id': appId, + }, + headers: { + 'TempToken': tempToken, + }, + query: { + '_token': token, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 跟app对话。 + * + * Args: + * app_id (str): 应用ID + * sessionid (str, required): 会话ID + * inputs (list, required): 输入内容列表 + * files (list, optional): 文件列表 + * mode (str, optional): 运行模式,默认为publish + * + * Returns: + * Response: SSE流式响应 + * + * Raises: + * ValueError: 当应用服务关闭时抛出 + * 向应用发送消息并获取流式响应(SSE格式) + * @param appId 应用ID + * @param authorization 认证令牌,格式: Bearer 或直接 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postConversationRun( + appId: string, + authorization: string, + requestBody: { + /** + * 文件列表(可选) + */ + files?: Array; + /** + * 输入内容列表 + */ + inputs: Array; + /** + * 运行模式,publish为发布模式,draft为草稿模式 + */ + mode?: 'publish' | 'draft'; + /** + * 会话ID + */ + sessionid: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/conversation/{app_id}/run', + path: { + 'app_id': appId, + }, + headers: { + 'Authorization': authorization, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 获取会话列表。 + * + * Args: + * app_id (str): 应用ID + * + * Returns: + * dict: 包含会话列表的字典 + * + * Raises: + * Exception: 当获取会话列表失败时抛出 + * 获取当前用户的所有对话会话列表 + * @param appId 应用ID + * @param authorization 认证令牌,格式: Bearer 或直接 + * @returns any 成功 + * @throws ApiError + */ + public static getConversationSessions( + appId: string, + authorization: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/conversation/{app_id}/sessions', + path: { + 'app_id': appId, + }, + headers: { + 'Authorization': authorization, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } +} diff --git a/front/infrastructure/api/generated/services/CostAuditService.ts b/front/infrastructure/api/generated/services/CostAuditService.ts new file mode 100644 index 0000000..689021b --- /dev/null +++ b/front/infrastructure/api/generated/services/CostAuditService.ts @@ -0,0 +1,440 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class CostAuditService { + /** + * 获取指定app_id的统计指标,优先从redis缓存读取。 + * + * Args: + * 通过JSON请求体传递参数: + * app_id (str): 应用的唯一标识符。 + * + * Returns: + * dict: 包含统计指标的字典,包括累计token消费、用户数、会话数、互动数等。 + * + * Example: + * 请求示例: + * POST /costaudit/app_statistics + * Content-Type: application/json + * { + * "app_id": "123e4567-e89b-12d3-a456-426614174000" + * } + * 获取指定app_id的统计指标,优先从redis缓存读取 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postCostauditAppStatistics( + requestBody: { + /** + * 应用ID + */ + app_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/costaudit/app_statistics', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询应用的成本审计信息。 + * + * Args: + * app_id (str): 应用的唯一标识符。 + * + * Returns: + * dict: 包含应用成本审计信息的字典,包括调试和发布模式的调用次数和Token使用数。 + * 查询指定应用的成本审计信息,包括调试和发布模式的调用次数和Token使用数 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getCostauditApps( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/costaudit/apps/{app_id}', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 遍历所有app_id,统计近7天、近30天的数据并缓存到redis。 + * + * Args: + * 通过JSON请求体传递参数: + * stat_date (str, optional): 统计基准日期,格式为"YYYY-MM-DD"。如果不提供,则使用今天作为基准日期。 + * + * Returns: + * dict: 包含操作结果的字典。 + * + * Example: + * 请求示例: + * POST /costaudit/cache_app_statistics_for_periods + * Content-Type: application/json + * { + * "stat_date": "2025-06-07" + * } + * 遍历所有app_id,统计近7天、近30天的数据并缓存到redis + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postCostauditCacheAppStatisticsForPeriods( + requestBody: { + /** + * 统计基准日期,格式为YYYY-MM-DD。如果不提供,则使用今天作为基准日期 + */ + stat_date?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/costaudit/cache_app_statistics_for_periods', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 统计指定app_id下的各类指标,并存入AppStatistics表。 + * + * Args: + * 通过JSON请求体传递参数: + * app_id (str): 应用的唯一标识符。 + * call_type (str, optional): 调用类型,默认为"release"。 + * stat_date (str, optional): 统计日期,格式为"YYYY-MM-DD"。 + * stat_date_start (str, optional): 统计开始日期,格式为"YYYY-MM-DD"。 + * stat_date_end (str, optional): 统计结束日期,格式为"YYYY-MM-DD"。 + * need_save_db (bool, optional): 是否需要保存到数据库,默认为False。 + * + * Returns: + * dict: 包含统计结果的字典。 + * + * Example: + * 请求示例: + * POST /costaudit/calc_and_save_app_statistics + * Content-Type: application/json + * { + * "app_id": "123e4567-e89b-12d3-a456-426614174000", + * "call_type": "release", + * "stat_date": "2025-06-01", + * "stat_date_start": "2025-06-01", + * "stat_date_end": "2025-06-07", + * "need_save_db": true + * } + * 统计指定app_id下的各类指标,并存入AppStatistics表 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postCostauditCalcAndSaveAppStatistics( + requestBody: { + /** + * 应用ID + */ + app_id?: string; + /** + * 调用类型 + */ + call_type?: 'debug' | 'release'; + /** + * 是否需要保存到数据库 + */ + need_save_db?: boolean; + /** + * 统计日期,格式为YYYY-MM-DD + */ + stat_date?: string; + /** + * 统计结束日期,格式为YYYY-MM-DD + */ + stat_date_end?: string; + /** + * 统计开始日期,格式为YYYY-MM-DD + */ + stat_date_start?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/costaudit/calc_and_save_app_statistics', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 遍历所有app_id,统计指定日期的数据并存入AppStatistics表。 + * + * Args: + * 通过JSON请求体传递参数: + * stat_date (str, optional): 统计日期,格式为"YYYY-MM-DD"。如果不提供,则统计昨天的数据。 + * + * Returns: + * dict: 包含操作结果的字典。 + * + * Example: + * 请求示例: + * POST /costaudit/daily_app_statistics + * Content-Type: application/json + * { + * "stat_date": "2025-06-01" + * } + * 遍历所有app_id,统计指定日期的数据并存入AppStatistics表 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postCostauditDailyAppStatistics( + requestBody: { + /** + * 统计日期,格式为YYYY-MM-DD。如果不提供,则统计昨天的数据 + */ + stat_date?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/costaudit/daily_app_statistics', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取指定app_id和时间区间的统计数据,优先从redis获取,未命中则实时统计。 + * + * Args: + * 通过JSON请求体传递参数: + * app_id (str): 应用的唯一标识符。 + * start_date (str): 起始日期,格式为"YYYY-MM-DD"。 + * end_date (str): 结束日期,格式为"YYYY-MM-DD"。 + * + * Returns: + * dict: 包含统计数据的字典。 + * + * Example: + * 请求示例: + * POST /costaudit/get_app_statistics_by_period + * Content-Type: application/json + * { + * "app_id": "123e4567-e89b-12d3-a456-426614174000", + * "start_date": "2025-06-01", + * "end_date": "2025-06-07" + * } + * 获取指定app_id和时间区间的统计数据,优先从redis获取,未命中则实时统计 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postCostauditGetAppStatisticsByPeriod( + requestBody: { + /** + * 应用ID + */ + app_id: string; + /** + * 结束日期,格式为YYYY-MM-DD + */ + end_date: string; + /** + * 起始日期,格式为YYYY-MM-DD + */ + start_date: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/costaudit/get_app_statistics_by_period', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询AppStatistics表,支持按app_id、时间区间、call_type过滤。 + * + * Args: + * 通过JSON请求体传递参数: + * app_id (str): 应用的唯一标识符。 + * start_date (str, optional): 起始日期,格式为"YYYY-MM-DD"。 + * end_date (str, optional): 结束日期,格式为"YYYY-MM-DD"。 + * call_type (str, optional): 调用类型,用于过滤数据。 + * + * Returns: + * dict: 包含查询结果的字典。 + * + * Example: + * 请求示例: + * POST /costaudit/query_app_statistics + * Content-Type: application/json + * { + * "app_id": "123e4567-e89b-12d3-a456-426614174000", + * "start_date": "2025-06-01", + * "end_date": "2025-06-07", + * "call_type": "release" + * } + * 查询AppStatistics表,支持按app_id、时间区间、call_type过滤 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postCostauditQueryAppStatistics( + requestBody: { + /** + * 应用ID + */ + app_id?: string; + /** + * 调用类型,用于过滤数据 + */ + call_type?: 'debug' | 'release'; + /** + * 结束日期,格式为YYYY-MM-DD + */ + end_date?: string; + /** + * 起始日期,格式为YYYY-MM-DD + */ + start_date?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/costaudit/query_app_statistics', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询Conversation表,支持按app_id、时间区间、from_who过滤。 + * + * Args: + * 通过JSON请求体传递参数: + * app_id (str, optional): 应用的唯一标识符。 + * start_time (str, optional): 起始时间,格式为"YYYY-MM-DD HH:MM:SS"。 + * end_time (str, optional): 结束时间,格式为"YYYY-MM-DD HH:MM:SS"。 + * from_who (str, optional): 用户ID,用于过滤特定用户的对话。 + * + * Returns: + * dict: 包含查询结果的字典。 + * + * Example: + * 请求示例: + * POST /costaudit/query_conversations + * Content-Type: application/json + * { + * "app_id": "123e4567-e89b-12d3-a456-426614174000", + * "start_time": "2025-06-01 00:00:00", + * "end_time": "2025-06-07 23:59:59", + * "from_who": "user-001" + * } + * 查询Conversation表,支持按app_id、时间区间、from_who过滤 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postCostauditQueryConversations( + requestBody: { + /** + * 应用ID(可选) + */ + app_id?: string; + /** + * 结束时间,格式为YYYY-MM-DD HH:MM:SS + */ + end_time?: string; + /** + * 用户ID,用于过滤特定用户的对话 + */ + from_who?: string; + /** + * 起始时间,格式为YYYY-MM-DD HH:MM:SS + */ + start_time?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/costaudit/query_conversations', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询费用统计数据。 + * + * Args: + * tenant_id (str, optional): 组织的唯一标识符。如果有组织ID,查询当前组织下所有用户的费用统计数据,否则查询当前用户的费用统计数据。 + * + * Returns: + * dict: 包含费用统计数据的字典,包括各类别的统计信息和总计数据。 + * 查询费用统计数据,支持按租户统计。如果有租户ID,查询该租户下所有用户的费用统计数据,否则查询当前用户的费用统计数据 + * @param tenantId 租户ID,如果提供则查询该租户下所有用户的费用统计数据 + * @returns any 成功 + * @throws ApiError + */ + public static getCostauditStats( + tenantId?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/costaudit/stats', + query: { + 'tenant_id': tenantId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + } diff --git a/front/infrastructure/api/generated/services/McpService.ts b/front/infrastructure/api/generated/services/McpService.ts new file mode 100644 index 0000000..1be0d2e --- /dev/null +++ b/front/infrastructure/api/generated/services/McpService.ts @@ -0,0 +1,994 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class McpService { + /** + * 获取MCP工具引用结果 + * 获取引用指定MCP工具的应用列表,需要登录 + * @param id MCP工具ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getMcpReferenceResult( + id: number, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/mcp/reference-result', + query: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取MCP服务器分页列表。 + * + * 根据传入的查询条件获取MCP服务器的分页列表,支持按发布状态、 + * 启用状态、标签、名称等条件进行筛选。 + * + * Args: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * publish (list, optional): 发布状态列表。 + * enable (bool, optional): 启用状态。 + * qtype (str, optional): 查询类型,可选值:mine/group/builtin/already,默认为already。 + * search_tags (list, optional): 搜索标签列表,默认为空列表。 + * search_name (str, optional): 搜索名称,默认为空字符串。 + * user_id (list, optional): 用户ID列表,默认为空列表。 + * + * Returns: + * dict: 包含MCP服务器分页信息的字典。 + * + * Raises: + * ValueError: 当请求参数不合法时抛出。 + * 根据传入的查询条件获取MCP服务器的分页列表,支持按发布状态、启用状态、标签、名称等条件进行筛选,需要登录 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postMcpServers( + requestBody?: { + /** + * 启用状态 + */ + enable?: boolean; + /** + * 页码,从 1 开始 + */ + page?: number; + /** + * 每页大小 + */ + page_size?: number; + /** + * 发布状态列表 + */ + publish?: Array; + /** + * 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 搜索名称 + */ + search_name?: string; + /** + * 搜索标签列表 + */ + search_tags?: Array; + /** + * 用户ID列表 + */ + user_id?: Array; + }, + ): CancelablePromise<{ + /** + * MCP服务器列表 + */ + data?: Array<{ + /** + * 创建时间 + */ + created_at?: string; + /** + * 服务器描述 + */ + description?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * HTTP头 + */ + headers?: Record; + /** + * HTTP URL + */ + http_url?: string; + /** + * 服务器图标 + */ + icon?: string; + /** + * 服务器ID + */ + id?: number; + /** + * 服务器名称 + */ + name?: string; + /** + * 是否发布 + */ + publish?: boolean; + /** + * 发布时间 + */ + publish_at?: string; + /** + * 发布类型 + */ + publish_type?: 'group' | 'builtin'; + /** + * 引用状态 + */ + ref_status?: boolean; + /** + * STDIO参数 + */ + stdio_arguments?: string; + /** + * STDIO命令 + */ + stdio_command?: string; + /** + * STDIO环境变量 + */ + stdio_env?: Record; + /** + * 同步工具时间 + */ + sync_tools_at?: string; + /** + * 标签列表 + */ + tags?: Array; + /** + * 租户ID + */ + tenant_id?: string; + /** + * 测试状态 + */ + test_state?: 'success' | 'error' | 'pending'; + /** + * 超时时间 + */ + timeout?: number; + /** + * 传输类型 + */ + transport_type?: 'stdio' | 'http'; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/servers', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 检查MCP服务器名称是否已存在。 + * + * 验证指定的服务器名称是否已经被使用。 + * + * Args: + * name (str): 要检查的服务器名称。 + * + * Returns: + * dict: 包含检查结果的字典,成功时返回{"message": "success", "code": 200}。 + * + * Raises: + * ValueError: 当输入参数格式有误或名称已存在时抛出。 + * 验证指定的服务器名称是否已经被使用,需要登录 + * @param requestBody 检查参数 + * @returns any 名称可用 + * @throws ApiError + */ + public static postMcpServersCheckName( + requestBody: { + /** + * 要检查的服务器名称 + */ + name: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/servers/check-name', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建或更新MCP服务器。 + * + * 根据传入的数据创建新的MCP服务器或更新已存在的服务器。 + * 如果数据中包含id字段则进行更新,否则创建新服务器。 + * + * Args: + * name (str): 服务器名称。 + * id (int, optional): 服务器ID,如果提供则进行更新。 + * description (str, optional): 服务器描述。 + * icon (str, optional): 服务器图标。 + * transport_type (str): 传输类型。 + * timeout (int, optional): 超时时间。 + * stdio_command (str, optional): STDIO命令。 + * stdio_arguments (str, optional): STDIO参数。 + * stdio_env (dict, optional): STDIO环境变量。 + * http_url (str, optional): HTTP URL。 + * headers (dict, optional): HTTP头。 + * + * Returns: + * dict: 包含创建或更新后服务器详细信息的字典。 + * + * Raises: + * ValueError: 当输入参数不合法或缺少必要参数时抛出。 + * 根据传入的数据创建新的MCP服务器或更新已存在的服务器。如果数据中包含id字段则进行更新,否则创建新服务器,需要登录和写入权限 + * @param requestBody 服务器数据 + * @returns any 创建或更新成功 + * @throws ApiError + */ + public static postMcpServersCreateUpdate( + requestBody: { + /** + * 服务器描述 + */ + description?: string; + /** + * HTTP头 + */ + headers?: Record; + /** + * HTTP URL + */ + http_url?: string; + /** + * 服务器图标 + */ + icon?: string; + /** + * 服务器ID,如果提供则进行更新 + */ + id?: number; + /** + * 服务器名称 + */ + name: string; + /** + * STDIO参数 + */ + stdio_arguments?: string; + /** + * STDIO命令 + */ + stdio_command?: string; + /** + * STDIO环境变量 + */ + stdio_env?: Record; + /** + * 超时时间 + */ + timeout?: number; + /** + * 传输类型:stdio 或 http + */ + transport_type: 'stdio' | 'http'; + }, + ): CancelablePromise<{ + /** + * 创建时间 + */ + created_at?: string; + /** + * 服务器描述 + */ + description?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * HTTP头 + */ + headers?: Record; + /** + * HTTP URL + */ + http_url?: string; + /** + * 服务器图标 + */ + icon?: string; + /** + * 服务器ID + */ + id?: number; + /** + * 服务器名称 + */ + name?: string; + /** + * 是否发布 + */ + publish?: boolean; + /** + * 发布时间 + */ + publish_at?: string; + /** + * 发布类型 + */ + publish_type?: 'group' | 'builtin'; + /** + * 引用状态 + */ + ref_status?: boolean; + /** + * STDIO参数 + */ + stdio_arguments?: string; + /** + * STDIO命令 + */ + stdio_command?: string; + /** + * STDIO环境变量 + */ + stdio_env?: Record; + /** + * 同步工具时间 + */ + sync_tools_at?: string; + /** + * 标签列表 + */ + tags?: Array; + /** + * 租户ID + */ + tenant_id?: string; + /** + * 测试状态 + */ + test_state?: 'success' | 'error' | 'pending'; + /** + * 超时时间 + */ + timeout?: number; + /** + * 传输类型 + */ + transport_type?: 'stdio' | 'http'; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/servers/create-update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除MCP服务器。 + * + * 删除指定的MCP服务器,删除前会检查服务器是否被引用。 + * + * Args: + * id (int): 要删除的服务器ID。 + * + * Returns: + * dict: 包含删除结果的字典。 + * + * Raises: + * ValueError: 当输入参数不合法或服务器被引用时抛出。 + * 删除指定的MCP服务器,删除前会检查服务器是否被引用,需要登录和管理员权限 + * @param requestBody MCP服务器ID + * @returns any 删除成功 + * @throws ApiError + */ + public static postMcpServersDelete( + requestBody: { + /** + * MCP服务器ID + */ + id: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/servers/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取MCP服务器详细信息。 + * + * 根据MCP服务器ID获取服务器的详细信息。 + * + * Args: + * mcp_server_id (int): MCP服务器ID。 + * + * Returns: + * dict: 包含MCP服务器详细信息的字典。 + * + * Raises: + * ValueError: 当找不到指定的MCP服务器时抛出。 + * ForbiddenError: 当用户没有读取权限时抛出。 + * 根据MCP服务器ID获取服务器的详细信息,需要登录 + * @param mcpServerId MCP服务器ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getMcpServersDetail( + mcpServerId: number, + ): CancelablePromise<{ + /** + * 创建时间 + */ + created_at?: string; + /** + * 服务器描述 + */ + description?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * HTTP头 + */ + headers?: Record; + /** + * HTTP URL + */ + http_url?: string; + /** + * 服务器图标 + */ + icon?: string; + /** + * 服务器ID + */ + id?: number; + /** + * 服务器名称 + */ + name?: string; + /** + * 是否发布 + */ + publish?: boolean; + /** + * 发布时间 + */ + publish_at?: string; + /** + * 发布类型 + */ + publish_type?: 'group' | 'builtin'; + /** + * 引用状态 + */ + ref_status?: boolean; + /** + * STDIO参数 + */ + stdio_arguments?: string; + /** + * STDIO命令 + */ + stdio_command?: string; + /** + * STDIO环境变量 + */ + stdio_env?: Record; + /** + * 同步工具时间 + */ + sync_tools_at?: string; + /** + * 标签列表 + */ + tags?: Array; + /** + * 租户ID + */ + tenant_id?: string; + /** + * 测试状态 + */ + test_state?: 'success' | 'error' | 'pending'; + /** + * 超时时间 + */ + timeout?: number; + /** + * 传输类型 + */ + transport_type?: 'stdio' | 'http'; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/mcp/servers/detail', + query: { + 'mcp_server_id': mcpServerId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 启用或禁用MCP服务器。 + * + * 设置MCP服务器的启用状态。 + * + * Args: + * id (int): 服务器ID。 + * enable (bool): 是否启用服务器。 + * + * Returns: + * dict: 包含操作结果的字典。 + * + * Raises: + * ValueError: 当输入参数不合法或缺少必要参数时抛出。 + * 设置MCP服务器的启用状态,需要登录和写入权限 + * @param requestBody 启用参数 + * @returns any 操作成功 + * @throws ApiError + */ + public static postMcpServersEnable( + requestBody: { + /** + * 是否启用服务器 + */ + enable: boolean; + /** + * 服务器ID + */ + id: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/servers/enable', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 发布MCP服务器。 + * + * 将MCP服务器发布为可用状态,支持不同的发布类型。 + * + * Args: + * id (str): 服务器ID。 + * publish_type (str): 发布类型。 + * + * Returns: + * dict: 包含发布结果的字典。 + * + * Raises: + * ValueError: 当输入参数不合法时抛出。 + * 将MCP服务器发布为可用状态,支持不同的发布类型,需要登录和写入权限 + * @param requestBody 发布参数 + * @returns any 发布成功 + * @throws ApiError + */ + public static postMcpServersPublish( + requestBody: { + /** + * 服务器ID + */ + id: string; + /** + * 发布类型:group(组) 或 builtin(内置) + */ + publish_type: 'group' | 'builtin'; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/servers/publish', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 同步MCP服务器的工具。 + * + * 从指定的MCP服务器同步工具,使用服务器端发送事件方式返回进度。 + * + * Args: + * id (int): MCP服务器ID。 + * + * Returns: + * Response: 服务器端发送事件流。 + * + * Raises: + * ValueError: 当输入参数不合法或MCP服务器ID为空时抛出。 + * ForbiddenError: 当用户没有写入权限时抛出。 + * 从指定的MCP服务器同步工具,使用服务器端发送事件方式返回进度,需要登录和写入权限 + * @param requestBody MCP服务器ID + * @returns string 同步成功(服务器端发送事件流) + * @throws ApiError + */ + public static postMcpServersSyncTools( + requestBody: { + /** + * MCP服务器ID + */ + id: number; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/servers/sync-tools', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取MCP工具列表。 + * + * 根据MCP服务器ID获取对应的工具列表。 + * + * Args: + * mcp_server_id (int): MCP服务器ID。 + * + * Returns: + * dict: 包含MCP工具列表的字典。 + * + * Raises: + * ValueError: 当输入参数不合法或MCP服务器ID为空时抛出。 + * ForbiddenError: 当用户没有读取权限时抛出。 + * 根据MCP服务器ID获取对应的工具列表,需要登录 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postMcpTools( + requestBody: { + /** + * MCP服务器ID + */ + mcp_server_id: number; + }, + ): CancelablePromise<{ + /** + * MCP工具列表 + */ + data?: Array<{ + /** + * 附加属性 + */ + additional_properties?: Record; + /** + * 注解 + */ + annotations?: Record; + /** + * 创建时间 + */ + created_at?: string; + /** + * 工具描述 + */ + description?: string; + /** + * 工具ID + */ + id?: number; + /** + * 输入schema + */ + input_schema?: Record; + /** + * MCP服务器ID + */ + mcp_server_id?: number; + /** + * 工具名称 + */ + name?: string; + /** + * Schema + */ + schema?: string; + /** + * 状态 + */ + status?: string; + /** + * 更新时间 + */ + updated_at?: string; + }>; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/tools', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取MCP工具详细信息。 + * + * 根据工具ID获取MCP工具的详细信息。 + * + * Args: + * tool_id (int): 工具ID。 + * + * Returns: + * dict: 包含MCP工具详细信息的字典。 + * + * Raises: + * ValueError: 当找不到指定的工具时抛出。 + * 根据工具ID获取MCP工具的详细信息,需要登录 + * @param toolId 工具ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getMcpToolsDetail( + toolId: number, + ): CancelablePromise<{ + /** + * 附加属性 + */ + additional_properties?: Record; + /** + * 注解 + */ + annotations?: Record; + /** + * 创建时间 + */ + created_at?: string; + /** + * 工具描述 + */ + description?: string; + /** + * 工具ID + */ + id?: number; + /** + * 输入schema + */ + input_schema?: Record; + /** + * MCP服务器ID + */ + mcp_server_id?: number; + /** + * 工具名称 + */ + name?: string; + /** + * Schema + */ + schema?: string; + /** + * 状态 + */ + status?: string; + /** + * 更新时间 + */ + updated_at?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/mcp/tools/detail', + query: { + 'tool_id': toolId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 测试MCP工具。 + * + * 使用指定的参数测试MCP工具的功能,并更新服务器的测试状态。 + * + * Args: + * mcp_server_id (int): MCP服务器ID。 + * tool_id (int): 工具ID。 + * param (dict, optional): 测试参数。 + * + * Returns: + * dict: 包含测试结果的字典。 + * + * Raises: + * ValueError: 当输入参数不合法或缺少必要参数时抛出。 + * ForbiddenError: 当用户没有写入权限时抛出。 + * 使用指定的参数测试MCP工具的功能,并更新服务器的测试状态,需要登录和写入权限 + * @param requestBody 测试参数 + * @returns any 测试成功 + * @throws ApiError + */ + public static postMcpToolsTestTool( + requestBody: { + /** + * MCP服务器ID + */ + mcp_server_id: number; + /** + * 测试参数 + */ + param?: Record; + /** + * 工具ID + */ + tool_id: number; + }, + ): CancelablePromise<{ + /** + * 测试结果消息 + */ + message?: string; + status?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mcp/tools/test-tool', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `测试失败`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } +} diff --git a/front/infrastructure/api/generated/services/PromptService.ts b/front/infrastructure/api/generated/services/PromptService.ts new file mode 100644 index 0000000..f205a98 --- /dev/null +++ b/front/infrastructure/api/generated/services/PromptService.ts @@ -0,0 +1,336 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class PromptService { + /** + * 创建新的提示信息。 + * + * 解析请求中的JSON数据,包括提示信息的名称、描述、内容和分类信息, + * 调用PromptService创建新的提示信息并返回创建成功后的ID。 + * + * Args: + * name (str): 提示信息的名称,必填。 + * describe (str, optional): 提示信息的描述,默认为空字符串。 + * content (str): 提示信息的内容,必填。 + * category (str, optional): 提示信息的分类,默认为None。 + * + * Returns: + * dict: 包含创建成功的提示信息ID的响应字典。 + * + * Raises: + * ValueError: 当参数错误或名称为空时抛出。 + * 创建新的提示信息,支持包含名称、描述、内容和分类的提示信息,需要登录和写入权限 + * @param requestBody 提示信息数据 + * @returns any 创建成功 + * @throws ApiError + */ + public static postPrompt( + requestBody: { + /** + * 提示信息的分类 + */ + category?: string; + /** + * 提示信息的内容(必需) + */ + content: string; + /** + * 提示信息的描述 + */ + describe?: string; + /** + * 提示信息的名称(必需) + */ + name: string; + }, + ): CancelablePromise<{ + code?: number; + data?: { + /** + * 创建的提示信息ID + */ + id?: number; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/prompt', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 处理POST请求,删除指定ID的提示信息。 + * + * - 调用PromptService的delete_prompt方法删除提示信息。 + * - 如果删除成功,记录日志并返回成功消息。 + * - 如果提示信息不存在,记录错误日志并返回错误消息。 + * 根据提示信息ID删除提示信息,内置提示信息需要超级管理员权限,需要登录和管理员权限 + * @param id 提示信息ID + * @returns any 删除成功 + * @throws ApiError + */ + public static postPromptDelete( + id: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/prompt/delete/{id}', + path: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 处理GET请求,分页获取所有提示信息。 + * + * - 解析请求中的分页参数,包括当前页码和每页数量。 + * - 调用PromptService的list_prompt方法获取提示信息列表和分页信息。 + * - 返回提示信息列表和分页信息。 + * 分页获取所有提示信息的列表,支持按查询类型、标签、名称、用户ID等条件筛选,需要登录 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postPromptList( + requestBody?: { + /** + * 页码,从 1 开始 + */ + page?: number; + /** + * 每页数量 + */ + per_page?: number; + /** + * 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 名称搜索条件 + */ + search_name?: string; + /** + * 标签搜索条件 + */ + search_tags?: Array; + /** + * 用户ID筛选 + */ + user_id?: Array; + }, + ): CancelablePromise<{ + code?: number; + data?: { + /** + * 当前页码 + */ + current_page?: number; + /** + * 下一页页码 + */ + next_page?: number; + /** + * 总页数 + */ + pages?: number; + /** + * 上一页页码 + */ + prev_page?: number; + /** + * 提示信息列表 + */ + prompts?: Array<{ + /** + * 提示信息分类 + */ + category?: string; + /** + * 提示信息内容 + */ + content?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 提示信息描述 + */ + describe?: string; + /** + * 提示信息ID + */ + id?: number; + /** + * 提示信息名称 + */ + name?: string; + /** + * 更新时间 + */ + updated_at?: string; + }>; + /** + * 总记录数 + */ + total?: number; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/prompt/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取指定ID的提示信息。 + * + * 调用PromptService获取提示信息的详细内容,包括权限检查。 + * 如果提示信息不存在则返回错误消息。 + * + * Args: + * id (int): 提示信息的唯一标识符。 + * + * Returns: + * dict: 包含提示信息详细内容的响应字典,包括id、name、describe、 + * content、category、created_at、updated_at字段。 + * + * Raises: + * ValueError: 当提示信息不存在时返回400状态码。 + * 根据提示信息ID获取其详细信息,包括名称、描述、内容、分类和时间戳等,需要登录 + * @param id 提示信息ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getPrompt( + id: number, + ): CancelablePromise<{ + code?: number; + data?: { + /** + * 提示信息分类 + */ + category?: string; + /** + * 提示信息内容 + */ + content?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 提示信息描述 + */ + describe?: string; + /** + * 提示信息ID + */ + id?: number; + /** + * 提示信息名称 + */ + name?: string; + /** + * 更新时间 + */ + updated_at?: string; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/prompt/{id}', + path: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 处理POST请求,更新指定ID的提示信息。 + * + * - 解析请求中的JSON数据,包括提示信息的名称、描述、内容和模板ID。 + * - 调用PromptService的update_prompt方法更新提示信息。 + * - 如果更新成功,返回成功消息。 + * - 如果提示信息不存在,返回错误消息。 + * 根据提示信息ID和用户提交的数据更新提示信息,内置提示信息需要超级管理员权限,需要登录和写入权限 + * @param id 提示信息ID + * @param requestBody 提示信息数据 + * @returns any 更新成功 + * @throws ApiError + */ + public static postPrompt1( + id: number, + requestBody: { + /** + * 提示信息的分类 + */ + category?: string; + /** + * 提示信息的内容 + */ + content?: string; + /** + * 提示信息的描述 + */ + describe?: string; + /** + * 提示信息的名称 + */ + name?: string; + /** + * 模板ID + */ + template_id?: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/prompt/{id}', + path: { + 'id': id, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } +} diff --git a/front/infrastructure/api/generated/services/Service.ts b/front/infrastructure/api/generated/services/Service.ts new file mode 100644 index 0000000..a3f0fe1 --- /dev/null +++ b/front/infrastructure/api/generated/services/Service.ts @@ -0,0 +1,13681 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class Service { + /** + * 接收引擎报告回调数据。 + * + * Args: + * id (str, required): 节点ID + * sessionid (str, required): 会话ID + * timecost (float, optional): 耗时 + * prompt_tokens (int, optional): 提示词token数 + * completion_tokens (int, optional): 完成token数 + * input (str, optional): 输入内容 + * output (str, optional): 输出内容 + * + * Returns: + * None: 无返回值 + * + * Raises: + * Exception: 当数据处理失败时抛出 + * 获取应用的使用报告 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppReport( + requestBody: { + /** + * 应用ID + */ + app_id: string; + /** + * 结束日期 + */ + end_date?: string; + /** + * 开始日期 + */ + start_date?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/app/report', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取应用列表。 + * + * 根据查询参数获取应用的分页列表,支持按名称、标签、发布状态等条件筛选。 + * + * Args: + * page (int, optional): 页码,范围1-99999,默认为1。 + * limit (int, optional): 每页数量,范围1-100,默认为20。 + * search_name (str, optional): 搜索应用名称,支持模糊匹配。 + * search_tags (str, optional): 搜索标签名称。 + * qtype (str, optional): 查询类型,可选值:mine(我的)/group(团队)/builtin(内置)/already(全部),默认为mine。 + * is_published (bool, optional): 是否已发布的过滤条件。 + * + * Returns: + * dict: 包含应用列表的分页数据,包含data、total、page、limit字段。 + * + * Raises: + * ValueError: 当参数验证失败时抛出。 + * 根据查询参数获取应用的分页列表,支持按名称、标签、发布状态等条件筛选 + * @param page 页码,从 1 开始 + * @param limit 每页数量 + * @param searchName 搜索应用名称 + * @param searchTags 搜索标签名称 + * @param qtype 查询类型:mine/group/builtin/already + * @param isPublished 是否已发布 + * @returns any 成功 + * @throws ApiError + */ + public static getApps( + page: number = 1, + limit: number = 20, + searchName?: string, + searchTags?: string, + qtype: 'mine' | 'group' | 'builtin' | 'already' = 'mine', + isPublished?: boolean, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps', + query: { + 'page': page, + 'limit': limit, + 'search_name': searchName, + 'search_tags': searchTags, + 'qtype': qtype, + 'is_published': isPublished, + }, + errors: { + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建空白的应用。 + * + * 根据传入的参数创建一个新的空白应用,并记录操作日志。 + * + * Args: + * name (str): 应用名称,必填。 + * description (str, optional): 应用描述。 + * icon (str, optional): 应用图标URL。 + * icon_background (str, optional): 图标背景色。 + * categories (list, optional): 应用分类列表。 + * + * Returns: + * tuple: 包含新创建的应用实例和状态码201的元组。 + * + * Raises: + * ValueError: 当应用名称重复或创建失败时抛出。 + * 创建空白的应用 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postApps( + requestBody: { + /** + * 应用分类 + */ + categories?: Array; + /** + * 应用描述 + */ + description?: string; + /** + * 应用图标 + */ + icon?: string; + /** + * 图标背景色 + */ + icon_background?: string; + /** + * 应用名称 + */ + name: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 从文件导入应用。 + * + * Args: + * file (FileStorage, required): 上传的应用配置文件 + * + * Returns: + * dict: 新创建的应用信息 + * + * Raises: + * ValueError: 当文件格式错误或创建失败时抛出 + * 从文件导入应用 + * @param formData + * @returns any 成功 + * @throws ApiError + */ + public static postAppsImport( + formData?: { + /** + * 应用文件 + */ + file: Blob; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/import', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取应用列表(分页版本)。 + * + * 使用POST方式获取应用的分页列表,支持更复杂的查询参数。 + * + * Args: + * page (int, optional): 页码,范围1-99999,默认为1。 + * limit (int, optional): 每页数量,范围1-100,默认为20。 + * search_name (str, optional): 搜索应用名称,支持模糊匹配。 + * search_tags (list, optional): 搜索标签列表。 + * qtype (str, optional): 查询类型,可选值:mine/group/builtin/already,默认为mine。 + * is_published (bool, optional): 是否已发布的过滤条件。 + * enable_api (bool, optional): 是否启用API的过滤条件。 + * + * Returns: + * dict: 包含应用列表的分页数据,使用app_pagination_fields格式。 + * + * Raises: + * ValueError: 当参数验证失败时抛出。 + * 使用POST方式获取应用的分页列表,支持更复杂的查询参数 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsListPage( + requestBody: { + /** + * 是否启用API + */ + enable_api?: boolean; + /** + * 是否已发布 + */ + is_published?: boolean; + /** + * 每页数量 + */ + limit?: number; + /** + * 页码 + */ + page?: number; + /** + * 查询类型:mine/group/builtin/already + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 搜索应用名称 + */ + search_name?: string; + /** + * 搜索标签列表 + */ + search_tags?: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/list/page', + body: requestBody, + mediaType: 'application/json', + errors: { + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 将应用转换为模板。 + * + * Args: + * id (str, required): 应用ID + * name (str, optional): 模板名称 + * description (str, optional): 模板描述 + * icon (str, optional): 模板图标 + * icon_background (str, optional): 图标背景色 + * categories (list, optional): 模板分类 + * + * Returns: + * dict: 转换操作结果 + * + * Raises: + * ValueError: 当应用未发布或名称重复时抛出 + * 将应用转换为模板 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsToApptemplate( + requestBody: { + /** + * 应用ID + */ + app_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/to/apptemplate', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 添加(删除)资源(节点)时上报的日志 + * 添加工作流执行日志 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsAddLog( + requestBody: { + /** + * 应用ID + */ + app_id: string; + /** + * 日志内容 + */ + log: string; + /** + * 节点ID + */ + node_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/workflows/add_log', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 批量调试时上报的结果日志 + * 批量添加工作流执行日志 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsBatchLog( + requestBody: { + /** + * 应用ID + */ + app_id: string; + /** + * 日志列表 + */ + logs: Array<{ + log?: string; + node_id?: string; + }>; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/workflows/batch_log', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 该函数用于处理AI代码助手的POST请求 + * + * Args: + * 无直接参数。请求体中应包含以下JSON字段: + * query (str): 用户输入的查询内容,必填。 + * session (str, optional): 会话ID,用于多轮对话,选填。 + * + * Returns: + * - 若成功,返回{"message": 结果, "session": session}, 200 + * - 若失败,返回{"message": 错误信息, "session": session}, 400 + * + * Raises: + * 无直接抛出异常,所有异常均被捕获并返回错误信息。 + * 使用AI代码助手生成代码 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsCodeAssistant( + requestBody: { + /** + * 现有代码 + */ + code?: string; + /** + * 编程语言 + */ + language?: string; + /** + * 提示词 + */ + prompt: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/workflows/code_assistant', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 拖拽app创建新的流程 + * 从应用创建新的工作流 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDragApp( + requestBody: { + /** + * 应用ID + */ + app_id: string; + /** + * 目标应用ID + */ + target_app_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/workflows/drag_app', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建空白workflow + * 从空白创建新的工作流 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDragEmpty( + requestBody: { + /** + * 应用ID + */ + app_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/workflows/drag_empty', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 拖拽template创建新的流程 + * 从模板创建新的工作流 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDragTemplate( + requestBody: { + /** + * 应用ID + */ + app_id: string; + /** + * 模板ID + */ + template_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/workflows/drag_template', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 处理AI提示语助手的POST请求。 + * + * 该函数用于处理AI提示语助手的POST请求,根据用户输入生成大模型提示语。 + * 首先通过意图识别过滤用户请求,然后使用配置的模型生成相应的提示语。 + * + * Args: + * 无直接参数。请求体中应包含以下JSON字段: + * query (str): 用户输入的查询内容,必填。 + * session (str, optional): 会话ID,用于多轮对话,选填。 + * + * Returns: + * - 若成功,返回{"message": 结果, "session": session}, 200 + * - 若失败,返回{"message": 错误信息, "session": session}, 400 + * + * Raises: + * 无直接抛出异常,所有异常均被捕获并返回错误信息。 + * 使用AI提示词助手优化提示词 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsPromptAssistant( + requestBody: { + /** + * 原始提示词 + */ + prompt: string; + /** + * 会话ID + */ + session?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/workflows/prompt_assistant', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除应用。 + * + * Args: + * app_id (str): 应用ID + * + * Returns: + * dict: 删除操作结果 + * + * Raises: + * ValueError: 当应用不存在、被引用或权限不足时抛出 + * 删除指定的应用 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static deleteApps( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/apps/{app_id}', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取应用详情。 + * + * Args: + * app_id (str): 应用ID + * + * Returns: + * dict: 应用详细信息 + * + * Raises: + * ValueError: 当应用不存在时抛出 + * 根据应用ID获取应用详细信息 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getApps1( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 更新应用信息。 + * + * Args: + * app_id (str): 应用ID + * name (str, optional): 应用名称 + * description (str, optional): 应用描述 + * icon (str, optional): 应用图标 + * icon_background (str, optional): 图标背景色 + * categories (list, optional): 应用分类 + * + * Returns: + * dict: 更新后的应用信息 + * + * Raises: + * ValueError: 当应用不存在或名称重复时抛出 + * 更新应用的基本信息 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static putApps( + appId: string, + requestBody: { + /** + * 应用分类 + */ + categories?: Array; + /** + * 应用描述 + */ + description?: string; + /** + * 应用图标 + */ + icon?: string; + /** + * 图标背景色 + */ + icon_background?: string; + /** + * 应用名称 + */ + name: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/apps/{app_id}', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 启用或禁用应用服务。 + * + * Args: + * app_id (str): 应用ID + * enable_api (bool, required): 是否启用API服务 + * + * Returns: + * Response: SSE流式响应,包含启动或停止服务的状态 + * + * Raises: + * ValueError: 当应用未发布、工作流不存在或GPU配额不足时抛出 + * 启用或禁用应用的API服务,返回SSE流式响应 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsEnableApi( + appId: string, + requestBody: { + /** + * 是否启用API服务 + */ + enable_api: boolean; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/enable_api', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 启用或禁用API调用功能。 + * + * Args: + * app_id (str): 应用ID + * enable_api_call (str, required): 是否启用API调用,值为'0'或'1' + * + * Returns: + * dict: 操作结果消息 + * + * Raises: + * ValueError: 当应用未启动或参数错误时抛出 + * 启用或禁用应用的API调用功能 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsEnableApiCall( + appId: string, + requestBody: { + /** + * API调用开关:0或1 + */ + enable_api_call: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/enable_api_call', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 启用或禁用数据回流功能。 + * + * Args: + * app_id (str): 应用ID + * enable_backflow (bool, required): 是否启用回流功能 + * + * Returns: + * dict: 更新后的应用信息 + * + * Raises: + * ValueError: 当应用不存在或权限不足时抛出 + * 启用或禁用应用的数据回流功能 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsEnableBackflow( + appId: string, + requestBody: { + /** + * 是否启用回流功能 + */ + enable_backflow: boolean; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/enable_backflow', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 导出应用配置。 + * + * Args: + * app_id (str): 应用ID + * format (str, optional): 导出格式,默认为文件下载 + * version (str, optional): 版本,默认为draft + * + * Returns: + * Response: JSON数据或文件下载响应 + * + * Raises: + * ValueError: 当应用不存在时抛出 + * 导出应用为文件 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getAppsExport( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/export', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取引用结果 + * 获取应用的引用结果 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getAppsReferenceResult( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/reference-result', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取应用版本 + * 获取应用的版本列表 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getAppsVersions( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/versions', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 检查版本数量 + * 检查应用的版本数量 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getAppsVersionsCheckCount( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/versions/check-count', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 恢复应用版本 + * 恢复到指定的应用版本 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsVersionsRestore( + appId: string, + requestBody: { + /** + * 版本ID + */ + version_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/versions/restore', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * cancel publish workflow + * 取消已发布的工作流 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsCancelPublish( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/cancel_publish', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * Document节点数据解析 + * 解析文档节点 + * @param appId 应用ID + * @param docId 文档ID + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDocNodeParse( + appId: string, + docId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/doc_node/{doc_id}/parse', + path: { + 'app_id': appId, + 'doc_id': docId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询Document节点数据解析状态 + * 获取文档解析状态 + * @param appId 应用ID + * @param docId 文档ID + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDocNodeParseStatus( + appId: string, + docId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/doc_node/{doc_id}/parse/status', + path: { + 'app_id': appId, + 'doc_id': docId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取草稿工作流。 + * + * Args: + * app_id (str): 应用ID + * + * Returns: + * dict: 草稿工作流信息 + * + * Raises: + * DraftWorkflowNotExist: 当草稿工作流不存在时抛出 + * 获取应用的草稿工作流 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getAppsWorkflowsDraft( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/workflows/draft', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 同步草稿工作流。 + * + * Args: + * app_id (str): 应用ID + * graph (dict, required): 工作流图配置 + * hash (str, optional): 工作流哈希值 + * + * Returns: + * dict: 同步结果 + * + * Raises: + * DraftWorkflowNotSync: 当工作流不同步时抛出 + * 同步草稿工作流的配置 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDraft( + appId: string, + requestBody: { + /** + * 工作流图配置 + */ + graph: Record; + /** + * 工作流哈希值 + */ + hash?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/draft', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 从文件导入工作流到草稿。 + * + * Args: + * app_id (str): 应用ID + * file (FileStorage, required): 上传的工作流配置文件 + * + * Returns: + * dict: 导入操作结果 + * + * Raises: + * ValueError: 当文件格式错误或应用不存在时抛出 + * 从文件导入草稿工作流 + * @param appId 应用ID + * @param formData + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDraftImport( + appId: string, + formData?: { + /** + * 工作流文件 + */ + file: Blob; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/draft/import', + path: { + 'app_id': appId, + }, + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 运行单节点调试(流式输出) + * 运行指定节点的流式响应 + * @param appId 应用ID + * @param nodeId 节点ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDraftNodesRunStream( + appId: string, + nodeId: string, + requestBody: { + /** + * 输入内容列表 + */ + inputs: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/draft/nodes/{node_id}/run/stream', + path: { + 'app_id': appId, + 'node_id': nodeId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 重置调试会话 + * 重置草稿工作流的会话 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDraftResetSession( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/draft/reset_session', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 运行草稿调试 + * 运行草稿工作流进行预览 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDraftRun( + appId: string, + requestBody: { + /** + * 文件列表 + */ + files?: Array; + /** + * 输入内容列表 + */ + inputs: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/draft/run', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 开始草稿调试 + * 开始草稿调试,返回SSE流式响应 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDraftStart( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/draft/start', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询草稿调试的状态 + * 查询草稿调试的状态 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getAppsWorkflowsDraftStatus( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/workflows/draft/status', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 结束草稿调试 + * 停止草稿调试 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDraftStop( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/draft/stop', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * Get published workflow + * 获取已发布的工作流 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getAppsWorkflowsPublish( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/workflows/publish', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * Publish workflow + * 发布草稿工作流为正式版本 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsPublish( + appId: string, + requestBody: { + /** + * 版本描述 + */ + description: string; + /** + * 版本号 + */ + version: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/publish', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取调试详情信息。 + * + * Args: + * app_id (str): 应用ID + * mode (str, optional): 模式,默认为draft + * conversation_type (str, optional): 对话类型,"single"表示单轮对话,"multi"表示多轮对话,默认为"single" + * + * Returns: + * dict: 调试详情数据 + * + * Raises: + * Exception: 当获取数据失败时抛出 + * 获取应用的调试详情 + * @param appId 应用ID + * @param mode 工作流模式:draft(草稿)或 publish(发布) + * @returns any 成功 + * @throws ApiError + */ + public static getAppsWorkflowsDebugDetail( + appId: string, + mode: 'draft' | 'publish', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/workflows/{mode}/debug-detail', + path: { + 'app_id': appId, + 'mode': mode, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 删除历史逐步调试信息。 + * + * Args: + * app_id (str): 应用ID + * mode (str, optional): 模式,默认为draft + * + * Returns: + * dict: 删除操作结果 + * + * Raises: + * Exception: 当删除失败时抛出 + * 删除指定的调试历史记录 + * @param appId 应用ID + * @param mode 工作流模式:draft(草稿)或 publish(发布) + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static deleteAppsWorkflowsDebugDetailHistory( + appId: string, + mode: 'draft' | 'publish', + requestBody: { + /** + * 历史记录ID + */ + history_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/apps/{app_id}/workflows/{mode}/debug-detail/history', + path: { + 'app_id': appId, + 'mode': mode, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取历史逐步调试信息。 + * + * Args: + * app_id (str): 应用ID + * mode (str, optional): 模式,默认为draft + * limit (int, optional): 限制返回的turn_number组数量 + * + * Returns: + * dict: 历史调试信息 + * + * Raises: + * Exception: 当获取历史数据失败时抛出 + * 获取调试历史记录 + * @param appId 应用ID + * @param mode 工作流模式:draft(草稿)或 publish(发布) + * @returns any 成功 + * @throws ApiError + */ + public static getAppsWorkflowsDebugDetailHistory( + appId: string, + mode: 'draft' | 'publish', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/workflows/{mode}/debug-detail/history', + path: { + 'app_id': appId, + 'mode': mode, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 实时SSE推送逐步调试信息。 + * + * Args: + * app_id (str): 应用ID + * mode (str, optional): 模式,默认为draft + * conversation_type (str, optional): 对话类型,"single"表示单轮对话,"multi"表示多轮对话,默认为"single" + * + * Returns: + * Response: SSE流式响应 + * + * Raises: + * Exception: 当流式推送失败时抛出 + * 获取调试详情的SSE流式响应 + * @param appId 应用ID + * @param mode 工作流模式:draft(草稿)或 publish(发布) + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static getAppsWorkflowsDebugDetailStream( + appId: string, + mode: 'draft' | 'publish', + requestBody: { + /** + * 文件列表 + */ + files?: Array; + /** + * 输入内容列表 + */ + inputs: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/workflows/{mode}/debug-detail/stream', + path: { + 'app_id': appId, + 'mode': mode, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取SSE流连接状态。 + * + * Args: + * app_id (str): 应用ID + * mode (str, optional): 模式,默认为draft + * + * Returns: + * dict: 连接状态信息 + * + * Raises: + * Exception: 当获取状态失败时抛出 + * 获取调试流的运行状态 + * @param appId 应用ID + * @param mode 工作流模式:draft(草稿)或 publish(发布) + * @returns any 成功 + * @throws ApiError + */ + public static getAppsWorkflowsDebugDetailStreamStatus( + appId: string, + mode: 'draft' | 'publish', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apps/{app_id}/workflows/{mode}/debug-detail/stream/status', + path: { + 'app_id': appId, + 'mode': mode, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 远程停止SSE流。 + * + * Args: + * app_id (str): 应用ID + * mode (str, optional): 模式,默认为draft + * connection_id (str, optional, in body): 连接ID;提供则精准停止该连接,否则全局停止 + * + * Returns: + * dict: 停止操作结果 + * + * Raises: + * Exception: 当停止失败时抛出 + * 停止调试的流式响应 + * @param appId 应用ID + * @param mode 工作流模式:draft(草稿)或 publish(发布) + * @returns any 成功 + * @throws ApiError + */ + public static postAppsWorkflowsDebugDetailStreamStop( + appId: string, + mode: 'draft' | 'publish', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apps/{app_id}/workflows/{mode}/debug-detail/stream/stop', + path: { + 'app_id': appId, + 'mode': mode, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取模板列表。 + * + * Args: + * page (int, optional): 页码,默认为1 + * limit (int, optional): 每页数量,默认为20 + * search_name (str, optional): 搜索模板名称 + * search_tags (str, optional): 搜索标签 + * qtype (str, optional): 查询类型,默认为mine + * + * Returns: + * dict: 包含模板列表的分页数据 + * + * Raises: + * ValueError: 当参数验证失败时抛出 + * 获取应用模板列表 + * @param page 页码,从 1 开始 + * @param limit 每页数量 + * @param searchName 搜索应用名称 + * @param searchTags 搜索标签名称 + * @param qtype 查询类型:mine/group/builtin/already + * @param isPublished 是否已发布 + * @returns any 成功 + * @throws ApiError + */ + public static getApptemplate( + page: number = 1, + limit: number = 20, + searchName?: string, + searchTags?: string, + qtype: 'mine' | 'group' | 'builtin' | 'already' = 'mine', + isPublished?: boolean, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apptemplate', + query: { + 'page': page, + 'limit': limit, + 'search_name': searchName, + 'search_tags': searchTags, + 'qtype': qtype, + 'is_published': isPublished, + }, + errors: { + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 将模板转换为应用。 + * + * Args: + * id (str, required): 模板ID + * name (str, optional): 应用名称 + * description (str, optional): 应用描述 + * icon (str, optional): 应用图标 + * icon_background (str, optional): 图标背景色 + * categories (list, optional): 应用分类 + * + * Returns: + * App: 新创建的应用实例 + * + * Raises: + * ValueError: 当模板不存在或名称重复时抛出 + * 将模板转换为应用 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postApptemplateToApps( + requestBody: { + /** + * 模板ID + */ + app_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/apptemplate/to/apps', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除模板。 + * + * Args: + * app_id (str): 模板ID + * + * Returns: + * dict: 删除操作结果 + * + * Raises: + * ValueError: 当模板不存在或权限不足时抛出 + * 删除指定的模板 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static deleteApptemplate( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/apptemplate/{app_id}', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取模板详情。 + * + * Args: + * app_id (str): 模板ID + * + * Returns: + * dict: 模板详细信息 + * + * Raises: + * ValueError: 当模板不存在时抛出 + * 根据模板ID获取模板详细信息 + * @param appId 应用ID + * @returns any 成功 + * @throws ApiError + */ + public static getApptemplate1( + appId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/apptemplate/{app_id}', + path: { + 'app_id': appId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 更新模板信息。 + * + * Args: + * app_id (str): 模板ID + * name (str, optional): 模板名称 + * description (str, optional): 模板描述 + * icon (str, optional): 模板图标 + * icon_background (str, optional): 图标背景色 + * categories (list, optional): 模板分类 + * + * Returns: + * dict: 更新后的模板信息 + * + * Raises: + * ValueError: 当模板不存在或名称重复时抛出 + * 更新模板的基本信息 + * @param appId 应用ID + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static putApptemplate( + appId: string, + requestBody: { + /** + * 应用分类 + */ + categories?: Array; + /** + * 应用描述 + */ + description?: string; + /** + * 应用图标 + */ + icon?: string; + /** + * 图标背景色 + */ + icon_background?: string; + /** + * 应用名称 + */ + name: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/apptemplate/{app_id}', + path: { + 'app_id': appId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 查询产商 + * 根据产商类型查询产商列表 + * @param type 产商类型,必填 + * @returns any 成功 + * @throws ApiError + */ + public static getBrands( + type: 'llm' | 'embedding' | 'reranker', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/brands', + query: { + 'type': type, + }, + errors: { + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建产商标签 + * 创建一个新的产商标签,只有超级用户可以执行此操作 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postBrandsCreate( + requestBody: { + /** + * 产商名称 + */ + name: string; + /** + * 产商类型 + */ + type: 'llm' | 'embedding' | 'reranker'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/brands/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除产商 + * 删除指定的产商标签 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postBrandsDelete( + requestBody: { + /** + * 产商名称 + */ + name: string; + /** + * 产商类型 + */ + type: 'llm' | 'embedding' | 'reranker'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/brands/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取指定数据集的详细信息。 + * + * Args: + * 通过URL参数传递: + * data_set_id (str): 数据集ID。 + * + * Returns: + * dict: 数据集的详细信息。 + * + * Raises: + * ValueError: 当数据集不存在时抛出异常。 + * 获取指定数据集的详细信息 + * @param dataSetId 数据集ID + * @returns any 成功 + * @throws ApiError + */ + public static getData( + dataSetId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data', + query: { + 'data_set_id': dataSetId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 创建新数据集。 + * + * Args: + * 通过JSON请求体传递参数: + * name (str): 数据集名称。 + * description (str, optional): 数据集描述。 + * data_type (str): 数据类型(doc或pic)。 + * upload_type (str): 上传类型(local或url)。 + * file_paths (list, optional): 本地文件路径列表。 + * file_urls (list, optional): 文件URL列表。 + * data_format (str, optional): 数据格式。 + * from_type (str, optional): 来源类型。 + * + * Returns: + * dict: 创建的数据集信息。 + * + * Raises: + * ValueError: 当必要参数缺失或文件上传失败时抛出异常。 + * 创建新的数据集,支持本地上传或URL上传 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataCreateDateSet( + requestBody: { + /** + * 数据格式 + */ + data_format?: string; + /** + * 数据类型(doc或pic) + */ + data_type: 'doc' | 'pic'; + /** + * 数据集描述 + */ + description?: string; + /** + * 本地文件路径列表(upload_type为local时必填) + */ + file_paths?: Array; + /** + * 文件URL列表(upload_type为url时必填) + */ + file_urls?: Array; + /** + * 来源类型 + */ + from_type?: string; + /** + * 数据集名称 + */ + name: string; + /** + * 上传类型(local或url) + */ + upload_type: 'local' | 'url'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/create_date_set', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除指定的数据集。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_id (str): 数据集ID。 + * + * Returns: + * dict: 删除结果信息。 + * + * Raises: + * ValueError: 当数据集ID为空或数据集正在被使用时抛出异常。 + * 删除指定的数据集 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataDelete( + requestBody: { + /** + * 数据集ID + */ + data_set_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取JSON文件内容并返回给前端。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_file_id (str): 数据集文件ID。 + * start (int, optional): 起始行号。 + * end (int, optional): 结束行号。 + * + * Returns: + * dict: 包含文件内容的响应。 + * + * Raises: + * ValueError: 当数据集文件ID为空时抛出异常。 + * 获取JSON文件内容并返回给前端,支持分页读取 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataFile( + requestBody: { + /** + * 数据集文件ID + */ + data_set_file_id: string; + /** + * 结束行号 + */ + end?: number; + /** + * 起始行号 + */ + start?: number; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/file', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除指定的数据集文件。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_file_ids (list): 数据集文件ID列表。 + * + * Returns: + * dict: 删除结果信息。 + * + * Raises: + * ValueError: 当文件ID列表为空或数据集版本正在被使用时抛出异常。 + * 删除指定的数据集文件 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataFileDelete( + requestBody: { + /** + * 数据集文件ID列表 + */ + data_set_file_ids: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/file/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取数据集版本下的文件分页列表。 + * + * Args: + * 通过URL参数传递: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * data_set_version_id (str): 数据集版本ID。 + * + * Returns: + * dict: 分页结果,包含数据集文件列表和分页信息。 + * 获取指定数据集版本下的文件分页列表 + * @param page 页码,从1开始 + * @param pageSize 每页大小 + * @param dataSetVersionId 数据集版本ID + * @returns any 成功 + * @throws ApiError + */ + public static getDataFileList( + page: number = 1, + pageSize: number = 20, + dataSetVersionId?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/file/list', + query: { + 'page': page, + 'page_size': pageSize, + 'data_set_version_id': dataSetVersionId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 修改数据集文件内容。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_file_id (str): 数据集文件ID。 + * content (str): 新的文件内容。 + * data_set_file_name (str, optional): 新的文件名。 + * start (int, optional): 起始行号。 + * end (int, optional): 结束行号。 + * + * Returns: + * dict: 更新结果信息,包含新的总行数。 + * + * Raises: + * ValueError: 当必要参数缺失时抛出异常。 + * 修改数据集文件内容 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataFileUpdate( + requestBody: { + /** + * 新的文件内容 + */ + content: string; + /** + * 数据集文件ID + */ + data_set_file_id: string; + /** + * 新的文件名 + */ + data_set_file_name?: string; + /** + * 结束行号 + */ + end?: number; + /** + * 起始行号 + */ + start?: number; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/file/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取数据集分页列表。 + * + * Args: + * 通过JSON请求体传递参数: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * name (str, optional): 数据集名称。 + * data_type (list, optional): 数据类型列表。 + * qtype (str, optional): 查询类型,默认为"already"。 + * search_tags (list, optional): 搜索标签列表。 + * search_name (str, optional): 搜索名称。 + * user_id (list, optional): 用户ID列表。 + * + * Returns: + * dict: 分页结果,包含数据集列表和分页信息。 + * 获取数据集分页列表,支持按名称、数据类型、标签等条件筛选 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataList( + requestBody: { + /** + * 数据类型列表 + */ + data_type?: Array<'doc' | 'pic'>; + /** + * 数据集名称 + */ + name?: string; + /** + * 页码,从1开始 + */ + page?: number; + /** + * 每页大小 + */ + page_size?: number; + /** + * 查询类型 + */ + qtype?: string; + /** + * 搜索名称 + */ + search_name?: string; + /** + * 搜索标签列表 + */ + search_tags?: Array; + /** + * 用户ID列表 + */ + user_id?: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 取消指定的数据处理任务。 + * + * Args: + * task_id (str): 任务ID。 + * + * Returns: + * dict: 取消结果信息。 + * + * Raises: + * Exception: 当任务不存在或无法取消时抛出异常。 + * 取消指定的数据处理任务 + * @param taskId 任务ID + * @returns any 成功 + * @throws ApiError + */ + public static postDataProcessingTaskCancel( + taskId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/processing/task/{task_id}/cancel', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取指定数据处理任务的进度信息。 + * + * Args: + * task_id (str): 任务ID。 + * + * Returns: + * dict: 任务进度信息。 + * + * Raises: + * Exception: 当任务不存在时抛出异常。 + * 获取指定数据处理任务的进度信息 + * @param taskId 任务ID + * @returns any 成功 + * @throws ApiError + */ + public static getDataProcessingTaskProgress( + taskId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/processing/task/{task_id}/progress', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 通过SSE实时推送任务进度。 + * + * Args: + * task_id (str): 任务ID。 + * + * Returns: + * Response: SSE流式响应,实时推送任务进度。 + * + * Raises: + * Exception: 当任务不存在时抛出异常。 + * 通过SSE实时推送任务进度 + * @param taskId 任务ID + * @returns any 成功 + * @throws ApiError + */ + public static getDataProcessingTaskStream( + taskId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/processing/task/{task_id}/stream', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取所有数据处理任务列表。 + * + * Returns: + * dict: 包含所有任务列表的响应信息。 + * 获取所有数据处理任务的列表 + * @returns any 成功 + * @throws ApiError + */ + public static getDataProcessingTasks(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/processing/tasks', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 发布应用回流数据。 + * + * Args: + * 通过JSON请求体传递参数: + * app_msg (dict): 应用消息数据。 + * node_msgs (list): 节点消息数据列表。 + * + * Returns: + * tuple: (响应数据, HTTP状态码) + * + * Raises: + * ValueError: 当缺少必要参数时抛出异常。 + * 处理应用发布时的数据回流 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataRefluxAppPublish( + requestBody: { + /** + * 应用消息数据 + */ + app_msg: Record; + /** + * 节点消息数据列表 + */ + node_msgs: Array>; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/reflux/app/publish', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建回流数据。 + * + * Args: + * 通过JSON请求体传递参数: + * data (dict): 回流数据。 + * + * Returns: + * tuple: (响应数据, HTTP状态码) + * 创建回流数据 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataRefluxCreate( + requestBody: { + /** + * 回流数据 + */ + data: Record; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/reflux/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除回流数据。 + * + * Args: + * 通过JSON请求体传递参数: + * reflux_data_ids (list): 要删除的回流数据ID列表。 + * + * Returns: + * tuple: (响应数据, HTTP状态码) + * + * Raises: + * ValueError: 当回流数据ID列表为空时抛出异常。 + * 删除指定的回流数据 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataRefluxDelete( + requestBody: { + /** + * 要删除的回流数据ID列表 + */ + reflux_data_ids: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/reflux/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取回流数据详情。 + * + * Args: + * 通过查询参数传递: + * reflux_data_id (str): 回流数据ID。 + * + * Returns: + * dict: 回流数据详情,包含内容和ID。 + * + * Raises: + * ValueError: 当回流数据ID为空时抛出异常。 + * 获取回流数据的详细信息 + * @param refluxDataId 回流数据ID + * @returns any 成功 + * @throws ApiError + */ + public static getDataRefluxDetail( + refluxDataId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/reflux/detail', + query: { + 'reflux_data_id': refluxDataId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新回流数据反馈。 + * + * Args: + * 通过JSON请求体传递参数: + * data (dict): 反馈数据。 + * + * Returns: + * tuple: (响应数据, HTTP状态码) + * 更新回流数据的反馈信息 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataRefluxFeedbackUpdate( + requestBody: { + /** + * 反馈数据 + */ + data: Record; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/reflux/feedback/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取回流数据分页列表。 + * + * Args: + * 通过查询参数传递: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * data_set_version_id (str, optional): 数据集版本ID。 + * + * Returns: + * dict: 分页结果,包含回流数据列表和分页信息。 + * 获取回流数据分页列表 + * @param page 页码,从1开始 + * @param pageSize 每页大小 + * @param dataSetVersionId 数据集版本ID + * @returns any 成功 + * @throws ApiError + */ + public static getDataRefluxList( + page: number = 1, + pageSize: number = 20, + dataSetVersionId?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/reflux/list', + query: { + 'page': page, + 'page_size': pageSize, + 'data_set_version_id': dataSetVersionId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 修改回流数据。 + * + * Args: + * 通过JSON请求体传递参数: + * reflux_data_id (str): 回流数据ID。 + * content (str): 更新内容。 + * + * Returns: + * tuple: (响应数据, HTTP状态码) + * + * Raises: + * ValueError: 当回流数据ID或内容为空时抛出异常。 + * 修改回流数据内容 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataRefluxUpdate( + requestBody: { + /** + * 更新内容 + */ + content: string; + /** + * 回流数据ID + */ + reflux_data_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/reflux/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 导出数据集版本。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_ids (list): 数据集版本ID列表。 + * + * Returns: + * Response: 文件下载响应。 + * + * Raises: + * ValueError: 当数据集版本ID列表为空时抛出异常。 + * Exception: 当导出失败时抛出异常。 + * 导出数据集版本,返回压缩文件 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataRefluxVersionExport( + requestBody: { + /** + * 数据集版本ID列表 + */ + data_set_version_ids: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/reflux/version/export', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 导出数据集版本(用于微调)。 + * + * Args: + * 通过查询参数传递: + * filename (str): 数据集文件名。 + * + * Returns: + * Response: 文件下载响应。 + * + * Raises: + * ValueError: 当文件名为空或文件不存在时抛出异常。 + * Exception: 当导出失败时抛出异常。 + * 导出数据集版本文件,用于微调 + * @param filename 数据集文件名 + * @returns any 成功 + * @throws ApiError + */ + public static getDataRefluxVersionExportFt( + filename: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/reflux/version/export/ft', + query: { + 'filename': filename, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 发布数据集版本回流数据。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * + * Returns: + * dict: 数据集版本信息。 + * + * Raises: + * ValueError: 当数据集版本ID为空时抛出异常。 + * 发布数据集版本回流数据 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataRefluxVersionPublish( + requestBody: { + /** + * 数据集版本ID + */ + data_set_version_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/reflux/version/publish', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取数据集的标签版本列表。 + * + * Args: + * 通过URL参数传递: + * data_set_id (str): 数据集ID。 + * + * Returns: + * dict: 包含数据集标签列表的响应。 + * 获取数据集的标签版本列表 + * @param dataSetId 数据集ID + * @returns any 成功 + * @throws ApiError + */ + public static getDataTagList( + dataSetId?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/tag/list', + query: { + 'data_set_id': dataSetId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 上传数据集文件。 + * + * Args: + * 通过multipart/form-data传递参数: + * file: 上传的文件。 + * file_type (str): 文件类型(pic或doc)。 + * + * Returns: + * dict: 上传结果信息,包含文件路径。 + * + * Raises: + * ValueError: 当文件类型不支持、文件大小超限或压缩包内容不符合要求时抛出异常。 + * 上传数据集文件,支持图片和文档类型,支持压缩包 + * @param formData + * @returns any 成功 + * @throws ApiError + */ + public static postDataUpload( + formData?: { + /** + * 上传的文件 + */ + file: Blob; + /** + * 文件类型(pic或doc) + */ + file_type: 'doc' | 'pic'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/upload', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取指定数据集版本的详细信息。 + * + * Args: + * 通过URL参数传递: + * data_set_version_id (str): 数据集版本ID。 + * + * Returns: + * dict: 数据集版本的详细信息。 + * + * Raises: + * ValueError: 当数据集版本不存在时抛出异常。 + * 获取指定数据集版本的详细信息 + * @param dataSetVersionId 数据集版本ID + * @returns any 成功 + * @throws ApiError + */ + public static getDataVersion( + dataSetVersionId: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/version', + query: { + 'data_set_version_id': dataSetVersionId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 向数据集版本添加新文件。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * name (str, optional): 版本名称。 + * version (str, optional): 版本号。 + * file_paths (list, optional): 本地文件路径列表。 + * file_urls (list, optional): 文件URL列表。 + * + * Returns: + * dict: 添加结果信息。 + * + * Raises: + * ValueError: 当数据集版本ID为空时抛出异常。 + * 向数据集版本添加新文件 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionAddFile( + requestBody: { + /** + * 数据集版本ID + */ + data_set_version_id: string; + /** + * 本地文件路径列表 + */ + file_paths?: Array; + /** + * 文件URL列表 + */ + file_urls?: Array; + /** + * 版本名称 + */ + name?: string; + /** + * 版本号 + */ + version?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/add/file', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 对数据集版本进行数据清洗或增强处理。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * data_set_script_id (str): 数据集脚本ID。 + * script_agent (str, optional): 脚本代理类型,默认为"script"。 + * script_type (str, optional): 脚本类型。 + * data_set_version_name (str, optional): 数据集版本名称。 + * + * Returns: + * dict: 处理后的数据集版本信息。 + * + * Raises: + * ValueError: 当必要参数缺失或数据集版本不存在时抛出异常。 + * Exception: 当处理过程中发生错误时抛出异常。 + * 对数据集版本进行数据清洗或增强处理 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionCleanOrAugment( + requestBody: { + /** + * 数据集脚本ID + */ + data_set_script_id: string; + /** + * 数据集版本ID + */ + data_set_version_id: string; + /** + * 数据集版本名称 + */ + data_set_version_name?: string; + /** + * 脚本代理类型 + */ + script_agent?: 'script'; + /** + * 脚本类型 + */ + script_type?: '数据过滤' | '数据增强' | '数据去噪' | '数据标注' | '智能处理'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/clean_or_augment', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 异步启动数据集版本的数据清洗或增强处理。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * data_set_script_id (str): 数据集脚本ID。 + * script_agent (str, optional): 脚本代理类型,默认为"script"。 + * script_type (str, optional): 脚本类型。 + * data_set_version_name (str, optional): 数据集版本名称。 + * + * Returns: + * dict: 包含任务ID的响应信息。 + * + * Raises: + * ValueError: 当必要参数缺失时抛出异常。 + * Exception: 当任务启动失败时抛出异常。 + * 异步启动数据集版本的数据清洗或增强处理 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionCleanOrAugmentAsync( + requestBody: { + /** + * 数据集脚本ID + */ + data_set_script_id: string; + /** + * 数据集版本ID + */ + data_set_version_id: string; + /** + * 数据集版本名称 + */ + data_set_version_name?: string; + /** + * 脚本代理类型 + */ + script_agent?: 'script'; + /** + * 脚本类型 + */ + script_type?: '数据过滤' | '数据增强' | '数据去噪' | '数据标注' | '智能处理'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/clean_or_augment_async', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 异步启动数据集版本的数据清洗或增强处理(基于数据条数统计)。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * data_set_script_id (str): 数据集脚本ID。 + * script_agent (str, optional): 脚本代理类型,默认为"script"。 + * script_type (str, optional): 脚本类型。 + * data_set_version_name (str, optional): 数据集版本名称。 + * + * Returns: + * dict: 包含任务ID的响应信息。 + * + * Raises: + * ValueError: 当必要参数缺失时抛出异常。 + * Exception: 当任务启动失败时抛出异常。 + * 异步启动数据集版本的数据清洗或增强处理,并统计数据条数 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionCleanOrAugmentAsyncWithItemCount( + requestBody: { + /** + * 数据集脚本ID + */ + data_set_script_id: string; + /** + * 数据集版本ID + */ + data_set_version_id: string; + /** + * 数据集版本名称 + */ + data_set_version_name?: string; + /** + * 脚本代理类型 + */ + script_agent?: 'script'; + /** + * 脚本类型 + */ + script_type?: '数据过滤' | '数据增强' | '数据去噪' | '数据标注' | '智能处理'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/clean_or_augment_async_with_item_count', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 根据标签创建数据集版本。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * name (str, optional): 新版本名称。 + * + * Returns: + * dict: 创建的数据集版本信息。 + * + * Raises: + * ValueError: 当数据集版本ID为空时抛出异常。 + * 基于标签版本创建新的分支版本 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionCreateByTag( + requestBody: { + /** + * 数据集版本ID + */ + data_set_version_id: string; + /** + * 新版本名称 + */ + name?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/create_by_tag', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除指定的数据集版本。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * + * Returns: + * dict: 删除结果信息,包含剩余版本数量。 + * + * Raises: + * ValueError: 当数据集版本ID为空或版本正在被使用时抛出异常。 + * 删除指定的数据集版本 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionDelete( + requestBody: { + /** + * 数据集版本ID + */ + data_set_version_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 导出一个或多个数据集版本。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_ids (list): 数据集版本ID列表。 + * + * Returns: + * Response: 压缩文件下载响应。 + * + * Raises: + * ValueError: 当数据集版本ID列表为空时抛出异常。 + * 导出一个或多个数据集版本,返回压缩文件 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionExport( + requestBody: { + /** + * 数据集版本ID列表 + */ + data_set_version_ids: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/export', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 导出数据集版本文件(微调专用)。 + * + * Args: + * 通过URL参数传递: + * filename (str): 文件路径。 + * filefrom (str): 文件来源(upload或return)。 + * + * Returns: + * Response: 文件下载响应。 + * + * Raises: + * ValueError: 当参数有误或文件不存在时抛出异常。 + * 导出数据集版本文件,用于微调 + * @param filename 文件路径 + * @param filefrom 文件来源(upload或return) + * @returns any 成功 + * @throws ApiError + */ + public static getDataVersionExportFt( + filename: string, + filefrom: 'upload' | 'return', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/version/export/ft', + query: { + 'filename': filename, + 'filefrom': filefrom, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取数据集版本分页列表。 + * + * Args: + * 通过URL参数传递: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * version_type (str, optional): 版本类型。 + * data_set_id (str): 数据集ID。 + * + * Returns: + * dict: 分页结果,包含数据集版本列表和分页信息。 + * 获取指定数据集的版本分页列表 + * @param page 页码,从1开始 + * @param pageSize 每页大小 + * @param versionType 版本类型 + * @param dataSetId 数据集ID + * @returns any 成功 + * @throws ApiError + */ + public static getDataVersionList( + page: number = 1, + pageSize: number = 20, + versionType?: 'branch' | 'tag', + dataSetId?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/data/version/list', + query: { + 'page': page, + 'page_size': pageSize, + 'version_type': versionType, + 'data_set_id': dataSetId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 发布数据集版本为标签版本。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * + * Returns: + * dict: 发布后的数据集版本信息。 + * + * Raises: + * ValueError: 当数据集版本ID为空时抛出异常。 + * 发布数据集版本为标签版本 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionPublish( + requestBody: { + /** + * 数据集版本ID + */ + data_set_version_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/publish', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 测试数据集版本状态变更功能。 + * + * Args: + * 通过JSON请求体传递参数: + * data_set_version_id (str): 数据集版本ID。 + * + * Returns: + * dict: 状态变更后的数据集版本信息。 + * + * Raises: + * Exception: 当状态变更失败时抛出异常。 + * 测试数据集版本状态变更功能 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postDataVersionTestStatus( + requestBody: { + /** + * 数据集版本ID + */ + data_set_version_id: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/data/version/test_status', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建新数据库。 + * + * 接收数据库名称和注释,验证名称格式,然后创建新的数据库。 + * 要求数据库名称以字母开头,只能包含字母、数字和下划线,且长度不超过20。 + * + * Returns: + * dict: 包含创建结果的响应字典 + * + * Raises: + * Exception: 当数据库名称格式无效或创建失败时抛出 + * 创建新数据库,要求数据库名称以字母开头,只能包含字母、数字和下划线,且长度不超过20 + * @param requestBody 数据库创建参数 + * @returns any 创建成功 + * @throws ApiError + */ + public static postDatabase( + requestBody: { + /** + * 数据库注释 + */ + comment: string; + /** + * 数据库名称(以字母开头,只能包含字母、数字和下划线,长度不超过20) + */ + db_name: string; + }, + ): CancelablePromise<{ + code?: number; + data?: Record; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/database', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 下载数据导入模板。 + * + * 生成并下载指定表的Excel导入模板文件,包含表的所有列。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 表ID + * + * Returns: + * File: Excel格式的导入模板文件 + * + * Raises: + * Exception: 当生成模板失败时抛出 + * 生成并下载指定表的Excel导入模板文件,包含表的所有列 + * @param databaseId 数据库ID + * @param tableId 表ID + * @returns binary 下载成功 + * @throws ApiError + */ + public static getDatabaseImport( + databaseId: number, + tableId: number, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/database/import/{database_id}/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 上传并预览导入数据。 + * + * 上传Excel文件并预览要导入的数据,包括数据验证和格式转换。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 表ID + * + * Form Data: + * file: 要上传的Excel文件 + * + * Returns: + * dict: 包含预览数据的字典,包括总行数、列定义和数据 + * + * Raises: + * ValueError: 当未上传文件时抛出 + * Exception: 当处理文件失败时抛出 + * 上传Excel文件并预览要导入的数据,包括数据验证和格式转换 + * @param databaseId 数据库ID + * @param tableId 表ID + * @param formData + * @returns any 预览成功 + * @throws ApiError + */ + public static postDatabaseImport( + databaseId: number, + tableId: number, + formData?: { + /** + * 要上传的Excel文件 + */ + file: Blob; + }, + ): CancelablePromise<{ + columns?: Array<{ + comment?: string; + default?: string | null; + name: string; + nullable?: boolean; + type: string; + }>; + data?: Array>; + total_rows?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/database/import/{database_id}/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 执行数据导入。 + * + * 根据预览的数据执行实际的数据导入操作。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 表ID + * + * Request Body: + * action (str): 操作类型,只支持"import" + * data (list): 要导入的数据列表 + * + * Returns: + * dict: 包含导入结果的响应字典 + * + * Raises: + * Exception: 当导入失败时抛出 + * 根据预览的数据执行实际的数据导入操作 + * @param databaseId 数据库ID + * @param tableId 表ID + * @param requestBody 数据导入参数 + * @returns any 导入成功 + * @throws ApiError + */ + public static putDatabaseImport( + databaseId: number, + tableId: number, + requestBody: { + /** + * 操作类型:preview(预览)/import(导入) + */ + action: 'preview' | 'import'; + /** + * 要导入的数据列表(当action为import时必填) + */ + data?: Array>; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'PUT', + url: '/database/import/{database_id}/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取数据库列表(分页)。 + * + * 分页获取用户可访问的数据库列表,支持按数据库名称筛选、 + * 按查询类型筛选和按用户ID筛选。 + * + * Request Body: + * page (int): 页码,默认为1 + * limit (int): 每页数量,默认为10 + * db_name (str): 数据库名称筛选,默认为空 + * qtype (str): 查询类型,可选值:mine/group/builtin/already,默认为already + * user_id (list): 用户ID列表筛选,默认为空列表 + * + * Returns: + * dict: 分页的数据库信息列表 + * 分页获取用户可访问的数据库列表,支持按数据库名称、查询类型、用户ID等条件筛选 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postDatabaseListPage( + requestBody?: { + /** + * 数据库名称筛选 + */ + db_name?: string; + /** + * 每页数量 + */ + limit?: number; + /** + * 页码 + */ + page?: number; + /** + * 查询类型:mine(我的)/group(组内)/builtin(内置)/already(已访问) + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 用户ID列表筛选 + */ + user_id?: Array; + }, + ): CancelablePromise<{ + data?: Array<{ + comment?: string; + created_at?: string; + created_by?: string; + created_by_account?: { + id?: string; + name?: string; + }; + database_name?: string; + id?: number; + name?: string; + table_count?: number; + tenant_id?: string; + type?: string; + updated_at?: string; + url?: string | null; + user_name?: string; + }>; + has_more?: boolean; + limit?: number; + page?: number; + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/database/list/page', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除数据库。 + * + * 删除指定的数据库,需要管理员权限。 + * + * Args: + * database_id (int): 要删除的数据库ID + * + * Returns: + * dict: 包含删除结果的响应字典 + * 删除指定的数据库,需要管理员权限 + * @param databaseId 数据库ID + * @returns any 删除成功 + * @throws ApiError + */ + public static deleteDatabase( + databaseId: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/database/{database_id}', + path: { + 'database_id': databaseId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新数据库信息。 + * + * 更新指定数据库的名称和注释信息。 + * + * Args: + * database_id (int): 数据库ID + * + * Request Body: + * db_name (str): 新的数据库名称 + * comment (str): 新的数据库注释 + * + * Returns: + * dict: 包含更新结果的响应字典 + * + * Raises: + * Exception: 当更新失败时抛出 + * 更新指定数据库的名称和注释信息 + * @param databaseId 数据库ID + * @param requestBody 数据库更新参数 + * @returns any 更新成功 + * @throws ApiError + */ + public static putDatabase( + databaseId: number, + requestBody: { + /** + * 新的数据库注释 + */ + comment: string; + /** + * 新的数据库名称 + */ + db_name: string; + }, + ): CancelablePromise<{ + code?: number; + data?: Record; + message?: string; + }> { + return __request(OpenAPI, { + method: 'PUT', + url: '/database/{database_id}', + path: { + 'database_id': databaseId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建新表。 + * + * 在指定数据库中创建新表,包括表名、注释和列定义。 + * 需要写入权限。 + * + * Args: + * database_id (int): 数据库ID + * + * Request Body: + * table_name (str): 表名 + * comment (str): 表注释 + * columns (list): 列定义列表 + * + * Returns: + * dict: 包含创建结果的响应字典 + * + * Raises: + * Exception: 当列类型为空或创建失败时抛出 + * 在指定数据库中创建新表,包括表名、注释和列定义,需要写入权限 + * @param databaseId 数据库ID + * @param requestBody 表创建参数 + * @returns any 创建成功 + * @throws ApiError + */ + public static postDatabaseTable( + databaseId: number, + requestBody: { + /** + * 列定义列表 + */ + columns: Array<{ + comment?: string; + default?: string | null; + name: string; + nullable?: boolean; + type: string; + }>; + /** + * 表注释 + */ + comment: string; + /** + * 表名 + */ + table_name: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/database/{database_id}/table', + path: { + 'database_id': databaseId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取数据库中的表列表。 + * + * 分页获取指定数据库中的所有表,支持按表名筛选。 + * + * Args: + * database_id (int): 数据库ID + * + * Query Parameters: + * page (int): 页码,默认为1 + * limit (int): 每页数量,默认为10 + * table_name (str): 表名筛选,默认为空 + * + * Returns: + * dict: 分页的表信息列表 + * 分页获取指定数据库中的所有表,支持按表名筛选 + * @param databaseId 数据库ID + * @param page 页码 + * @param limit 每页数量 + * @param tableName 表名筛选 + * @returns any 获取成功 + * @throws ApiError + */ + public static getDatabaseTableList( + databaseId: number, + page: number = 1, + limit: number = 10, + tableName: string = '', + ): CancelablePromise<{ + data?: Array<{ + comment?: string; + created_at?: string; + created_by?: string; + created_by_account?: { + id?: string; + name?: string; + }; + id?: number; + name?: string; + row_count?: number; + tenant_id?: string; + updated_at?: string; + }>; + has_more?: boolean; + limit?: number; + page?: number; + total?: number; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/database/{database_id}/table/list', + path: { + 'database_id': databaseId, + }, + query: { + 'page': page, + 'limit': limit, + 'table_name': tableName, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除表。 + * + * 删除指定数据库中的指定表,需要管理员权限。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 要删除的表ID + * + * Returns: + * dict: 包含删除结果的响应字典 + * 删除指定数据库中的指定表,需要管理员权限 + * @param databaseId 数据库ID + * @param tableId 表ID + * @returns any 删除成功 + * @throws ApiError + */ + public static deleteDatabaseTable( + databaseId: number, + tableId: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/database/{database_id}/table/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 根据表ID获取表结构。 + * + * 获取指定数据库中指定表ID的表结构信息。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 表ID + * + * Returns: + * dict: 包含表结构信息的响应字典 + * 获取指定数据库中指定表ID的表结构信息 + * @param databaseId 数据库ID + * @param tableId 表ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getDatabaseTable( + databaseId: number, + tableId: number, + ): CancelablePromise<{ + code?: number; + data?: { + columns?: Array<{ + comment?: string; + default?: string | null; + name?: string; + nullable?: boolean; + type?: string; + }>; + comment?: string; + table_id?: number; + table_name?: string; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/database/{database_id}/table/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 编辑表结构。 + * + * 修改指定表的结构,包括表名、注释和列定义。 + * 需要写入权限。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 表ID + * + * Request Body: + * table_name (str): 新的表名 + * comment (str): 新的表注释 + * columns (list): 列定义列表 + * + * Returns: + * dict: 包含修改结果的响应字典 + * + * Raises: + * Exception: 当列类型为空或修改失败时抛出 + * 修改指定表的结构,包括表名、注释和列定义,需要写入权限 + * @param databaseId 数据库ID + * @param tableId 表ID + * @param requestBody 表更新参数 + * @returns any 修改成功 + * @throws ApiError + */ + public static putDatabaseTable( + databaseId: number, + tableId: number, + requestBody: { + /** + * 列定义列表 + */ + columns: Array<{ + comment?: string; + default?: string | null; + name: string; + nullable?: boolean; + type: string; + }>; + /** + * 表注释 + */ + comment: string; + /** + * 表名 + */ + table_name: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'PUT', + url: '/database/{database_id}/table/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除表数据。 + * + * 删除指定表中的数据记录。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 表ID + * + * Request Body: + * data_items (list): 要删除的数据项列表 + * table_name (str): 表名 + * + * Returns: + * dict: 包含删除结果的响应字典 + * 删除指定表中的数据记录 + * @param databaseId 数据库ID + * @param tableId 表ID + * @param requestBody 表数据删除参数 + * @returns any 删除成功 + * @throws ApiError + */ + public static deleteDatabaseTableData( + databaseId: number, + tableId: number, + requestBody: { + /** + * 要删除的数据项列表 + */ + data_items: Array>; + /** + * 表名 + */ + table_name?: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/database/{database_id}/table_data/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取表数据(分页)。 + * + * 分页获取指定表中的数据记录。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 表ID + * + * Query Parameters: + * page (int): 页码,默认为1 + * limit (int): 每页数量,默认为10 + * + * Returns: + * dict: 分页的表数据 + * 分页获取指定表中的数据记录 + * @param databaseId 数据库ID + * @param tableId 表ID + * @param page 页码 + * @param limit 每页数量 + * @returns any 获取成功 + * @throws ApiError + */ + public static getDatabaseTableData( + databaseId: number, + tableId: number, + page: number = 1, + limit: number = 10, + ): CancelablePromise<{ + data?: Array>; + has_more?: boolean; + limit?: number; + page?: number; + total?: number; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/database/{database_id}/table_data/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + query: { + 'page': page, + 'limit': limit, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 批量更新表数据。 + * + * 批量执行表数据的增加、更新和删除操作。 + * + * Args: + * database_id (int): 数据库ID + * table_id (int): 表ID + * + * Request Body: + * add_items (list): 要添加的数据项列表 + * update_items (list): 要更新的数据项列表 + * delete_items (list): 要删除的数据项列表 + * table_name (str): 表名 + * + * Returns: + * dict: 包含操作结果的响应字典 + * 批量执行表数据的增加、更新和删除操作 + * @param databaseId 数据库ID + * @param tableId 表ID + * @param requestBody 表数据更新参数 + * @returns any 更新成功 + * @throws ApiError + */ + public static putDatabaseTableData( + databaseId: number, + tableId: number, + requestBody: { + /** + * 要添加的数据项列表 + */ + add_items?: Array>; + /** + * 要删除的数据项列表 + */ + delete_items?: Array>; + /** + * 表名 + */ + table_name?: string; + /** + * 要更新的数据项列表 + */ + update_items?: Array>; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'PUT', + url: '/database/{database_id}/table_data/{table_id}', + path: { + 'database_id': databaseId, + 'table_id': tableId, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 根据表名获取表结构。 + * + * 获取指定数据库中指定表名的表结构信息。 + * + * Args: + * database_id (int): 数据库ID + * table_name (str): 表名 + * + * Returns: + * dict: 包含表结构信息的响应字典 + * 获取指定数据库中指定表名的表结构信息 + * @param databaseId 数据库ID + * @param tableName 表名 + * @returns any 获取成功 + * @throws ApiError + */ + public static getDatabaseTableName( + databaseId: number, + tableName: string, + ): CancelablePromise<{ + code?: number; + data?: { + columns?: Array<{ + comment?: string; + default?: string | null; + name?: string; + nullable?: boolean; + type?: string; + }>; + comment?: string; + table_id?: number; + table_name?: string; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/database/{database_id}/table_name/{table_name}', + path: { + 'database_id': databaseId, + 'table_name': tableName, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取文档图片。 + * + * Args: + * subpath (str): 图片文件路径 + * + * Returns: + * Response: 包含图片内容的响应对象 + * 根据图片路径获取文档图片,不需要登录 + * @param subpath 图片文件路径 + * @returns binary 获取成功 + * @throws ApiError + */ + public static getDocImage( + subpath: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/doc/image/{subpath}', + path: { + 'subpath': subpath, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 404: `资源不存在`, + }, + }); + } + /** + * 删除文档。 + * + * Returns: + * bool: 删除成功返回 True + * 删除指定文档,需要登录和管理员权限 + * @param id 文档ID + * @returns any 删除成功 + * @throws ApiError + */ + public static deleteDocManage( + id: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/doc/manage', + query: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取单个文档详情。 + * + * Returns: + * dict: 文档详细信息 + * 根据文档ID获取文档的详细信息,需要登录 + * @param id 文档ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getDocManage( + id: number, + ): CancelablePromise<{ + code?: number; + data?: { + created_at?: string; + /** + * 创建者ID + */ + created_by?: string; + created_by_account?: { + avatar?: string; + id?: string; + name?: string; + }; + /** + * 文档内容(Markdown格式) + */ + doc_content?: string; + /** + * 文档ID + */ + id?: number; + /** + * 文档索引 + */ + index?: string; + /** + * 文档状态 + */ + status?: string; + /** + * 文档状态标签 + */ + status_label?: string; + /** + * 文档标题 + */ + title?: string; + updated_at?: string; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/doc/manage', + query: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建新文档。 + * + * Returns: + * dict: 创建的文档信息 + * 创建新文档,需要登录和管理员权限 + * @param requestBody + * @returns any 创建成功 + * @throws ApiError + */ + public static postDocManage( + requestBody: { + /** + * 文档内容(Markdown格式) + */ + doc_content: string; + /** + * 文档索引 + */ + index?: string; + /** + * 文档标题 + */ + title: string; + }, + ): CancelablePromise<{ + code?: number; + data?: { + created_at?: string; + /** + * 创建者ID + */ + created_by?: string; + created_by_account?: { + avatar?: string; + id?: string; + name?: string; + }; + /** + * 文档内容(Markdown格式) + */ + doc_content?: string; + /** + * 文档ID + */ + id?: number; + /** + * 文档索引 + */ + index?: string; + /** + * 文档状态 + */ + status?: string; + /** + * 文档状态标签 + */ + status_label?: string; + /** + * 文档标题 + */ + title?: string; + updated_at?: string; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/doc/manage', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新文档。 + * + * Returns: + * dict: 更新后的文档信息 + * 更新指定文档的信息,需要登录和管理员权限 + * @param requestBody + * @returns any 更新成功 + * @throws ApiError + */ + public static putDocManage( + requestBody: { + /** + * 文档内容(Markdown格式) + */ + doc_content: string; + /** + * 文档ID + */ + id: number; + /** + * 文档索引 + */ + index?: string; + /** + * 文档标题 + */ + title: string; + }, + ): CancelablePromise<{ + code?: number; + data?: { + created_at?: string; + /** + * 创建者ID + */ + created_by?: string; + created_by_account?: { + avatar?: string; + id?: string; + name?: string; + }; + /** + * 文档内容(Markdown格式) + */ + doc_content?: string; + /** + * 文档ID + */ + id?: number; + /** + * 文档索引 + */ + index?: string; + /** + * 文档状态 + */ + status?: string; + /** + * 文档状态标签 + */ + status_label?: string; + /** + * 文档标题 + */ + title?: string; + updated_at?: string; + }; + }> { + return __request(OpenAPI, { + method: 'PUT', + url: '/doc/manage', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取文档列表。 + * + * Returns: + * dict: 包含分页文档列表的响应数据 + * 分页获取文档列表,支持按文档名称搜索,不需要登录 + * @param page 页码,从1开始 + * @param limit 每页数量 + * @param searchName 文档名称搜索关键词 + * @returns any 获取成功 + * @throws ApiError + */ + public static getDocManageList( + page: number = 1, + limit: number = 20, + searchName?: string, + ): CancelablePromise<{ + /** + * 文档列表 + */ + data?: Array<{ + created_at?: string; + /** + * 创建者ID + */ + created_by?: string; + created_by_account?: { + avatar?: string; + id?: string; + name?: string; + }; + /** + * 文档内容(Markdown格式) + */ + doc_content?: string; + /** + * 文档ID + */ + id?: number; + /** + * 文档索引 + */ + index?: string; + /** + * 文档状态 + */ + status?: string; + /** + * 文档状态标签 + */ + status_label?: string; + /** + * 文档标题 + */ + title?: string; + updated_at?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 每页数量 + */ + limit?: number; + /** + * 当前页码 + */ + page?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/doc/manage/list', + query: { + 'page': page, + 'limit': limit, + 'search_name': searchName, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 发布文档。 + * + * Returns: + * bool: 发布成功返回 True + * 发布指定文档,使其对外可见,需要登录 + * @param id 文档ID + * @returns any 发布成功 + * @throws ApiError + */ + public static getDocManagePublish( + id: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/doc/manage/publish', + query: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 下架文档。 + * + * Returns: + * bool: 下架成功返回 True + * 下架指定文档,使其不再对外可见,需要登录 + * @param id 文档ID + * @returns any 下架成功 + * @throws ApiError + */ + public static getDocManageUnpublish( + id: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/doc/manage/unpublish', + query: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 上传文档图片。 + * + * Returns: + * tuple: (响应数据, 状态码) 包含图片URL的响应 + * 上传文档中使用的图片文件,需要登录 + * @param formData + * @returns any 上传成功 + * @throws ApiError + */ + public static postDocManageUploadImage( + formData?: { + /** + * 要上传的图片文件 + */ + file: Blob; + /** + * 文件名 + */ + file_name: string; + }, + ): CancelablePromise<{ + /** + * 图片访问URL + */ + url?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/doc/manage/upload_image', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取文档视图。 + * + * Args: + * subpath (str, optional): 子路径,用于访问具体的文档或资源 + * + * Returns: + * Response: HTML 页面或文档内容的响应对象 + * 访问文档的Web视图,支持Markdown文档渲染,不需要登录 + * @param subpath 文档视图子路径,用于访问具体的文档或资源 + * @returns string 获取成功 + * @throws ApiError + */ + public static getDocView( + subpath: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/doc/view', + path: { + 'subpath': subpath, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 404: `资源不存在`, + 500: `服务器错误`, + }, + }); + } + /** + * 获取文档视图。 + * + * Args: + * subpath (str, optional): 子路径,用于访问具体的文档或资源 + * + * Returns: + * Response: HTML 页面或文档内容的响应对象 + * 访问文档的Web视图,支持Markdown文档渲染,不需要登录 + * @param subpath 文档视图子路径,用于访问具体的文档或资源 + * @returns string 获取成功 + * @throws ApiError + */ + public static getDocView1( + subpath: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/doc/view/{subpath}', + path: { + 'subpath': subpath, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 404: `资源不存在`, + 500: `服务器错误`, + }, + }); + } + /** + * 上传本地文件供大模型使用。 + * + * 此端点允许在不需要身份验证的情况下上传文件, + * 因为访客也可以访问。上传的文件会保存到工作流目录中, + * 并使用随机生成的文件名。 + * + * Args: + * None (使用Flask请求解析器从表单数据获取文件) + * + * Returns: + * dict: 包含已上传文件路径的字典。 + * 示例: {"file_path": "/path/to/uploaded/file.txt"} + * + * Raises: + * werkzeug.exceptions.BadRequest: 当请求中未提供文件时抛出。 + * OSError: 当创建存储目录或保存文件时出现问题时抛出。 + * 上传本地文件供大模型使用。此端点允许在不需要身份验证的情况下上传文件,因为访客也可以访问。上传的文件会保存到工作流目录中,并使用随机生成的文件名 + * @param formData + * @returns any 上传成功 + * @throws ApiError + */ + public static postFilesUpload( + formData?: { + /** + * 要上传的文件,文件会保存到工作流目录中,并使用随机生成的文件名 + */ + file: Blob; + }, + ): CancelablePromise<{ + /** + * 上传文件的保存路径 + */ + file_path?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/files/upload', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 创建微调任务。 + * + * 接收微调任务配置信息,创建新的微调任务。 + * + * Args: + * base (dict): 基础配置信息 + * name (str): 任务名称 + * base_model (str): 基础模型uuid,调用ft接口后固定传0 + * base_model_key (str): 调用ft接口获取的模型名字 + * target_model_name (str): 微调后的模型名称 + * created_from_info (str): 创建来源 + * datasets (list): 数据集uuids + * datasets_type (list): 数据集类型 + * finetuning_type (str): 微调类型 LoRA, QLoRA, Full + * finetune_config (dict): 微调配置信息 + * num_gpus (int): GPU数量 + * training_type (str): 训练模式 PT, SFT, RM, PPO, DPO + * val_size (float): 验证集占比 + * num_epochs (int): 重复次数 + * learning_rate (float): 学习率 + * lr_scheduler_type (str): 学习率调整策略 + * batch_size (int): 批次大小 + * cutoff_len (str): 序列最大长度 + * lora_r (int): LoRa秩 + * lora_rate (int): 微调占比 + * + * Returns: + * dict: 创建的微调任务详细信息 + * + * Raises: + * ValidationError: 当输入数据验证失败时 + * CommonError: 当创建任务失败时 + * 创建新的模型微调任务,需要登录和写入权限 + * @param requestBody + * @returns any 创建成功 + * @throws ApiError + */ + public static postFinetune( + requestBody: { + base: { + /** + * 基础模型UUID,调用ft接口后固定传0 + */ + base_model?: string; + /** + * 调用ft接口获取的模型名字(格式:model_key:ams) + */ + base_model_key: string; + /** + * 创建来源 + */ + created_from_info?: string; + /** + * 数据集UUID列表 + */ + datasets: Array; + /** + * 数据集类型列表 + */ + datasets_type?: Array; + /** + * 微调类型:LoRA/QLoRA/Full + */ + finetuning_type: 'LoRA' | 'QLoRA' | 'Full'; + /** + * 任务名称 + */ + name: string; + /** + * 微调后的模型名称 + */ + target_model_name: string; + }; + finetune_config: { + /** + * 批次大小 + */ + batch_size?: number; + /** + * 序列最大长度 + */ + cutoff_len?: string; + /** + * 学习率 + */ + learning_rate?: number; + /** + * LoRa秩 + */ + lora_r?: number; + /** + * 微调占比 + */ + lora_rate?: number; + /** + * 学习率调整策略 + */ + lr_scheduler_type?: string; + /** + * 重复次数 + */ + num_epochs?: number; + /** + * GPU数量 + */ + num_gpus?: number; + /** + * 训练模式:PT/SFT/RM/PPO/DPO + */ + training_type?: 'PT' | 'SFT' | 'RM' | 'PPO' | 'DPO'; + /** + * 验证集占比 + */ + val_size?: number; + }; + }, + ): CancelablePromise<{ + code?: number; + data?: { + /** + * 基础模型UUID + */ + base_model?: string; + /** + * 基础模型key + */ + base_model_key?: string; + created_at?: string; + /** + * 创建者ID + */ + created_by?: string; + created_by_account?: { + avatar?: string; + id?: string; + name?: string; + }; + /** + * 创建来源 + */ + created_from_info?: string; + /** + * 任务描述 + */ + description?: string; + /** + * 微调配置 + */ + finetune_config?: Record; + /** + * 微调类型 + */ + finetuning_type?: string; + /** + * 任务ID + */ + id?: number; + /** + * 日志路径 + */ + log_path?: string; + /** + * 任务名称 + */ + name?: string; + /** + * 任务状态 + */ + status?: string; + /** + * 任务状态(中文) + */ + status_label?: string; + /** + * 目标模型UUID + */ + target_model?: string; + /** + * 微调后的模型名称 + */ + target_model_name?: string; + train_end_time?: string; + /** + * 训练运行时间(秒) + */ + train_runtime?: number; + updated_at?: string; + /** + * 用户名 + */ + user_name?: string; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/finetune', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 取消微调任务。 + * + * 取消正在进行的微调任务。 + * + * Args: + * task_id (int): 微调任务ID + * + * Returns: + * tuple: (响应消息, HTTP状态码) + * 成功: ({"message": "success", "code": 200}, 200) + * 失败: ({"message": "cancel fail", "code": 400}, 400) + * + * Raises: + * PermissionError: 当用户没有取消权限时 + * ValueError: 当任务不存在时 + * 取消正在进行的微调任务,需要登录和写入权限 + * @param taskId 微调任务ID + * @returns any 取消成功 + * @throws ApiError + */ + public static deleteFinetuneCancel( + taskId: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/finetune/cancel/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取可用于微调的数据集列表。 + * + * 根据查询类型获取可用于微调的数据集列表。 + * + * Args: + * qtype (str): 查询类型,可选值:mine/group/builtin/already,默认为already + * + * Returns: + * dict: 数据集树形结构 + * + * Raises: + * ValueError: 当查询类型无效时 + * Exception: 当获取数据集列表失败时 + * 根据查询类型获取可用于微调的数据集列表(树形结构),需要登录 + * @param qtype 查询类型:mine/group/builtin/already + * @returns any 获取成功 + * @throws ApiError + */ + public static getFinetuneDatasets( + qtype: 'mine' | 'group' | 'builtin' | 'already' = 'already', + ): CancelablePromise<{ + code?: number; + /** + * 数据集树形结构 + */ + data?: Record; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/datasets', + query: { + 'qtype': qtype, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除微调任务。 + * + * 删除指定的微调任务。 + * + * Args: + * task_id (int): 微调任务ID + * + * Returns: + * tuple: (响应消息, HTTP状态码) + * 成功: ({"message": "success", "code": 200}, 200) + * 失败: ({"message": "delete fail", "code": 400}, 400) + * + * Raises: + * PermissionError: 当用户没有删除权限时 + * ValueError: 当任务不存在时 + * 删除指定的微调任务,需要登录和管理员权限 + * @param taskId 微调任务ID + * @returns any 删除成功 + * @throws ApiError + */ + public static deleteFinetuneDelete( + taskId: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/finetune/delete/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取微调任务详细信息。 + * + * 获取指定微调任务的详细信息。 + * + * Args: + * task_id (int): 微调任务ID + * + * Returns: + * dict: 微调任务的详细信息 + * + * Raises: + * PermissionError: 当用户没有读取权限时 + * ValueError: 当任务不存在时 + * 获取指定微调任务的详细信息,需要登录 + * @param taskId 微调任务ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getFinetuneDetail( + taskId: number, + ): CancelablePromise<{ + code?: number; + data?: { + /** + * 基础模型UUID + */ + base_model?: string; + /** + * 基础模型key + */ + base_model_key?: string; + created_at?: string; + /** + * 创建者ID + */ + created_by?: string; + created_by_account?: { + avatar?: string; + id?: string; + name?: string; + }; + /** + * 创建来源 + */ + created_from_info?: string; + /** + * 任务描述 + */ + description?: string; + /** + * 微调配置 + */ + finetune_config?: Record; + /** + * 微调类型 + */ + finetuning_type?: string; + /** + * 任务ID + */ + id?: number; + /** + * 日志路径 + */ + log_path?: string; + /** + * 任务名称 + */ + name?: string; + /** + * 任务状态 + */ + status?: string; + /** + * 任务状态(中文) + */ + status_label?: string; + /** + * 目标模型UUID + */ + target_model?: string; + /** + * 微调后的模型名称 + */ + target_model_name?: string; + train_end_time?: string; + /** + * 训练运行时间(秒) + */ + train_runtime?: number; + updated_at?: string; + /** + * 用户名 + */ + user_name?: string; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/detail/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取FT模型列表。 + * + * 获取可用的FT模型列表。 + * + * Returns: + * tuple: (响应数据, HTTP状态码) + * 成功: ({"message": "success", "code": 200, "data": 模型列表}, 200) + * 失败: ({"message": "failed", "code": 400, "data": 错误信息}, 400) + * + * Raises: + * Exception: 当获取模型列表失败时 + * 获取可用的FT模型列表,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getFinetuneFtModels(): CancelablePromise<{ + code?: number; + /** + * FT模型列表 + */ + data?: Array>; + message?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/ft/models', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取微调任务分页列表。 + * + * 根据查询条件获取微调任务的分页列表。 + * + * Args: + * page (int): 页码,默认为1 + * limit (int): 每页数量,默认为20 + * qtype (str): 查询类型,可选值:mine/group/builtin/already,默认为already + * search_name (str): 搜索名称 + * status (list): 状态过滤列表 + * user_id (list): 用户ID过滤列表 + * + * Returns: + * dict: 分页的微调任务列表 + * + * Raises: + * ValueError: 当分页参数无效时 + * 分页获取微调任务列表,支持按任务名称、状态、用户ID等条件筛选,需要登录 + * @param requestBody + * @returns any 获取成功 + * @throws ApiError + */ + public static postFinetuneListPage( + requestBody: { + /** + * 每页数量 + */ + limit?: number; + /** + * 页码,从1开始 + */ + page?: number; + /** + * 查询类型:mine(我的)/group(组内)/builtin(内置)/already(已访问) + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 任务名称搜索关键词 + */ + search_name?: string; + /** + * 状态过滤列表 + */ + status?: Array; + /** + * 用户ID过滤列表 + */ + user_id?: Array; + }, + ): CancelablePromise<{ + /** + * 微调任务列表 + */ + data?: Array<{ + /** + * 基础模型UUID + */ + base_model?: string; + /** + * 基础模型key + */ + base_model_key?: string; + created_at?: string; + /** + * 创建者ID + */ + created_by?: string; + created_by_account?: { + avatar?: string; + id?: string; + name?: string; + }; + /** + * 创建来源 + */ + created_from_info?: string; + /** + * 任务描述 + */ + description?: string; + /** + * 微调配置 + */ + finetune_config?: Record; + /** + * 微调类型 + */ + finetuning_type?: string; + /** + * 任务ID + */ + id?: number; + /** + * 日志路径 + */ + log_path?: string; + /** + * 任务名称 + */ + name?: string; + /** + * 任务状态 + */ + status?: string; + /** + * 任务状态(中文) + */ + status_label?: string; + /** + * 目标模型UUID + */ + target_model?: string; + /** + * 微调后的模型名称 + */ + target_model_name?: string; + train_end_time?: string; + /** + * 训练运行时间(秒) + */ + train_runtime?: number; + updated_at?: string; + /** + * 用户名 + */ + user_name?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 每页数量 + */ + limit?: number; + /** + * 当前页码 + */ + page?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/finetune/list/page', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取微调任务日志。 + * + * 获取指定微调任务的日志内容。 + * + * Args: + * task_id (int): 微调任务ID + * + * Returns: + * Response: 日志文件响应,包含日志内容 + * + * Raises: + * PermissionError: 当用户没有读取权限时 + * FileNotFoundError: 当日志文件不存在时 + * 获取指定微调任务的日志内容,需要登录 + * @param taskId 微调任务ID + * @returns binary 获取成功 + * @throws ApiError + */ + public static getFinetuneLog( + taskId: number, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/log/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取可用于微调的模型列表。 + * + * 根据查询类型获取可用于微调的模型列表。 + * + * Args: + * qtype (str): 查询类型,可选值:mine/group/builtin/already,默认为already + * + * Returns: + * list: 模型列表 + * + * Raises: + * ValueError: 当查询类型无效时 + * Exception: 当获取模型列表失败时 + * 根据查询类型获取可用于微调的模型列表,需要登录 + * @param qtype 查询类型:mine/group/builtin/already + * @returns any 获取成功 + * @throws ApiError + */ + public static getFinetuneModels( + qtype: 'mine' | 'group' | 'builtin' | 'already' = 'already', + ): CancelablePromise<{ + code?: number; + /** + * 模型列表 + */ + data?: Array>; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/models', + query: { + 'qtype': qtype, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 暂停微调任务。 + * + * 暂停正在进行的微调任务。 + * + * Args: + * task_id (int): 微调任务ID + * + * Returns: + * tuple: (响应消息, HTTP状态码) + * 成功: ({"message": "操作成功", "code": 200}, 200) + * 失败: ({"message": 错误信息, "code": 400}, 400) + * + * Raises: + * PermissionError: 当用户没有暂停权限时 + * ValueError: 当任务不存在时 + * CommonError: 当暂停失败时(包含详细错误信息) + * 暂停正在进行的微调任务,需要登录和写入权限 + * @param taskId 微调任务ID + * @returns any 暂停成功 + * @throws ApiError + */ + public static getFinetunePause( + taskId: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/pause/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 恢复微调任务。 + * + * 恢复已暂停的微调任务。 + * + * Args: + * task_id (int): 微调任务ID + * + * Returns: + * tuple: (响应消息, HTTP状态码) + * 成功: ({"message": "操作成功", "code": 200}, 200) + * 失败: ({"message": 错误信息, "code": 400}, 400) + * + * Raises: + * PermissionError: 当用户没有恢复权限时 + * ValueError: 当任务不存在时 + * CommonError: 当恢复失败时(包含详细错误信息) + * 恢复已暂停的微调任务,需要登录和写入权限 + * @param taskId 微调任务ID + * @returns any 恢复成功 + * @throws ApiError + */ + public static getFinetuneResume( + taskId: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/resume/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取微调任务运行指标。 + * + * 获取指定微调任务的实时运行指标。 + * + * Args: + * task_id (int): 微调任务ID + * + * Returns: + * tuple: (响应数据, HTTP状态码) + * 成功: (指标数据, 200) + * 失败: ({"message": "get_running_metrics fail", "code": 400}, 400) + * + * Raises: + * PermissionError: 当用户没有读取权限时 + * ValueError: 当任务不存在时 + * 获取指定微调任务的实时运行指标,需要登录 + * @param taskId 微调任务ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getFinetuneRunningMetrics( + taskId: number, + ): CancelablePromise<{ + code?: number; + /** + * 运行指标数据 + */ + data?: Record; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/running_metrics/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 启动微调任务。 + * + * 异步启动指定的微调任务。 + * + * Args: + * task_id (int): 微调任务ID + * + * Returns: + * bool: 启动操作是否成功 + * + * Raises: + * ValueError: 当任务不存在时 + * Exception: 当启动任务失败时 + * 异步启动指定的微调任务,需要登录和写入权限 + * @param taskId 微调任务ID + * @returns boolean 启动成功 + * @throws ApiError + */ + public static getFinetuneStart( + taskId: number, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune/start/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除自定义参数。 + * + * 删除指定的自定义参数记录。 + * + * Args: + * record_id (int): 记录ID,默认为0 + * + * Returns: + * tuple: (响应消息, HTTP状态码) + * 成功: ({"message": "success", "code": 200}, 200) + * 失败: ({"message": "delete fail", "code": 400}, 400) + * + * Raises: + * ValueError: 当记录ID无效时 + * Exception: 当删除失败时 + * 删除指定的自定义参数记录,需要登录和写入权限 + * @param recordId 记录ID + * @returns any 删除成功 + * @throws ApiError + */ + public static deleteFinetuneParam( + recordId?: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/finetune_param', + query: { + 'record_id': recordId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取自定义参数列表。 + * + * 获取当前用户的自定义参数列表。 + * + * Returns: + * list: 自定义参数列表 + * + * Raises: + * Exception: 当获取参数列表失败时 + * 获取当前用户的自定义参数列表,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getFinetuneParam(): CancelablePromise<{ + code?: number; + /** + * 自定义参数列表 + */ + data?: Array<{ + finetune_config?: { + /** + * 批次大小 + */ + batch_size?: number; + /** + * 序列最大长度 + */ + cutoff_len?: number; + /** + * 学习率 + */ + learning_rate?: number; + /** + * LoRa alpha + */ + lora_alpha?: number; + /** + * LoRa秩 + */ + lora_r?: number; + /** + * 微调占比 + */ + lora_rate?: number; + /** + * 学习率调整策略 + */ + lr_scheduler_type?: string; + /** + * 重复次数 + */ + num_epochs?: number; + /** + * GPU数量 + */ + num_gpus?: number; + /** + * 训练模式 (PT, SFT, RM, PPO, DPO) + */ + training_type?: string; + /** + * 验证集占比 + */ + val_size?: number; + }; + /** + * 参数ID + */ + id?: string; + /** + * 是否默认 + */ + is_default?: boolean; + /** + * 参数名称 + */ + name?: string; + }>; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/finetune_param', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 保存自定义参数。 + * + * 保存用户的自定义参数配置。 + * + * Args: + * data (dict): 自定义参数配置数据 + * + * Returns: + * dict: 保存的自定义参数信息 + * + * Raises: + * ValidationError: 当参数数据验证失败时 + * Exception: 当保存参数失败时 + * 保存用户的自定义参数配置,需要登录和写入权限 + * @param requestBody + * @returns any 保存成功 + * @throws ApiError + */ + public static postFinetuneParam( + requestBody: { + /** + * 微调配置 + */ + finetune_config: { + /** + * 批次大小 + */ + batch_size?: number; + /** + * 序列最大长度 + */ + cutoff_len?: number; + /** + * 学习率 + */ + learning_rate?: number; + /** + * LoRa alpha + */ + lora_alpha?: number; + /** + * LoRa秩 + */ + lora_r?: number; + /** + * 微调占比 + */ + lora_rate?: number; + /** + * 学习率调整策略 + */ + lr_scheduler_type?: string; + /** + * 重复次数 + */ + num_epochs?: number; + /** + * GPU数量 + */ + num_gpus?: number; + /** + * 训练模式 (PT, SFT, RM, PPO, DPO) + */ + training_type?: string; + /** + * 验证集占比 + */ + val_size?: number; + }; + /** + * 参数名称 + */ + name: string; + }, + ): CancelablePromise<{ + code?: number; + data?: { + finetune_config?: { + /** + * 批次大小 + */ + batch_size?: number; + /** + * 序列最大长度 + */ + cutoff_len?: number; + /** + * 学习率 + */ + learning_rate?: number; + /** + * LoRa alpha + */ + lora_alpha?: number; + /** + * LoRa秩 + */ + lora_r?: number; + /** + * 微调占比 + */ + lora_rate?: number; + /** + * 学习率调整策略 + */ + lr_scheduler_type?: string; + /** + * 重复次数 + */ + num_epochs?: number; + /** + * GPU数量 + */ + num_gpus?: number; + /** + * 训练模式 (PT, SFT, RM, PPO, DPO) + */ + training_type?: string; + /** + * 验证集占比 + */ + val_size?: number; + }; + /** + * 参数ID + */ + id?: string; + /** + * 是否默认 + */ + is_default?: boolean; + /** + * 参数名称 + */ + name?: string; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/finetune_param', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取云服务状态 + * 查询cloud-service的启用状态,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getInferServiceCloudStatus(): CancelablePromise<{ + /** + * 是否启用 + */ + enabled?: boolean; + /** + * 状态消息 + */ + message?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/infer-service/cloud/status', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 处理POST请求,关闭推理服务组。 + * + * 验证权限,关闭服务组中的所有服务。 + * + * Returns: + * dict: 关闭结果的响应字典。 + * + * Raises: + * ValueError: 当权限不足或服务组不存在时抛出异常。 + * 关闭指定服务组中的所有服务,需要登录和写入权限 + * @param requestBody 服务组ID + * @returns any 关闭成功 + * @throws ApiError + */ + public static postInferServiceGroupClose( + requestBody: { + /** + * 服务组ID + */ + group_id: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/infer-service/group/close', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 处理POST请求,创建推理服务组。 + * + * 验证模型信息,检查AMS支持,创建服务组。 + * + * Returns: + * dict: 创建结果的响应字典。 + * + * Raises: + * ValueError: 当模型不存在或AMS不支持时抛出异常。 + * 创建推理服务组,需要登录和写入权限,需要启用推理服务功能 + * @param requestBody 服务组数据 + * @returns any 创建成功 + * @throws ApiError + */ + public static postInferServiceGroupCreate( + requestBody: { + /** + * 模型ID + */ + model_id: number; + /** + * 模型类型 + */ + model_type: string; + /** + * 服务配置列表 + */ + services: Array<{ + /** + * 服务名称 + */ + name: string; + /** + * GPU数量 + */ + num_gpus?: number; + }>; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/infer-service/group/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 处理POST请求,启动推理服务组。 + * + * 验证权限,启动服务组中的所有服务。 + * + * Returns: + * dict: 启动结果的响应字典。 + * + * Raises: + * ValueError: 当权限不足或服务组不存在时抛出异常。 + * 启动指定服务组中的所有服务,需要登录和写入权限,需要启用推理服务功能 + * @param requestBody 服务组ID + * @returns any 启动成功 + * @throws ApiError + */ + public static postInferServiceGroupStart( + requestBody: { + /** + * 服务组ID + */ + group_id: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/infer-service/group/start', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 处理POST请求,分页获取推理服务列表。 + * + * 解析请求中的分页参数,调用InferService获取服务列表和分页信息。 + * + * Returns: + * dict: 包含服务列表和分页信息的响应字典。 + * + * Raises: + * Exception: 当获取服务列表失败时抛出异常。 + * 分页获取推理服务列表,支持按名称、状态、用户ID、租户等条件筛选,需要登录 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postInferServiceList( + requestBody?: { + /** + * 页码,从 1 开始 + */ + page?: number; + /** + * 每页数量 + */ + per_page?: number; + /** + * 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 搜索名称 + */ + search_name?: string; + /** + * 状态筛选 + */ + status?: Array<'Ready' | 'Pending' | 'Running' | 'Stopped' | 'Error'>; + /** + * 租户筛选 + */ + tenant?: string; + /** + * 用户ID筛选 + */ + user_id?: Array; + }, + ): CancelablePromise<{ + code?: number; + data?: { + /** + * 当前页码 + */ + current_page?: number; + /** + * 下一页页码 + */ + next_page?: number; + /** + * 总页数 + */ + pages?: number; + /** + * 上一页页码 + */ + prev_page?: number; + /** + * 服务列表 + */ + result?: Array<{ + /** + * 创建者ID + */ + created_by?: string; + /** + * 创建时间 + */ + created_time?: string; + /** + * 组ID + */ + gid?: string; + /** + * 服务组ID + */ + group_id?: number; + /** + * 服务ID + */ + id?: number; + /** + * 任务ID + */ + job_id?: string; + /** + * 模型ID + */ + model_id?: number; + /** + * 模型名称 + */ + model_name?: string; + /** + * 模型类型 + */ + model_type?: string; + /** + * 服务名称 + */ + name?: string; + /** + * 服务状态 + */ + status?: string; + /** + * 租户ID + */ + tenant_id?: string; + /** + * 更新时间 + */ + updated_time?: string; + }>; + /** + * 总记录数 + */ + total?: number; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/infer-service/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 处理GET请求,获取在线模型列表。 + * + * 获取可用于绘图的在线推理服务列表。 + * + * Returns: + * dict: 包含在线模型列表的响应字典。 + * + * Raises: + * Exception: 当获取在线模型列表失败时抛出异常。 + * 获取可用于画布的在线推理服务列表,支持按模型种类筛选,需要登录 + * @param modelKind 模型种类 + * @returns any 获取成功 + * @throws ApiError + */ + public static getInferServiceListDraw( + modelKind: string = '', + ): CancelablePromise<{ + code?: number; + data?: { + result?: Array<{ + /** + * 服务ID + */ + id?: number; + /** + * 模型名称 + */ + model_name?: string; + /** + * 服务名称 + */ + name?: string; + /** + * 服务状态 + */ + status?: string; + }>; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/infer-service/list/draw', + query: { + 'model_kind': modelKind, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 处理GET请求,获取模型列表。 + * + * 根据查询参数获取本地模型列表,包括微调模型。 + * + * Returns: + * list: 模型列表。 + * + * Raises: + * Exception: 当获取模型列表失败时抛出异常。 + * 获取可用于创建推理服务的模型列表,支持按模型类型、模型种类筛选,需要登录 + * @param modelType 模型类型 + * @param modelKind 模型种类 + * @param qtype 查询类型 + * @returns any 获取成功 + * @throws ApiError + */ + public static getInferServiceModelList( + modelType: string = 'local', + modelKind: string = '', + qtype: string = '', + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/infer-service/model/list', + query: { + 'model_type': modelType, + 'model_kind': modelKind, + 'qtype': qtype, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 处理GET请求,获取AMS支持的本地模型列表。 + * + * 根据模型类型获取AMS支持的本地模型列表,包括微调模型。 + * + * Returns: + * list: AMS支持的模型列表。 + * + * Raises: + * Exception: 当获取AMS模型列表失败时抛出异常。 + * 获取AMS支持的本地模型列表,包括微调模型,需要登录 + * @param modelType 模型类型 + * @returns any 获取成功 + * @throws ApiError + */ + public static getInferServiceModelListAms( + modelType: string = '', + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/infer-service/model/list/ams', + query: { + 'model_type': modelType, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 处理POST请求,创建推理服务。 + * + * 验证权限,创建推理服务。 + * + * Returns: + * dict: 创建结果的响应字典。 + * + * Raises: + * ValueError: 当权限不足或服务组不存在时抛出异常。 + * 在指定服务组中创建推理服务,需要登录和写入权限,需要启用推理服务功能 + * @param requestBody 服务数据 + * @returns any 创建成功 + * @throws ApiError + */ + public static postInferServiceServiceCreate( + requestBody: { + /** + * 服务组ID + */ + group_id: number; + /** + * 服务配置列表 + */ + services: Array<{ + /** + * 服务名称 + */ + name: string; + /** + * GPU数量 + */ + num_gpus?: number; + }>; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/infer-service/service/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 处理POST请求,删除推理服务。 + * + * 验证权限,删除指定的推理服务。 + * + * Returns: + * dict: 删除结果的响应字典。 + * + * Raises: + * ValueError: 当权限不足或服务不存在时抛出异常。 + * 删除指定的推理服务,需要登录和写入权限 + * @param requestBody 服务ID + * @returns any 删除成功 + * @throws ApiError + */ + public static postInferServiceServiceDelete( + requestBody: { + /** + * 服务ID + */ + service_id: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/infer-service/service/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + 500: `服务器错误`, + }, + }); + } + /** + * 处理POST请求,启动推理服务。 + * + * 验证权限,启动指定的推理服务。 + * + * Returns: + * dict: 启动结果的响应字典。 + * + * Raises: + * ValueError: 当权限不足或服务不存在时抛出异常。 + * 启动指定的推理服务,需要登录和写入权限,需要启用推理服务功能 + * @param requestBody 服务ID + * @returns any 启动成功 + * @throws ApiError + */ + public static postInferServiceServiceStart( + requestBody: { + /** + * 服务ID + */ + service_id: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/infer-service/service/start', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 处理POST请求,停止推理服务。 + * + * 验证权限,停止指定的推理服务。 + * + * Returns: + * dict: 停止结果的响应字典。 + * + * Raises: + * ValueError: 当权限不足或服务不存在时抛出异常。 + * 停止指定的推理服务,需要登录和写入权限 + * @param requestBody 服务ID + * @returns any 停止成功 + * @throws ApiError + */ + public static postInferServiceServiceStop( + requestBody: { + /** + * 服务ID + */ + service_id: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/infer-service/service/stop', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 创建空的知识库。 + * + * Returns: + * dict: 创建的知识库信息 + * 创建新的空知识库,需要写入权限 + * @param requestBody + * @returns any 创建成功 + * @throws ApiError + */ + public static postKbCreate( + requestBody: { + /** + * 知识库描述 + */ + description: string; + /** + * 知识库名称 + */ + name: string; + }, + ): CancelablePromise<{ + code?: number; + data?: { + created_at?: string; + /** + * 知识库描述 + */ + description?: string; + id?: string; + /** + * 知识库名称 + */ + name?: string; + /** + * 知识库路径 + */ + path?: string; + /** + * 是否被引用 + */ + ref_status?: boolean; + /** + * 标签列表 + */ + tags?: Array; + updated_at?: string; + /** + * 创建者用户ID + */ + user_id?: string; + /** + * 创建者用户名 + */ + user_name?: string; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除知识库。 + * + * Returns: + * dict: 删除成功的响应消息 + * 删除指定的知识库,需要管理员权限 + * @param requestBody + * @returns any 删除成功 + * @throws ApiError + */ + public static postKbDelete( + requestBody: { + /** + * 知识库ID + */ + id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 下载单个或多个文件。 + * + * Returns: + * Response: 文件下载响应,单个文件直接下载,多个文件打包为zip下载 + * 下载单个或多个文件。单个文件直接下载,多个文件打包为zip下载 + * @param requestBody + * @returns binary 下载成功 + * @throws ApiError + */ + public static postKbDownload( + requestBody: { + /** + * 文件ID列表,单个文件直接下载,多个文件打包为zip下载 + */ + file_ids: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/download', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + }, + }); + } + /** + * 往知识库添加文件。 + * + * Returns: + * dict: 添加成功的响应消息 + * 将已上传的文件添加到指定的知识库中,需要对该知识库有写入权限 + * @param requestBody + * @returns any 添加成功 + * @throws ApiError + */ + public static postKbFileAdd( + requestBody: { + /** + * 文件ID列表 + */ + file_ids: Array; + /** + * 知识库ID + */ + knowledge_base_id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/file/add', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 批量删除文件。 + * + * Returns: + * dict: 删除成功的响应消息 + * 批量删除知识库中的文件,需要对该知识库有管理员权限 + * @param requestBody + * @returns any 删除成功 + * @throws ApiError + */ + public static postKbFileDelete( + requestBody: { + /** + * 要删除的文件ID列表 + */ + file_ids: Array; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/file/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取单个文件详情。 + * + * Returns: + * dict: 文件详细信息 + * 根据文件ID获取文件的详细信息 + * @param requestBody + * @returns any 获取成功 + * @throws ApiError + */ + public static postKbFileGet( + requestBody: { + /** + * 文件ID + */ + file_id: string; + }, + ): CancelablePromise<{ + code?: number; + data?: { + created_at?: string; + /** + * 文件MD5值 + */ + file_md5?: string; + /** + * 文件路径 + */ + file_path?: string; + /** + * 文件类型 + */ + file_type?: string; + id?: string; + /** + * 所属知识库ID + */ + knowledge_base_id?: string; + /** + * 文件名 + */ + name?: string; + /** + * 文件大小(字节) + */ + size?: number; + /** + * 存储类型 + */ + storage_type?: string; + updated_at?: string; + /** + * 是否已使用 + */ + used?: boolean; + /** + * 用户ID + */ + user_id?: string; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/file/get', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取知识库详情与文件列表。 + * + * Returns: + * dict: 知识库信息和分页文件列表 + * 分页获取指定知识库中的文件列表,同时返回知识库的基本信息,需要对该知识库有读取权限 + * @param knowledgeBaseId 知识库ID + * @param page 页码,从1开始 + * @param pageSize 每页数量 + * @param fileName 文件名搜索关键词 + * @returns any 获取成功 + * @throws ApiError + */ + public static getKbFileList( + knowledgeBaseId: string, + page: number = 1, + pageSize: number = 20, + fileName: string = '', + ): CancelablePromise<{ + /** + * 文件列表 + */ + data?: Array<{ + created_at?: string; + /** + * 文件MD5值 + */ + file_md5?: string; + /** + * 文件路径 + */ + file_path?: string; + /** + * 文件类型 + */ + file_type?: string; + id?: string; + /** + * 所属知识库ID + */ + knowledge_base_id?: string; + /** + * 文件名 + */ + name?: string; + /** + * 文件大小(字节) + */ + size?: number; + /** + * 存储类型 + */ + storage_type?: string; + updated_at?: string; + /** + * 是否已使用 + */ + used?: boolean; + /** + * 用户ID + */ + user_id?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 知识库信息 + */ + knowledge_base_info?: { + created_at?: string; + /** + * 知识库描述 + */ + description?: string; + id?: string; + /** + * 知识库名称 + */ + name?: string; + /** + * 知识库路径 + */ + path?: string; + /** + * 是否被引用 + */ + ref_status?: boolean; + /** + * 标签列表 + */ + tags?: Array; + updated_at?: string; + /** + * 创建者用户ID + */ + user_id?: string; + /** + * 创建者用户名 + */ + user_name?: string; + }; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/kb/file/list', + query: { + 'knowledge_base_id': knowledgeBaseId, + 'page': page, + 'page_size': pageSize, + 'file_name': fileName, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取知识库列表。 + * + * Returns: + * dict: 包含分页知识库列表的响应数据 + * 分页获取用户可访问的知识库列表,支持按知识库名称、查询类型、标签、用户ID等条件筛选 + * @param requestBody + * @returns any 获取成功 + * @throws ApiError + */ + public static postKbList( + requestBody: { + /** + * 页码,从1开始 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 查询类型:mine(我的)/group(组内)/builtin(内置)/already(已访问) + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 知识库名称搜索关键词 + */ + search_name?: string; + /** + * 标签筛选列表 + */ + search_tags?: Array; + /** + * 用户ID筛选列表 + */ + user_id?: Array; + }, + ): CancelablePromise<{ + /** + * 知识库列表 + */ + data?: Array<{ + created_at?: string; + /** + * 知识库描述 + */ + description?: string; + id?: string; + /** + * 知识库名称 + */ + name?: string; + /** + * 知识库路径 + */ + path?: string; + /** + * 是否被引用 + */ + ref_status?: boolean; + /** + * 标签列表 + */ + tags?: Array; + updated_at?: string; + /** + * 创建者用户ID + */ + user_id?: string; + /** + * 创建者用户名 + */ + user_name?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取知识库引用结果 + * 获取引用指定知识库的应用列表,需要对该知识库有读取权限 + * @param id 知识库ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getKbReferenceResult( + id: string, + ): CancelablePromise<{ + code?: number; + /** + * 引用该知识库的应用列表 + */ + data?: Array<{ + id?: string; + /** + * 是否公开 + */ + is_public?: boolean; + /** + * 应用名称 + */ + name?: string; + }>; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/kb/reference-result', + query: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 修改知识库。 + * + * Returns: + * dict: 更新后的知识库信息 + * 更新指定知识库的名称和描述信息,需要写入权限 + * @param requestBody + * @returns any 更新成功 + * @throws ApiError + */ + public static postKbUpdate( + requestBody: { + /** + * 知识库描述 + */ + description: string; + /** + * 知识库ID + */ + id: string; + /** + * 知识库名称 + */ + name: string; + }, + ): CancelablePromise<{ + code?: number; + data?: { + created_at?: string; + /** + * 知识库描述 + */ + description?: string; + id?: string; + /** + * 知识库名称 + */ + name?: string; + /** + * 知识库路径 + */ + path?: string; + /** + * 是否被引用 + */ + ref_status?: boolean; + /** + * 标签列表 + */ + tags?: Array; + updated_at?: string; + /** + * 创建者用户ID + */ + user_id?: string; + /** + * 创建者用户名 + */ + user_name?: string; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 上传单个文件。 + * + * Returns: + * dict: 上传成功的文件信息 + * 上传单个文件到系统,支持格式:.xls, .xlsx, .doc, .docx, .zip, .csv, .json, .txt, .pdf, .html, .tex, .md, .ppt, .pptx, .xml。单个文件最大50MB,zip文件最大500MB。需要写入权限 + * @param formData + * @returns any 上传成功 + * @throws ApiError + */ + public static postKbUpload( + formData?: { + /** + * 要上传的文件,支持格式:.xls, .xlsx, .doc, .docx, .zip, .csv, .json, .txt, .pdf, .html, .tex, .md, .ppt, .pptx, .xml。单个文件最大50MB,zip文件最大500MB + */ + file: Blob; + }, + ): CancelablePromise<{ + code?: number; + data?: { + /** + * 文件列表 + */ + files?: Array<{ + created_at?: string; + /** + * 文件MD5值 + */ + file_md5?: string; + /** + * 文件路径 + */ + file_path?: string; + /** + * 文件类型 + */ + file_type?: string; + id?: string; + /** + * 所属知识库ID + */ + knowledge_base_id?: string; + /** + * 文件名 + */ + name?: string; + /** + * 文件大小(字节) + */ + size?: number; + /** + * 存储类型 + */ + storage_type?: string; + updated_at?: string; + /** + * 是否已使用 + */ + used?: boolean; + /** + * 用户ID + */ + user_id?: string; + }>; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/kb/upload', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询用户的操作日志。 + * + * 所有时间参数均为北京时间(Asia/Shanghai),系统会自动转换为 UTC 进行查询。 + * 只有管理员才有权查看其他用户的操作日志,普通用户只能查看自己的日志。 + * + * Args: + * organization_id (int, optional): 组织的唯一标识符。如果有组织ID,查询该组织下所有用户的操作日志。 + * start_date (str, optional): 开始日期,格式为 'YYYY-MM-DD'。如果有开始日期,过滤该日期之后的操作日志。 + * end_date (str, optional): 结束日期,格式为 'YYYY-MM-DD'。如果有结束日期,过滤该日期之前的操作日志。 + * details (str, optional): 操作的详细信息。如果有详细信息,模糊匹配该信息的操作日志。 + * page (int, optional): 分页页码,默认为1。 + * per_page (int, optional): 每页记录数,默认为10。 + * account_id (str, optional): 用户账户ID。 + * user_name (str, optional): 用户名称。 + * module (str, optional): 操作模块名称。 + * action (str, optional): 操作动作名称。 + * + * Returns: + * dict: 包含操作日志数据的响应字典,包含data、total、page、per_page字段。 + * + * Raises: + * ValueError: 当日期格式不正确时抛出。 + * PermissionError: 当用户没有权限查看其他用户日志时抛出。 + * 查询用户的操作日志,支持按日期、用户、模块、动作等条件筛选。所有时间参数均为北京时间(Asia/Shanghai),系统会自动转换为 UTC 进行查询。只有管理员才有权查看其他用户的操作日志,普通用户只能查看自己的日志,需要登录 + * @param startDate 开始日期,格式为 YYYY-MM-DD,默认为今天。所有时间参数均为北京时间(Asia/Shanghai) + * @param endDate 结束日期,格式为 YYYY-MM-DD,默认为今天。所有时间参数均为北京时间(Asia/Shanghai) + * @param details 操作的详细信息,支持模糊匹配 + * @param page 分页页码,从 1 开始 + * @param perPage 每页记录数 + * @param organizationId 组织的唯一标识符。如果有组织ID,查询该组织下所有用户的操作日志(当前日志中并未记录日志所属的工作空间信息,故该参数无效) + * @param accountId 用户账户ID。只有管理员才有权查看其他用户的操作日志,普通用户只能查看自己的日志 + * @param userName 用户名称,支持模糊匹配 + * @param module 操作模块名称,支持模糊匹配 + * @param action 操作动作名称,支持模糊匹配 + * @returns any 获取成功 + * @throws ApiError + */ + public static getLogs( + startDate?: string, + endDate?: string, + details?: string, + page: number = 1, + perPage: number = 10, + organizationId: string = '', + accountId: string = '', + userName?: string, + module?: string, + action?: string, + ): CancelablePromise<{ + code?: number; + data?: { + /** + * 日志列表 + */ + data?: Array<{ + /** + * 操作动作名称 + */ + action?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 操作详细信息 + */ + details?: string; + /** + * 日志ID + */ + id?: number; + /** + * 操作模块名称 + */ + module?: string; + /** + * 用户名 + */ + username?: string; + }>; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + per_page?: number; + /** + * 总记录数 + */ + total?: number; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/logs', + query: { + 'start_date': startDate, + 'end_date': endDate, + 'details': details, + 'page': page, + 'per_page': perPage, + 'organization_id': organizationId, + 'account_id': accountId, + 'user_name': userName, + 'module': module, + 'action': action, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 检查模型名称是否合法。 + * + * Args: + * model_name (str): 模型名称(必需)。 + * model_from (str, optional): 模型来源。 + * + * Returns: + * dict: 包含检查结果的字典。 + * + * Raises: + * ValueError: 当模型名称已存在或模型已添加时抛出。 + * 检查模型名称是否合法,验证名称是否已存在,需要登录 + * @param requestBody 检查参数 + * @returns any 名称可用 + * @throws ApiError + */ + public static postMhCheckModelName( + requestBody: { + /** + * 模型来源 + */ + model_from?: string; + /** + * 模型名称(必需) + */ + model_name: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/check/model_name', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建新模型。 + * + * Args: + * model_type (str): 模型类型(必需)。 + * model_icon (str, optional): 模型图标路径。 + * model_name (str, optional): 模型名称。 + * description (str, optional): 模型描述。 + * model_from (str, optional): 模型来源。 + * model_kind (str, optional): 模型种类。 + * model_key (str, optional): 模型密钥。 + * access_tokens (str, optional): 访问令牌。 + * prompt_keys (str, optional): 提示词密钥。 + * model_brand (str, optional): 模型品牌。 + * model_url (str, optional): 模型URL。 + * proxy_url (str, optional): 代理URL。 + * model_list (str, optional): 模型列表。 + * model_dir (str, optional): 模型目录。 + * tag_names (list, optional): 标签名称列表。 + * + * Returns: + * dict: 创建的模型信息,使用 model_fields 格式。 + * + * Raises: + * CommonError: 当不支持的模型品牌时抛出。 + * 创建新的模型,支持本地模型和在线模型,需要登录和写入权限 + * @param requestBody 模型数据 + * @returns any 创建成功 + * @throws ApiError + */ + public static postMhCreate( + requestBody: { + /** + * 访问令牌 + */ + access_tokens?: string; + /** + * 模型描述 + */ + description?: string; + /** + * 模型品牌 + */ + model_brand?: string; + /** + * 模型目录 + */ + model_dir?: string; + /** + * 模型来源 + */ + model_from?: 'localModel' | 'existModel' | 'hf' | 'ms'; + /** + * 模型图标路径 + */ + model_icon?: string; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型种类 + */ + model_kind?: string; + /** + * 模型列表 + */ + model_list?: string; + /** + * 模型名称 + */ + model_name?: string; + /** + * 模型类型(必需) + */ + model_type: 'local' | 'online'; + /** + * 模型URL + */ + model_url?: string; + /** + * 提示词密钥 + */ + prompt_keys?: string; + /** + * 代理URL + */ + proxy_url?: string; + /** + * 标签名称列表 + */ + tag_names?: Array; + }, + ): CancelablePromise<{ + /** + * API密钥 + */ + api_key?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 模型描述 + */ + description?: string; + /** + * 下载消息 + */ + download_message?: string; + /** + * 模型ID + */ + id?: string; + /** + * 模型品牌 + */ + model_brand?: string; + /** + * 模型目录 + */ + model_dir?: string; + /** + * 模型来源 + */ + model_from?: string; + /** + * 模型图标 + */ + model_icon?: string; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型种类 + */ + model_kind?: string; + /** + * 模型种类显示 + */ + model_kind_display?: string; + /** + * 模型列表 + */ + model_list?: Array<{ + /** + * 是否为微调模型 + */ + is_finetune_model?: boolean; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型名称 + */ + model_name?: string; + }>; + /** + * 模型名称 + */ + model_name?: string; + /** + * 模型路径 + */ + model_path?: string; + /** + * 模型状态 + */ + model_status?: string; + /** + * 模型类型 + */ + model_type?: string; + /** + * 模型URL + */ + model_url?: string; + /** + * 提示词密钥 + */ + prompt_keys?: string; + /** + * 标签列表 + */ + tags?: Array; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建微调模型。 + * + * Args: + * base_model_id (int): 基础模型ID(必需)。 + * model_from (str): 模型来源(必需)。 + * model_key (str, optional): 模型密钥。 + * access_tokens (str, optional): 访问令牌。 + * prompt_keys (str, optional): 提示词密钥。 + * model_type (str, optional): 模型类型。 + * model_dir (str, optional): 模型目录。 + * model_name (str, optional): 模型名称。 + * + * Returns: + * dict: 创建的微调模型信息,使用 model_fields 格式。 + * 创建微调模型,基于指定的基础模型,需要登录和写入权限 + * @param requestBody 微调模型数据 + * @returns any 创建成功 + * @throws ApiError + */ + public static postMhCreateFinetune( + requestBody: { + /** + * 访问令牌 + */ + access_tokens?: string; + /** + * 基础模型ID(必需) + */ + base_model_id: number; + /** + * 模型目录 + */ + model_dir?: string; + /** + * 模型来源(必需) + */ + model_from: string; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型名称 + */ + model_name?: string; + /** + * 模型类型 + */ + model_type?: string; + /** + * 提示词密钥 + */ + prompt_keys?: string; + }, + ): CancelablePromise<{ + /** + * API密钥 + */ + api_key?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 模型描述 + */ + description?: string; + /** + * 下载消息 + */ + download_message?: string; + /** + * 模型ID + */ + id?: string; + /** + * 模型品牌 + */ + model_brand?: string; + /** + * 模型目录 + */ + model_dir?: string; + /** + * 模型来源 + */ + model_from?: string; + /** + * 模型图标 + */ + model_icon?: string; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型种类 + */ + model_kind?: string; + /** + * 模型种类显示 + */ + model_kind_display?: string; + /** + * 模型列表 + */ + model_list?: Array<{ + /** + * 是否为微调模型 + */ + is_finetune_model?: boolean; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型名称 + */ + model_name?: string; + }>; + /** + * 模型名称 + */ + model_name?: string; + /** + * 模型路径 + */ + model_path?: string; + /** + * 模型状态 + */ + model_status?: string; + /** + * 模型类型 + */ + model_type?: string; + /** + * 模型URL + */ + model_url?: string; + /** + * 提示词密钥 + */ + prompt_keys?: string; + /** + * 标签列表 + */ + tags?: Array; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/create_finetune', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 保存在线模型列表。 + * + * Args: + * model_id (int): 基础模型ID。 + * model_list (list): 在线模型列表,每个元素包含 model_key 和 can_finetune 字段。 + * + * Returns: + * dict: 保存操作的结果。 + * + * Raises: + * ValueError: 当 model_id 或 model_list 为空时抛出。 + * 保存指定基础模型的在线模型列表,需要登录和写入权限 + * @param requestBody 在线模型列表数据 + * @returns any 保存成功 + * @throws ApiError + */ + public static postMhCreateOnlineModelList( + requestBody: { + /** + * 基础模型ID + */ + model_id: number; + /** + * 在线模型列表 + */ + model_list: Array<{ + /** + * 是否可微调 + */ + can_finetune?: boolean; + /** + * 模型密钥 + */ + model_key?: string; + }>; + }, + ): CancelablePromise<{ + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/create_online_model_list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取默认图标列表。 + * + * Returns: + * list: 默认图标列表。 + * 获取系统默认的图标列表,需要登录 + * @returns string 获取成功 + * @throws ApiError + */ + public static getMhDefaultIconList(): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/mh/default_icon_list', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除模型。 + * + * Args: + * model_id (str): 模型ID(必需)。 + * qtype (str, optional): 查询类型。默认为"mine"。 + * + * Returns: + * dict: 包含操作结果的字典。 + * + * Raises: + * ValueError: 当模型被引用时抛出。 + * 删除指定的模型,删除前会检查模型是否被引用,需要登录和管理员权限 + * @param requestBody 删除参数 + * @param qtype 查询类型 + * @returns any 删除成功 + * @throws ApiError + */ + public static postMhDelete( + requestBody: { + /** + * 模型ID(必需) + */ + model_id: string; + }, + qtype: string = 'mine', + ): CancelablePromise<{ + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/delete', + query: { + 'qtype': qtype, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 删除微调模型。 + * + * Args: + * model_id (int): 基础模型ID。 + * finetune_model_id (int): 微调模型ID。 + * + * Returns: + * dict: 删除操作的结果。 + * 删除指定的微调模型,需要登录和管理员权限 + * @param modelId 模型ID + * @param finetuneModelId 微调模型ID + * @returns any 删除成功 + * @throws ApiError + */ + public static deleteMhDeleteFinetuneModel( + modelId: number, + finetuneModelId: number, + ): CancelablePromise<{ + message?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/mh/delete_finetune_model/{model_id}/{finetune_model_id}', + path: { + 'model_id': modelId, + 'finetune_model_id': finetuneModelId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 删除在线模型列表中的指定模型。 + * + * Args: + * model_id (int): 基础模型ID。 + * model_keys (list): 要删除的模型密钥列表。 + * + * Returns: + * dict: 删除操作的结果。 + * + * Raises: + * ValueError: 当 model_id 或 model_keys 为空时抛出。 + * CommonError: 当删除操作失败时抛出。 + * 删除在线模型列表中的指定模型,需要登录和管理员权限 + * @param requestBody 删除参数 + * @returns any 删除成功 + * @throws ApiError + */ + public static postMhDeleteOnlineModelList( + requestBody: { + /** + * 基础模型ID + */ + model_id: number; + /** + * 要删除的模型密钥列表 + */ + model_keys: Array; + }, + ): CancelablePromise<{ + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/delete_online_model_list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除上传但未被引用的模型文件或分片临时目录。 + * + * Args: + * filename (str): 文件名(必需)。 + * file_dir (str): 文件目录(必需)。 + * + * Returns: + * dict: 删除操作的结果。 + * + * Raises: + * ValueError: 当 filename 或 file_dir 为空时抛出。 + * Exception: 当删除操作失败时抛出。 + * 删除上传但未被引用的模型文件或分片临时目录,需要登录和写入权限 + * @param requestBody 删除参数 + * @returns any 删除成功 + * @throws ApiError + */ + public static postMhDeleteUploadedFile( + requestBody: { + /** + * 文件目录(必需) + */ + file_dir: string; + /** + * 文件名(必需) + */ + filename: string; + }, + ): CancelablePromise<{ + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/delete_uploaded_file', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取已存在的第三方模型列表。 + * + * Returns: + * list: 已存在的第三方模型列表。 + * 获取已存在的第三方模型列表,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getMhExistModelList(): CancelablePromise>> { + return __request(OpenAPI, { + method: 'GET', + url: '/mh/exist_model_list', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取微调模型分页列表。 + * + * Args: + * model_id (str, optional): 模型ID筛选条件。默认为0。 + * online_model_id (str, optional): 在线模型ID筛选条件。默认为0。 + * page (int, optional): 页码。默认为1。 + * page_size (int, optional): 每页大小。默认为20。 + * qtype (str, optional): 查询类型。默认为"already"。 + * + * Returns: + * dict: 包含微调模型列表的分页数据,使用 finetune_pagination_fields 格式。 + * 获取微调模型的分页列表,支持按模型ID筛选,需要登录 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postMhFinetuneModelPage( + requestBody?: { + /** + * 模型ID筛选条件 + */ + model_id?: string; + /** + * 在线模型ID筛选条件 + */ + online_model_id?: string; + /** + * 页码 + */ + page?: number; + /** + * 每页大小 + */ + page_size?: number; + /** + * 查询类型 + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + }, + ): CancelablePromise<{ + /** + * 微调模型列表 + */ + data?: Array<{ + /** + * 创建时间 + */ + created_at?: string; + /** + * 模型描述 + */ + description?: string; + /** + * 微调任务ID + */ + finetune_task_id?: number; + /** + * 模型ID + */ + id?: string; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型名称 + */ + model_name?: string; + /** + * 模型状态 + */ + model_status?: string; + /** + * 来源信息 + */ + source_info?: string; + /** + * 更新时间 + */ + updated_at?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/finetune_model_page', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 重试下载微调模型。 + * + * Args: + * model_id (int): 基础模型ID。 + * finetune_model_id (int): 微调模型ID。 + * + * Returns: + * bool: 操作成功返回True。 + * + * Raises: + * CommonError: 当模型不支持重试下载或不是本地模型时抛出。 + * 重试下载指定的微调模型,只支持本地模型,需要登录和写入权限 + * @param modelId 模型ID + * @param finetuneModelId 微调模型ID + * @returns boolean 操作成功 + * @throws ApiError + */ + public static getMhFinetuneRetryDownload( + modelId: number, + finetuneModelId: number, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/mh/finetune_retry_download/{model_id}/{finetune_model_id}', + path: { + 'model_id': modelId, + 'finetune_model_id': finetuneModelId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询模型翻页列表。 + * + * Args: + * model_type (str, optional): 模型类型筛选条件。默认为空字符串。 + * page (int, optional): 页码。默认为1。 + * page_size (int, optional): 每页大小。默认为20。 + * qtype (str, optional): 查询类型。默认为"already"。 + * search_tags (list, optional): 标签搜索条件。默认为空列表。 + * search_name (str, optional): 模型名称搜索条件。默认为空字符串。 + * available (int, optional): 可用性筛选条件。 + * status (str, optional): 状态筛选条件。默认为空字符串。 + * model_kind (str, optional): 模型种类筛选条件。默认为空字符串。 + * model_brand (str, optional): 模型品牌筛选条件。默认为空字符串。 + * tenant (str, optional): 租户筛选条件。默认为空字符串。 + * + * Returns: + * dict: 包含模型列表的分页数据,使用 model_pagination_fields 格式。 + * 根据传入的查询条件获取模型的分页列表,支持按模型类型、状态、标签、名称等条件进行筛选,需要登录 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postMhList( + requestBody?: { + /** + * 可用性筛选条件 + */ + available?: number; + /** + * 模型品牌筛选条件 + */ + model_brand?: string; + /** + * 模型种类筛选条件 + */ + model_kind?: string; + /** + * 模型类型筛选条件 + */ + model_type?: string; + /** + * 页码,从 1 开始 + */ + page?: number; + /** + * 每页大小 + */ + page_size?: number; + /** + * 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 模型名称搜索条件 + */ + search_name?: string; + /** + * 标签搜索条件 + */ + search_tags?: Array; + /** + * 状态筛选条件 + */ + status?: string; + /** + * 租户筛选条件 + */ + tenant?: string; + }, + ): CancelablePromise<{ + /** + * 模型列表 + */ + data?: Array<{ + /** + * API密钥 + */ + api_key?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 模型描述 + */ + description?: string; + /** + * 下载消息 + */ + download_message?: string; + /** + * 模型ID + */ + id?: string; + /** + * 模型品牌 + */ + model_brand?: string; + /** + * 模型目录 + */ + model_dir?: string; + /** + * 模型来源 + */ + model_from?: string; + /** + * 模型图标 + */ + model_icon?: string; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型种类 + */ + model_kind?: string; + /** + * 模型种类显示 + */ + model_kind_display?: string; + /** + * 模型列表 + */ + model_list?: Array<{ + /** + * 是否为微调模型 + */ + is_finetune_model?: boolean; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型名称 + */ + model_name?: string; + }>; + /** + * 模型名称 + */ + model_name?: string; + /** + * 模型路径 + */ + model_path?: string; + /** + * 模型状态 + */ + model_status?: string; + /** + * 模型类型 + */ + model_type?: string; + /** + * 模型URL + */ + model_url?: string; + /** + * 提示词密钥 + */ + prompt_keys?: string; + /** + * 标签列表 + */ + tags?: Array; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取模型详细信息。 + * + * Args: + * model_id (int): 模型ID。 + * qtype (str, optional): 查询类型。默认为"mine"。 + * namespace (str, optional): 命名空间。默认为"already"。 + * + * Returns: + * dict: 模型详细信息。 + * 获取指定模型的详细信息,需要登录 + * @param modelId 模型ID + * @param qtype 查询类型 + * @param namespace 命名空间 + * @returns any 获取成功 + * @throws ApiError + */ + public static getMhModelInfo( + modelId: number, + qtype: string = 'mine', + namespace: string = 'already', + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/mh/model_info/{model_id}', + path: { + 'model_id': modelId, + }, + query: { + 'qtype': qtype, + 'namespace': namespace, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取模型树结构。 + * + * Args: + * qtype (str, optional): 查询类型。默认为"already"。 + * model_type (str, optional): 模型类型筛选条件。默认为空字符串。 + * model_kind (str, optional): 模型种类筛选条件。默认为空字符串。 + * + * Returns: + * dict: 模型树结构数据。 + * 获取模型的树形结构数据,支持按模型类型、模型种类筛选,需要登录 + * @param qtype 查询类型 + * @param modelType 模型类型筛选条件 + * @param modelKind 模型种类筛选条件 + * @returns any 获取成功 + * @throws ApiError + */ + public static getMhModelsTree( + qtype: 'mine' | 'group' | 'builtin' | 'already' = 'already', + modelType: string = '', + modelKind: string = '', + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/mh/models_tree', + query: { + 'qtype': qtype, + 'model_type': modelType, + 'model_kind': modelKind, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取支持的在线模型列表。 + * + * Returns: + * list: 支持的在线模型列表。 + * 获取系统支持的在线模型列表,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getMhOnlineModelSupportList(): CancelablePromise>> { + return __request(OpenAPI, { + method: 'GET', + url: '/mh/online_model_support_list', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 重试下载模型。 + * + * Args: + * model_id (int): 模型ID。 + * + * Returns: + * bool: 操作成功返回True。 + * + * Raises: + * CommonError: 当模型不支持重试下载时抛出。 + * 重试下载指定的模型,只支持从hf、ms导入的本地模型,需要登录 + * @param modelId 模型ID + * @returns boolean 操作成功 + * @throws ApiError + */ + public static getMhRetryDownload( + modelId: number, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/mh/retry_download/{model_id}', + path: { + 'model_id': modelId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新模型配置。 + * + * Args: + * model_id (str): 模型ID(必需)。 + * api_key (str): API密钥(必需)。 + * + * Returns: + * dict: 更新后的模型信息,使用 model_fields 格式。 + * + * Raises: + * CommonError: 当不支持的模型品牌时抛出。 + * 更新模型的配置信息,主要是API密钥,需要登录和写入权限 + * @param requestBody 更新数据 + * @returns any 更新成功 + * @throws ApiError + */ + public static postMhUpdate( + requestBody: { + /** + * API密钥(必需) + */ + api_key: string; + /** + * 模型ID(必需) + */ + model_id: string; + }, + ): CancelablePromise<{ + /** + * API密钥 + */ + api_key?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 模型描述 + */ + description?: string; + /** + * 下载消息 + */ + download_message?: string; + /** + * 模型ID + */ + id?: string; + /** + * 模型品牌 + */ + model_brand?: string; + /** + * 模型目录 + */ + model_dir?: string; + /** + * 模型来源 + */ + model_from?: string; + /** + * 模型图标 + */ + model_icon?: string; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型种类 + */ + model_kind?: string; + /** + * 模型种类显示 + */ + model_kind_display?: string; + /** + * 模型列表 + */ + model_list?: Array<{ + /** + * 是否为微调模型 + */ + is_finetune_model?: boolean; + /** + * 模型密钥 + */ + model_key?: string; + /** + * 模型名称 + */ + model_name?: string; + }>; + /** + * 模型名称 + */ + model_name?: string; + /** + * 模型路径 + */ + model_path?: string; + /** + * 模型状态 + */ + model_status?: string; + /** + * 模型类型 + */ + model_type?: string; + /** + * 模型URL + */ + model_url?: string; + /** + * 提示词密钥 + */ + prompt_keys?: string; + /** + * 标签列表 + */ + tags?: Array; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 清除数据库中的 api_key。 + * + * Args: + * model_brand (str): 模型品牌(必需)。 + * + * Returns: + * dict: 包含操作状态和结果的字典。 + * 清除数据库中的 api_key,需要登录和写入权限 + * @param requestBody 删除参数 + * @returns any 清除成功 + * @throws ApiError + */ + public static deleteMhUpdateApikey( + requestBody: { + /** + * 模型品牌(必需) + */ + model_brand: string; + }, + ): CancelablePromise<{ + result?: Record; + status?: string; + }> { + return __request(OpenAPI, { + method: 'DELETE', + url: '/mh/update_apikey', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 根据 model_brand 和 api_key 新增或更新 LazyModelConfigInfo 中的 api_key。 + * + * Args: + * model_brand (str): 模型品牌(必需)。 + * api_key (str): API密钥(必需)。 + * proxy_url (str, optional): 代理URL。 + * proxy_auth_info (dict, optional): 代理认证信息。 + * + * Returns: + * dict: 包含操作状态和结果的字典。 + * 根据 model_brand 和 api_key 新增或更新 LazyModelConfigInfo 中的 api_key,需要登录和写入权限 + * @param requestBody API密钥数据 + * @returns any 操作成功 + * @throws ApiError + */ + public static postMhUpdateApikey( + requestBody: { + /** + * API密钥 + */ + api_key?: string; + /** + * 模型品牌(必需) + */ + model_brand: string; + /** + * 代理认证信息 + */ + proxy_auth_info?: Record; + /** + * 代理URL + */ + proxy_url?: string; + }, + ): CancelablePromise<{ + result?: Record; + status?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/update_apikey', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新在线模型列表。 + * + * Args: + * base_model_id (int): 基础模型ID。 + * qtype (str, optional): 查询类型。默认为"already"。 + * + * Returns: + * dict: 更新操作的结果。 + * + * Raises: + * CommonError: 当模型不存在时抛出。 + * 更新指定基础模型的在线模型列表,需要登录和写入权限 + * @param requestBody 更新参数 + * @param qtype 查询类型 + * @returns any 更新成功 + * @throws ApiError + */ + public static postMhUpdateOnlineModelList( + requestBody: { + /** + * 基础模型ID + */ + base_model_id: number; + }, + qtype: string = 'already', + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/update_online_model_list', + query: { + 'qtype': qtype, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 上传本地模型文件分片。 + * + * Args: + * file (FileStorage): 上传的文件分片。 + * chunk_number (int): 分片编号。 + * total_chunks (int): 总分片数。 + * filename (str): 文件名。 + * file_dir (str): 文件目录。 + * + * Returns: + * dict: 包含上传结果的字典。 + * + * Raises: + * ValueError: 当未上传文件或上传多个文件时抛出。 + * 上传本地模型文件的分片,支持大文件分片上传,需要登录和写入权限 + * @param formData + * @returns any 上传成功 + * @throws ApiError + */ + public static postMhUploadChunk( + formData?: { + /** + * 上传的文件分片 + */ + file: Blob; + /** + * 分片编号 + */ + chunk_number: number; + /** + * 总分片数 + */ + total_chunks: number; + /** + * 文件名 + */ + file_name: string; + /** + * 文件目录 + */ + file_dir: string; + }, + ): CancelablePromise<{ + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/upload/chunk', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 上传模型图标文件。 + * + * Args: + * file (FileStorage): 上传的文件对象。 + * + * Returns: + * dict: 包含文件路径的字典。 + * + * Raises: + * ValueError: 当文件格式不支持或未上传文件时抛出。 + * 上传模型图标文件,支持jpg、jpeg、png、gif、bmp格式,需要登录和写入权限 + * @param formData + * @returns any 上传成功 + * @throws ApiError + */ + public static postMhUploadIcon( + formData?: { + /** + * 图标文件 + */ + file: Blob; + }, + ): CancelablePromise<{ + /** + * 文件路径 + */ + file_path?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/upload/icon', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 合并本地模型文件分片。 + * + * Args: + * filename (str): 文件名(必需)。 + * file_dir (str): 文件目录(必需)。 + * + * Returns: + * dict: 合并后的文件信息,使用 file_fields 格式。 + * + * Raises: + * ValueError: 当文件名为空时抛出。 + * 合并上传的本地模型文件分片,需要登录和写入权限 + * @param requestBody 合并参数 + * @returns any 合并成功 + * @throws ApiError + */ + public static postMhUploadMerge( + requestBody: { + /** + * 文件目录(必需) + */ + file_dir: string; + /** + * 文件名(必需) + */ + filename: string; + }, + ): CancelablePromise<{ + /** + * 文件ID + */ + id?: number; + /** + * 文件名 + */ + name?: string; + /** + * 文件路径 + */ + path?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/mh/upload/merge', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取可用的评估模型列表。 + * + * Returns: + * dict: 评估模型列表。 + * 获取可用于评估的模型列表,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getModelEvalutionAllModel(): CancelablePromise<{ + code?: number; + /** + * 模型列表 + */ + result?: Array>; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/all_model', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取在线评估数据。 + * + * Returns: + * dict: 在线评估数据列表。 + * 获取可用的在线评估数据集列表,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getModelEvalutionAllOnlineDatasets(): CancelablePromise<{ + code?: number; + /** + * 在线数据集列表 + */ + result?: Array>; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/all_online_datasets', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建新的评估任务。 + * + * Args: + * 通过JSON请求体传递参数: + * name (str): 任务名称。 + * description (str, optional): 任务描述。 + * dataset_ids (list): 数据集ID列表。 + * model_ids (list): 模型ID列表。 + * evaluation_dimensions (list): 评估维度列表。 + * + * Returns: + * dict: 创建结果信息,包含任务ID。 + * + * Raises: + * ValueError: 当必要参数缺失时抛出异常。 + * 创建新的评估任务,支持人工测评和AI测评两种方式,需要登录和写入权限 + * @param requestBody + * @returns any 创建成功 + * @throws ApiError + */ + public static postModelEvalutionCreateTask( + requestBody: { + /** + * AI评估器名称(当evaluation_method为ai时必填) + */ + ai_evaluator_name?: string; + /** + * 数据集ID列表 + */ + dataset_id: Array; + /** + * 评估维度列表 + */ + dimensions: Array<{ + ai_base_score?: number; + dimension_description?: string; + dimension_name?: string; + options?: Array<{ + option_description?: string; + value?: number; + }>; + }>; + /** + * 评估方法:manual(人工测评)/ai(AI测评) + */ + evaluation_method: 'manual' | 'ai'; + /** + * 评估类型:offline(离线)/online(在线) + */ + evaluation_type: 'offline' | 'online'; + /** + * 测评模型名称 + */ + model_name: string; + /** + * AI评估prompt(当evaluation_method为ai时可选,需包含{scene}、{scene_descrp}、{standard}、{instruction}、{output}、{response}占位符) + */ + prompt?: string; + /** + * 任务名称 + */ + task_name: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/model_evalution/create_task', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除指定的评估任务。 + * + * Args: + * task_id (str): 评估任务ID。 + * + * Returns: + * dict: 删除结果信息。 + * + * Raises: + * ValueError: 当任务ID为空或任务不存在时抛出异常。 + * 删除指定的评估任务,需要登录和管理员权限 + * @param taskId 任务ID + * @returns any 删除成功 + * @throws ApiError + */ + public static postModelEvalutionDeleteTask( + taskId: number, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/model_evalution/delete_task/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 执行评估任务。 + * + * Args: + * 通过JSON请求体传递参数: + * task_id (str): 评估任务ID。 + * evaluation_data (list): 评估数据列表。 + * + * Returns: + * dict: 评估结果信息。 + * + * Raises: + * ValueError: 当必要参数缺失或任务不存在时抛出异常。 + * 提交评估结果,支持人工测评和AI测评,需要登录和管理员权限 + * @param requestBody + * @returns any 提交成功 + * @throws ApiError + */ + public static postModelEvalutionEvaluateSave( + requestBody: { + /** + * 数据ID + */ + data_id: number; + /** + * 评估数据列表 + */ + evaluations: Array<{ + /** + * 维度ID + */ + dimension_id?: number; + /** + * 选项ID(人工测评) + */ + option_select_id?: number; + /** + * 评分(AI测评) + */ + score?: number; + }>; + /** + * 任务ID + */ + task_id: number; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/model_evalution/evaluate_save', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取评估数据分页列表。 + * + * Args: + * task_id (str): 评估任务ID。 + * 通过URL参数传递: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * + * Returns: + * dict: 分页结果,包含评估数据列表和分页信息。 + * 分页获取指定任务的评估数据,支持按选项筛选,需要登录 + * @param taskId 任务ID + * @param page 页码 + * @param optionSelectId 选项ID(用于报告查看) + * @returns any 获取成功 + * @throws ApiError + */ + public static getModelEvalutionEvaluationData( + taskId: number, + page?: number, + optionSelectId?: number, + ): CancelablePromise<{ + code?: number; + /** + * 评估数据分页结果 + */ + result?: Record; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/evaluation_data/{task_id}', + path: { + 'task_id': taskId, + }, + query: { + 'page': page, + 'option_select_id': optionSelectId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 下载指定类型的评估数据集模板。 + * + * Args: + * template_type (str): 模板类型。 + * + * Returns: + * Response: 模板文件下载响应。 + * + * Raises: + * ValueError: 当模板类型不支持时抛出异常。 + * 下载评估数据集的模板文件,支持xlsx、csv、json三种格式,不需要登录 + * @param templateType 模板类型:xlsx/csv/json + * @returns binary 下载成功 + * @throws ApiError + */ + public static getModelEvalutionEvaluationDatasettplDownload( + templateType: 'xlsx' | 'csv' | 'json', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/evaluation_datasettpl_download/{template_type}', + path: { + 'template_type': templateType, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取指定任务的评估总结信息。 + * + * Args: + * task_id (str): 评估任务ID。 + * + * Returns: + * dict: 评估总结信息。 + * + * Raises: + * ValueError: 当任务不存在时抛出异常。 + * 获取指定任务的评估总结信息,包括各维度的统计信息,需要登录 + * @param taskId 任务ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getModelEvalutionEvaluationSummary( + taskId: number, + ): CancelablePromise<{ + code?: number; + result?: { + /** + * 创建者 + */ + created_by?: string; + /** + * 维度总结列表 + */ + dimensions?: Array<{ + /** + * 平均分 + */ + average_score?: number; + /** + * 维度名称 + */ + dimension_name?: string; + /** + * 指标列表(仅人工测评) + */ + indicators?: Array<{ + name?: string; + option_id?: number; + percentage?: string; + score?: number; + total_score?: number; + }>; + /** + * 标准差 + */ + std_dev?: number; + /** + * 总分 + */ + total_score?: number; + }>; + /** + * 评估方法 + */ + evaluation_method?: string; + /** + * 任务进度 + */ + progress?: string; + /** + * 任务名称 + */ + task_name?: string; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/evaluation_summary/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 下载评估任务的Excel报告。 + * + * Args: + * task_id (str): 评估任务ID。 + * 通过URL参数传递: + * token (str, optional): 认证令牌。 + * + * Returns: + * Response: Excel文件下载响应。 + * + * Raises: + * ValueError: 当任务不存在或认证失败时抛出异常。 + * 下载评估任务的Excel报告文件,可通过token参数进行认证,不需要登录(通过token认证) + * @param taskId 任务ID + * @param token 认证令牌 + * @returns binary 下载成功 + * @throws ApiError + */ + public static getModelEvalutionEvaluationSummaryDownload( + taskId: number, + token?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/evaluation_summary_download/{task_id}', + path: { + 'task_id': taskId, + }, + query: { + 'token': token, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取指定任务的评估维度信息。 + * + * Args: + * task_id (str): 评估任务ID。 + * + * Returns: + * dict: 评估维度信息。 + * + * Raises: + * ValueError: 当任务不存在时抛出异常。 + * 获取指定任务的评估维度信息,包括维度选项,需要登录 + * @param taskId 任务ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getModelEvalutionGetEvaluationDimensions( + taskId: number, + ): CancelablePromise<{ + code?: number; + /** + * 评估维度列表 + */ + result?: Array<{ + /** + * AI基础分值 + */ + ai_base_score?: number; + /** + * 维度描述 + */ + dimension_description?: string; + /** + * 维度名称 + */ + dimension_name?: string; + /** + * 维度ID + */ + id?: number; + /** + * 维度选项列表 + */ + options?: Array<{ + /** + * 选项ID + */ + id?: number; + /** + * 选项描述 + */ + option_description?: string; + /** + * 选项分值 + */ + value?: number; + }>; + }>; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/get_evaluation_dimensions/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取评估任务分页列表。 + * + * Args: + * 通过URL参数传递: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * + * Returns: + * dict: 分页结果,包含任务列表和分页信息。 + * 分页获取评估任务列表,支持按关键词和查询类型筛选,需要登录 + * @param page 页码,从1开始 + * @param perPage 每页数量 + * @param keyword 搜索关键词 + * @param qtype 查询类型 + * @returns any 获取成功 + * @throws ApiError + */ + public static getModelEvalutionList( + page: number = 1, + perPage: number = 10, + keyword?: string, + qtype?: string, + ): CancelablePromise<{ + code?: number; + result?: { + /** + * 当前页码 + */ + current_page?: number; + /** + * 总页数 + */ + pages?: number; + /** + * 每页数量 + */ + per_page?: number; + /** + * 任务列表 + */ + tasks?: Array<{ + created_time?: string; + /** + * 创建者 + */ + creator?: string; + /** + * 评估方法 + */ + evaluation_method?: string; + /** + * 任务ID + */ + id?: number; + /** + * 模型名称 + */ + model_name?: string; + /** + * 任务名称 + */ + name?: string; + /** + * 任务进度 + */ + process?: string; + /** + * 任务状态 + */ + status?: string; + /** + * 任务状态(中文) + */ + status_zh?: string; + }>; + /** + * 总记录数 + */ + total?: number; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/list', + query: { + 'page': page, + 'per_page': perPage, + 'keyword': keyword, + 'qtype': qtype, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取指定评估任务的详细信息。 + * + * Args: + * task_id (str): 评估任务ID。 + * + * Returns: + * dict: 任务详细信息。 + * + * Raises: + * ValueError: 当任务不存在时抛出异常。 + * 获取指定评估任务的详细信息,需要登录 + * @param taskId 任务ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getModelEvalutionTaskInfo( + taskId: number, + ): CancelablePromise<{ + code?: number; + result?: { + task_info?: { + /** + * AI评估失败数 + */ + ai_eva_fail?: number; + /** + * AI评估成功数 + */ + ai_eva_success?: number; + /** + * AI评估器名称 + */ + ai_evaluator_name?: string; + created_time?: string; + /** + * 评估方法(manual/ai) + */ + evaluation_method?: string; + /** + * 任务ID + */ + id?: number; + /** + * 模型名称 + */ + model_name?: string; + /** + * 任务名称 + */ + name?: string; + /** + * 任务进度 + */ + process?: string; + /** + * 任务状态 + */ + status?: string; + /** + * 任务状态(中文) + */ + status_zh?: string; + /** + * 创建者用户名 + */ + username?: string; + }; + }; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/model_evalution/task_info/{task_id}', + path: { + 'task_id': taskId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 上传评估数据集文件。 + * + * Args: + * 通过multipart/form-data传递参数: + * files: 要上传的文件列表。 + * + * Returns: + * dict: 上传结果信息,包含数据集ID。 + * + * Raises: + * Exception: 当文件上传、解压或处理失败时抛出异常。 + * 上传评估数据集文件,支持格式:json、csv、xlsx、zip、tar.gz。单个文件最大1GB,需要登录 + * @param formData + * @returns any 上传成功 + * @throws ApiError + */ + public static postModelEvalutionUploadDataset( + formData?: { + /** + * 要上传的文件列表,支持格式:json、csv、xlsx、zip、tar.gz。单个文件最大1GB + */ + files: Blob; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + result?: { + /** + * 数据集ID + */ + dataset_id?: number; + }; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/model_evalution/upload_dataset', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建新的通知。 + * + * 创建包含用户通知和审批人通知的完整通知记录。 + * + * Args: + * module (str): 模块名称,如"quota_request"。 + * source_id (str): 源对象ID。 + * user_id (str): 用户ID。 + * user_body (str): 用户通知内容。 + * user_read (bool): 用户是否已读。 + * user_read_time (str): 用户阅读时间。 + * notify_user1_id (str): 通知用户1的ID。 + * notify_user1_body (str): 通知用户1的内容。 + * notify_user1_read (bool): 通知用户1是否已读。 + * notify_user1_read_time (str): 通知用户1的阅读时间。 + * notify_user2_id (str, optional): 通知用户2的ID。 + * notify_user2_body (str, optional): 通知用户2的内容。 + * notify_user2_read (bool, optional): 通知用户2是否已读。 + * notify_user2_read_time (str, optional): 通知用户2的阅读时间。 + * created_at (str): 创建时间。 + * + * Returns: + * dict: 创建的通知信息字典。 + * + * Raises: + * ValueError: 当必需参数缺失时。 + * Exception: 当创建通知失败时。 + * 创建新的通知,支持多用户通知场景,创建包含用户通知和审批人通知的完整通知记录,需要登录 + * @param requestBody 通知数据 + * @returns any 创建成功 + * @throws ApiError + */ + public static postNotificationsCreate( + requestBody: { + /** + * 创建时间 + */ + created_at?: string; + /** + * 模块名称,如"quota_request" + */ + module: string; + /** + * 通知用户1的内容 + */ + notify_user1_body: string; + /** + * 通知用户1的ID + */ + notify_user1_id: string; + /** + * 通知用户1是否已读 + */ + notify_user1_read?: boolean; + /** + * 通知用户1的阅读时间 + */ + notify_user1_read_time?: string; + /** + * 通知用户2的内容 + */ + notify_user2_body?: string; + /** + * 通知用户2的ID + */ + notify_user2_id?: string; + /** + * 通知用户2是否已读 + */ + notify_user2_read?: boolean; + /** + * 通知用户2的阅读时间 + */ + notify_user2_read_time?: string; + /** + * 源对象ID + */ + source_id: string; + /** + * 用户通知内容 + */ + user_body: string; + /** + * 用户ID + */ + user_id: string; + /** + * 用户是否已读 + */ + user_read?: boolean; + /** + * 用户阅读时间 + */ + user_read_time?: string; + }, + ): CancelablePromise<{ + /** + * 创建时间 + */ + created_at?: string; + /** + * 通知ID + */ + id?: string; + /** + * 消息所属模块 + */ + module?: string; + /** + * 通知人1消息体 + */ + notify_user1_body?: string; + /** + * 通知人1的ID + */ + notify_user1_id?: string; + /** + * 通知人1是否已读 + */ + notify_user1_read?: boolean; + /** + * 通知人1已读时间 + */ + notify_user1_read_time?: string; + /** + * 通知人2消息体 + */ + notify_user2_body?: string; + /** + * 通知人2的ID + */ + notify_user2_id?: string; + /** + * 通知人2是否已读 + */ + notify_user2_read?: boolean; + /** + * 通知人2已读时间 + */ + notify_user2_read_time?: string; + /** + * 来源ID + */ + source_id?: string; + /** + * 用户回执消息体 + */ + user_body?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户是否已读回执消息 + */ + user_read?: boolean; + /** + * 用户已读回执时间 + */ + user_read_time?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/notifications/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取通知详情。 + * + * 获取指定通知的详细信息。 + * + * Args: + * notification_id (str): 通知ID,通过查询参数传递。 + * + * Returns: + * dict: 通知详细信息字典。 + * + * Raises: + * ValueError: 当通知ID缺失或无权限查看时。 + * Exception: 当获取通知详情失败时。 + * 获取指定通知的详细信息,只有管理员或通知所属用户才能查看,需要登录 + * @param notificationId 通知ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getNotificationsDetail( + notificationId: string, + ): CancelablePromise<{ + /** + * 创建时间 + */ + created_at?: string; + /** + * 通知ID + */ + id?: string; + /** + * 消息所属模块 + */ + module?: string; + /** + * 通知人1消息体 + */ + notify_user1_body?: string; + /** + * 通知人1的ID + */ + notify_user1_id?: string; + /** + * 通知人1是否已读 + */ + notify_user1_read?: boolean; + /** + * 通知人1已读时间 + */ + notify_user1_read_time?: string; + /** + * 通知人2消息体 + */ + notify_user2_body?: string; + /** + * 通知人2的ID + */ + notify_user2_id?: string; + /** + * 通知人2是否已读 + */ + notify_user2_read?: boolean; + /** + * 通知人2已读时间 + */ + notify_user2_read_time?: string; + /** + * 来源ID + */ + source_id?: string; + /** + * 用户回执消息体 + */ + user_body?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户是否已读回执消息 + */ + user_read?: boolean; + /** + * 用户已读回执时间 + */ + user_read_time?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/notifications/detail', + query: { + 'notification_id': notificationId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取通知列表。 + * + * 支持分页、所有字段过滤、时间区间过滤的消息列表查询。 + * + * Args: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页数量,默认为100。 + * created_at_start (str, optional): 创建时间开始。 + * created_at_end (str, optional): 创建时间结束。 + * user_read (bool, optional): 用户是否已读过滤。 + * **filters: 其他过滤条件。 + * + * Returns: + * dict: 包含通知列表和分页信息的字典。 + * + * Raises: + * Exception: 当查询失败时。 + * 支持分页、所有字段过滤、时间区间过滤的消息列表查询,需要登录 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postNotificationsList( + requestBody?: { + /** + * 创建时间结束 + */ + created_at_end?: string; + /** + * 创建时间开始 + */ + created_at_start?: string; + /** + * 模块名称过滤 + */ + module?: string; + /** + * 页码,从 1 开始 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 来源ID过滤 + */ + source_id?: string; + /** + * 用户是否已读过滤 + */ + user_read?: boolean; + }, + ): CancelablePromise<{ + /** + * 通知列表 + */ + items?: Array<{ + /** + * 创建时间 + */ + created_at?: string; + /** + * 通知ID + */ + id?: string; + /** + * 消息所属模块 + */ + module?: string; + /** + * 通知人1消息体 + */ + notify_user1_body?: string; + /** + * 通知人1的ID + */ + notify_user1_id?: string; + /** + * 通知人1是否已读 + */ + notify_user1_read?: boolean; + /** + * 通知人1已读时间 + */ + notify_user1_read_time?: string; + /** + * 通知人2消息体 + */ + notify_user2_body?: string; + /** + * 通知人2的ID + */ + notify_user2_id?: string; + /** + * 通知人2是否已读 + */ + notify_user2_read?: boolean; + /** + * 通知人2已读时间 + */ + notify_user2_read_time?: string; + /** + * 来源ID + */ + source_id?: string; + /** + * 用户回执消息体 + */ + user_body?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户是否已读回执消息 + */ + user_read?: boolean; + /** + * 用户已读回执时间 + */ + user_read_time?: string; + }>; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 总页数 + */ + pages?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/notifications/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 标记通知为已读。 + * + * 通过通知ID和用户ID将通知标记为已读。 + * + * Args: + * notification_id (str): 通知ID。 + * + * Returns: + * dict: 更新后的通知信息字典。 + * + * Raises: + * ValueError: 当通知ID为空时。 + * Exception: 当标记已读失败时。 + * 通过通知ID和用户ID将通知标记为已读,需要登录 + * @param requestBody 标记参数 + * @returns any 标记成功 + * @throws ApiError + */ + public static postNotificationsRead( + requestBody: { + /** + * 通知ID + */ + notification_id: string; + }, + ): CancelablePromise<{ + /** + * 创建时间 + */ + created_at?: string; + /** + * 通知ID + */ + id?: string; + /** + * 消息所属模块 + */ + module?: string; + /** + * 通知人1消息体 + */ + notify_user1_body?: string; + /** + * 通知人1的ID + */ + notify_user1_id?: string; + /** + * 通知人1是否已读 + */ + notify_user1_read?: boolean; + /** + * 通知人1已读时间 + */ + notify_user1_read_time?: string; + /** + * 通知人2消息体 + */ + notify_user2_body?: string; + /** + * 通知人2的ID + */ + notify_user2_id?: string; + /** + * 通知人2是否已读 + */ + notify_user2_read?: boolean; + /** + * 通知人2已读时间 + */ + notify_user2_read_time?: string; + /** + * 来源ID + */ + source_id?: string; + /** + * 用户回执消息体 + */ + user_body?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户是否已读回执消息 + */ + user_read?: boolean; + /** + * 用户已读回执时间 + */ + user_read_time?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/notifications/read', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建新脚本。 + * + * Args: + * 通过JSON请求体传递参数: + * name (str): 脚本名称。 + * description (str, optional): 脚本描述。 + * icon (str, optional): 脚本图标,默认为"/app/upload/script.jpg"。 + * script_url (str, optional): 脚本URL。 + * script_type (str, optional): 脚本类型。 + * data_type (str, optional): 数据类型。 + * + * Returns: + * dict: 创建的脚本信息。 + * + * Raises: + * ValueError: 当缺少必要参数时抛出异常。 + * 创建新的脚本 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postScriptCreate( + requestBody: { + /** + * 数据类型 + */ + data_type?: 'doc' | 'pic'; + /** + * 脚本描述 + */ + description?: string; + /** + * 脚本图标 + */ + icon?: string; + /** + * 脚本名称 + */ + name: string; + /** + * 脚本类型 + */ + script_type?: string; + /** + * 脚本URL + */ + script_url?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/script/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除指定脚本。 + * + * Args: + * 通过JSON请求体传递参数: + * script_id (int): 脚本ID。 + * + * Returns: + * tuple: (响应数据, HTTP状态码) + * + * Raises: + * ValueError: 当脚本ID为空时抛出异常。 + * 删除指定的脚本 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postScriptDelete( + requestBody: { + /** + * 脚本ID + */ + script_id: number; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/script/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取脚本分页列表。 + * + * Args: + * 通过JSON请求体传递参数: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * script_type (list, optional): 脚本类型列表。 + * name (str, optional): 脚本名称。 + * qtype (str, optional): 查询类型,默认为"already"。 + * search_tags (list, optional): 搜索标签列表。 + * search_name (str, optional): 搜索名称。 + * user_id (list, optional): 用户ID列表。 + * + * Returns: + * dict: 分页结果,包含脚本列表和分页信息。 + * 获取脚本分页列表,支持按脚本类型、名称、标签等条件筛选 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postScriptList( + requestBody: { + /** + * 脚本名称 + */ + name?: string; + /** + * 页码,从1开始 + */ + page?: number; + /** + * 每页大小 + */ + page_size?: number; + /** + * 查询类型 + */ + qtype?: string; + /** + * 脚本类型列表 + */ + script_type?: Array; + /** + * 搜索名称 + */ + search_name?: string; + /** + * 搜索标签列表 + */ + search_tags?: Array; + /** + * 用户ID列表 + */ + user_id?: Array; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/script/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 根据脚本类型获取脚本列表。 + * + * Args: + * 通过URL参数传递: + * script_type (str): 脚本类型。 + * + * Returns: + * list: 指定类型的脚本列表。 + * 根据脚本类型获取脚本列表 + * @param scriptType 脚本类型 + * @returns any 成功 + * @throws ApiError + */ + public static getScriptListByType( + scriptType?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/script/list_by_type', + query: { + 'script_type': scriptType, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新指定脚本信息。 + * + * Args: + * 通过JSON请求体传递参数: + * script_id (int): 脚本ID。 + * name (str, optional): 脚本名称。 + * description (str, optional): 脚本描述。 + * icon (str, optional): 脚本图标。 + * script_url (str, optional): 脚本URL。 + * script_type (str, optional): 脚本类型。 + * data_type (str, optional): 数据类型。 + * + * Returns: + * dict: 更新后的脚本信息。 + * + * Raises: + * ValueError: 当脚本ID为空时抛出异常。 + * 更新指定脚本的信息 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postScriptUpdate( + requestBody: { + /** + * 数据类型 + */ + data_type?: 'doc' | 'pic'; + /** + * 脚本描述 + */ + description?: string; + /** + * 脚本图标 + */ + icon?: string; + /** + * 脚本名称 + */ + name?: string; + /** + * 脚本ID + */ + script_id: number; + /** + * 脚本类型 + */ + script_type?: string; + /** + * 脚本URL + */ + script_url?: string; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/script/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 上传脚本文件。 + * + * Args: + * 通过multipart/form-data传递参数: + * file: 上传的脚本文件,必须是.py格式。 + * + * Returns: + * dict: 上传结果信息。 + * + * Raises: + * ValueError: 当没有上传文件、文件类型不支持或上传多个文件时抛出异常。 + * 上传脚本文件(.py格式),文件大小不能超过1MB + * @param formData + * @returns any 成功 + * @throws ApiError + */ + public static postScriptUpload( + formData?: { + /** + * 脚本文件(.py格式) + */ + file: Blob; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/script/upload', + formData: formData, + mediaType: 'application/x-www-form-urlencoded', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询标签列表。 + * + * 根据指定的标签类型和可选的关键词查询标签列表。 + * + * Args: + * type (str): 标签类型,必填,必须是预定义的标签类型之一。 + * keyword (str, optional): 搜索关键词,默认为空字符串。 + * + * Returns: + * list: 包含标签信息的列表。 + * + * Raises: + * ValueError: 当标签类型不在允许的选项中时抛出。 + * 根据标签类型和关键词查询标签列表 + * @param type 标签类型,必填 + * @param keyword 搜索关键词,可选 + * @returns any 成功 + * @throws ApiError + */ + public static getTags( + type: 'knowledgebase' | 'app' | 'model' | 'tool' | 'prompt' | 'dataset' | 'script' | 'mcp', + keyword: string = '', + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/tags', + query: { + 'type': type, + 'keyword': keyword, + }, + errors: { + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 更新关系 + * 更新目标对象与标签的绑定关系 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postTagsBindingsUpdate( + requestBody: { + /** + * 标签名称列表 + */ + tag_names: Array; + /** + * 目标对象ID + */ + target_id: string; + /** + * 标签类型 + */ + type: 'knowledgebase' | 'app' | 'model' | 'tool' | 'prompt' | 'dataset' | 'script' | 'mcp'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/tags/bindings/update', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建内置标签。 + * + * 创建一个新的内置标签,只有超级用户可以执行此操作。 + * + * Args: + * name (str): 标签名称,必填。 + * type (str): 标签类型,必填,必须是预定义的标签类型之一。 + * + * Returns: + * dict: 包含新创建标签的id、name、type信息的字典。 + * + * Raises: + * ValueError: 当参数错误或标签类型不合法时抛出。 + * PermissionError: 当用户不是超级用户时抛出。 + * 创建一个新的内置标签,只有超级用户可以执行此操作 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postTagsCreate( + requestBody: { + /** + * 标签名称 + */ + name: string; + /** + * 标签类型 + */ + type: 'knowledgebase' | 'app' | 'model' | 'tool' | 'prompt' | 'dataset' | 'script' | 'mcp'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/tags/create', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除标签 + * 删除指定的标签 + * @param requestBody + * @returns any 成功 + * @throws ApiError + */ + public static postTagsDelete( + requestBody: { + /** + * 标签名称 + */ + name: string; + /** + * 标签类型 + */ + type: 'knowledgebase' | 'app' | 'model' | 'tool' | 'prompt' | 'dataset' | 'script' | 'mcp'; + }, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/tags/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 授权回调 + * 处理OAuth授权回调,不需要登录 + * @param code 授权码 + * @param state 状态 + * @returns any 授权成功 + * @throws ApiError + */ + public static getToolAuth( + code?: string, + state?: string, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/tool/auth', + query: { + 'code': code, + 'state': state, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 授权分享 + * 设置工具的授权分享状态,需要登录和写入权限 + * @param requestBody 分享参数 + * @returns any 操作成功 + * @throws ApiError + */ + public static postToolAuthShare( + requestBody: { + /** + * 分享状态 + */ + share_status: boolean; + /** + * 工具ID + */ + tool_id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/auth_share', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 发布工具 + * 取消工具的发布状态,需要登录和写入权限 + * @param requestBody 工具ID + * @returns any 操作成功 + * @throws ApiError + */ + public static postToolCancelPublish( + requestBody: { + /** + * 工具ID + */ + id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/cancel_publish', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 检查名字重复 + * 验证指定的工具名称是否已经被使用,需要登录 + * @param requestBody 检查参数 + * @returns any 名称可用 + * @throws ApiError + */ + public static postToolCheckName( + requestBody: { + /** + * 要检查的工具名称 + */ + name: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/check_name', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 复制一份新的工具 + * 复制一份新的工具,需要登录和读取权限 + * @param requestBody 工具ID + * @returns any 复制成功 + * @throws ApiError + */ + public static postToolCopyTool( + requestBody: { + /** + * 工具ID + */ + id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/copy_tool', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * field部分的页面编辑(API+IDE两种模式都有,每次都是新增数据) + * 创建或更新工具的字段(API+IDE两种模式都有),每次都是新增数据,需要登录和写入权限 + * @param requestBody 工具字段数据 + * @returns any 操作成功 + * @throws ApiError + */ + public static postToolCreateUpdateField( + requestBody: { + /** + * 工具字段列表 + */ + fields: Array<{ + /** + * 默认值 + */ + default_value?: string; + /** + * 字段描述 + */ + description?: string; + /** + * 字段格式 + */ + field_format?: string; + /** + * 字段类型 + */ + field_type?: string; + /** + * 带入方法 + */ + field_use_model?: string; + /** + * 字段ID,如果提供则进行更新 + */ + id?: number; + /** + * 字段名称 + */ + name?: string; + /** + * 是否必填 + */ + required?: boolean; + /** + * 工具ID + */ + tool_id?: string; + /** + * 是否可见 + */ + visible?: boolean; + }>; + }, + ): CancelablePromise<{ + /** + * 保存错误 + */ + save_error?: string; + /** + * 成功保存的字段列表 + */ + save_success_field?: Array>; + /** + * 更新错误 + */ + update_error?: string; + /** + * 成功更新的字段列表 + */ + update_success_field?: Array>; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/create_update_field', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 创建与更新工具 + * 根据传入的数据创建新的工具或更新已存在的工具。如果数据中包含id字段则进行更新,否则创建新工具,需要登录和写入权限 + * @param requestBody 工具数据 + * @returns any 创建或更新成功 + * @throws ApiError + */ + public static postToolCreateUpdateTool( + requestBody: { + /** + * 工具描述 + */ + description?: string; + /** + * 工具图标 + */ + icon?: string; + /** + * 工具ID,如果提供则进行更新 + */ + id?: string; + /** + * 工具名称(必需) + */ + name: string; + /** + * 工具IDE代码 + */ + tool_ide_code?: string; + /** + * 工具IDE代码类型 + */ + tool_ide_code_type?: string; + /** + * 工具类别 + */ + tool_kind?: string; + /** + * 工具模式:API 或 IDE + */ + tool_mode?: 'API' | 'IDE'; + /** + * 工具类型 + */ + tool_type?: '官方内置' | '自定义'; + }, + ): CancelablePromise<{ + /** + * 是否授权 0-默认值 1-授权 2-未授权 3已过期 + */ + auth?: number; + /** + * 创建时间 + */ + created_at?: string; + /** + * 工具描述 + */ + description?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * 工具图标 + */ + icon?: string; + /** + * 工具ID + */ + id?: string; + /** + * 工具名称 + */ + name?: string; + /** + * 是否展示共享按钮 + */ + need_share?: boolean; + /** + * 是否发布 + */ + publish?: boolean; + /** + * 发布时间 + */ + publish_at?: string; + /** + * 发布类型 + */ + publish_type?: string; + /** + * 引用状态 + */ + ref_status?: boolean; + /** + * 共享状态 + */ + share?: boolean; + /** + * 标签列表 + */ + tags?: Array; + /** + * 测试状态 + */ + test_state?: string; + /** + * 工具API ID + */ + tool_api_id?: string; + /** + * 工具字段输入ID列表 + */ + tool_field_input_ids?: Array; + /** + * 工具字段输出ID列表 + */ + tool_field_output_ids?: Array; + /** + * 工具IDE代码 + */ + tool_ide_code?: string; + /** + * 工具IDE代码类型 + */ + tool_ide_code_type?: string; + /** + * 工具类别 + */ + tool_kind?: string; + /** + * 工具模式 + */ + tool_mode?: string; + /** + * 工具类型 + */ + tool_type?: string; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/create_update_tool', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除授权 + * 删除工具的用户授权,需要登录和写入权限 + * @param requestBody 授权参数 + * @returns any 删除成功 + * @throws ApiError + */ + public static postToolDeleteAuthByUser( + requestBody: { + /** + * 工具ID + */ + tool_id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/delete_auth_by_user', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除工具 + * 删除指定的工具,需要登录和管理员权限 + * @param requestBody 工具ID + * @returns any 删除成功 + * @throws ApiError + */ + public static postToolDeleteTool( + requestBody: { + /** + * 工具ID + */ + id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/delete_tool', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 启用工具 + * 设置工具的启用状态,需要登录和写入权限 + * @param requestBody 启用参数 + * @returns any 操作成功 + * @throws ApiError + */ + public static postToolEnableTool( + requestBody: { + /** + * 是否启用工具 + */ + enable: boolean; + /** + * 工具ID + */ + id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/enable_tool', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 导出文件 + * 导出工具为JSON格式,支持直接返回JSON或下载文件,需要登录和读取权限 + * @param id 工具ID + * @param format 导出格式:json 或 file + * @returns any 导出成功 + * @throws ApiError + */ + public static getToolExport( + id: number, + format?: string, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/tool/export', + query: { + 'id': id, + 'format': format, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取工具分页列表。 + * + * 根据传入的查询条件获取工具的分页列表,支持按工具类型、发布状态、 + * 启用状态、标签、名称等条件进行筛选。 + * + * Args: + * page (int, optional): 页码,默认为1。 + * page_size (int, optional): 每页大小,默认为20。 + * tool_type (str, optional): 工具类型,默认为空字符串。 + * published (list, optional): 发布状态列表。 + * enabled (list, optional): 启用状态列表。 + * qtype (str, optional): 查询类型,可选值:mine/group/builtin/already,默认为already。 + * search_tags (list, optional): 搜索标签列表,默认为空列表。 + * search_name (str, optional): 搜索名称,默认为空字符串。 + * tool_mode (list, optional): 工具模式列表,默认为空列表。 + * user_id (list, optional): 用户ID列表,默认为空列表。 + * + * Returns: + * dict: 包含工具分页信息的字典。 + * + * Raises: + * ValueError: 当请求参数不合法时抛出。 + * 根据传入的查询条件获取工具的分页列表,支持按工具类型、发布状态、启用状态、标签、名称等条件进行筛选,需要登录 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postToolList( + requestBody?: { + /** + * 启用状态列表 + */ + enabled?: Array; + /** + * 是否为草稿 + */ + is_draft?: boolean; + /** + * 页码,从 1 开始 + */ + page?: number; + /** + * 每页大小 + */ + page_size?: number; + /** + * 发布状态列表 + */ + published?: Array; + /** + * 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + */ + qtype?: 'mine' | 'group' | 'builtin' | 'already'; + /** + * 名称搜索条件 + */ + search_name?: string; + /** + * 标签搜索条件 + */ + search_tags?: Array; + /** + * 工具模式列表 + */ + tool_mode?: Array; + /** + * 工具类型 + */ + tool_type?: string; + /** + * 用户ID列表 + */ + user_id?: Array; + }, + ): CancelablePromise<{ + /** + * 工具列表 + */ + data?: Array<{ + /** + * 是否授权 0-默认值 1-授权 2-未授权 3已过期 + */ + auth?: number; + /** + * 创建时间 + */ + created_at?: string; + /** + * 工具描述 + */ + description?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * 工具图标 + */ + icon?: string; + /** + * 工具ID + */ + id?: string; + /** + * 工具名称 + */ + name?: string; + /** + * 是否展示共享按钮 + */ + need_share?: boolean; + /** + * 是否发布 + */ + publish?: boolean; + /** + * 发布时间 + */ + publish_at?: string; + /** + * 发布类型 + */ + publish_type?: string; + /** + * 引用状态 + */ + ref_status?: boolean; + /** + * 共享状态 + */ + share?: boolean; + /** + * 标签列表 + */ + tags?: Array; + /** + * 测试状态 + */ + test_state?: string; + /** + * 工具API ID + */ + tool_api_id?: string; + /** + * 工具字段输入ID列表 + */ + tool_field_input_ids?: Array; + /** + * 工具字段输出ID列表 + */ + tool_field_output_ids?: Array; + /** + * 工具IDE代码 + */ + tool_ide_code?: string; + /** + * 工具IDE代码类型 + */ + tool_ide_code_type?: string; + /** + * 工具类别 + */ + tool_kind?: string; + /** + * 工具模式 + */ + tool_mode?: string; + /** + * 工具类型 + */ + tool_type?: string; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 发布工具 + * 将工具发布为可用状态,支持不同的发布类型,需要登录和写入权限 + * @param requestBody 发布参数 + * @returns any 发布成功 + * @throws ApiError + */ + public static postToolPublishTool( + requestBody: { + /** + * 工具ID + */ + id: string; + /** + * 发布类型:预发布 或 正式发布 + */ + publish_type?: '预发布' | '正式发布'; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/publish_tool', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取工具引用结果 + * 获取引用指定工具的应用列表,不需要登录 + * @param id 工具ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getToolReferenceResult( + id: number, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/tool/reference-result', + query: { + 'id': id, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 生成授权URL + * 生成对应的授权URL,需要登录和写入权限 + * @param requestBody 授权参数 + * @returns any 生成成功 + * @throws ApiError + */ + public static postToolReturnAuthUrl( + requestBody: { + /** + * 工具ID + */ + tool_id: string; + }, + ): CancelablePromise<{ + /** + * 授权URL + */ + url?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/return_auth_url', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 测试工具日志 + * 测试工具日志功能,需要登录和写入权限 + * @param requestBody 工具ID + * @returns any 操作成功 + * @throws ApiError + */ + public static postToolTest( + requestBody: { + /** + * 工具ID + */ + id: string; + }, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/test', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 测试工具 + * 使用指定的参数测试工具的功能,需要登录和写入权限,需要启用工具运行功能 + * @param requestBody 测试参数 + * @returns any 测试成功 + * @throws ApiError + */ + public static postToolTestTool( + requestBody: { + /** + * 工具ID + */ + id: string; + /** + * 输入参数 + */ + input?: Record; + /** + * 代码变量 + */ + vars_for_code?: Record; + }, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/test_tool', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 工具详情 + * 根据工具ID获取工具的详细信息,需要登录 + * @param toolId 工具ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getToolToolApi( + toolId: string, + ): CancelablePromise<{ + /** + * 是否授权 0-默认值 1-授权 2-未授权 3已过期 + */ + auth?: number; + /** + * 创建时间 + */ + created_at?: string; + /** + * 工具描述 + */ + description?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * 工具图标 + */ + icon?: string; + /** + * 工具ID + */ + id?: string; + /** + * 工具名称 + */ + name?: string; + /** + * 是否展示共享按钮 + */ + need_share?: boolean; + /** + * 是否发布 + */ + publish?: boolean; + /** + * 发布时间 + */ + publish_at?: string; + /** + * 发布类型 + */ + publish_type?: string; + /** + * 引用状态 + */ + ref_status?: boolean; + /** + * 共享状态 + */ + share?: boolean; + /** + * 标签列表 + */ + tags?: Array; + /** + * 测试状态 + */ + test_state?: string; + /** + * 工具API ID + */ + tool_api_id?: string; + /** + * 工具字段输入ID列表 + */ + tool_field_input_ids?: Array; + /** + * 工具字段输出ID列表 + */ + tool_field_output_ids?: Array; + /** + * 工具IDE代码 + */ + tool_ide_code?: string; + /** + * 工具IDE代码类型 + */ + tool_ide_code_type?: string; + /** + * 工具类别 + */ + tool_kind?: string; + /** + * 工具模式 + */ + tool_mode?: string; + /** + * 工具类型 + */ + tool_type?: string; + /** + * 更新时间 + */ + updated_at?: string; + /** + * 用户ID + */ + user_id?: string; + /** + * 用户名 + */ + user_name?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/tool/tool_api', + query: { + 'tool_id': toolId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * HTTP部分的数据详情 + * 获取工具的HTTP API配置详情,需要登录 + * @param apiId API ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getToolToolApiInfo( + apiId?: number, + ): CancelablePromise<{ + /** + * API密钥 + */ + api_key?: string; + /** + * 受众 + */ + audience?: string; + /** + * 认证方法 + */ + auth_method?: string; + /** + * 授权内容类型 + */ + authorization_content_type?: string; + /** + * 授权URL + */ + authorization_url?: string; + /** + * 客户端ID + */ + client_id?: string; + /** + * 客户端密钥 + */ + client_secret?: string; + /** + * 客户端URL + */ + client_url?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 端点URL + */ + endpoint_url?: string; + /** + * 授权类型 + */ + grant_type?: string; + /** + * 请求头 + */ + header?: Record; + /** + * API ID + */ + id?: string; + /** + * 位置 + */ + location?: string; + /** + * 参数名 + */ + param_name?: string; + /** + * 请求类型 + */ + request_type?: string; + /** + * 作用域 + */ + scope?: string; + /** + * 更新时间 + */ + updated_at?: string; + /** + * URL + */ + url?: string; + /** + * 用户ID + */ + user_id?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/tool/tool_api_info', + query: { + 'api_id': apiId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * field部分的数据详情(API+IDE两种模式都有) + * 获取工具字段的数据详情(API+IDE两种模式都有),需要登录和写入权限 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postToolToolFields( + requestBody?: { + /** + * 字段ID列表 + */ + fields?: Array; + }, + ): CancelablePromise<{ + /** + * 工具字段列表 + */ + data?: Array>; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/tool_fields', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * HTTP部分的页面编辑(每次都是新增就很诡异) + * 创建或更新工具的HTTP API配置,需要登录和写入权限 + * @param requestBody API数据 + * @returns any 操作成功 + * @throws ApiError + */ + public static postToolUpsertToolApi( + requestBody: { + /** + * API密钥 + */ + api_key?: string; + /** + * 认证方法 + */ + auth_method?: string; + /** + * 请求头 + */ + header?: Record; + /** + * API ID,如果提供则进行更新 + */ + id?: string; + /** + * 请求类型 + */ + request_type?: string; + /** + * 工具ID + */ + tool_id?: string; + /** + * URL + */ + url?: string; + }, + ): CancelablePromise<{ + /** + * API密钥 + */ + api_key?: string; + /** + * 受众 + */ + audience?: string; + /** + * 认证方法 + */ + auth_method?: string; + /** + * 授权内容类型 + */ + authorization_content_type?: string; + /** + * 授权URL + */ + authorization_url?: string; + /** + * 客户端ID + */ + client_id?: string; + /** + * 客户端密钥 + */ + client_secret?: string; + /** + * 客户端URL + */ + client_url?: string; + /** + * 创建时间 + */ + created_at?: string; + /** + * 端点URL + */ + endpoint_url?: string; + /** + * 授权类型 + */ + grant_type?: string; + /** + * 请求头 + */ + header?: Record; + /** + * API ID + */ + id?: string; + /** + * 位置 + */ + location?: string; + /** + * 参数名 + */ + param_name?: string; + /** + * 请求类型 + */ + request_type?: string; + /** + * 作用域 + */ + scope?: string; + /** + * 更新时间 + */ + updated_at?: string; + /** + * URL + */ + url?: string; + /** + * 用户ID + */ + user_id?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/tool/upsert_tool_api', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看用户加入的租户。 + * + * Returns: + * dict: 用户加入的租户列表 + * 查看用户加入的租户,需要登录 + * @param accountId 账户ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesAccountTenants( + accountId: string, + ): CancelablePromise<{ + /** + * 租户列表 + */ + tenants?: Array<{ + /** + * 创建时间 + */ + created_at?: number; + /** + * 是否为当前租户 + */ + current?: boolean; + /** + * 是否启用AI + */ + enable_ai?: boolean; + /** + * GPU配额 + */ + gpu_quota?: number; + /** + * 已使用GPU + */ + gpu_used?: number; + /** + * 是否有资产 + */ + has_assets?: boolean; + /** + * 租户ID + */ + id?: string; + /** + * 租户名称 + */ + name?: string; + /** + * 角色 + */ + role?: string; + /** + * 状态 + */ + status?: string; + /** + * 存储配额 + */ + storage_quota?: number; + /** + * 已使用存储 + */ + storage_used?: number; + }>; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/account/tenants', + query: { + 'account_id': accountId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 添加租户。 + * + * Returns: + * dict: 创建的租户信息 + * 创建新的租户,需要登录和写入权限 + * @param requestBody 租户数据 + * @returns any 创建成功 + * @throws ApiError + */ + public static postWorkspacesAdd( + requestBody: { + /** + * 租户名称 + */ + name: string; + }, + ): CancelablePromise<{ + /** + * 创建时间 + */ + created_at?: number; + /** + * 是否为当前租户 + */ + current?: boolean; + /** + * 是否启用AI + */ + enable_ai?: boolean; + /** + * GPU配额 + */ + gpu_quota?: number; + /** + * 已使用GPU + */ + gpu_used?: number; + /** + * 是否有资产 + */ + has_assets?: boolean; + /** + * 租户ID + */ + id?: string; + /** + * 租户名称 + */ + name?: string; + /** + * 角色 + */ + role?: string; + /** + * 状态 + */ + status?: string; + /** + * 存储配额 + */ + storage_quota?: number; + /** + * 已使用存储 + */ + storage_used?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/add', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取租户的AI能力配置。 + * + * 该函数用于获取租户的AI工具配置信息。 + * + * Args: + * 无直接参数。请求体中应包含以下JSON字段: + * tenant_id (str): 租户ID,选填,为空就代表设定当前租户。 + * + * Returns: + * - 若成功,返回({"message": "success", "code": 200, "data": 数据}, 200) + * 获取租户的AI能力配置,需要登录 + * @param tenantId 租户ID,为空则使用当前租户 + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesAiToolList( + tenantId?: string, + ): CancelablePromise<{ + code?: number; + /** + * JSON格式的配置数据 + */ + data?: string; + message?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/ai-tool/list', + query: { + 'tenant_id': tenantId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 设置租户的AI能力配置。 + * + * 该函数用于批量更新指定租户的AI工具配置信息。首先删除该租户现有的所有AI工具配置, + * 然后根据提供的数据创建新的AI工具配置记录。 + * + * Args: + * 无直接参数。请求体中应包含以下JSON字段: + * data (list): AI工具配置数据列表,必填。 + * tenant_id (str): 租户ID,必填。 + * + * Returns: + * - 若成功,返回({"message": "success", "code": 200}, 200) + * - 若失败,返回({"message": 错误信息, "code": 400}, 400) + * + * Raises: + * 无直接抛出异常,所有异常均被捕获并返回错误信息。 + * 设置租户的AI能力配置,需要登录和超级管理员权限 + * @param requestBody AI工具配置数据 + * @returns any 设置成功 + * @throws ApiError + */ + public static postWorkspacesAiToolSet( + requestBody: { + /** + * AI工具配置数据列表 + */ + data: Array>; + /** + * 租户ID + */ + tenant_id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/ai-tool/set', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看所有的用户。 + * + * Returns: + * dict: 包含分页用户列表的响应数据 + * 查看所有的用户,支持分页和搜索,需要登录 + * @param page 页码,从 1 开始 + * @param limit 每页数量 + * @param searchName 名称搜索 + * @param searchPhone 电话搜索 + * @param searchEmail 邮箱搜索 + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesAllMembers( + page: number = 1, + limit: number = 20, + searchName?: string, + searchPhone?: string, + searchEmail?: string, + ): CancelablePromise<{ + /** + * 账户列表 + */ + data?: Array<{ + /** + * 头像 + */ + avatar?: string; + /** + * 创建时间 + */ + created_at?: number; + /** + * 邮箱 + */ + email?: string; + /** + * 账户ID + */ + id?: string; + /** + * 最后活跃时间 + */ + last_active_at?: number; + /** + * 最后登录时间 + */ + last_login_at?: number; + /** + * 账户名称 + */ + name?: string; + /** + * 电话 + */ + phone?: string; + /** + * 角色 + */ + role?: string; + /** + * 状态 + */ + status?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 每页数量 + */ + limit?: number; + /** + * 当前页码 + */ + page?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/all/members', + query: { + 'page': page, + 'limit': limit, + 'search_name': searchName, + 'search_phone': searchPhone, + 'search_email': searchEmail, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看所有的租户。 + * + * Returns: + * dict: 包含分页租户列表的响应数据 + * 查看所有的租户,支持分页和搜索,需要登录 + * @param page 页码,从 1 开始 + * @param limit 每页数量 + * @param searchName 名称搜索 + * @param searchUser 用户搜索 + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesAllTenants( + page: number = 1, + limit: number = 20, + searchName?: string, + searchUser?: string, + ): CancelablePromise<{ + /** + * 租户列表 + */ + data?: Array<{ + /** + * 创建时间 + */ + created_at?: number; + /** + * 是否为当前租户 + */ + current?: boolean; + /** + * 是否启用AI + */ + enable_ai?: boolean; + /** + * GPU配额 + */ + gpu_quota?: number; + /** + * 已使用GPU + */ + gpu_used?: number; + /** + * 是否有资产 + */ + has_assets?: boolean; + /** + * 租户ID + */ + id?: string; + /** + * 租户名称 + */ + name?: string; + /** + * 角色 + */ + role?: string; + /** + * 状态 + */ + status?: string; + /** + * 存储配额 + */ + storage_quota?: number; + /** + * 已使用存储 + */ + storage_used?: number; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 每页数量 + */ + limit?: number; + /** + * 当前页码 + */ + page?: number; + /** + * 总记录数 + */ + total?: number; + /** + * 用户ID + */ + user_id?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/all/tenants', + query: { + 'page': page, + 'limit': limit, + 'search_name': searchName, + 'search_user': searchUser, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 关闭协作 + * 关闭指定目标的协作功能,需要登录和写入权限 + * @param requestBody 关闭参数 + * @returns any 操作成功 + * @throws ApiError + */ + public static postWorkspacesCoopClose( + requestBody: { + /** + * 目标ID + */ + target_id: string; + /** + * 目标类型 + */ + target_type: 'app' | 'dataset' | 'knowledge_base' | 'doc'; + }, + ): CancelablePromise<{ + /** + * 账户列表 + */ + accounts?: Array; + /** + * 创建者 + */ + created_by?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * 目标ID + */ + target_id?: string; + /** + * 目标类型 + */ + target_type?: string; + /** + * 租户ID + */ + tenant_id?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/coop/close', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看自己被加入协作的列表 + * 查看自己被加入协作的列表,需要登录 + * @param targetType 目标类型 + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesCoopJoins( + targetType: 'app' | 'dataset' | 'knowledge_base' | 'doc', + ): CancelablePromise<{ + /** + * ID列表 + */ + data?: Array; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/coop/joins', + query: { + 'target_type': targetType, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 打开协作 + * 打开指定目标的协作功能,需要登录和写入权限 + * @param requestBody 协作参数 + * @returns any 操作成功 + * @throws ApiError + */ + public static postWorkspacesCoopOpen( + requestBody: { + /** + * 账户ID列表 + */ + accounts: Array; + /** + * 目标ID + */ + target_id: string; + /** + * 目标类型 + */ + target_type: 'app' | 'dataset' | 'knowledge_base' | 'doc'; + }, + ): CancelablePromise<{ + /** + * 账户列表 + */ + accounts?: Array; + /** + * 创建者 + */ + created_by?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * 目标ID + */ + target_id?: string; + /** + * 目标类型 + */ + target_type?: string; + /** + * 租户ID + */ + tenant_id?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/coop/open', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询协作的设置详情 + * 查询协作的设置详情,需要登录 + * @param targetType 目标类型 + * @param targetId 目标ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesCoopStatus( + targetType: 'app' | 'dataset' | 'knowledge_base' | 'doc', + targetId: string, + ): CancelablePromise<{ + /** + * 账户列表 + */ + accounts?: Array; + /** + * 创建者 + */ + created_by?: string; + /** + * 是否启用 + */ + enable?: boolean; + /** + * 目标ID + */ + target_id?: string; + /** + * 目标类型 + */ + target_type?: string; + /** + * 租户ID + */ + tenant_id?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/coop/status', + query: { + 'target_type': targetType, + 'target_id': targetId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看当前用户加入的租户。 + * + * Returns: + * dict: 当前用户加入的租户列表 + * 查看当前用户加入的租户,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesCurrentList(): CancelablePromise<{ + /** + * 租户列表 + */ + tenants?: Array<{ + /** + * 创建时间 + */ + created_at?: number; + /** + * 是否为当前租户 + */ + current?: boolean; + /** + * 是否启用AI + */ + enable_ai?: boolean; + /** + * GPU配额 + */ + gpu_quota?: number; + /** + * 已使用GPU + */ + gpu_used?: number; + /** + * 是否有资产 + */ + has_assets?: boolean; + /** + * 租户ID + */ + id?: string; + /** + * 租户名称 + */ + name?: string; + /** + * 角色 + */ + role?: string; + /** + * 状态 + */ + status?: string; + /** + * 存储配额 + */ + storage_quota?: number; + /** + * 已使用存储 + */ + storage_used?: number; + }>; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/current/list', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看当前租户。 + * + * Returns: + * dict: 当前租户ID + * 查看当前租户ID,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesCurrentTenant(): CancelablePromise<{ + /** + * 当前租户ID + */ + tenant_id?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/current/tenant', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除租户 + * 删除指定的租户,需要登录和超级管理员或创建者权限 + * @param requestBody 删除参数 + * @returns any 删除成功 + * @throws ApiError + */ + public static postWorkspacesDelete( + requestBody: { + /** + * 租户ID + */ + tenant_id: string; + }, + ): CancelablePromise<{ + result?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/delete', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 删除账户 + * 删除指定的账户,需要登录和超级管理员权限 + * @param requestBody 账户ID + * @returns any 删除成功 + * @throws ApiError + */ + public static postWorkspacesDeleteAccount( + requestBody: { + /** + * 账户ID + */ + account_id: string; + }, + ): CancelablePromise<{ + result?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/delete-account', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 从租户中删除用户 + * 从租户中删除用户,需要登录和管理员权限 + * @param requestBody 删除参数 + * @returns any 删除成功 + * @throws ApiError + */ + public static postWorkspacesDeleteRole( + requestBody: { + /** + * 账户ID + */ + account_id: string; + /** + * 租户ID + */ + tenant_id: string; + }, + ): CancelablePromise<{ + result?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/delete-role', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看租户用户详细。 + * + * Returns: + * dict: 租户详细信息和用户列表 + * 查看租户详细信息和用户列表,需要登录和写入权限 + * @param tenantId 租户ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesDetail( + tenantId: string, + ): CancelablePromise<{ + /** + * 账户列表 + */ + accounts?: Array>; + /** + * 创建时间 + */ + created_at?: number; + /** + * 是否为当前租户 + */ + current?: boolean; + /** + * 是否启用AI + */ + enable_ai?: boolean; + /** + * GPU配额 + */ + gpu_quota?: number; + /** + * 已使用GPU + */ + gpu_used?: number; + /** + * 是否有资产 + */ + has_assets?: boolean; + /** + * 租户ID + */ + id?: string; + /** + * 租户名称 + */ + name?: string; + /** + * 角色 + */ + role?: string; + /** + * 状态 + */ + status?: string; + /** + * 存储配额 + */ + storage_quota?: number; + /** + * 已使用存储 + */ + storage_used?: number; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/detail', + query: { + 'tenant_id': tenantId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 退出租户 + * 退出指定的租户,超管和创建者不能退出,需要登录 + * @param requestBody 退出参数 + * @returns any 退出成功 + * @throws ApiError + */ + public static postWorkspacesExit( + requestBody: { + /** + * 租户ID + */ + tenant_id: string; + }, + ): CancelablePromise<{ + result?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/exit', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 迁移资产 + * 在租户内迁移用户资产,需要登录和超级管理员权限 + * @param requestBody 迁移参数 + * @returns any 迁移成功 + * @throws ApiError + */ + public static postWorkspacesMoveAssets( + requestBody: { + /** + * 源账户ID + */ + source_account_id: string; + /** + * 目标账户ID + */ + target_account_id: string; + /** + * 租户ID + */ + tenant_id: string; + }, + ): CancelablePromise<{ + result?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/move-assets', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取个人空间资源配置信息 + * 获取个人空间资源配置信息,需要登录 + * @param accountId 账户ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesPersonalSpaceResources( + accountId: string, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/personal-space/resources', + query: { + 'account_id': accountId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 修改个人空间GPU配额 + * 修改个人空间GPU配额,需要登录和超级管理员权限 + * @param requestBody 个人空间数据 + * @returns any 修改成功 + * @throws ApiError + */ + public static postWorkspacesPersonalSpaceResources( + requestBody: { + /** + * GPU配额 + */ + gpu_quota: number; + /** + * 存储配额(GB) + */ + storage_quota: number; + /** + * 租户ID + */ + tenant_id: string; + }, + ): CancelablePromise<{ + result?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/personal-space/resources', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 获取配额申请详情 + * 获取配额申请详情,需要登录和超级管理员权限 + * @param requestId 申请ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesQuotaRequestsDetails( + requestId: string, + ): CancelablePromise<{ + /** + * 账户ID + */ + account_id?: string; + /** + * 账户名称 + */ + account_name?: string; + /** + * 批准数量 + */ + approved_amount?: number; + /** + * 创建时间 + */ + created_at?: string; + /** + * 申请ID + */ + id?: string; + /** + * 处理时间 + */ + processed_at?: string; + /** + * 申请原因 + */ + reason?: string; + /** + * 拒绝原因 + */ + reject_reason?: string; + /** + * 申请类型 + */ + request_type?: string; + /** + * 申请数量 + */ + requested_amount?: number; + /** + * 状态 + */ + status?: string; + /** + * 租户ID + */ + tenant_id?: string; + /** + * 租户名称 + */ + tenant_name?: string; + /** + * 更新时间 + */ + updated_at?: string; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/quota-requests/details', + query: { + 'request_id': requestId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + 404: `资源不存在`, + }, + }); + } + /** + * 获取配额申请列表 + * 获取工作空间配额申请列表,需要登录和超级管理员权限 + * @param requestBody 查询参数 + * @returns any 获取成功 + * @throws ApiError + */ + public static postWorkspacesQuotaRequestsList( + requestBody?: { + /** + * 账户名称 + */ + account_name?: string; + /** + * 页码,从 1 开始 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 申请类型 + */ + request_type?: 'storage' | 'gpu'; + /** + * 状态 + */ + status?: 'pending' | 'approved' | 'rejected'; + /** + * 租户名称 + */ + tenant_name?: string; + }, + ): CancelablePromise<{ + /** + * 配额申请列表 + */ + data?: Array<{ + /** + * 账户ID + */ + account_id?: string; + /** + * 账户名称 + */ + account_name?: string; + /** + * 批准数量 + */ + approved_amount?: number; + /** + * 创建时间 + */ + created_at?: string; + /** + * 申请ID + */ + id?: string; + /** + * 处理时间 + */ + processed_at?: string; + /** + * 申请原因 + */ + reason?: string; + /** + * 拒绝原因 + */ + reject_reason?: string; + /** + * 申请类型 + */ + request_type?: string; + /** + * 申请数量 + */ + requested_amount?: number; + /** + * 状态 + */ + status?: string; + /** + * 租户ID + */ + tenant_id?: string; + /** + * 租户名称 + */ + tenant_name?: string; + /** + * 更新时间 + */ + updated_at?: string; + }>; + /** + * 是否有下一页 + */ + has_next?: boolean; + /** + * 是否有上一页 + */ + has_prev?: boolean; + /** + * 当前页码 + */ + page?: number; + /** + * 每页数量 + */ + page_size?: number; + /** + * 总页数 + */ + pages?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/quota-requests/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 处理配额申请 + * 管理员处理配额申请(批准或拒绝),需要登录和超级管理员权限 + * @param requestBody 处理参数 + * @returns any 处理成功 + * @throws ApiError + */ + public static postWorkspacesQuotaRequestsProcess( + requestBody: { + /** + * 操作类型:approve 或 reject + */ + action: 'approve' | 'reject'; + /** + * 批准数量(仅当 action 为 approve 时必需) + */ + amount?: number; + /** + * 拒绝原因(仅当 action 为 reject 时必需) + */ + reason?: string; + /** + * 申请ID + */ + request_id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/quota-requests/process', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 提交配额申请 + * 提交配额申请(存储或GPU),需要登录和管理员权限 + * @param requestBody 申请数据 + * @returns any 提交成功 + * @throws ApiError + */ + public static postWorkspacesQuotaRequestsRequests( + requestBody: { + /** + * 申请数量 + */ + amount: number; + /** + * 申请原因 + */ + reason: string; + /** + * 租户ID + */ + tenant_id: string; + /** + * 申请类型:storage 或 gpu + */ + type: 'storage' | 'gpu'; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/quota-requests/requests', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看所有的用户(仅在选择用户列表中使用)。 + * + * Returns: + * dict: 包含分页用户列表的响应数据 + * 查看所有的用户(仅在选择用户列表中使用),支持分页和搜索,需要登录 + * @param page 页码,从 1 开始 + * @param limit 每页数量 + * @param searchName 名称搜索 + * @param searchPhone 电话搜索 + * @param searchEmail 邮箱搜索 + * @param tenantId 租户ID + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesSelectMembers( + page: number = 1, + limit: number = 20, + searchName?: string, + searchPhone?: string, + searchEmail?: string, + tenantId?: string, + ): CancelablePromise<{ + /** + * 账户列表 + */ + data?: Array<{ + /** + * 头像 + */ + avatar?: string; + /** + * 创建时间 + */ + created_at?: number; + /** + * 邮箱 + */ + email?: string; + /** + * 账户ID + */ + id?: string; + /** + * 最后活跃时间 + */ + last_active_at?: number; + /** + * 最后登录时间 + */ + last_login_at?: number; + /** + * 账户名称 + */ + name?: string; + /** + * 电话 + */ + phone?: string; + /** + * 角色 + */ + role?: string; + /** + * 状态 + */ + status?: string; + }>; + /** + * 是否有更多数据 + */ + has_more?: boolean; + /** + * 每页数量 + */ + limit?: number; + /** + * 当前页码 + */ + page?: number; + /** + * 总记录数 + */ + total?: number; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/select/members', + query: { + 'page': page, + 'limit': limit, + 'search_name': searchName, + 'search_phone': searchPhone, + 'search_email': searchEmail, + 'tenant_id': tenantId, + }, + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查看当前工作组的存储空间使用情况 + * 查看当前工作组的存储空间使用情况,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesStorageCheck(): CancelablePromise<{ + /** + * 是否有可用空间 + */ + data?: boolean; + }> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/storage/check', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 切换租户。 + * + * Returns: + * dict: 切换成功的响应消息 + * 切换当前用户的租户,需要登录 + * @param requestBody 切换参数 + * @returns any 切换成功 + * @throws ApiError + */ + public static postWorkspacesSwitch( + requestBody: { + /** + * 租户ID + */ + tenant_id: string; + }, + ): CancelablePromise<{ + result?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/switch', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 设置是否开启租户的AI能力。 + * + * Args: + * 无直接参数。请求体中应包含以下JSON字段: + * enable (bool): 是否开启,必填。 + * tenant_id (str): 租户ID,必填。 + * + * Returns: + * - 若成功,返回({"message": "success", "code": 200, "data": 数据}, 200) + * 设置是否开启租户的AI能力,需要登录和超级管理员权限 + * @param requestBody 启用参数 + * @returns any 设置成功 + * @throws ApiError + */ + public static postWorkspacesTenantEnableAi( + requestBody: { + /** + * 是否启用AI + */ + enable: boolean; + /** + * 租户ID + */ + tenant_id: string; + }, + ): CancelablePromise<{ + code?: number; + message?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/tenant/enable_ai', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 查询当前租户下全部用户列表 + * 查询当前租户下全部用户列表,需要登录 + * @returns any 获取成功 + * @throws ApiError + */ + public static getWorkspacesTenantUserList(): CancelablePromise>> { + return __request(OpenAPI, { + method: 'GET', + url: '/workspaces/tenant/user_list', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + /** + * 修改租户内的用户身份 + * "data_list": [ + * { + * "account_id": "87079ad4-5bce-4f28-972c-644084d939e7", + * "name": "名字", + * "role": "owner" + * }, + * ] + * 修改租户内的用户身份和配额,需要登录和管理员权限 + * @param requestBody 角色数据 + * @returns any 更新成功 + * @throws ApiError + */ + public static postWorkspacesUpdateRoles( + requestBody: { + /** + * 用户角色列表 + */ + data_list?: Array<{ + account_id?: string; + name?: string; + role?: string; + }>; + /** + * GPU配额 + */ + gpu_quota?: number; + /** + * 存储配额(GB) + */ + storage_quota: number; + /** + * 租户ID + */ + tenant_id: string; + /** + * 租户名称 + */ + tenant_name?: string; + }, + ): CancelablePromise<{ + result?: string; + }> { + return __request(OpenAPI, { + method: 'POST', + url: '/workspaces/update-roles', + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `参数错误`, + 401: `未授权`, + 403: `无权限`, + }, + }); + } + } diff --git a/front/infrastructure/api/knowledgeBase.ts b/front/infrastructure/api/knowledgeBase.ts deleted file mode 100644 index 7cc1844..0000000 --- a/front/infrastructure/api/knowledgeBase.ts +++ /dev/null @@ -1,44 +0,0 @@ -import type { Fetcher } from 'swr' -import { get, post } from './base' -import type { - - BaseResponse, - -} from '@/core/data/common' - -export const getScriptList: Fetcher = ({ url, options }) => - get(url, options) - -export const getKnowledgeBaseList: Fetcher = ({ url, body }) => - post(url, { body }) - -export const createKnowledgeBase: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const updateKnowledgeBase: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const deleteKnowledgeBase: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const getFileList: Fetcher = ({ url, options }) => - get(url, options) - -export const addFile: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const deleteFile: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const getFilePathById: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const handleFile: Fetcher = ({ url, body }) => { - return post(url, { body }) -} diff --git a/front/infrastructure/api/modelTest.ts b/front/infrastructure/api/modelTest.ts deleted file mode 100644 index d417fa0..0000000 --- a/front/infrastructure/api/modelTest.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { Fetcher } from 'swr' -import { get, post } from './base' -import type { - - BaseResponse, - -} from '@/core/data/common' - -export const deleteTest: Fetcher = ({ url }) => { - return post(url) -} - -export const saveChoose: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const getResultInfo: Fetcher = ({ url, options }) => - get(url, options) - -export const getAdjustInfo: Fetcher = ({ url }) => - get(url) - -export const getTestList: Fetcher = ({ url, options }) => - get(url, options) diff --git a/front/infrastructure/api/modelWarehouse.ts b/front/infrastructure/api/modelWarehouse.ts index 61d7928..a828ee9 100644 --- a/front/infrastructure/api/modelWarehouse.ts +++ b/front/infrastructure/api/modelWarehouse.ts @@ -14,14 +14,6 @@ export const uploadMerge: Fetcher(url, { body }) } -export const checkName: Fetcher = ({ url, body }) => { - return post any }>(url, { body }) -} - -export const deleteModel: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - export const editModel: Fetcher = ({ url, body }) => { return post(url, { body }) } diff --git a/front/infrastructure/api/prompt.ts b/front/infrastructure/api/prompt.ts deleted file mode 100644 index 2194dc4..0000000 --- a/front/infrastructure/api/prompt.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Fetcher } from 'swr' -import { get, post } from './base' -import type { BaseResponse, PromptAIResponse } from '@/core/data/common' - -export const getValidateStatu: Fetcher = ({ url }) => - get(url) - -export const getPromptDetail: Fetcher = ({ url }) => - get(url) - -export const createCodeAI = ({ url, body }: { url: string; body: Record }, otherOptions?: any) => { - return post(url, { body }, { customTimeout: 1000 * 60 * 5, ...otherOptions }) as Promise -} - -// ai提示词 -export const createPromptAI: Fetcher }> = ({ body }) => { - return post('/apps/workflows/prompt_assistant', { body }, { customTimeout: 1000 * 60 * 5 }) as Promise -} - -export const deletePrompt: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const createPrompt: Fetcher }> = ({ url, body }) => { - return post(url, { body }, { customTimeout: 1000 * 60 * 5 }) as Promise -} - -export const getAdjustList: Fetcher = ({ url, body }) => { - return post(url, { body }) -} - -export const getPromptList: Fetcher = ({ url, options }) => - get(url, options) diff --git a/front/openapi.yaml b/front/openapi.yaml new file mode 100644 index 0000000..52185d6 --- /dev/null +++ b/front/openapi.yaml @@ -0,0 +1,18577 @@ +openapi: 3.0.0 +info: + contact: + name: LazyLLM Team + description: LazyCraft 平台 API 文档 + title: LazyCraft API + version: 1.0.0 +paths: + /account/add_user: + post: + description: 管理员创建新用户账号,不需要短信验证码 + requestBody: + content: + application/json: + schema: + properties: + confirm_password: + description: 确认密码 + type: string + email: + description: 邮箱(可选) + format: email + type: string + name: + description: 用户名 + type: string + password: + description: 密码 + type: string + phone: + description: 手机号(可选) + type: string + required: + - name + - password + - confirm_password + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 管理员添加用户。 + + 允许管理员创建新用户账号,不需要短信验证码。 + 只有具有管理员权限的用户才能调用此接口。 + + Returns: + dict: 包含创建成功结果和用户ID的字典 + + Raises: + ValueError: 当非管理员调用或输入信息无效时抛出 + tags: + - auth + /account/password: + post: + description: 修改当前用户的登录密码 + requestBody: + content: + application/json: + schema: + properties: + new_password: + description: 新密码 + type: string + password: + description: 当前密码(可选) + type: string + repeat_new_password: + description: 确认新密码 + type: string + required: + - new_password + - repeat_new_password + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 修改用户密码。 + + 允许用户修改自己的登录密码,需要提供当前密码进行验证。 + 修改成功后记录密码变更日志。 + + Returns: + dict: 密码修改成功的结果字典 + + Raises: + ValueError: 当新密码确认不一致或当前密码验证失败时抛出 + tags: + - auth + /account/profile: + get: + description: 获取当前登录用户的详细信息和租户信息 + responses: + "200": + description: 成功 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取当前用户资料信息。 + + 返回当前登录用户的详细信息以及当前租户信息和权限角色。 + 包括用户基本信息、租户状态、用户在租户中的角色等。 + + Returns: + dict: 包含用户信息和租户信息的字典 + tags: + - auth + /account/update: + post: + description: 更新当前用户的基本信息(姓名、邮箱、手机号) + requestBody: + $ref: "#/components/requestBodies/Body5" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 更新用户基本信息。 + + 允许用户修改姓名、邮箱、手机号等基本信息。 + 会验证信息格式和唯一性约束,修改成功后记录更新日志。 + + Returns: + dict: 用户信息更新成功的结果字典 + + Raises: + ValueError: 当输入格式无效或违反唯一性约束时抛出 + tags: + - auth + /account/validate_exist: + post: + description: 验证用户名、手机号或邮箱是否已被使用 + requestBody: + $ref: "#/components/requestBodies/Body5" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 校验用户信息唯一性。 + + 验证用户名、手机号或邮箱是否已被其他用户使用。 + 用于注册前的重复性检查。 + + Returns: + dict: 包含验证结果的字典,success表示可用,failed表示已存在 + + Note: + 即使验证失败也不会抛出异常,而是返回包含错误信息的字典 + tags: + - auth + /apikey: + delete: + description: 删除指定的 API Key + requestBody: + content: + application/json: + schema: + properties: + id: + description: API Key ID + type: integer + required: + - id + type: object + required: true + responses: + "200": + description: 成功 + "204": + description: 成功删除 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除指定的API Key。 + + Args: + id (int, required): 要删除的API Key的ID + + Returns: + dict: 删除操作的结果 + + Raises: + CommonError: 当API Key不存在或不属于当前用户时抛出 + tags: + - API Key + get: + description: 获取当前用户的所有 API Key 列表 + responses: + "200": + description: 成功 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取当前用户的所有API Key列表。 + + Returns: + dict: 包含API Key详细信息的字典,使用apikey_detail_fields格式化 + + Raises: + CommonError: 当查询失败时抛出 + tags: + - API Key + post: + description: 创建新的 API Key + requestBody: + content: + application/json: + schema: + properties: + description: + description: API Key 描述 + type: string + expire_date: + description: 过期日期,格式:YYYY-MM-DD + format: date + type: string + tenant_id: + description: 空间ID,多个空间ID用逗号分隔 + type: string + required: + - tenant_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新的API Key。 + + Args: + description (str, optional): API Key的描述信息 + expire_date (str, optional): 过期时间,格式为YYYY-MM-DD + tenant_id (str, required): 空间ID,多个空间ID用逗号分隔 + + Returns: + dict: 新创建的API Key详细信息 + + Raises: + CommonError: 当参数验证失败或创建失败时抛出 + tags: + - API Key + put: + description: 更新 API Key 的状态(active, disabled, deleted, expired) + requestBody: + content: + application/json: + schema: + properties: + id: + description: API Key ID + type: integer + status: + description: 状态:active, disabled, deleted, expired + enum: + - active + - disabled + - deleted + - expired + type: string + required: + - id + - status + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 更新API Key的状态。 + + Args: + id (int, required): 要更新的API Key的ID + status (str, required): 新的状态,可选值:active, disabled, deleted, expired + + Returns: + dict: 更新后的API Key详细信息 + + Raises: + CommonError: 当API Key不存在、不属于当前用户或状态转换不允许时抛出 + tags: + - API Key + "/apikey/chat/{app_id}": + post: + description: 使用 API Key 与指定应用进行对话 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + files: + description: 文件列表,可为空 + items: + type: string + type: array + inputs: + description: 输入内容列表 + items: + type: string + minItems: 1 + type: array + mode: + default: publish + description: 运行模式,默认为 publish + type: string + required: + - inputs + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 使用API Key与指定应用进行对话。 + + Args: + app_id (str): 应用ID + inputs (list, required): 输入内容列表 + mode (str, optional): 运行模式,默认为"publish" + files (list, optional): 文件列表,可为空 + + Returns: + dict: 对话结果数据 + + Raises: + CommonError: 当API Key验证失败、应用不存在或服务未开启时抛出 + tags: + - API Key + /app/report: + post: + description: 获取应用的使用报告 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + end_date: + description: 结束日期 + format: date + type: string + start_date: + description: 开始日期 + format: date + type: string + required: + - app_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 接收引擎报告回调数据。 + + Args: + id (str, required): 节点ID + sessionid (str, required): 会话ID + timecost (float, optional): 耗时 + prompt_tokens (int, optional): 提示词token数 + completion_tokens (int, optional): 完成token数 + input (str, optional): 输入内容 + output (str, optional): 输出内容 + + Returns: + None: 无返回值 + + Raises: + Exception: 当数据处理失败时抛出 + tags: + - 应用商店 + /apps: + get: + description: 根据查询参数获取应用的分页列表,支持按名称、标签、发布状态等条件筛选 + parameters: + - description: 页码,从 1 开始 + in: query + name: page + required: false + schema: + type: integer + minimum: 1 + maximum: 99999 + default: 1 + - description: 每页数量 + in: query + name: limit + required: false + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + - description: 搜索应用名称 + in: query + name: search_name + required: false + schema: + type: string + - description: 搜索标签名称 + in: query + name: search_tags + required: false + schema: + type: string + - description: 查询类型:mine/group/builtin/already + in: query + name: qtype + required: false + schema: + type: string + enum: + - mine + - group + - builtin + - already + default: mine + - description: 是否已发布 + in: query + name: is_published + required: false + schema: + type: boolean + responses: + "200": + description: 成功 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: >- + 获取应用列表。 + + + 根据查询参数获取应用的分页列表,支持按名称、标签、发布状态等条件筛选。 + + + Args: + page (int, optional): 页码,范围1-99999,默认为1。 + limit (int, optional): 每页数量,范围1-100,默认为20。 + search_name (str, optional): 搜索应用名称,支持模糊匹配。 + search_tags (str, optional): 搜索标签名称。 + qtype (str, optional): 查询类型,可选值:mine(我的)/group(团队)/builtin(内置)/already(全部),默认为mine。 + is_published (bool, optional): 是否已发布的过滤条件。 + + Returns: + dict: 包含应用列表的分页数据,包含data、total、page、limit字段。 + + Raises: + ValueError: 当参数验证失败时抛出。 + tags: + - 应用商店 + post: + description: 创建空白的应用 + requestBody: + $ref: "#/components/requestBodies/Body7" + responses: + "200": + description: 成功 + "201": + description: 成功创建应用 + content: + "*/*": + schema: + properties: + categories: + description: 应用分类 + items: + type: string + type: array + created_at: + description: 创建时间 + format: date-time + type: string + created_by: + description: 创建者ID + type: string + description: + description: 应用描述 + type: string + enable_api: + description: 是否启用API + type: boolean + enable_api_call: + description: API调用开关 + type: string + enable_backflow: + description: 是否启用回流 + type: boolean + enable_site: + description: 是否启用站点 + type: boolean + engine_status: + description: 引擎状态 + type: string + icon: + description: 应用图标 + type: string + icon_background: + description: 图标背景色 + type: string + id: + description: 应用ID + type: string + mode: + description: 模式 + type: string + model_config: + description: 模型配置 + type: object + name: + description: 应用名称 + type: string + publish_status: + description: 发布状态 + type: string + ref_status: + description: 引用状态 + type: boolean + status: + description: 状态 + type: string + tags: + description: 标签列表 + items: + type: string + type: array + tracing: + description: 追踪配置 + type: object + updated_at: + description: 更新时间 + format: date-time + type: string + workflow_id: + description: 工作流ID + type: string + workflow_updated_at: + description: 工作流更新时间 + format: date-time + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建空白的应用。 + + 根据传入的参数创建一个新的空白应用,并记录操作日志。 + + Args: + name (str): 应用名称,必填。 + description (str, optional): 应用描述。 + icon (str, optional): 应用图标URL。 + icon_background (str, optional): 图标背景色。 + categories (list, optional): 应用分类列表。 + + Returns: + tuple: 包含新创建的应用实例和状态码201的元组。 + + Raises: + ValueError: 当应用名称重复或创建失败时抛出。 + tags: + - 应用商店 + /apps/import: + post: + description: 从文件导入应用 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 应用文件 + type: string + format: binary + required: + - file + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 从文件导入应用。 + + Args: + file (FileStorage, required): 上传的应用配置文件 + + Returns: + dict: 新创建的应用信息 + + Raises: + ValueError: 当文件格式错误或创建失败时抛出 + tags: + - 应用商店 + /apps/list/page: + post: + description: 使用POST方式获取应用的分页列表,支持更复杂的查询参数 + requestBody: + content: + application/json: + schema: + properties: + enable_api: + description: 是否启用API + type: boolean + is_published: + description: 是否已发布 + type: boolean + limit: + default: 20 + description: 每页数量 + maximum: 100 + minimum: 1 + type: integer + page: + default: 1 + description: 页码 + maximum: 99999 + minimum: 1 + type: integer + qtype: + default: mine + description: 查询类型:mine/group/builtin/already + enum: + - mine + - group + - builtin + - already + type: string + search_name: + description: 搜索应用名称 + type: string + search_tags: + description: 搜索标签列表 + items: + type: string + type: array + type: object + required: true + responses: + "200": + description: 成功 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取应用列表(分页版本)。 + + 使用POST方式获取应用的分页列表,支持更复杂的查询参数。 + + Args: + page (int, optional): 页码,范围1-99999,默认为1。 + limit (int, optional): 每页数量,范围1-100,默认为20。 + search_name (str, optional): 搜索应用名称,支持模糊匹配。 + search_tags (list, optional): 搜索标签列表。 + qtype (str, optional): 查询类型,可选值:mine/group/builtin/already,默认为mine。 + is_published (bool, optional): 是否已发布的过滤条件。 + enable_api (bool, optional): 是否启用API的过滤条件。 + + Returns: + dict: 包含应用列表的分页数据,使用app_pagination_fields格式。 + + Raises: + ValueError: 当参数验证失败时抛出。 + tags: + - 应用商店 + /apps/to/apptemplate: + post: + description: 将应用转换为模板 + requestBody: + $ref: "#/components/requestBodies/Body" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 将应用转换为模板。 + + Args: + id (str, required): 应用ID + name (str, optional): 模板名称 + description (str, optional): 模板描述 + icon (str, optional): 模板图标 + icon_background (str, optional): 图标背景色 + categories (list, optional): 模板分类 + + Returns: + dict: 转换操作结果 + + Raises: + ValueError: 当应用未发布或名称重复时抛出 + tags: + - 应用商店 + /apps/workflows/add_log: + post: + description: 添加工作流执行日志 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + log: + description: 日志内容 + type: string + node_id: + description: 节点ID + type: string + required: + - app_id + - node_id + - log + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 添加(删除)资源(节点)时上报的日志 + tags: + - 应用商店 + /apps/workflows/batch_log: + post: + description: 批量添加工作流执行日志 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + logs: + description: 日志列表 + items: + properties: + log: + type: string + node_id: + type: string + type: object + type: array + required: + - app_id + - logs + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 批量调试时上报的结果日志 + tags: + - 应用商店 + /apps/workflows/code_assistant: + post: + description: 使用AI代码助手生成代码 + requestBody: + content: + application/json: + schema: + properties: + code: + description: 现有代码 + type: string + language: + description: 编程语言 + type: string + prompt: + description: 提示词 + type: string + required: + - prompt + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 该函数用于处理AI代码助手的POST请求 + + Args: + 无直接参数。请求体中应包含以下JSON字段: + query (str): 用户输入的查询内容,必填。 + session (str, optional): 会话ID,用于多轮对话,选填。 + + Returns: + - 若成功,返回{"message": 结果, "session": session}, 200 + - 若失败,返回{"message": 错误信息, "session": session}, 400 + + Raises: + 无直接抛出异常,所有异常均被捕获并返回错误信息。 + tags: + - 应用商店 + /apps/workflows/drag_app: + post: + description: 从应用创建新的工作流 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + target_app_id: + description: 目标应用ID + format: uuid + type: string + required: + - app_id + - target_app_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 拖拽app创建新的流程 + tags: + - 应用商店 + /apps/workflows/drag_empty: + post: + description: 从空白创建新的工作流 + requestBody: + $ref: "#/components/requestBodies/Body" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 创建空白workflow + tags: + - 应用商店 + /apps/workflows/drag_template: + post: + description: 从模板创建新的工作流 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + template_id: + description: 模板ID + format: uuid + type: string + required: + - app_id + - template_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 拖拽template创建新的流程 + tags: + - 应用商店 + /apps/workflows/prompt_assistant: + post: + description: 使用AI提示词助手优化提示词 + requestBody: + content: + application/json: + schema: + properties: + prompt: + description: 原始提示词 + type: string + session: + description: 会话ID + type: string + required: + - prompt + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 处理AI提示语助手的POST请求。 + + 该函数用于处理AI提示语助手的POST请求,根据用户输入生成大模型提示语。 + 首先通过意图识别过滤用户请求,然后使用配置的模型生成相应的提示语。 + + Args: + 无直接参数。请求体中应包含以下JSON字段: + query (str): 用户输入的查询内容,必填。 + session (str, optional): 会话ID,用于多轮对话,选填。 + + Returns: + - 若成功,返回{"message": 结果, "session": session}, 200 + - 若失败,返回{"message": 错误信息, "session": session}, 400 + + Raises: + 无直接抛出异常,所有异常均被捕获并返回错误信息。 + tags: + - 应用商店 + "/apps/{app_id}": + delete: + description: 删除指定的应用 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "204": + description: 成功删除 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 删除应用。 + + Args: + app_id (str): 应用ID + + Returns: + dict: 删除操作结果 + + Raises: + ValueError: 当应用不存在、被引用或权限不足时抛出 + tags: + - 应用商店 + get: + description: 根据应用ID获取应用详细信息 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取应用详情。 + + Args: + app_id (str): 应用ID + + Returns: + dict: 应用详细信息 + + Raises: + ValueError: 当应用不存在时抛出 + tags: + - 应用商店 + put: + description: 更新应用的基本信息 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + $ref: "#/components/requestBodies/Body7" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 更新应用信息。 + + Args: + app_id (str): 应用ID + name (str, optional): 应用名称 + description (str, optional): 应用描述 + icon (str, optional): 应用图标 + icon_background (str, optional): 图标背景色 + categories (list, optional): 应用分类 + + Returns: + dict: 更新后的应用信息 + + Raises: + ValueError: 当应用不存在或名称重复时抛出 + tags: + - 应用商店 + "/apps/{app_id}/enable_api": + post: + description: 启用或禁用应用的API服务,返回SSE流式响应 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + properties: + enable_api: + description: 是否启用API服务 + type: boolean + required: + - enable_api + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 启用或禁用应用服务。 + + Args: + app_id (str): 应用ID + enable_api (bool, required): 是否启用API服务 + + Returns: + Response: SSE流式响应,包含启动或停止服务的状态 + + Raises: + ValueError: 当应用未发布、工作流不存在或GPU配额不足时抛出 + tags: + - 应用商店 + "/apps/{app_id}/enable_api_call": + post: + description: 启用或禁用应用的API调用功能 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + properties: + enable_api_call: + description: API调用开关:0或1 + type: string + required: + - enable_api_call + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 启用或禁用API调用功能。 + + Args: + app_id (str): 应用ID + enable_api_call (str, required): 是否启用API调用,值为'0'或'1' + + Returns: + dict: 操作结果消息 + + Raises: + ValueError: 当应用未启动或参数错误时抛出 + tags: + - 应用商店 + "/apps/{app_id}/enable_backflow": + post: + description: 启用或禁用应用的数据回流功能 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + properties: + enable_backflow: + description: 是否启用回流功能 + type: boolean + required: + - enable_backflow + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 启用或禁用数据回流功能。 + + Args: + app_id (str): 应用ID + enable_backflow (bool, required): 是否启用回流功能 + + Returns: + dict: 更新后的应用信息 + + Raises: + ValueError: 当应用不存在或权限不足时抛出 + tags: + - 应用商店 + "/apps/{app_id}/export": + get: + description: 导出应用为文件 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 导出应用配置。 + + Args: + app_id (str): 应用ID + format (str, optional): 导出格式,默认为文件下载 + version (str, optional): 版本,默认为draft + + Returns: + Response: JSON数据或文件下载响应 + + Raises: + ValueError: 当应用不存在时抛出 + tags: + - 应用商店 + "/apps/{app_id}/reference-result": + get: + description: 获取应用的引用结果 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 获取引用结果 + tags: + - 应用商店 + "/apps/{app_id}/versions": + get: + description: 获取应用的版本列表 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 获取应用版本 + tags: + - 应用商店 + "/apps/{app_id}/versions/check-count": + get: + description: 检查应用的版本数量 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 检查版本数量 + tags: + - 应用商店 + "/apps/{app_id}/versions/restore": + post: + description: 恢复到指定的应用版本 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + properties: + version_id: + description: 版本ID + type: string + required: + - version_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 恢复应用版本 + tags: + - 应用商店 + "/apps/{app_id}/workflows/cancel_publish": + post: + description: 取消已发布的工作流 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: cancel publish workflow + tags: + - 应用商店 + "/apps/{app_id}/workflows/doc_node/{doc_id}/parse": + post: + description: 解析文档节点 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 文档ID + in: path + name: doc_id + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: Document节点数据解析 + tags: + - 应用商店 + "/apps/{app_id}/workflows/doc_node/{doc_id}/parse/status": + post: + description: 获取文档解析状态 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 文档ID + in: path + name: doc_id + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 查询Document节点数据解析状态 + tags: + - 应用商店 + "/apps/{app_id}/workflows/draft": + get: + description: 获取应用的草稿工作流 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取草稿工作流。 + + Args: + app_id (str): 应用ID + + Returns: + dict: 草稿工作流信息 + + Raises: + DraftWorkflowNotExist: 当草稿工作流不存在时抛出 + tags: + - 应用商店 + post: + description: 同步草稿工作流的配置 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + properties: + graph: + description: 工作流图配置 + type: object + hash: + description: 工作流哈希值 + type: string + required: + - graph + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 同步草稿工作流。 + + Args: + app_id (str): 应用ID + graph (dict, required): 工作流图配置 + hash (str, optional): 工作流哈希值 + + Returns: + dict: 同步结果 + + Raises: + DraftWorkflowNotSync: 当工作流不同步时抛出 + tags: + - 应用商店 + "/apps/{app_id}/workflows/draft/import": + post: + description: 从文件导入草稿工作流 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 工作流文件 + type: string + format: binary + required: + - file + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 从文件导入工作流到草稿。 + + Args: + app_id (str): 应用ID + file (FileStorage, required): 上传的工作流配置文件 + + Returns: + dict: 导入操作结果 + + Raises: + ValueError: 当文件格式错误或应用不存在时抛出 + tags: + - 应用商店 + "/apps/{app_id}/workflows/draft/nodes/{node_id}/run/stream": + post: + description: 运行指定节点的流式响应 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 节点ID + in: path + name: node_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + inputs: + description: 输入内容列表 + items: + type: string + type: array + required: + - inputs + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 运行单节点调试(流式输出) + tags: + - 应用商店 + "/apps/{app_id}/workflows/draft/reset_session": + post: + description: 重置草稿工作流的会话 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 重置调试会话 + tags: + - 应用商店 + "/apps/{app_id}/workflows/draft/run": + post: + description: 运行草稿工作流进行预览 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + $ref: "#/components/requestBodies/Body3" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 运行草稿调试 + tags: + - 应用商店 + "/apps/{app_id}/workflows/draft/start": + post: + description: 开始草稿调试,返回SSE流式响应 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 开始草稿调试 + tags: + - 应用商店 + "/apps/{app_id}/workflows/draft/status": + get: + description: 查询草稿调试的状态 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 查询草稿调试的状态 + tags: + - 应用商店 + "/apps/{app_id}/workflows/draft/stop": + post: + description: 停止草稿调试 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 结束草稿调试 + tags: + - 应用商店 + "/apps/{app_id}/workflows/publish": + get: + description: 获取已发布的工作流 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: Get published workflow + tags: + - 应用商店 + post: + description: 发布草稿工作流为正式版本 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + content: + application/json: + schema: + properties: + description: + description: 版本描述 + type: string + version: + description: 版本号 + type: string + required: + - version + - description + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: Publish workflow + tags: + - 应用商店 + "/apps/{app_id}/workflows/{mode}/debug-detail": + get: + description: 获取应用的调试详情 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 工作流模式:draft(草稿)或 publish(发布) + in: path + name: mode + required: true + schema: + type: string + enum: + - draft + - publish + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: >- + 获取调试详情信息。 + + + Args: + app_id (str): 应用ID + mode (str, optional): 模式,默认为draft + conversation_type (str, optional): 对话类型,"single"表示单轮对话,"multi"表示多轮对话,默认为"single" + + Returns: + dict: 调试详情数据 + + Raises: + Exception: 当获取数据失败时抛出 + tags: + - 应用商店 + "/apps/{app_id}/workflows/{mode}/debug-detail/history": + delete: + description: 删除指定的调试历史记录 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 工作流模式:draft(草稿)或 publish(发布) + in: path + name: mode + required: true + schema: + type: string + enum: + - draft + - publish + requestBody: + content: + application/json: + schema: + properties: + history_id: + description: 历史记录ID + type: string + required: + - history_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 删除历史逐步调试信息。 + + Args: + app_id (str): 应用ID + mode (str, optional): 模式,默认为draft + + Returns: + dict: 删除操作结果 + + Raises: + Exception: 当删除失败时抛出 + tags: + - 应用商店 + get: + description: 获取调试历史记录 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 工作流模式:draft(草稿)或 publish(发布) + in: path + name: mode + required: true + schema: + type: string + enum: + - draft + - publish + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取历史逐步调试信息。 + + Args: + app_id (str): 应用ID + mode (str, optional): 模式,默认为draft + limit (int, optional): 限制返回的turn_number组数量 + + Returns: + dict: 历史调试信息 + + Raises: + Exception: 当获取历史数据失败时抛出 + tags: + - 应用商店 + "/apps/{app_id}/workflows/{mode}/debug-detail/stream": + get: + description: 获取调试详情的SSE流式响应 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 工作流模式:draft(草稿)或 publish(发布) + in: path + name: mode + required: true + schema: + type: string + enum: + - draft + - publish + requestBody: + $ref: "#/components/requestBodies/Body3" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: >- + 实时SSE推送逐步调试信息。 + + + Args: + app_id (str): 应用ID + mode (str, optional): 模式,默认为draft + conversation_type (str, optional): 对话类型,"single"表示单轮对话,"multi"表示多轮对话,默认为"single" + + Returns: + Response: SSE流式响应 + + Raises: + Exception: 当流式推送失败时抛出 + tags: + - 应用商店 + "/apps/{app_id}/workflows/{mode}/debug-detail/stream/status": + get: + description: 获取调试流的运行状态 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 工作流模式:draft(草稿)或 publish(发布) + in: path + name: mode + required: true + schema: + type: string + enum: + - draft + - publish + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取SSE流连接状态。 + + Args: + app_id (str): 应用ID + mode (str, optional): 模式,默认为draft + + Returns: + dict: 连接状态信息 + + Raises: + Exception: 当获取状态失败时抛出 + tags: + - 应用商店 + "/apps/{app_id}/workflows/{mode}/debug-detail/stream/stop": + post: + description: 停止调试的流式响应 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + - description: 工作流模式:draft(草稿)或 publish(发布) + in: path + name: mode + required: true + schema: + type: string + enum: + - draft + - publish + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 远程停止SSE流。 + + Args: + app_id (str): 应用ID + mode (str, optional): 模式,默认为draft + connection_id (str, optional, in body): 连接ID;提供则精准停止该连接,否则全局停止 + + Returns: + dict: 停止操作结果 + + Raises: + Exception: 当停止失败时抛出 + tags: + - 应用商店 + /apptemplate: + get: + description: 获取应用模板列表 + parameters: + - description: 页码,从 1 开始 + in: query + name: page + required: false + schema: + type: integer + minimum: 1 + maximum: 99999 + default: 1 + - description: 每页数量 + in: query + name: limit + required: false + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + - description: 搜索应用名称 + in: query + name: search_name + required: false + schema: + type: string + - description: 搜索标签名称 + in: query + name: search_tags + required: false + schema: + type: string + - description: 查询类型:mine/group/builtin/already + in: query + name: qtype + required: false + schema: + type: string + enum: + - mine + - group + - builtin + - already + default: mine + - description: 是否已发布 + in: query + name: is_published + required: false + schema: + type: boolean + responses: + "200": + description: 成功 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取模板列表。 + + Args: + page (int, optional): 页码,默认为1 + limit (int, optional): 每页数量,默认为20 + search_name (str, optional): 搜索模板名称 + search_tags (str, optional): 搜索标签 + qtype (str, optional): 查询类型,默认为mine + + Returns: + dict: 包含模板列表的分页数据 + + Raises: + ValueError: 当参数验证失败时抛出 + tags: + - 应用商店 + /apptemplate/to/apps: + post: + description: 将模板转换为应用 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 模板ID + format: uuid + type: string + required: + - app_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 将模板转换为应用。 + + Args: + id (str, required): 模板ID + name (str, optional): 应用名称 + description (str, optional): 应用描述 + icon (str, optional): 应用图标 + icon_background (str, optional): 图标背景色 + categories (list, optional): 应用分类 + + Returns: + App: 新创建的应用实例 + + Raises: + ValueError: 当模板不存在或名称重复时抛出 + tags: + - 应用商店 + "/apptemplate/{app_id}": + delete: + description: 删除指定的模板 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "204": + description: 成功删除 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 删除模板。 + + Args: + app_id (str): 模板ID + + Returns: + dict: 删除操作结果 + + Raises: + ValueError: 当模板不存在或权限不足时抛出 + tags: + - 应用商店 + get: + description: 根据模板ID获取模板详细信息 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取模板详情。 + + Args: + app_id (str): 模板ID + + Returns: + dict: 模板详细信息 + + Raises: + ValueError: 当模板不存在时抛出 + tags: + - 应用商店 + put: + description: 更新模板的基本信息 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + requestBody: + $ref: "#/components/requestBodies/Body7" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 更新模板信息。 + + Args: + app_id (str): 模板ID + name (str, optional): 模板名称 + description (str, optional): 模板描述 + icon (str, optional): 模板图标 + icon_background (str, optional): 图标背景色 + categories (list, optional): 模板分类 + + Returns: + dict: 更新后的模板信息 + + Raises: + ValueError: 当模板不存在或名称重复时抛出 + tags: + - 应用商店 + /brands: + get: + description: 根据产商类型查询产商列表 + parameters: + - description: 产商类型,必填 + in: query + name: type + required: true + schema: + type: string + enum: + - llm + - embedding + - reranker + responses: + "200": + description: 成功 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 查询产商 + tags: + - 标签管理 + /brands/create: + post: + description: 创建一个新的产商标签,只有超级用户可以执行此操作 + requestBody: + $ref: "#/components/requestBodies/Body8" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 创建产商标签 + tags: + - 标签管理 + /brands/delete: + post: + description: 删除指定的产商标签 + requestBody: + $ref: "#/components/requestBodies/Body8" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 删除产商 + tags: + - 标签管理 + "/conversation/{app_id}/feedback": + post: + description: 对对话结果进行用户反馈 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + - description: "认证令牌,格式: Bearer 或直接 " + in: header + name: Authorization + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + is_satisfied: + description: 是否满意 + type: boolean + sessionid: + description: 会话ID + type: string + speak_id: + description: 对话消息ID + type: integer + user_feedback: + description: 用户反馈内容 + type: string + required: + - sessionid + - speak_id + - is_satisfied + - user_feedback + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 对对话的结果进行反馈。 + + Args: + app_id (str): 应用ID + sessionid (str, required): 会话ID + speak_id (int, required): 对话消息ID + is_satisfied (bool, required): 是否满意 + user_feedback (str, required): 用户反馈内容 + + Returns: + dict: 反馈结果 + + Raises: + Exception: 当反馈处理失败时抛出 + tags: + - conversation + "/conversation/{app_id}/history": + get: + description: 获取指定会话的历史对话记录 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + - description: 会话ID + in: query + name: sessionid + required: true + schema: + type: string + - description: 起始消息ID,用于分页 + in: query + name: start_id + required: false + schema: + type: integer + - description: "认证令牌,格式: Bearer 或直接 " + in: header + name: Authorization + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 获取某个会话的历史记录。 + + Args: + app_id (str): 应用ID + sessionid (str, required): 会话ID + start_id (int, optional): 起始消息ID + + Returns: + dict: 包含历史记录的字典 + + Raises: + Exception: 当获取历史记录失败时抛出 + tags: + - conversation + "/conversation/{app_id}/init": + get: + description: 初始化用户身份并获取认证令牌,用于后续对话接口的认证 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + - description: 临时令牌(可选) + in: header + name: TempToken + required: false + schema: + type: string + - description: 认证令牌(可选) + in: query + name: _token + required: false + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 换取用户信息。 + + Args: + app_id (str): 应用ID + + Returns: + dict: 包含认证令牌的字典 + + Raises: + Exception: 当初始化失败时抛出 + tags: + - conversation + "/conversation/{app_id}/run": + post: + description: 向应用发送消息并获取流式响应(SSE格式) + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + - description: "认证令牌,格式: Bearer 或直接 " + in: header + name: Authorization + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + files: + description: 文件列表(可选) + items: + type: string + type: array + inputs: + description: 输入内容列表 + items: + type: string + type: array + mode: + default: publish + description: 运行模式,publish为发布模式,draft为草稿模式 + enum: + - publish + - draft + type: string + sessionid: + description: 会话ID + type: string + required: + - sessionid + - inputs + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 跟app对话。 + + Args: + app_id (str): 应用ID + sessionid (str, required): 会话ID + inputs (list, required): 输入内容列表 + files (list, optional): 文件列表 + mode (str, optional): 运行模式,默认为publish + + Returns: + Response: SSE流式响应 + + Raises: + ValueError: 当应用服务关闭时抛出 + tags: + - conversation + "/conversation/{app_id}/sessions": + get: + description: 获取当前用户的所有对话会话列表 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + - description: "认证令牌,格式: Bearer 或直接 " + in: header + name: Authorization + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 获取会话列表。 + + Args: + app_id (str): 应用ID + + Returns: + dict: 包含会话列表的字典 + + Raises: + Exception: 当获取会话列表失败时抛出 + tags: + - conversation + /costaudit/app_statistics: + post: + description: 获取指定app_id的统计指标,优先从redis缓存读取 + requestBody: + $ref: "#/components/requestBodies/Body" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取指定app_id的统计指标,优先从redis缓存读取。 + + Args: + 通过JSON请求体传递参数: + app_id (str): 应用的唯一标识符。 + + Returns: + dict: 包含统计指标的字典,包括累计token消费、用户数、会话数、互动数等。 + + Example: + 请求示例: + POST /costaudit/app_statistics + Content-Type: application/json + { + "app_id": "123e4567-e89b-12d3-a456-426614174000" + } + tags: + - cost_audit + "/costaudit/apps/{app_id}": + get: + description: 查询指定应用的成本审计信息,包括调试和发布模式的调用次数和Token使用数 + parameters: + - description: 应用ID + in: path + name: app_id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 查询应用的成本审计信息。 + + Args: + app_id (str): 应用的唯一标识符。 + + Returns: + dict: 包含应用成本审计信息的字典,包括调试和发布模式的调用次数和Token使用数。 + tags: + - cost_audit + /costaudit/cache_app_statistics_for_periods: + post: + description: 遍历所有app_id,统计近7天、近30天的数据并缓存到redis + requestBody: + content: + application/json: + schema: + properties: + stat_date: + description: 统计基准日期,格式为YYYY-MM-DD。如果不提供,则使用今天作为基准日期 + format: date + type: string + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: >- + 遍历所有app_id,统计近7天、近30天的数据并缓存到redis。 + + + Args: + 通过JSON请求体传递参数: + stat_date (str, optional): 统计基准日期,格式为"YYYY-MM-DD"。如果不提供,则使用今天作为基准日期。 + + Returns: + dict: 包含操作结果的字典。 + + Example: + 请求示例: + POST /costaudit/cache_app_statistics_for_periods + Content-Type: application/json + { + "stat_date": "2025-06-07" + } + tags: + - cost_audit + /costaudit/calc_and_save_app_statistics: + post: + description: 统计指定app_id下的各类指标,并存入AppStatistics表 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + call_type: + default: release + description: 调用类型 + enum: + - debug + - release + type: string + need_save_db: + default: false + description: 是否需要保存到数据库 + type: boolean + stat_date: + description: 统计日期,格式为YYYY-MM-DD + format: date + type: string + stat_date_end: + description: 统计结束日期,格式为YYYY-MM-DD + format: date + type: string + stat_date_start: + description: 统计开始日期,格式为YYYY-MM-DD + format: date + type: string + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 统计指定app_id下的各类指标,并存入AppStatistics表。 + + Args: + 通过JSON请求体传递参数: + app_id (str): 应用的唯一标识符。 + call_type (str, optional): 调用类型,默认为"release"。 + stat_date (str, optional): 统计日期,格式为"YYYY-MM-DD"。 + stat_date_start (str, optional): 统计开始日期,格式为"YYYY-MM-DD"。 + stat_date_end (str, optional): 统计结束日期,格式为"YYYY-MM-DD"。 + need_save_db (bool, optional): 是否需要保存到数据库,默认为False。 + + Returns: + dict: 包含统计结果的字典。 + + Example: + 请求示例: + POST /costaudit/calc_and_save_app_statistics + Content-Type: application/json + { + "app_id": "123e4567-e89b-12d3-a456-426614174000", + "call_type": "release", + "stat_date": "2025-06-01", + "stat_date_start": "2025-06-01", + "stat_date_end": "2025-06-07", + "need_save_db": true + } + tags: + - cost_audit + /costaudit/daily_app_statistics: + post: + description: 遍历所有app_id,统计指定日期的数据并存入AppStatistics表 + requestBody: + content: + application/json: + schema: + properties: + stat_date: + description: 统计日期,格式为YYYY-MM-DD。如果不提供,则统计昨天的数据 + format: date + type: string + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 遍历所有app_id,统计指定日期的数据并存入AppStatistics表。 + + Args: + 通过JSON请求体传递参数: + stat_date (str, optional): 统计日期,格式为"YYYY-MM-DD"。如果不提供,则统计昨天的数据。 + + Returns: + dict: 包含操作结果的字典。 + + Example: + 请求示例: + POST /costaudit/daily_app_statistics + Content-Type: application/json + { + "stat_date": "2025-06-01" + } + tags: + - cost_audit + /costaudit/get_app_statistics_by_period: + post: + description: 获取指定app_id和时间区间的统计数据,优先从redis获取,未命中则实时统计 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + end_date: + description: 结束日期,格式为YYYY-MM-DD + format: date + type: string + start_date: + description: 起始日期,格式为YYYY-MM-DD + format: date + type: string + required: + - app_id + - start_date + - end_date + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取指定app_id和时间区间的统计数据,优先从redis获取,未命中则实时统计。 + + Args: + 通过JSON请求体传递参数: + app_id (str): 应用的唯一标识符。 + start_date (str): 起始日期,格式为"YYYY-MM-DD"。 + end_date (str): 结束日期,格式为"YYYY-MM-DD"。 + + Returns: + dict: 包含统计数据的字典。 + + Example: + 请求示例: + POST /costaudit/get_app_statistics_by_period + Content-Type: application/json + { + "app_id": "123e4567-e89b-12d3-a456-426614174000", + "start_date": "2025-06-01", + "end_date": "2025-06-07" + } + tags: + - cost_audit + /costaudit/query_app_statistics: + post: + description: 查询AppStatistics表,支持按app_id、时间区间、call_type过滤 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + call_type: + description: 调用类型,用于过滤数据 + enum: + - debug + - release + type: string + end_date: + description: 结束日期,格式为YYYY-MM-DD + format: date + type: string + start_date: + description: 起始日期,格式为YYYY-MM-DD + format: date + type: string + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查询AppStatistics表,支持按app_id、时间区间、call_type过滤。 + + Args: + 通过JSON请求体传递参数: + app_id (str): 应用的唯一标识符。 + start_date (str, optional): 起始日期,格式为"YYYY-MM-DD"。 + end_date (str, optional): 结束日期,格式为"YYYY-MM-DD"。 + call_type (str, optional): 调用类型,用于过滤数据。 + + Returns: + dict: 包含查询结果的字典。 + + Example: + 请求示例: + POST /costaudit/query_app_statistics + Content-Type: application/json + { + "app_id": "123e4567-e89b-12d3-a456-426614174000", + "start_date": "2025-06-01", + "end_date": "2025-06-07", + "call_type": "release" + } + tags: + - cost_audit + /costaudit/query_conversations: + post: + description: 查询Conversation表,支持按app_id、时间区间、from_who过滤 + requestBody: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID(可选) + format: uuid + type: string + end_time: + description: 结束时间,格式为YYYY-MM-DD HH:MM:SS + format: date-time + type: string + from_who: + description: 用户ID,用于过滤特定用户的对话 + type: string + start_time: + description: 起始时间,格式为YYYY-MM-DD HH:MM:SS + format: date-time + type: string + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查询Conversation表,支持按app_id、时间区间、from_who过滤。 + + Args: + 通过JSON请求体传递参数: + app_id (str, optional): 应用的唯一标识符。 + start_time (str, optional): 起始时间,格式为"YYYY-MM-DD HH:MM:SS"。 + end_time (str, optional): 结束时间,格式为"YYYY-MM-DD HH:MM:SS"。 + from_who (str, optional): 用户ID,用于过滤特定用户的对话。 + + Returns: + dict: 包含查询结果的字典。 + + Example: + 请求示例: + POST /costaudit/query_conversations + Content-Type: application/json + { + "app_id": "123e4567-e89b-12d3-a456-426614174000", + "start_time": "2025-06-01 00:00:00", + "end_time": "2025-06-07 23:59:59", + "from_who": "user-001" + } + tags: + - cost_audit + /costaudit/stats: + get: + description: 查询费用统计数据,支持按租户统计。如果有租户ID,查询该租户下所有用户的费用统计数据,否则查询当前用户的费用统计数据 + parameters: + - description: 租户ID,如果提供则查询该租户下所有用户的费用统计数据 + in: query + name: tenant_id + required: false + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: >- + 查询费用统计数据。 + + + Args: + tenant_id (str, optional): 组织的唯一标识符。如果有组织ID,查询当前组织下所有用户的费用统计数据,否则查询当前用户的费用统计数据。 + + Returns: + dict: 包含费用统计数据的字典,包括各类别的统计信息和总计数据。 + tags: + - cost_audit + /data: + get: + description: 获取指定数据集的详细信息 + parameters: + - description: 数据集ID + in: query + name: data_set_id + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取指定数据集的详细信息。 + + Args: + 通过URL参数传递: + data_set_id (str): 数据集ID。 + + Returns: + dict: 数据集的详细信息。 + + Raises: + ValueError: 当数据集不存在时抛出异常。 + tags: + - 数据集 + /data/create_date_set: + post: + description: 创建新的数据集,支持本地上传或URL上传 + requestBody: + content: + application/json: + schema: + properties: + data_format: + description: 数据格式 + type: string + data_type: + description: 数据类型(doc或pic) + enum: + - doc + - pic + type: string + description: + description: 数据集描述 + type: string + file_paths: + description: 本地文件路径列表(upload_type为local时必填) + items: + type: string + type: array + file_urls: + description: 文件URL列表(upload_type为url时必填) + items: + type: string + type: array + from_type: + description: 来源类型 + type: string + name: + description: 数据集名称 + type: string + upload_type: + description: 上传类型(local或url) + enum: + - local + - url + type: string + required: + - name + - data_type + - upload_type + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新数据集。 + + Args: + 通过JSON请求体传递参数: + name (str): 数据集名称。 + description (str, optional): 数据集描述。 + data_type (str): 数据类型(doc或pic)。 + upload_type (str): 上传类型(local或url)。 + file_paths (list, optional): 本地文件路径列表。 + file_urls (list, optional): 文件URL列表。 + data_format (str, optional): 数据格式。 + from_type (str, optional): 来源类型。 + + Returns: + dict: 创建的数据集信息。 + + Raises: + ValueError: 当必要参数缺失或文件上传失败时抛出异常。 + tags: + - 数据集 + /data/delete: + post: + description: 删除指定的数据集 + requestBody: + content: + application/json: + schema: + properties: + data_set_id: + description: 数据集ID + type: string + required: + - data_set_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除指定的数据集。 + + Args: + 通过JSON请求体传递参数: + data_set_id (str): 数据集ID。 + + Returns: + dict: 删除结果信息。 + + Raises: + ValueError: 当数据集ID为空或数据集正在被使用时抛出异常。 + tags: + - 数据集 + /data/file: + post: + description: 获取JSON文件内容并返回给前端,支持分页读取 + requestBody: + content: + application/json: + schema: + properties: + data_set_file_id: + description: 数据集文件ID + type: string + end: + description: 结束行号 + type: integer + start: + description: 起始行号 + type: integer + required: + - data_set_file_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取JSON文件内容并返回给前端。 + + Args: + 通过JSON请求体传递参数: + data_set_file_id (str): 数据集文件ID。 + start (int, optional): 起始行号。 + end (int, optional): 结束行号。 + + Returns: + dict: 包含文件内容的响应。 + + Raises: + ValueError: 当数据集文件ID为空时抛出异常。 + tags: + - 数据集 + /data/file/delete: + post: + description: 删除指定的数据集文件 + requestBody: + content: + application/json: + schema: + properties: + data_set_file_ids: + description: 数据集文件ID列表 + items: + type: integer + type: array + required: + - data_set_file_ids + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除指定的数据集文件。 + + Args: + 通过JSON请求体传递参数: + data_set_file_ids (list): 数据集文件ID列表。 + + Returns: + dict: 删除结果信息。 + + Raises: + ValueError: 当文件ID列表为空或数据集版本正在被使用时抛出异常。 + tags: + - 数据集 + /data/file/list: + get: + description: 获取指定数据集版本下的文件分页列表 + parameters: + - description: 页码,从1开始 + in: query + name: page + required: false + schema: + type: integer + minimum: 1 + default: 1 + - description: 每页大小 + in: query + name: page_size + required: false + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + - description: 数据集版本ID + in: query + name: data_set_version_id + required: false + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取数据集版本下的文件分页列表。 + + Args: + 通过URL参数传递: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + data_set_version_id (str): 数据集版本ID。 + + Returns: + dict: 分页结果,包含数据集文件列表和分页信息。 + tags: + - 数据集 + /data/file/update: + post: + description: 修改数据集文件内容 + requestBody: + content: + application/json: + schema: + properties: + content: + description: 新的文件内容 + type: string + data_set_file_id: + description: 数据集文件ID + type: string + data_set_file_name: + description: 新的文件名 + type: string + end: + description: 结束行号 + type: integer + start: + description: 起始行号 + type: integer + required: + - data_set_file_id + - content + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 修改数据集文件内容。 + + Args: + 通过JSON请求体传递参数: + data_set_file_id (str): 数据集文件ID。 + content (str): 新的文件内容。 + data_set_file_name (str, optional): 新的文件名。 + start (int, optional): 起始行号。 + end (int, optional): 结束行号。 + + Returns: + dict: 更新结果信息,包含新的总行数。 + + Raises: + ValueError: 当必要参数缺失时抛出异常。 + tags: + - 数据集 + /data/list: + post: + description: 获取数据集分页列表,支持按名称、数据类型、标签等条件筛选 + requestBody: + content: + application/json: + schema: + properties: + data_type: + description: 数据类型列表 + items: + enum: + - doc + - pic + type: string + type: array + name: + description: 数据集名称 + type: string + page: + default: 1 + description: 页码,从1开始 + minimum: 1 + type: integer + page_size: + default: 20 + description: 每页大小 + maximum: 100 + minimum: 1 + type: integer + qtype: + default: already + description: 查询类型 + type: string + search_name: + description: 搜索名称 + type: string + search_tags: + description: 搜索标签列表 + items: + type: string + type: array + user_id: + description: 用户ID列表 + items: + type: string + type: array + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取数据集分页列表。 + + Args: + 通过JSON请求体传递参数: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + name (str, optional): 数据集名称。 + data_type (list, optional): 数据类型列表。 + qtype (str, optional): 查询类型,默认为"already"。 + search_tags (list, optional): 搜索标签列表。 + search_name (str, optional): 搜索名称。 + user_id (list, optional): 用户ID列表。 + + Returns: + dict: 分页结果,包含数据集列表和分页信息。 + tags: + - 数据集 + "/data/processing/task/{task_id}/cancel": + post: + description: 取消指定的数据处理任务 + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 取消指定的数据处理任务。 + + Args: + task_id (str): 任务ID。 + + Returns: + dict: 取消结果信息。 + + Raises: + Exception: 当任务不存在或无法取消时抛出异常。 + tags: + - 数据集 + "/data/processing/task/{task_id}/progress": + get: + description: 获取指定数据处理任务的进度信息 + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取指定数据处理任务的进度信息。 + + Args: + task_id (str): 任务ID。 + + Returns: + dict: 任务进度信息。 + + Raises: + Exception: 当任务不存在时抛出异常。 + tags: + - 数据集 + "/data/processing/task/{task_id}/stream": + get: + description: 通过SSE实时推送任务进度 + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 通过SSE实时推送任务进度。 + + Args: + task_id (str): 任务ID。 + + Returns: + Response: SSE流式响应,实时推送任务进度。 + + Raises: + Exception: 当任务不存在时抛出异常。 + tags: + - 数据集 + /data/processing/tasks: + get: + description: 获取所有数据处理任务的列表 + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取所有数据处理任务列表。 + + Returns: + dict: 包含所有任务列表的响应信息。 + tags: + - 数据集 + /data/reflux/app/publish: + post: + description: 处理应用发布时的数据回流 + requestBody: + content: + application/json: + schema: + properties: + app_msg: + description: 应用消息数据 + type: object + node_msgs: + description: 节点消息数据列表 + items: + type: object + type: array + required: + - app_msg + - node_msgs + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 发布应用回流数据。 + + Args: + 通过JSON请求体传递参数: + app_msg (dict): 应用消息数据。 + node_msgs (list): 节点消息数据列表。 + + Returns: + tuple: (响应数据, HTTP状态码) + + Raises: + ValueError: 当缺少必要参数时抛出异常。 + tags: + - 数据集 + /data/reflux/create: + post: + description: 创建回流数据 + requestBody: + content: + application/json: + schema: + properties: + data: + description: 回流数据 + type: object + required: + - data + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建回流数据。 + + Args: + 通过JSON请求体传递参数: + data (dict): 回流数据。 + + Returns: + tuple: (响应数据, HTTP状态码) + tags: + - 数据集 + /data/reflux/delete: + post: + description: 删除指定的回流数据 + requestBody: + content: + application/json: + schema: + properties: + reflux_data_ids: + description: 要删除的回流数据ID列表 + items: + type: integer + type: array + required: + - reflux_data_ids + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除回流数据。 + + Args: + 通过JSON请求体传递参数: + reflux_data_ids (list): 要删除的回流数据ID列表。 + + Returns: + tuple: (响应数据, HTTP状态码) + + Raises: + ValueError: 当回流数据ID列表为空时抛出异常。 + tags: + - 数据集 + /data/reflux/detail: + get: + description: 获取回流数据的详细信息 + parameters: + - description: 回流数据ID + in: query + name: reflux_data_id + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取回流数据详情。 + + Args: + 通过查询参数传递: + reflux_data_id (str): 回流数据ID。 + + Returns: + dict: 回流数据详情,包含内容和ID。 + + Raises: + ValueError: 当回流数据ID为空时抛出异常。 + tags: + - 数据集 + /data/reflux/feedback/update: + post: + description: 更新回流数据的反馈信息 + requestBody: + content: + application/json: + schema: + properties: + data: + description: 反馈数据 + type: object + required: + - data + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: [] + summary: |- + 更新回流数据反馈。 + + Args: + 通过JSON请求体传递参数: + data (dict): 反馈数据。 + + Returns: + tuple: (响应数据, HTTP状态码) + tags: + - 数据集 + /data/reflux/list: + get: + description: 获取回流数据分页列表 + parameters: + - description: 页码,从1开始 + in: query + name: page + required: false + schema: + type: integer + minimum: 1 + default: 1 + - description: 每页大小 + in: query + name: page_size + required: false + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + - description: 数据集版本ID + in: query + name: data_set_version_id + required: false + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取回流数据分页列表。 + + Args: + 通过查询参数传递: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + data_set_version_id (str, optional): 数据集版本ID。 + + Returns: + dict: 分页结果,包含回流数据列表和分页信息。 + tags: + - 数据集 + /data/reflux/update: + post: + description: 修改回流数据内容 + requestBody: + content: + application/json: + schema: + properties: + content: + description: 更新内容 + type: string + reflux_data_id: + description: 回流数据ID + type: string + required: + - reflux_data_id + - content + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 修改回流数据。 + + Args: + 通过JSON请求体传递参数: + reflux_data_id (str): 回流数据ID。 + content (str): 更新内容。 + + Returns: + tuple: (响应数据, HTTP状态码) + + Raises: + ValueError: 当回流数据ID或内容为空时抛出异常。 + tags: + - 数据集 + /data/reflux/version/export: + post: + description: 导出数据集版本,返回压缩文件 + requestBody: + $ref: "#/components/requestBodies/Body9" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 导出数据集版本。 + + Args: + 通过JSON请求体传递参数: + data_set_version_ids (list): 数据集版本ID列表。 + + Returns: + Response: 文件下载响应。 + + Raises: + ValueError: 当数据集版本ID列表为空时抛出异常。 + Exception: 当导出失败时抛出异常。 + tags: + - 数据集 + /data/reflux/version/export/ft: + get: + description: 导出数据集版本文件,用于微调 + parameters: + - description: 数据集文件名 + in: query + name: filename + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: [] + summary: |- + 导出数据集版本(用于微调)。 + + Args: + 通过查询参数传递: + filename (str): 数据集文件名。 + + Returns: + Response: 文件下载响应。 + + Raises: + ValueError: 当文件名为空或文件不存在时抛出异常。 + Exception: 当导出失败时抛出异常。 + tags: + - 数据集 + /data/reflux/version/publish: + post: + description: 发布数据集版本回流数据 + requestBody: + $ref: "#/components/requestBodies/Body10" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 发布数据集版本回流数据。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + + Returns: + dict: 数据集版本信息。 + + Raises: + ValueError: 当数据集版本ID为空时抛出异常。 + tags: + - 数据集 + /data/tag/list: + get: + description: 获取数据集的标签版本列表 + parameters: + - description: 数据集ID + in: query + name: data_set_id + required: false + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取数据集的标签版本列表。 + + Args: + 通过URL参数传递: + data_set_id (str): 数据集ID。 + + Returns: + dict: 包含数据集标签列表的响应。 + tags: + - 数据集 + /data/upload: + post: + description: 上传数据集文件,支持图片和文档类型,支持压缩包 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 上传的文件 + type: string + format: binary + file_type: + description: 文件类型(pic或doc) + type: string + enum: + - doc + - pic + required: + - file + - file_type + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 上传数据集文件。 + + Args: + 通过multipart/form-data传递参数: + file: 上传的文件。 + file_type (str): 文件类型(pic或doc)。 + + Returns: + dict: 上传结果信息,包含文件路径。 + + Raises: + ValueError: 当文件类型不支持、文件大小超限或压缩包内容不符合要求时抛出异常。 + tags: + - 数据集 + /data/version: + get: + description: 获取指定数据集版本的详细信息 + parameters: + - description: 数据集版本ID + in: query + name: data_set_version_id + required: true + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取指定数据集版本的详细信息。 + + Args: + 通过URL参数传递: + data_set_version_id (str): 数据集版本ID。 + + Returns: + dict: 数据集版本的详细信息。 + + Raises: + ValueError: 当数据集版本不存在时抛出异常。 + tags: + - 数据集 + /data/version/add/file: + post: + description: 向数据集版本添加新文件 + requestBody: + content: + application/json: + schema: + properties: + data_set_version_id: + description: 数据集版本ID + type: string + file_paths: + description: 本地文件路径列表 + items: + type: string + type: array + file_urls: + description: 文件URL列表 + items: + type: string + type: array + name: + description: 版本名称 + type: string + version: + description: 版本号 + type: string + required: + - data_set_version_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 向数据集版本添加新文件。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + name (str, optional): 版本名称。 + version (str, optional): 版本号。 + file_paths (list, optional): 本地文件路径列表。 + file_urls (list, optional): 文件URL列表。 + + Returns: + dict: 添加结果信息。 + + Raises: + ValueError: 当数据集版本ID为空时抛出异常。 + tags: + - 数据集 + /data/version/clean_or_augment: + post: + description: 对数据集版本进行数据清洗或增强处理 + requestBody: + $ref: "#/components/requestBodies/Body11" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 对数据集版本进行数据清洗或增强处理。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + data_set_script_id (str): 数据集脚本ID。 + script_agent (str, optional): 脚本代理类型,默认为"script"。 + script_type (str, optional): 脚本类型。 + data_set_version_name (str, optional): 数据集版本名称。 + + Returns: + dict: 处理后的数据集版本信息。 + + Raises: + ValueError: 当必要参数缺失或数据集版本不存在时抛出异常。 + Exception: 当处理过程中发生错误时抛出异常。 + tags: + - 数据集 + /data/version/clean_or_augment_async: + post: + description: 异步启动数据集版本的数据清洗或增强处理 + requestBody: + $ref: "#/components/requestBodies/Body11" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 异步启动数据集版本的数据清洗或增强处理。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + data_set_script_id (str): 数据集脚本ID。 + script_agent (str, optional): 脚本代理类型,默认为"script"。 + script_type (str, optional): 脚本类型。 + data_set_version_name (str, optional): 数据集版本名称。 + + Returns: + dict: 包含任务ID的响应信息。 + + Raises: + ValueError: 当必要参数缺失时抛出异常。 + Exception: 当任务启动失败时抛出异常。 + tags: + - 数据集 + /data/version/clean_or_augment_async_with_item_count: + post: + description: 异步启动数据集版本的数据清洗或增强处理,并统计数据条数 + requestBody: + $ref: "#/components/requestBodies/Body11" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 异步启动数据集版本的数据清洗或增强处理(基于数据条数统计)。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + data_set_script_id (str): 数据集脚本ID。 + script_agent (str, optional): 脚本代理类型,默认为"script"。 + script_type (str, optional): 脚本类型。 + data_set_version_name (str, optional): 数据集版本名称。 + + Returns: + dict: 包含任务ID的响应信息。 + + Raises: + ValueError: 当必要参数缺失时抛出异常。 + Exception: 当任务启动失败时抛出异常。 + tags: + - 数据集 + /data/version/create_by_tag: + post: + description: 基于标签版本创建新的分支版本 + requestBody: + content: + application/json: + schema: + properties: + data_set_version_id: + description: 数据集版本ID + type: string + name: + description: 新版本名称 + type: string + required: + - data_set_version_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 根据标签创建数据集版本。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + name (str, optional): 新版本名称。 + + Returns: + dict: 创建的数据集版本信息。 + + Raises: + ValueError: 当数据集版本ID为空时抛出异常。 + tags: + - 数据集 + /data/version/delete: + post: + description: 删除指定的数据集版本 + requestBody: + $ref: "#/components/requestBodies/Body10" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除指定的数据集版本。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + + Returns: + dict: 删除结果信息,包含剩余版本数量。 + + Raises: + ValueError: 当数据集版本ID为空或版本正在被使用时抛出异常。 + tags: + - 数据集 + /data/version/export: + post: + description: 导出一个或多个数据集版本,返回压缩文件 + requestBody: + $ref: "#/components/requestBodies/Body9" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 导出一个或多个数据集版本。 + + Args: + 通过JSON请求体传递参数: + data_set_version_ids (list): 数据集版本ID列表。 + + Returns: + Response: 压缩文件下载响应。 + + Raises: + ValueError: 当数据集版本ID列表为空时抛出异常。 + tags: + - 数据集 + /data/version/export/ft: + get: + description: 导出数据集版本文件,用于微调 + parameters: + - description: 文件路径 + in: query + name: filename + required: true + schema: + type: string + - description: 文件来源(upload或return) + in: query + name: filefrom + required: true + schema: + type: string + enum: + - upload + - return + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: [] + summary: |- + 导出数据集版本文件(微调专用)。 + + Args: + 通过URL参数传递: + filename (str): 文件路径。 + filefrom (str): 文件来源(upload或return)。 + + Returns: + Response: 文件下载响应。 + + Raises: + ValueError: 当参数有误或文件不存在时抛出异常。 + tags: + - 数据集 + /data/version/list: + get: + description: 获取指定数据集的版本分页列表 + parameters: + - description: 页码,从1开始 + in: query + name: page + required: false + schema: + type: integer + minimum: 1 + default: 1 + - description: 每页大小 + in: query + name: page_size + required: false + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + - description: 版本类型 + in: query + name: version_type + required: false + schema: + type: string + enum: + - branch + - tag + - description: 数据集ID + in: query + name: data_set_id + required: false + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取数据集版本分页列表。 + + Args: + 通过URL参数传递: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + version_type (str, optional): 版本类型。 + data_set_id (str): 数据集ID。 + + Returns: + dict: 分页结果,包含数据集版本列表和分页信息。 + tags: + - 数据集 + /data/version/publish: + post: + description: 发布数据集版本为标签版本 + requestBody: + $ref: "#/components/requestBodies/Body10" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 发布数据集版本为标签版本。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + + Returns: + dict: 发布后的数据集版本信息。 + + Raises: + ValueError: 当数据集版本ID为空时抛出异常。 + tags: + - 数据集 + /data/version/test_status: + post: + description: 测试数据集版本状态变更功能 + requestBody: + $ref: "#/components/requestBodies/Body10" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 测试数据集版本状态变更功能。 + + Args: + 通过JSON请求体传递参数: + data_set_version_id (str): 数据集版本ID。 + + Returns: + dict: 状态变更后的数据集版本信息。 + + Raises: + Exception: 当状态变更失败时抛出异常。 + tags: + - 数据集 + /database: + post: + description: 创建新数据库,要求数据库名称以字母开头,只能包含字母、数字和下划线,且长度不超过20 + requestBody: + content: + application/json: + schema: + properties: + comment: + description: 数据库注释 + type: string + db_name: + description: 数据库名称(以字母开头,只能包含字母、数字和下划线,长度不超过20) + type: string + required: + - db_name + - comment + type: object + description: 数据库创建参数 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + type: object + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新数据库。 + + 接收数据库名称和注释,验证名称格式,然后创建新的数据库。 + 要求数据库名称以字母开头,只能包含字母、数字和下划线,且长度不超过20。 + + Returns: + dict: 包含创建结果的响应字典 + + Raises: + Exception: 当数据库名称格式无效或创建失败时抛出 + tags: + - 数据库管理 + "/database/import/{database_id}/{table_id}": + get: + description: 生成并下载指定表的Excel导入模板文件,包含表的所有列 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + responses: + "200": + description: 下载成功 + content: + "*/*": + schema: + type: string + format: binary + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + summary: |- + 下载数据导入模板。 + + 生成并下载指定表的Excel导入模板文件,包含表的所有列。 + + Args: + database_id (int): 数据库ID + table_id (int): 表ID + + Returns: + File: Excel格式的导入模板文件 + + Raises: + Exception: 当生成模板失败时抛出 + tags: + - 数据库管理 + post: + description: 上传Excel文件并预览要导入的数据,包括数据验证和格式转换 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 要上传的Excel文件 + type: string + format: binary + required: + - file + responses: + "200": + description: 预览成功 + content: + "*/*": + schema: + properties: + columns: + items: + properties: + comment: + type: string + default: + type: string + nullable: true + name: + type: string + nullable: + type: boolean + type: + type: string + required: + - name + - type + type: object + type: array + data: + items: + type: object + type: array + total_rows: + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 上传并预览导入数据。 + + 上传Excel文件并预览要导入的数据,包括数据验证和格式转换。 + + Args: + database_id (int): 数据库ID + table_id (int): 表ID + + Form Data: + file: 要上传的Excel文件 + + Returns: + dict: 包含预览数据的字典,包括总行数、列定义和数据 + + Raises: + ValueError: 当未上传文件时抛出 + Exception: 当处理文件失败时抛出 + tags: + - 数据库管理 + put: + description: 根据预览的数据执行实际的数据导入操作 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + properties: + action: + description: 操作类型:preview(预览)/import(导入) + enum: + - preview + - import + type: string + data: + description: 要导入的数据列表(当action为import时必填) + items: + type: object + type: array + required: + - action + type: object + description: 数据导入参数 + required: true + responses: + "200": + description: 导入成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 执行数据导入。 + + 根据预览的数据执行实际的数据导入操作。 + + Args: + database_id (int): 数据库ID + table_id (int): 表ID + + Request Body: + action (str): 操作类型,只支持"import" + data (list): 要导入的数据列表 + + Returns: + dict: 包含导入结果的响应字典 + + Raises: + Exception: 当导入失败时抛出 + tags: + - 数据库管理 + /database/list/page: + post: + description: 分页获取用户可访问的数据库列表,支持按数据库名称、查询类型、用户ID等条件筛选 + requestBody: + content: + application/json: + schema: + properties: + db_name: + default: "" + description: 数据库名称筛选 + type: string + limit: + default: 10 + description: 每页数量 + type: integer + page: + default: 1 + description: 页码 + type: integer + qtype: + default: already + description: 查询类型:mine(我的)/group(组内)/builtin(内置)/already(已访问) + enum: + - mine + - group + - builtin + - already + type: string + user_id: + default: [] + description: 用户ID列表筛选 + items: + type: string + type: array + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + items: + properties: + comment: + type: string + created_at: + format: date-time + type: string + created_by: + type: string + created_by_account: + properties: + id: + type: string + name: + type: string + type: object + database_name: + type: string + id: + type: integer + name: + type: string + table_count: + type: integer + tenant_id: + type: string + type: + type: string + updated_at: + format: date-time + type: string + url: + type: string + nullable: true + user_name: + type: string + type: object + type: array + has_more: + type: boolean + limit: + type: integer + page: + type: integer + total: + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取数据库列表(分页)。 + + 分页获取用户可访问的数据库列表,支持按数据库名称筛选、 + 按查询类型筛选和按用户ID筛选。 + + Request Body: + page (int): 页码,默认为1 + limit (int): 每页数量,默认为10 + db_name (str): 数据库名称筛选,默认为空 + qtype (str): 查询类型,可选值:mine/group/builtin/already,默认为already + user_id (list): 用户ID列表筛选,默认为空列表 + + Returns: + dict: 分页的数据库信息列表 + tags: + - 数据库管理 + "/database/{database_id}": + delete: + description: 删除指定的数据库,需要管理员权限 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除数据库。 + + 删除指定的数据库,需要管理员权限。 + + Args: + database_id (int): 要删除的数据库ID + + Returns: + dict: 包含删除结果的响应字典 + tags: + - 数据库管理 + put: + description: 更新指定数据库的名称和注释信息 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + properties: + comment: + description: 新的数据库注释 + type: string + db_name: + description: 新的数据库名称 + type: string + required: + - db_name + - comment + type: object + description: 数据库更新参数 + required: true + responses: + "200": + description: 更新成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + type: object + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 更新数据库信息。 + + 更新指定数据库的名称和注释信息。 + + Args: + database_id (int): 数据库ID + + Request Body: + db_name (str): 新的数据库名称 + comment (str): 新的数据库注释 + + Returns: + dict: 包含更新结果的响应字典 + + Raises: + Exception: 当更新失败时抛出 + tags: + - 数据库管理 + "/database/{database_id}/table": + post: + description: 在指定数据库中创建新表,包括表名、注释和列定义,需要写入权限 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + properties: + columns: + description: 列定义列表 + items: + properties: + comment: + type: string + default: + type: string + nullable: true + name: + type: string + nullable: + type: boolean + type: + type: string + required: + - name + - type + type: object + type: array + comment: + description: 表注释 + type: string + table_name: + description: 表名 + type: string + required: + - table_name + - comment + - columns + type: object + description: 表创建参数 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新表。 + + 在指定数据库中创建新表,包括表名、注释和列定义。 + 需要写入权限。 + + Args: + database_id (int): 数据库ID + + Request Body: + table_name (str): 表名 + comment (str): 表注释 + columns (list): 列定义列表 + + Returns: + dict: 包含创建结果的响应字典 + + Raises: + Exception: 当列类型为空或创建失败时抛出 + tags: + - 数据库管理 + "/database/{database_id}/table/list": + get: + description: 分页获取指定数据库中的所有表,支持按表名筛选 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 页码 + in: query + name: page + schema: + type: integer + default: 1 + - description: 每页数量 + in: query + name: limit + schema: + type: integer + default: 10 + - description: 表名筛选 + in: query + name: table_name + schema: + type: string + default: "" + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + items: + properties: + comment: + type: string + created_at: + format: date-time + type: string + created_by: + type: string + created_by_account: + properties: + id: + type: string + name: + type: string + type: object + id: + type: integer + name: + type: string + row_count: + type: integer + tenant_id: + type: string + updated_at: + format: date-time + type: string + type: object + type: array + has_more: + type: boolean + limit: + type: integer + page: + type: integer + total: + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取数据库中的表列表。 + + 分页获取指定数据库中的所有表,支持按表名筛选。 + + Args: + database_id (int): 数据库ID + + Query Parameters: + page (int): 页码,默认为1 + limit (int): 每页数量,默认为10 + table_name (str): 表名筛选,默认为空 + + Returns: + dict: 分页的表信息列表 + tags: + - 数据库管理 + "/database/{database_id}/table/{table_id}": + delete: + description: 删除指定数据库中的指定表,需要管理员权限 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除表。 + + 删除指定数据库中的指定表,需要管理员权限。 + + Args: + database_id (int): 数据库ID + table_id (int): 要删除的表ID + + Returns: + dict: 包含删除结果的响应字典 + tags: + - 数据库管理 + get: + description: 获取指定数据库中指定表ID的表结构信息 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + columns: + items: + properties: + comment: + type: string + default: + type: string + nullable: true + name: + type: string + nullable: + type: boolean + type: + type: string + type: object + type: array + comment: + type: string + table_id: + type: integer + table_name: + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 根据表ID获取表结构。 + + 获取指定数据库中指定表ID的表结构信息。 + + Args: + database_id (int): 数据库ID + table_id (int): 表ID + + Returns: + dict: 包含表结构信息的响应字典 + tags: + - 数据库管理 + put: + description: 修改指定表的结构,包括表名、注释和列定义,需要写入权限 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + properties: + columns: + description: 列定义列表 + items: + properties: + comment: + type: string + default: + type: string + nullable: true + name: + type: string + nullable: + type: boolean + type: + type: string + required: + - name + - type + type: object + type: array + comment: + description: 表注释 + type: string + table_name: + description: 表名 + type: string + required: + - table_name + - comment + - columns + type: object + description: 表更新参数 + required: true + responses: + "200": + description: 修改成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 编辑表结构。 + + 修改指定表的结构,包括表名、注释和列定义。 + 需要写入权限。 + + Args: + database_id (int): 数据库ID + table_id (int): 表ID + + Request Body: + table_name (str): 新的表名 + comment (str): 新的表注释 + columns (list): 列定义列表 + + Returns: + dict: 包含修改结果的响应字典 + + Raises: + Exception: 当列类型为空或修改失败时抛出 + tags: + - 数据库管理 + "/database/{database_id}/table_data/{table_id}": + delete: + description: 删除指定表中的数据记录 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + properties: + data_items: + description: 要删除的数据项列表 + items: + type: object + type: array + table_name: + description: 表名 + type: string + required: + - data_items + type: object + description: 表数据删除参数 + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除表数据。 + + 删除指定表中的数据记录。 + + Args: + database_id (int): 数据库ID + table_id (int): 表ID + + Request Body: + data_items (list): 要删除的数据项列表 + table_name (str): 表名 + + Returns: + dict: 包含删除结果的响应字典 + tags: + - 数据库管理 + get: + description: 分页获取指定表中的数据记录 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + - description: 页码 + in: query + name: page + schema: + type: integer + default: 1 + - description: 每页数量 + in: query + name: limit + schema: + type: integer + default: 10 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + items: + type: object + type: array + has_more: + type: boolean + limit: + type: integer + page: + type: integer + total: + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取表数据(分页)。 + + 分页获取指定表中的数据记录。 + + Args: + database_id (int): 数据库ID + table_id (int): 表ID + + Query Parameters: + page (int): 页码,默认为1 + limit (int): 每页数量,默认为10 + + Returns: + dict: 分页的表数据 + tags: + - 数据库管理 + put: + description: 批量执行表数据的增加、更新和删除操作 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表ID + in: path + name: table_id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + properties: + add_items: + description: 要添加的数据项列表 + items: + type: object + type: array + delete_items: + description: 要删除的数据项列表 + items: + type: object + type: array + table_name: + description: 表名 + type: string + update_items: + description: 要更新的数据项列表 + items: + type: object + type: array + type: object + description: 表数据更新参数 + required: true + responses: + "200": + description: 更新成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 批量更新表数据。 + + 批量执行表数据的增加、更新和删除操作。 + + Args: + database_id (int): 数据库ID + table_id (int): 表ID + + Request Body: + add_items (list): 要添加的数据项列表 + update_items (list): 要更新的数据项列表 + delete_items (list): 要删除的数据项列表 + table_name (str): 表名 + + Returns: + dict: 包含操作结果的响应字典 + tags: + - 数据库管理 + "/database/{database_id}/table_name/{table_name}": + get: + description: 获取指定数据库中指定表名的表结构信息 + parameters: + - description: 数据库ID + in: path + name: database_id + required: true + schema: + type: integer + - description: 表名 + in: path + name: table_name + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + columns: + items: + properties: + comment: + type: string + default: + type: string + nullable: true + name: + type: string + nullable: + type: boolean + type: + type: string + type: object + type: array + comment: + type: string + table_id: + type: integer + table_name: + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 根据表名获取表结构。 + + 获取指定数据库中指定表名的表结构信息。 + + Args: + database_id (int): 数据库ID + table_name (str): 表名 + + Returns: + dict: 包含表结构信息的响应字典 + tags: + - 数据库管理 + "/doc/image/{subpath}": + get: + description: 根据图片路径获取文档图片,不需要登录 + parameters: + - description: 图片文件路径 + in: path + name: subpath + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + type: string + format: binary + "400": + description: 参数错误 + "401": + description: 未授权 + "404": + description: 资源不存在 + summary: |- + 获取文档图片。 + + Args: + subpath (str): 图片文件路径 + + Returns: + Response: 包含图片内容的响应对象 + tags: + - 文档管理 + /doc/manage: + delete: + description: 删除指定文档,需要登录和管理员权限 + parameters: + - description: 文档ID + in: query + name: id + required: true + schema: + type: integer + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除文档。 + + Returns: + bool: 删除成功返回 True + tags: + - 文档管理 + get: + description: 根据文档ID获取文档的详细信息,需要登录 + parameters: + - description: 文档ID + in: query + name: id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + created_at: + format: date-time + type: string + created_by: + description: 创建者ID + type: string + created_by_account: + properties: + avatar: + type: string + id: + type: string + name: + type: string + type: object + doc_content: + description: 文档内容(Markdown格式) + type: string + id: + description: 文档ID + type: integer + index: + description: 文档索引 + type: string + status: + description: 文档状态 + type: string + status_label: + description: 文档状态标签 + type: string + title: + description: 文档标题 + type: string + updated_at: + format: date-time + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取单个文档详情。 + + Returns: + dict: 文档详细信息 + tags: + - 文档管理 + post: + description: 创建新文档,需要登录和管理员权限 + requestBody: + content: + application/json: + schema: + properties: + doc_content: + description: 文档内容(Markdown格式) + type: string + index: + description: 文档索引 + type: string + title: + description: 文档标题 + type: string + required: + - title + - doc_content + type: object + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + created_at: + format: date-time + type: string + created_by: + description: 创建者ID + type: string + created_by_account: + properties: + avatar: + type: string + id: + type: string + name: + type: string + type: object + doc_content: + description: 文档内容(Markdown格式) + type: string + id: + description: 文档ID + type: integer + index: + description: 文档索引 + type: string + status: + description: 文档状态 + type: string + status_label: + description: 文档状态标签 + type: string + title: + description: 文档标题 + type: string + updated_at: + format: date-time + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新文档。 + + Returns: + dict: 创建的文档信息 + tags: + - 文档管理 + put: + description: 更新指定文档的信息,需要登录和管理员权限 + requestBody: + content: + application/json: + schema: + properties: + doc_content: + description: 文档内容(Markdown格式) + type: string + id: + description: 文档ID + type: integer + index: + description: 文档索引 + type: string + title: + description: 文档标题 + type: string + required: + - id + - title + - doc_content + type: object + required: true + responses: + "200": + description: 更新成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + created_at: + format: date-time + type: string + created_by: + description: 创建者ID + type: string + created_by_account: + properties: + avatar: + type: string + id: + type: string + name: + type: string + type: object + doc_content: + description: 文档内容(Markdown格式) + type: string + id: + description: 文档ID + type: integer + index: + description: 文档索引 + type: string + status: + description: 文档状态 + type: string + status_label: + description: 文档状态标签 + type: string + title: + description: 文档标题 + type: string + updated_at: + format: date-time + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 更新文档。 + + Returns: + dict: 更新后的文档信息 + tags: + - 文档管理 + /doc/manage/list: + get: + description: 分页获取文档列表,支持按文档名称搜索,不需要登录 + parameters: + - description: 页码,从1开始 + in: query + name: page + schema: + type: integer + minimum: 1 + maximum: 99999 + default: 1 + - description: 每页数量 + in: query + name: limit + schema: + type: integer + minimum: 1 + maximum: 100 + default: 20 + - description: 文档名称搜索关键词 + in: query + name: search_name + required: false + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 文档列表 + items: + properties: + created_at: + format: date-time + type: string + created_by: + description: 创建者ID + type: string + created_by_account: + properties: + avatar: + type: string + id: + type: string + name: + type: string + type: object + doc_content: + description: 文档内容(Markdown格式) + type: string + id: + description: 文档ID + type: integer + index: + description: 文档索引 + type: string + status: + description: 文档状态 + type: string + status_label: + description: 文档状态标签 + type: string + title: + description: 文档标题 + type: string + updated_at: + format: date-time + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + limit: + description: 每页数量 + type: integer + page: + description: 当前页码 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + summary: |- + 获取文档列表。 + + Returns: + dict: 包含分页文档列表的响应数据 + tags: + - 文档管理 + /doc/manage/publish: + get: + description: 发布指定文档,使其对外可见,需要登录 + parameters: + - description: 文档ID + in: query + name: id + required: true + schema: + type: integer + responses: + "200": + description: 发布成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 发布文档。 + + Returns: + bool: 发布成功返回 True + tags: + - 文档管理 + /doc/manage/unpublish: + get: + description: 下架指定文档,使其不再对外可见,需要登录 + parameters: + - description: 文档ID + in: query + name: id + required: true + schema: + type: integer + responses: + "200": + description: 下架成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 下架文档。 + + Returns: + bool: 下架成功返回 True + tags: + - 文档管理 + /doc/manage/upload_image: + post: + description: 上传文档中使用的图片文件,需要登录 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 要上传的图片文件 + type: string + format: binary + file_name: + description: 文件名 + type: string + required: + - file + - file_name + responses: + "200": + description: 上传成功 + content: + "*/*": + schema: + properties: + url: + description: 图片访问URL + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 上传文档图片。 + + Returns: + tuple: (响应数据, 状态码) 包含图片URL的响应 + tags: + - 文档管理 + /doc/view: + get: + description: 访问文档的Web视图,支持Markdown文档渲染,不需要登录 + parameters: + - description: 文档视图子路径,用于访问具体的文档或资源 + in: path + name: subpath + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + description: HTML页面或Markdown内容 + type: string + "400": + description: 参数错误 + "401": + description: 未授权 + "404": + description: 资源不存在 + "500": + description: 服务器错误 + summary: |- + 获取文档视图。 + + Args: + subpath (str, optional): 子路径,用于访问具体的文档或资源 + + Returns: + Response: HTML 页面或文档内容的响应对象 + tags: + - 文档管理 + "/doc/view/{subpath}": + get: + description: 访问文档的Web视图,支持Markdown文档渲染,不需要登录 + parameters: + - description: 文档视图子路径,用于访问具体的文档或资源 + in: path + name: subpath + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + description: HTML页面或Markdown内容 + type: string + "400": + description: 参数错误 + "401": + description: 未授权 + "404": + description: 资源不存在 + "500": + description: 服务器错误 + summary: |- + 获取文档视图。 + + Args: + subpath (str, optional): 子路径,用于访问具体的文档或资源 + + Returns: + Response: HTML 页面或文档内容的响应对象 + tags: + - 文档管理 + /files/upload: + post: + description: 上传本地文件供大模型使用。此端点允许在不需要身份验证的情况下上传文件,因为访客也可以访问。上传的文件会保存到工作流目录中,并使用随机生成的文件名 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 要上传的文件,文件会保存到工作流目录中,并使用随机生成的文件名 + type: string + format: binary + required: + - file + responses: + "200": + description: 上传成功 + content: + "*/*": + schema: + properties: + file_path: + description: 上传文件的保存路径 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + summary: |- + 上传本地文件供大模型使用。 + + 此端点允许在不需要身份验证的情况下上传文件, + 因为访客也可以访问。上传的文件会保存到工作流目录中, + 并使用随机生成的文件名。 + + Args: + None (使用Flask请求解析器从表单数据获取文件) + + Returns: + dict: 包含已上传文件路径的字典。 + 示例: {"file_path": "/path/to/uploaded/file.txt"} + + Raises: + werkzeug.exceptions.BadRequest: 当请求中未提供文件时抛出。 + OSError: 当创建存储目录或保存文件时出现问题时抛出。 + tags: + - 文件管理 + /finetune: + post: + description: 创建新的模型微调任务,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + base: + properties: + base_model: + description: 基础模型UUID,调用ft接口后固定传0 + type: string + base_model_key: + description: 调用ft接口获取的模型名字(格式:model_key:ams) + type: string + created_from_info: + description: 创建来源 + type: string + datasets: + description: 数据集UUID列表 + items: + format: uuid + type: string + type: array + datasets_type: + description: 数据集类型列表 + items: + type: string + type: array + finetuning_type: + description: 微调类型:LoRA/QLoRA/Full + enum: + - LoRA + - QLoRA + - Full + type: string + name: + description: 任务名称 + type: string + target_model_name: + description: 微调后的模型名称 + type: string + required: + - name + - base_model_key + - target_model_name + - datasets + - finetuning_type + type: object + finetune_config: + properties: + batch_size: + description: 批次大小 + type: integer + cutoff_len: + description: 序列最大长度 + type: string + learning_rate: + description: 学习率 + type: number + lora_r: + description: LoRa秩 + type: integer + lora_rate: + description: 微调占比 + type: integer + lr_scheduler_type: + description: 学习率调整策略 + type: string + num_epochs: + description: 重复次数 + type: integer + num_gpus: + description: GPU数量 + type: integer + training_type: + description: 训练模式:PT/SFT/RM/PPO/DPO + enum: + - PT + - SFT + - RM + - PPO + - DPO + type: string + val_size: + description: 验证集占比 + type: number + required: [] + type: object + required: + - base + - finetune_config + type: object + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + base_model: + description: 基础模型UUID + type: string + base_model_key: + description: 基础模型key + type: string + created_at: + format: date-time + type: string + created_by: + description: 创建者ID + type: string + created_by_account: + properties: + avatar: + type: string + id: + type: string + name: + type: string + type: object + created_from_info: + description: 创建来源 + type: string + description: + description: 任务描述 + type: string + finetune_config: + description: 微调配置 + type: object + finetuning_type: + description: 微调类型 + type: string + id: + description: 任务ID + type: integer + log_path: + description: 日志路径 + type: string + name: + description: 任务名称 + type: string + status: + description: 任务状态 + type: string + status_label: + description: 任务状态(中文) + type: string + target_model: + description: 目标模型UUID + type: string + target_model_name: + description: 微调后的模型名称 + type: string + train_end_time: + format: date-time + type: string + train_runtime: + description: 训练运行时间(秒) + type: integer + updated_at: + format: date-time + type: string + user_name: + description: 用户名 + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建微调任务。 + + 接收微调任务配置信息,创建新的微调任务。 + + Args: + base (dict): 基础配置信息 + name (str): 任务名称 + base_model (str): 基础模型uuid,调用ft接口后固定传0 + base_model_key (str): 调用ft接口获取的模型名字 + target_model_name (str): 微调后的模型名称 + created_from_info (str): 创建来源 + datasets (list): 数据集uuids + datasets_type (list): 数据集类型 + finetuning_type (str): 微调类型 LoRA, QLoRA, Full + finetune_config (dict): 微调配置信息 + num_gpus (int): GPU数量 + training_type (str): 训练模式 PT, SFT, RM, PPO, DPO + val_size (float): 验证集占比 + num_epochs (int): 重复次数 + learning_rate (float): 学习率 + lr_scheduler_type (str): 学习率调整策略 + batch_size (int): 批次大小 + cutoff_len (str): 序列最大长度 + lora_r (int): LoRa秩 + lora_rate (int): 微调占比 + + Returns: + dict: 创建的微调任务详细信息 + + Raises: + ValidationError: 当输入数据验证失败时 + CommonError: 当创建任务失败时 + tags: + - 模型微调 + "/finetune/cancel/{task_id}": + delete: + description: 取消正在进行的微调任务,需要登录和写入权限 + parameters: + - description: 微调任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 取消成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 取消微调任务。 + + 取消正在进行的微调任务。 + + Args: + task_id (int): 微调任务ID + + Returns: + tuple: (响应消息, HTTP状态码) + 成功: ({"message": "success", "code": 200}, 200) + 失败: ({"message": "cancel fail", "code": 400}, 400) + + Raises: + PermissionError: 当用户没有取消权限时 + ValueError: 当任务不存在时 + tags: + - 模型微调 + /finetune/datasets: + get: + description: 根据查询类型获取可用于微调的数据集列表(树形结构),需要登录 + parameters: + - description: 查询类型:mine/group/builtin/already + in: query + name: qtype + required: true + schema: + type: string + enum: + - mine + - group + - builtin + - already + default: already + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + description: 数据集树形结构 + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取可用于微调的数据集列表。 + + 根据查询类型获取可用于微调的数据集列表。 + + Args: + qtype (str): 查询类型,可选值:mine/group/builtin/already,默认为already + + Returns: + dict: 数据集树形结构 + + Raises: + ValueError: 当查询类型无效时 + Exception: 当获取数据集列表失败时 + tags: + - 模型微调 + "/finetune/delete/{task_id}": + delete: + description: 删除指定的微调任务,需要登录和管理员权限 + parameters: + - description: 微调任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除微调任务。 + + 删除指定的微调任务。 + + Args: + task_id (int): 微调任务ID + + Returns: + tuple: (响应消息, HTTP状态码) + 成功: ({"message": "success", "code": 200}, 200) + 失败: ({"message": "delete fail", "code": 400}, 400) + + Raises: + PermissionError: 当用户没有删除权限时 + ValueError: 当任务不存在时 + tags: + - 模型微调 + "/finetune/detail/{task_id}": + get: + description: 获取指定微调任务的详细信息,需要登录 + parameters: + - description: 微调任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + base_model: + description: 基础模型UUID + type: string + base_model_key: + description: 基础模型key + type: string + created_at: + format: date-time + type: string + created_by: + description: 创建者ID + type: string + created_by_account: + properties: + avatar: + type: string + id: + type: string + name: + type: string + type: object + created_from_info: + description: 创建来源 + type: string + description: + description: 任务描述 + type: string + finetune_config: + description: 微调配置 + type: object + finetuning_type: + description: 微调类型 + type: string + id: + description: 任务ID + type: integer + log_path: + description: 日志路径 + type: string + name: + description: 任务名称 + type: string + status: + description: 任务状态 + type: string + status_label: + description: 任务状态(中文) + type: string + target_model: + description: 目标模型UUID + type: string + target_model_name: + description: 微调后的模型名称 + type: string + train_end_time: + format: date-time + type: string + train_runtime: + description: 训练运行时间(秒) + type: integer + updated_at: + format: date-time + type: string + user_name: + description: 用户名 + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取微调任务详细信息。 + + 获取指定微调任务的详细信息。 + + Args: + task_id (int): 微调任务ID + + Returns: + dict: 微调任务的详细信息 + + Raises: + PermissionError: 当用户没有读取权限时 + ValueError: 当任务不存在时 + tags: + - 模型微调 + /finetune/ft/models: + get: + description: 获取可用的FT模型列表,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + description: FT模型列表 + items: + type: object + type: array + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取FT模型列表。 + + 获取可用的FT模型列表。 + + Returns: + tuple: (响应数据, HTTP状态码) + 成功: ({"message": "success", "code": 200, "data": 模型列表}, 200) + 失败: ({"message": "failed", "code": 400, "data": 错误信息}, 400) + + Raises: + Exception: 当获取模型列表失败时 + tags: + - 模型微调 + /finetune/list/page: + post: + description: 分页获取微调任务列表,支持按任务名称、状态、用户ID等条件筛选,需要登录 + requestBody: + content: + application/json: + schema: + properties: + limit: + default: 20 + description: 每页数量 + maximum: 100 + minimum: 1 + type: integer + page: + default: 1 + description: 页码,从1开始 + maximum: 99999 + minimum: 1 + type: integer + qtype: + default: already + description: 查询类型:mine(我的)/group(组内)/builtin(内置)/already(已访问) + enum: + - mine + - group + - builtin + - already + type: string + search_name: + default: "" + description: 任务名称搜索关键词 + type: string + status: + default: [] + description: 状态过滤列表 + items: + type: string + type: array + user_id: + default: [] + description: 用户ID过滤列表 + items: + type: string + type: array + required: [] + type: object + required: true + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 微调任务列表 + items: + properties: + base_model: + description: 基础模型UUID + type: string + base_model_key: + description: 基础模型key + type: string + created_at: + format: date-time + type: string + created_by: + description: 创建者ID + type: string + created_by_account: + properties: + avatar: + type: string + id: + type: string + name: + type: string + type: object + created_from_info: + description: 创建来源 + type: string + description: + description: 任务描述 + type: string + finetune_config: + description: 微调配置 + type: object + finetuning_type: + description: 微调类型 + type: string + id: + description: 任务ID + type: integer + log_path: + description: 日志路径 + type: string + name: + description: 任务名称 + type: string + status: + description: 任务状态 + type: string + status_label: + description: 任务状态(中文) + type: string + target_model: + description: 目标模型UUID + type: string + target_model_name: + description: 微调后的模型名称 + type: string + train_end_time: + format: date-time + type: string + train_runtime: + description: 训练运行时间(秒) + type: integer + updated_at: + format: date-time + type: string + user_name: + description: 用户名 + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + limit: + description: 每页数量 + type: integer + page: + description: 当前页码 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取微调任务分页列表。 + + 根据查询条件获取微调任务的分页列表。 + + Args: + page (int): 页码,默认为1 + limit (int): 每页数量,默认为20 + qtype (str): 查询类型,可选值:mine/group/builtin/already,默认为already + search_name (str): 搜索名称 + status (list): 状态过滤列表 + user_id (list): 用户ID过滤列表 + + Returns: + dict: 分页的微调任务列表 + + Raises: + ValueError: 当分页参数无效时 + tags: + - 模型微调 + "/finetune/log/{task_id}": + get: + description: 获取指定微调任务的日志内容,需要登录 + parameters: + - description: 微调任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + type: string + format: binary + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取微调任务日志。 + + 获取指定微调任务的日志内容。 + + Args: + task_id (int): 微调任务ID + + Returns: + Response: 日志文件响应,包含日志内容 + + Raises: + PermissionError: 当用户没有读取权限时 + FileNotFoundError: 当日志文件不存在时 + tags: + - 模型微调 + /finetune/models: + get: + description: 根据查询类型获取可用于微调的模型列表,需要登录 + parameters: + - description: 查询类型:mine/group/builtin/already + in: query + name: qtype + required: true + schema: + type: string + enum: + - mine + - group + - builtin + - already + default: already + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + description: 模型列表 + items: + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取可用于微调的模型列表。 + + 根据查询类型获取可用于微调的模型列表。 + + Args: + qtype (str): 查询类型,可选值:mine/group/builtin/already,默认为already + + Returns: + list: 模型列表 + + Raises: + ValueError: 当查询类型无效时 + Exception: 当获取模型列表失败时 + tags: + - 模型微调 + "/finetune/pause/{task_id}": + get: + description: 暂停正在进行的微调任务,需要登录和写入权限 + parameters: + - description: 微调任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 暂停成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: 操作成功 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 暂停微调任务。 + + 暂停正在进行的微调任务。 + + Args: + task_id (int): 微调任务ID + + Returns: + tuple: (响应消息, HTTP状态码) + 成功: ({"message": "操作成功", "code": 200}, 200) + 失败: ({"message": 错误信息, "code": 400}, 400) + + Raises: + PermissionError: 当用户没有暂停权限时 + ValueError: 当任务不存在时 + CommonError: 当暂停失败时(包含详细错误信息) + tags: + - 模型微调 + "/finetune/resume/{task_id}": + get: + description: 恢复已暂停的微调任务,需要登录和写入权限 + parameters: + - description: 微调任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 恢复成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: 操作成功 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 恢复微调任务。 + + 恢复已暂停的微调任务。 + + Args: + task_id (int): 微调任务ID + + Returns: + tuple: (响应消息, HTTP状态码) + 成功: ({"message": "操作成功", "code": 200}, 200) + 失败: ({"message": 错误信息, "code": 400}, 400) + + Raises: + PermissionError: 当用户没有恢复权限时 + ValueError: 当任务不存在时 + CommonError: 当恢复失败时(包含详细错误信息) + tags: + - 模型微调 + "/finetune/running_metrics/{task_id}": + get: + description: 获取指定微调任务的实时运行指标,需要登录 + parameters: + - description: 微调任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + description: 运行指标数据 + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取微调任务运行指标。 + + 获取指定微调任务的实时运行指标。 + + Args: + task_id (int): 微调任务ID + + Returns: + tuple: (响应数据, HTTP状态码) + 成功: (指标数据, 200) + 失败: ({"message": "get_running_metrics fail", "code": 400}, 400) + + Raises: + PermissionError: 当用户没有读取权限时 + ValueError: 当任务不存在时 + tags: + - 模型微调 + "/finetune/start/{task_id}": + get: + description: 异步启动指定的微调任务,需要登录和写入权限 + parameters: + - description: 微调任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 启动成功 + content: + "*/*": + schema: + example: true + type: boolean + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 启动微调任务。 + + 异步启动指定的微调任务。 + + Args: + task_id (int): 微调任务ID + + Returns: + bool: 启动操作是否成功 + + Raises: + ValueError: 当任务不存在时 + Exception: 当启动任务失败时 + tags: + - 模型微调 + /finetune_param: + delete: + description: 删除指定的自定义参数记录,需要登录和写入权限 + parameters: + - description: 记录ID + in: query + name: record_id + schema: + type: integer + default: 0 + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除自定义参数。 + + 删除指定的自定义参数记录。 + + Args: + record_id (int): 记录ID,默认为0 + + Returns: + tuple: (响应消息, HTTP状态码) + 成功: ({"message": "success", "code": 200}, 200) + 失败: ({"message": "delete fail", "code": 400}, 400) + + Raises: + ValueError: 当记录ID无效时 + Exception: 当删除失败时 + tags: + - 模型微调 + get: + description: 获取当前用户的自定义参数列表,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + description: 自定义参数列表 + items: + properties: + finetune_config: + properties: + batch_size: + description: 批次大小 + type: integer + cutoff_len: + description: 序列最大长度 + type: integer + learning_rate: + description: 学习率 + type: number + lora_alpha: + description: LoRa alpha + type: integer + lora_r: + description: LoRa秩 + type: integer + lora_rate: + description: 微调占比 + type: integer + lr_scheduler_type: + description: 学习率调整策略 + type: string + num_epochs: + description: 重复次数 + type: integer + num_gpus: + description: GPU数量 + type: integer + training_type: + description: 训练模式 (PT, SFT, RM, PPO, DPO) + type: string + val_size: + description: 验证集占比 + type: number + type: object + id: + description: 参数ID + type: string + is_default: + description: 是否默认 + type: boolean + name: + description: 参数名称 + type: string + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取自定义参数列表。 + + 获取当前用户的自定义参数列表。 + + Returns: + list: 自定义参数列表 + + Raises: + Exception: 当获取参数列表失败时 + tags: + - 模型微调 + post: + description: 保存用户的自定义参数配置,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + finetune_config: + description: 微调配置 + properties: + batch_size: + description: 批次大小 + type: integer + cutoff_len: + description: 序列最大长度 + type: integer + learning_rate: + description: 学习率 + type: number + lora_alpha: + description: LoRa alpha + type: integer + lora_r: + description: LoRa秩 + type: integer + lora_rate: + description: 微调占比 + type: integer + lr_scheduler_type: + description: 学习率调整策略 + type: string + num_epochs: + description: 重复次数 + type: integer + num_gpus: + description: GPU数量 + type: integer + training_type: + description: 训练模式 (PT, SFT, RM, PPO, DPO) + type: string + val_size: + description: 验证集占比 + type: number + type: object + name: + description: 参数名称 + type: string + required: + - name + - finetune_config + type: object + required: true + responses: + "200": + description: 保存成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + finetune_config: + properties: + batch_size: + description: 批次大小 + type: integer + cutoff_len: + description: 序列最大长度 + type: integer + learning_rate: + description: 学习率 + type: number + lora_alpha: + description: LoRa alpha + type: integer + lora_r: + description: LoRa秩 + type: integer + lora_rate: + description: 微调占比 + type: integer + lr_scheduler_type: + description: 学习率调整策略 + type: string + num_epochs: + description: 重复次数 + type: integer + num_gpus: + description: GPU数量 + type: integer + training_type: + description: 训练模式 (PT, SFT, RM, PPO, DPO) + type: string + val_size: + description: 验证集占比 + type: number + type: object + id: + description: 参数ID + type: string + is_default: + description: 是否默认 + type: boolean + name: + description: 参数名称 + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 保存自定义参数。 + + 保存用户的自定义参数配置。 + + Args: + data (dict): 自定义参数配置数据 + + Returns: + dict: 保存的自定义参数信息 + + Raises: + ValidationError: 当参数数据验证失败时 + Exception: 当保存参数失败时 + tags: + - 模型微调 + /forgot-password: + post: + description: 向用户注册邮箱发送包含重置链接的邮件 + requestBody: + content: + application/json: + schema: + properties: + email: + description: 用户邮箱 + format: email + type: string + required: + - email + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 发送密码重置邮件。 + + 向用户注册邮箱发送包含重置链接的邮件。在调试模式下, + 响应中会包含重置令牌用于测试目的。 + + Request Body: + email (str): 用户注册邮箱地址 + + Returns: + dict: 包含操作结果的字典 + - result (str): 操作结果状态 + - token (str, optional): 调试模式下的重置令牌 + + Raises: + InvalidEmailError: 邮箱格式无效 + ValueError: 邮箱未注册 + + Example: + POST /forgot-password + { + "email": "user@example.com" + } + tags: + - auth + /forgot-password/admin-resets: + post: + description: 管理员强制重置指定用户的密码 + requestBody: + content: + application/json: + schema: + properties: + name: + description: 目标用户名 + type: string + new_password: + description: 新密码 + type: string + password_confirm: + description: 确认新密码 + type: string + required: + - name + - new_password + - password_confirm + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 管理员强制重置用户密码。 + + 允许具有管理员权限的用户为任意指定用户重置密码, + 无需密码重置令牌。操作会被详细记录在审计日志中。 + + Request Body: + name (str): 目标用户名 + new_password (str): 新密码 + password_confirm (str): 新密码确认 + + Returns: + dict: 包含操作结果的字典 + - result (str): 操作结果状态 + + Raises: + PasswordMismatchError: 密码确认不一致 + ValueError: 权限不足、用户不存在或密码强度不足 + + Example: + POST /forgot-password/admin-resets + { + "name": "target_user", + "new_password": "new_secure_password", + "password_confirm": "new_secure_password" + } + tags: + - auth + /forgot-password/resets: + post: + description: 使用有效的重置令牌更新用户密码 + requestBody: + content: + application/json: + schema: + properties: + new_password: + description: 新密码 + type: string + password_confirm: + description: 确认新密码 + type: string + token: + description: 密码重置令牌 + type: string + required: + - token + - new_password + - password_confirm + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: [] + summary: |- + 重置用户密码。 + + 使用有效的重置令牌更新用户密码。验证新密码的强度和一致性, + 生成新的密码哈希,更新数据库并记录操作日志。 + + Request Body: + token (str): 密码重置令牌(管理员重置时可为特殊值) + new_password (str): 新密码 + password_confirm (str): 新密码确认 + + Returns: + dict: 包含操作结果的字典 + - result (str): 操作结果状态 + + Raises: + PasswordMismatchError: 密码确认不一致 + InvalidTokenError: 令牌无效或已过期 + ValueError: 密码强度不足或其他验证错误 + + Example: + POST /forgot-password/resets + { + "token": "reset_token_string", + "new_password": "new_secure_password", + "password_confirm": "new_secure_password" + } + tags: + - auth + /forgot-password/validity: + post: + description: 验证密码重置令牌的有效性 + requestBody: + content: + application/json: + schema: + properties: + token: + description: 密码重置令牌 + type: string + required: + - token + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 验证密码重置令牌的有效性。 + + 检查用户提供的重置令牌是否有效且未过期。 + 返回令牌状态和关联的邮箱地址。 + + Request Body: + token (str): 密码重置令牌 + + Returns: + dict: 包含验证结果的字典 + - is_valid (bool): 令牌是否有效 + - email (str or None): 关联的邮箱地址 + + Example: + POST /forgot-password/validity + { + "token": "reset_token_string" + } + tags: + - auth + /infer-service/cloud/status: + get: + description: 查询cloud-service的启用状态,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + enabled: + description: 是否启用 + type: boolean + message: + description: 状态消息 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 获取云服务状态 + tags: + - 推理服务 + /infer-service/group/close: + post: + description: 关闭指定服务组中的所有服务,需要登录和写入权限 + requestBody: + $ref: "#/components/requestBodies/Body12" + responses: + "200": + description: 关闭成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: Service deleted successfully + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 处理POST请求,关闭推理服务组。 + + 验证权限,关闭服务组中的所有服务。 + + Returns: + dict: 关闭结果的响应字典。 + + Raises: + ValueError: 当权限不足或服务组不存在时抛出异常。 + tags: + - 推理服务 + /infer-service/group/create: + post: + description: 创建推理服务组,需要登录和写入权限,需要启用推理服务功能 + requestBody: + content: + application/json: + schema: + properties: + model_id: + description: 模型ID + type: integer + model_type: + description: 模型类型 + type: string + services: + description: 服务配置列表 + items: + properties: + name: + description: 服务名称 + type: string + num_gpus: + default: 1 + description: GPU数量 + type: integer + required: + - name + type: object + type: array + required: + - model_type + - model_id + - services + type: object + description: 服务组数据 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: Group created successfully + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 处理POST请求,创建推理服务组。 + + 验证模型信息,检查AMS支持,创建服务组。 + + Returns: + dict: 创建结果的响应字典。 + + Raises: + ValueError: 当模型不存在或AMS不支持时抛出异常。 + tags: + - 推理服务 + /infer-service/group/start: + post: + description: 启动指定服务组中的所有服务,需要登录和写入权限,需要启用推理服务功能 + requestBody: + $ref: "#/components/requestBodies/Body12" + responses: + "200": + description: 启动成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: Service started successfully + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 处理POST请求,启动推理服务组。 + + 验证权限,启动服务组中的所有服务。 + + Returns: + dict: 启动结果的响应字典。 + + Raises: + ValueError: 当权限不足或服务组不存在时抛出异常。 + tags: + - 推理服务 + /infer-service/list: + post: + description: 分页获取推理服务列表,支持按名称、状态、用户ID、租户等条件筛选,需要登录 + requestBody: + content: + application/json: + schema: + properties: + page: + default: 1 + description: 页码,从 1 开始 + type: integer + per_page: + default: 10 + description: 每页数量 + type: integer + qtype: + default: already + description: 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + enum: + - mine + - group + - builtin + - already + type: string + search_name: + default: "" + description: 搜索名称 + type: string + status: + default: [] + description: 状态筛选 + items: + enum: + - Ready + - Pending + - Running + - Stopped + - Error + type: string + type: array + tenant: + default: "" + description: 租户筛选 + type: string + user_id: + default: [] + description: 用户ID筛选 + items: + type: string + type: array + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + current_page: + description: 当前页码 + type: integer + next_page: + description: 下一页页码 + type: integer + pages: + description: 总页数 + type: integer + prev_page: + description: 上一页页码 + type: integer + result: + description: 服务列表 + items: + properties: + created_by: + description: 创建者ID + type: string + created_time: + description: 创建时间 + format: date-time + type: string + gid: + description: 组ID + type: string + group_id: + description: 服务组ID + type: integer + id: + description: 服务ID + type: integer + job_id: + description: 任务ID + type: string + model_id: + description: 模型ID + type: integer + model_name: + description: 模型名称 + type: string + model_type: + description: 模型类型 + type: string + name: + description: 服务名称 + type: string + status: + description: 服务状态 + type: string + tenant_id: + description: 租户ID + type: string + updated_time: + description: 更新时间 + format: date-time + type: string + type: object + type: array + total: + description: 总记录数 + type: integer + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 处理POST请求,分页获取推理服务列表。 + + 解析请求中的分页参数,调用InferService获取服务列表和分页信息。 + + Returns: + dict: 包含服务列表和分页信息的响应字典。 + + Raises: + Exception: 当获取服务列表失败时抛出异常。 + tags: + - 推理服务 + /infer-service/list/draw: + get: + description: 获取可用于画布的在线推理服务列表,支持按模型种类筛选,需要登录 + parameters: + - description: 模型种类 + in: query + name: model_kind + required: false + schema: + type: string + default: "" + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + result: + items: + properties: + id: + description: 服务ID + type: integer + model_name: + description: 模型名称 + type: string + name: + description: 服务名称 + type: string + status: + description: 服务状态 + type: string + type: object + type: array + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 处理GET请求,获取在线模型列表。 + + 获取可用于绘图的在线推理服务列表。 + + Returns: + dict: 包含在线模型列表的响应字典。 + + Raises: + Exception: 当获取在线模型列表失败时抛出异常。 + tags: + - 推理服务 + /infer-service/model/list: + get: + description: 获取可用于创建推理服务的模型列表,支持按模型类型、模型种类筛选,需要登录 + parameters: + - description: 模型类型 + in: query + name: model_type + required: false + schema: + type: string + default: local + - description: 模型种类 + in: query + name: model_kind + required: false + schema: + type: string + default: "" + - description: 查询类型 + in: query + name: qtype + required: false + schema: + type: string + default: "" + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + items: + properties: + id: + description: 模型ID + type: integer + model_name: + description: 模型名称 + type: string + need_confirm: + description: 是否需要确认 + type: boolean + type: object + type: array + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 处理GET请求,获取模型列表。 + + 根据查询参数获取本地模型列表,包括微调模型。 + + Returns: + list: 模型列表。 + + Raises: + Exception: 当获取模型列表失败时抛出异常。 + tags: + - 推理服务 + /infer-service/model/list/ams: + get: + description: 获取AMS支持的本地模型列表,包括微调模型,需要登录 + parameters: + - description: 模型类型 + in: query + name: model_type + required: false + schema: + type: string + default: "" + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + items: + properties: + id: + description: 模型ID + type: integer + model_name: + description: 模型名称 + type: string + need_confirm: + description: 是否需要确认 + type: boolean + type: object + type: array + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 处理GET请求,获取AMS支持的本地模型列表。 + + 根据模型类型获取AMS支持的本地模型列表,包括微调模型。 + + Returns: + list: AMS支持的模型列表。 + + Raises: + Exception: 当获取AMS模型列表失败时抛出异常。 + tags: + - 推理服务 + /infer-service/service/create: + post: + description: 在指定服务组中创建推理服务,需要登录和写入权限,需要启用推理服务功能 + requestBody: + content: + application/json: + schema: + properties: + group_id: + description: 服务组ID + type: integer + services: + description: 服务配置列表 + items: + properties: + name: + description: 服务名称 + type: string + num_gpus: + default: 1 + description: GPU数量 + type: integer + required: + - name + type: object + type: array + required: + - group_id + - services + type: object + description: 服务数据 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: Service created successfully + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 处理POST请求,创建推理服务。 + + 验证权限,创建推理服务。 + + Returns: + dict: 创建结果的响应字典。 + + Raises: + ValueError: 当权限不足或服务组不存在时抛出异常。 + tags: + - 推理服务 + /infer-service/service/delete: + post: + description: 删除指定的推理服务,需要登录和写入权限 + requestBody: + $ref: "#/components/requestBodies/Body13" + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: Service deleted successfully + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + "500": + description: 服务器错误 + security: + - Bearer: [] + summary: |- + 处理POST请求,删除推理服务。 + + 验证权限,删除指定的推理服务。 + + Returns: + dict: 删除结果的响应字典。 + + Raises: + ValueError: 当权限不足或服务不存在时抛出异常。 + tags: + - 推理服务 + /infer-service/service/start: + post: + description: 启动指定的推理服务,需要登录和写入权限,需要启用推理服务功能 + requestBody: + $ref: "#/components/requestBodies/Body13" + responses: + "200": + description: 启动成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: Service started successfully + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 处理POST请求,启动推理服务。 + + 验证权限,启动指定的推理服务。 + + Returns: + dict: 启动结果的响应字典。 + + Raises: + ValueError: 当权限不足或服务不存在时抛出异常。 + tags: + - 推理服务 + /infer-service/service/stop: + post: + description: 停止指定的推理服务,需要登录和写入权限 + requestBody: + $ref: "#/components/requestBodies/Body13" + responses: + "200": + description: 停止成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: Service stopped successfully + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 处理POST请求,停止推理服务。 + + 验证权限,停止指定的推理服务。 + + Returns: + dict: 停止结果的响应字典。 + + Raises: + ValueError: 当权限不足或服务不存在时抛出异常。 + tags: + - 推理服务 + /kb/create: + post: + description: 创建新的空知识库,需要写入权限 + requestBody: + content: + application/json: + schema: + properties: + description: + description: 知识库描述 + type: string + name: + description: 知识库名称 + type: string + required: + - name + - description + type: object + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + created_at: + format: date-time + type: string + description: + description: 知识库描述 + type: string + id: + format: uuid + type: string + name: + description: 知识库名称 + type: string + path: + description: 知识库路径 + type: string + ref_status: + description: 是否被引用 + type: boolean + tags: + description: 标签列表 + items: + type: string + type: array + updated_at: + format: date-time + type: string + user_id: + description: 创建者用户ID + type: string + user_name: + description: 创建者用户名 + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建空的知识库。 + + Returns: + dict: 创建的知识库信息 + tags: + - 知识库管理 + /kb/delete: + post: + description: 删除指定的知识库,需要管理员权限 + requestBody: + content: + application/json: + schema: + properties: + id: + description: 知识库ID + format: uuid + type: string + required: + - id + type: object + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除知识库。 + + Returns: + dict: 删除成功的响应消息 + tags: + - 知识库管理 + /kb/download: + post: + description: 下载单个或多个文件。单个文件直接下载,多个文件打包为zip下载 + requestBody: + content: + application/json: + schema: + properties: + file_ids: + description: 文件ID列表,单个文件直接下载,多个文件打包为zip下载 + items: + type: integer + type: array + required: + - file_ids + type: object + required: true + responses: + "200": + description: 下载成功 + content: + "*/*": + schema: + type: string + format: binary + "400": + description: 参数错误 + "401": + description: 未授权 + security: + - Bearer: [] + summary: |- + 下载单个或多个文件。 + + Returns: + Response: 文件下载响应,单个文件直接下载,多个文件打包为zip下载 + tags: + - 知识库管理 + /kb/file/add: + post: + description: 将已上传的文件添加到指定的知识库中,需要对该知识库有写入权限 + requestBody: + content: + application/json: + schema: + properties: + file_ids: + description: 文件ID列表 + items: + format: uuid + type: string + type: array + knowledge_base_id: + description: 知识库ID + format: uuid + type: string + required: + - knowledge_base_id + - file_ids + type: object + required: true + responses: + "200": + description: 添加成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 往知识库添加文件。 + + Returns: + dict: 添加成功的响应消息 + tags: + - 知识库管理 + /kb/file/delete: + post: + description: 批量删除知识库中的文件,需要对该知识库有管理员权限 + requestBody: + content: + application/json: + schema: + properties: + file_ids: + description: 要删除的文件ID列表 + items: + format: uuid + type: string + type: array + required: + - file_ids + type: object + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 批量删除文件。 + + Returns: + dict: 删除成功的响应消息 + tags: + - 知识库管理 + /kb/file/get: + post: + description: 根据文件ID获取文件的详细信息 + requestBody: + content: + application/json: + schema: + properties: + file_id: + description: 文件ID + format: uuid + type: string + required: + - file_id + type: object + required: true + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + created_at: + format: date-time + type: string + file_md5: + description: 文件MD5值 + type: string + file_path: + description: 文件路径 + type: string + file_type: + description: 文件类型 + type: string + id: + format: uuid + type: string + knowledge_base_id: + description: 所属知识库ID + format: uuid + type: string + name: + description: 文件名 + type: string + size: + description: 文件大小(字节) + type: integer + storage_type: + description: 存储类型 + type: string + updated_at: + format: date-time + type: string + used: + description: 是否已使用 + type: boolean + user_id: + description: 用户ID + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取单个文件详情。 + + Returns: + dict: 文件详细信息 + tags: + - 知识库管理 + /kb/file/list: + get: + description: 分页获取指定知识库中的文件列表,同时返回知识库的基本信息,需要对该知识库有读取权限 + parameters: + - description: 知识库ID + in: query + name: knowledge_base_id + required: true + schema: + type: string + format: uuid + - description: 页码,从1开始 + in: query + name: page + schema: + type: integer + default: 1 + - description: 每页数量 + in: query + name: page_size + schema: + type: integer + default: 20 + - description: 文件名搜索关键词 + in: query + name: file_name + schema: + type: string + default: "" + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 文件列表 + items: + properties: + created_at: + format: date-time + type: string + file_md5: + description: 文件MD5值 + type: string + file_path: + description: 文件路径 + type: string + file_type: + description: 文件类型 + type: string + id: + format: uuid + type: string + knowledge_base_id: + description: 所属知识库ID + format: uuid + type: string + name: + description: 文件名 + type: string + size: + description: 文件大小(字节) + type: integer + storage_type: + description: 存储类型 + type: string + updated_at: + format: date-time + type: string + used: + description: 是否已使用 + type: boolean + user_id: + description: 用户ID + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + knowledge_base_info: + description: 知识库信息 + properties: + created_at: + format: date-time + type: string + description: + description: 知识库描述 + type: string + id: + format: uuid + type: string + name: + description: 知识库名称 + type: string + path: + description: 知识库路径 + type: string + ref_status: + description: 是否被引用 + type: boolean + tags: + description: 标签列表 + items: + type: string + type: array + updated_at: + format: date-time + type: string + user_id: + description: 创建者用户ID + type: string + user_name: + description: 创建者用户名 + type: string + type: object + page: + description: 当前页码 + type: integer + page_size: + description: 每页数量 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取知识库详情与文件列表。 + + Returns: + dict: 知识库信息和分页文件列表 + tags: + - 知识库管理 + /kb/list: + post: + description: 分页获取用户可访问的知识库列表,支持按知识库名称、查询类型、标签、用户ID等条件筛选 + requestBody: + content: + application/json: + schema: + properties: + page: + default: 1 + description: 页码,从1开始 + type: integer + page_size: + default: 20 + description: 每页数量 + type: integer + qtype: + default: already + description: 查询类型:mine(我的)/group(组内)/builtin(内置)/already(已访问) + enum: + - mine + - group + - builtin + - already + type: string + search_name: + default: "" + description: 知识库名称搜索关键词 + type: string + search_tags: + default: [] + description: 标签筛选列表 + items: + type: string + type: array + user_id: + default: [] + description: 用户ID筛选列表 + items: + type: string + type: array + required: [] + type: object + required: true + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 知识库列表 + items: + properties: + created_at: + format: date-time + type: string + description: + description: 知识库描述 + type: string + id: + format: uuid + type: string + name: + description: 知识库名称 + type: string + path: + description: 知识库路径 + type: string + ref_status: + description: 是否被引用 + type: boolean + tags: + description: 标签列表 + items: + type: string + type: array + updated_at: + format: date-time + type: string + user_id: + description: 创建者用户ID + type: string + user_name: + description: 创建者用户名 + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + page: + description: 当前页码 + type: integer + page_size: + description: 每页数量 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取知识库列表。 + + Returns: + dict: 包含分页知识库列表的响应数据 + tags: + - 知识库管理 + /kb/reference-result: + get: + description: 获取引用指定知识库的应用列表,需要对该知识库有读取权限 + parameters: + - description: 知识库ID + in: query + name: id + required: true + schema: + type: string + format: uuid + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + description: 引用该知识库的应用列表 + items: + properties: + id: + format: uuid + type: string + is_public: + description: 是否公开 + type: boolean + name: + description: 应用名称 + type: string + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 获取知识库引用结果 + tags: + - 知识库管理 + /kb/update: + post: + description: 更新指定知识库的名称和描述信息,需要写入权限 + requestBody: + content: + application/json: + schema: + properties: + description: + description: 知识库描述 + type: string + id: + description: 知识库ID + format: uuid + type: string + name: + description: 知识库名称 + type: string + required: + - id + - name + - description + type: object + required: true + responses: + "200": + description: 更新成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + created_at: + format: date-time + type: string + description: + description: 知识库描述 + type: string + id: + format: uuid + type: string + name: + description: 知识库名称 + type: string + path: + description: 知识库路径 + type: string + ref_status: + description: 是否被引用 + type: boolean + tags: + description: 标签列表 + items: + type: string + type: array + updated_at: + format: date-time + type: string + user_id: + description: 创建者用户ID + type: string + user_name: + description: 创建者用户名 + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 修改知识库。 + + Returns: + dict: 更新后的知识库信息 + tags: + - 知识库管理 + /kb/upload: + post: + description: 上传单个文件到系统,支持格式:.xls, .xlsx, .doc, .docx, .zip, .csv, .json, .txt, .pdf, + .html, .tex, .md, .ppt, .pptx, .xml。单个文件最大50MB,zip文件最大500MB。需要写入权限 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 要上传的文件,支持格式:.xls, .xlsx, .doc, .docx, .zip, .csv, .json, + .txt, .pdf, .html, .tex, .md, .ppt, .pptx, + .xml。单个文件最大50MB,zip文件最大500MB + type: string + format: binary + required: + - file + responses: + "200": + description: 上传成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + files: + description: 文件列表 + items: + properties: + created_at: + format: date-time + type: string + file_md5: + description: 文件MD5值 + type: string + file_path: + description: 文件路径 + type: string + file_type: + description: 文件类型 + type: string + id: + format: uuid + type: string + knowledge_base_id: + description: 所属知识库ID + format: uuid + type: string + name: + description: 文件名 + type: string + size: + description: 文件大小(字节) + type: integer + storage_type: + description: 存储类型 + type: string + updated_at: + format: date-time + type: string + used: + description: 是否已使用 + type: boolean + user_id: + description: 用户ID + type: string + type: object + type: array + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 上传单个文件。 + + Returns: + dict: 上传成功的文件信息 + tags: + - 知识库管理 + /key_exchange: + post: + description: 进行 ECDH 密钥交换,获取会话密钥用于数据加密 + requestBody: + content: + application/json: + schema: + properties: + frontend_public_key: + description: 前端公钥(Base64编码) + type: string + required: + - frontend_public_key + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 进行 ECDH 密钥交换 + + 请求格式: + { + "frontend_public_key": "Base64编码的前端公钥" + } + + 响应格式: + { + "backend_public_key": "Base64编码的后端公钥", + "session_id": "会话ID(UUID)", + "expires_in": 300, + "algorithm": "ECDH-P256 + AES-256-GCM" + } + + Returns: + dict: 包含后端公钥和会话 ID 的字典 + + Raises: + ValueError: 当前端公钥格式错误时抛出 + tags: + - auth + /login: + post: + description: 使用用户名/邮箱/手机号和密码进行登录 + requestBody: + $ref: "#/components/requestBodies/Body14" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 用户密码登录。 + + 接收 encrypted_data 和 session_id 参数,使用 ECDH 会话密钥解密。 + 请求数据应包含:name 或 email 或 phone(至少一个),以及 password + + 使用用户名/邮箱和密码进行身份验证并登录系统。 + 验证成功后记录登录日志并返回访问令牌。 + + Returns: + dict: 包含登录成功结果和访问令牌的字典 + + Raises: + ValueError: 当身份验证失败时抛出 + tags: + - auth + /login_sms: + post: + description: 使用手机号和短信验证码进行登录 + requestBody: + $ref: "#/components/requestBodies/Body14" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 短信验证码登录。 + + 接收 encrypted_data 和 session_id 参数,使用 ECDH 会话密钥解密。 + 请求数据应包含:phone, verify_code + + 使用手机号和短信验证码进行身份验证并登录系统。 + 如果用户账号不存在,会缓存验证码用于后续注册流程。 + + Returns: + dict: 包含登录成功结果和访问令牌的字典 + + Raises: + ValueError: 当验证码验证失败或用户认证失败时抛出 + tags: + - auth + /logout: + get: + description: 注销当前用户会话 + responses: + "200": + description: 成功 + "401": + description: 未授权 + security: + - Bearer: [] + summary: |- + 用户退出登录。 + + 注销当前用户会话,删除访问令牌并记录退出日志。 + + Returns: + dict: 退出成功的结果字典 + tags: + - auth + /logs: + get: + description: 查询用户的操作日志,支持按日期、用户、模块、动作等条件筛选。所有时间参数均为北京时间(Asia/Shanghai),系统会自动转换为 UTC + 进行查询。只有管理员才有权查看其他用户的操作日志,普通用户只能查看自己的日志,需要登录 + parameters: + - description: 开始日期,格式为 YYYY-MM-DD,默认为今天。所有时间参数均为北京时间(Asia/Shanghai) + in: query + name: start_date + required: false + schema: + type: string + format: date + - description: 结束日期,格式为 YYYY-MM-DD,默认为今天。所有时间参数均为北京时间(Asia/Shanghai) + in: query + name: end_date + required: false + schema: + type: string + format: date + - description: 操作的详细信息,支持模糊匹配 + in: query + name: details + required: false + schema: + type: string + - description: 分页页码,从 1 开始 + in: query + name: page + required: false + schema: + type: integer + minimum: 1 + default: 1 + - description: 每页记录数 + in: query + name: per_page + required: false + schema: + type: integer + minimum: 1 + maximum: 100 + default: 10 + - description: 组织的唯一标识符。如果有组织ID,查询该组织下所有用户的操作日志(当前日志中并未记录日志所属的工作空间信息,故该参数无效) + in: query + name: organization_id + required: false + schema: + type: string + default: "" + - description: 用户账户ID。只有管理员才有权查看其他用户的操作日志,普通用户只能查看自己的日志 + in: query + name: account_id + required: false + schema: + type: string + default: "" + - description: 用户名称,支持模糊匹配 + in: query + name: user_name + required: false + schema: + type: string + - description: 操作模块名称,支持模糊匹配 + in: query + name: module + required: false + schema: + type: string + - description: 操作动作名称,支持模糊匹配 + in: query + name: action + required: false + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + data: + description: 日志列表 + items: + properties: + action: + description: 操作动作名称 + type: string + created_at: + description: 创建时间 + format: date-time + type: string + details: + description: 操作详细信息 + type: string + id: + description: 日志ID + type: integer + module: + description: 操作模块名称 + type: string + username: + description: 用户名 + type: string + type: object + type: array + page: + description: 当前页码 + type: integer + per_page: + description: 每页数量 + type: integer + total: + description: 总记录数 + type: integer + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: >- + 查询用户的操作日志。 + + + 所有时间参数均为北京时间(Asia/Shanghai),系统会自动转换为 UTC 进行查询。 + + 只有管理员才有权查看其他用户的操作日志,普通用户只能查看自己的日志。 + + + Args: + organization_id (int, optional): 组织的唯一标识符。如果有组织ID,查询该组织下所有用户的操作日志。 + start_date (str, optional): 开始日期,格式为 'YYYY-MM-DD'。如果有开始日期,过滤该日期之后的操作日志。 + end_date (str, optional): 结束日期,格式为 'YYYY-MM-DD'。如果有结束日期,过滤该日期之前的操作日志。 + details (str, optional): 操作的详细信息。如果有详细信息,模糊匹配该信息的操作日志。 + page (int, optional): 分页页码,默认为1。 + per_page (int, optional): 每页记录数,默认为10。 + account_id (str, optional): 用户账户ID。 + user_name (str, optional): 用户名称。 + module (str, optional): 操作模块名称。 + action (str, optional): 操作动作名称。 + + Returns: + dict: 包含操作日志数据的响应字典,包含data、total、page、per_page字段。 + + Raises: + ValueError: 当日期格式不正确时抛出。 + PermissionError: 当用户没有权限查看其他用户日志时抛出。 + tags: + - 操作日志 + /mcp/reference-result: + get: + description: 获取引用指定MCP工具的应用列表,需要登录 + parameters: + - description: MCP工具ID + in: query + name: id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + items: + properties: + id: + description: 应用ID + type: string + is_public: + description: 是否公开 + type: boolean + name: + description: 应用名称 + type: string + type: object + type: array + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 获取MCP工具引用结果 + tags: + - MCP工具 + /mcp/servers: + post: + description: 根据传入的查询条件获取MCP服务器的分页列表,支持按发布状态、启用状态、标签、名称等条件进行筛选,需要登录 + requestBody: + content: + application/json: + schema: + properties: + enable: + description: 启用状态 + type: boolean + page: + default: 1 + description: 页码,从 1 开始 + type: integer + page_size: + default: 20 + description: 每页大小 + type: integer + publish: + description: 发布状态列表 + items: + type: boolean + type: array + qtype: + default: already + description: 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + enum: + - mine + - group + - builtin + - already + type: string + search_name: + default: "" + description: 搜索名称 + type: string + search_tags: + default: [] + description: 搜索标签列表 + items: + type: string + type: array + user_id: + default: [] + description: 用户ID列表 + items: + type: string + type: array + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: MCP服务器列表 + items: + properties: + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 服务器描述 + type: string + enable: + description: 是否启用 + type: boolean + headers: + description: HTTP头 + type: object + http_url: + description: HTTP URL + type: string + icon: + description: 服务器图标 + type: string + id: + description: 服务器ID + type: integer + name: + description: 服务器名称 + type: string + publish: + description: 是否发布 + type: boolean + publish_at: + description: 发布时间 + format: date-time + type: string + publish_type: + description: 发布类型 + enum: + - group + - builtin + type: string + ref_status: + description: 引用状态 + type: boolean + stdio_arguments: + description: STDIO参数 + type: string + stdio_command: + description: STDIO命令 + type: string + stdio_env: + description: STDIO环境变量 + type: object + sync_tools_at: + description: 同步工具时间 + format: date-time + type: string + tags: + description: 标签列表 + items: + type: string + type: array + tenant_id: + description: 租户ID + type: string + test_state: + description: 测试状态 + enum: + - success + - error + - pending + type: string + timeout: + description: 超时时间 + type: integer + transport_type: + description: 传输类型 + enum: + - stdio + - http + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + page: + description: 当前页码 + type: integer + page_size: + description: 每页数量 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: >- + 获取MCP服务器分页列表。 + + + 根据传入的查询条件获取MCP服务器的分页列表,支持按发布状态、 + + 启用状态、标签、名称等条件进行筛选。 + + + Args: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + publish (list, optional): 发布状态列表。 + enable (bool, optional): 启用状态。 + qtype (str, optional): 查询类型,可选值:mine/group/builtin/already,默认为already。 + search_tags (list, optional): 搜索标签列表,默认为空列表。 + search_name (str, optional): 搜索名称,默认为空字符串。 + user_id (list, optional): 用户ID列表,默认为空列表。 + + Returns: + dict: 包含MCP服务器分页信息的字典。 + + Raises: + ValueError: 当请求参数不合法时抛出。 + tags: + - MCP工具 + /mcp/servers/check-name: + post: + description: 验证指定的服务器名称是否已经被使用,需要登录 + requestBody: + content: + application/json: + schema: + properties: + name: + description: 要检查的服务器名称 + type: string + required: + - name + type: object + description: 检查参数 + required: true + responses: + "200": + description: 名称可用 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 检查MCP服务器名称是否已存在。 + + 验证指定的服务器名称是否已经被使用。 + + Args: + name (str): 要检查的服务器名称。 + + Returns: + dict: 包含检查结果的字典,成功时返回{"message": "success", "code": 200}。 + + Raises: + ValueError: 当输入参数格式有误或名称已存在时抛出。 + tags: + - MCP工具 + /mcp/servers/create-update: + post: + description: 根据传入的数据创建新的MCP服务器或更新已存在的服务器。如果数据中包含id字段则进行更新,否则创建新服务器,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + description: + description: 服务器描述 + type: string + headers: + description: HTTP头 + type: object + http_url: + description: HTTP URL + type: string + icon: + description: 服务器图标 + type: string + id: + description: 服务器ID,如果提供则进行更新 + type: integer + name: + description: 服务器名称 + type: string + stdio_arguments: + description: STDIO参数 + type: string + stdio_command: + description: STDIO命令 + type: string + stdio_env: + description: STDIO环境变量 + type: object + timeout: + description: 超时时间 + type: integer + transport_type: + description: 传输类型:stdio 或 http + enum: + - stdio + - http + type: string + required: + - name + - transport_type + type: object + description: 服务器数据 + required: true + responses: + "200": + description: 创建或更新成功 + content: + "*/*": + schema: + properties: + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 服务器描述 + type: string + enable: + description: 是否启用 + type: boolean + headers: + description: HTTP头 + type: object + http_url: + description: HTTP URL + type: string + icon: + description: 服务器图标 + type: string + id: + description: 服务器ID + type: integer + name: + description: 服务器名称 + type: string + publish: + description: 是否发布 + type: boolean + publish_at: + description: 发布时间 + format: date-time + type: string + publish_type: + description: 发布类型 + enum: + - group + - builtin + type: string + ref_status: + description: 引用状态 + type: boolean + stdio_arguments: + description: STDIO参数 + type: string + stdio_command: + description: STDIO命令 + type: string + stdio_env: + description: STDIO环境变量 + type: object + sync_tools_at: + description: 同步工具时间 + format: date-time + type: string + tags: + description: 标签列表 + items: + type: string + type: array + tenant_id: + description: 租户ID + type: string + test_state: + description: 测试状态 + enum: + - success + - error + - pending + type: string + timeout: + description: 超时时间 + type: integer + transport_type: + description: 传输类型 + enum: + - stdio + - http + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建或更新MCP服务器。 + + 根据传入的数据创建新的MCP服务器或更新已存在的服务器。 + 如果数据中包含id字段则进行更新,否则创建新服务器。 + + Args: + name (str): 服务器名称。 + id (int, optional): 服务器ID,如果提供则进行更新。 + description (str, optional): 服务器描述。 + icon (str, optional): 服务器图标。 + transport_type (str): 传输类型。 + timeout (int, optional): 超时时间。 + stdio_command (str, optional): STDIO命令。 + stdio_arguments (str, optional): STDIO参数。 + stdio_env (dict, optional): STDIO环境变量。 + http_url (str, optional): HTTP URL。 + headers (dict, optional): HTTP头。 + + Returns: + dict: 包含创建或更新后服务器详细信息的字典。 + + Raises: + ValueError: 当输入参数不合法或缺少必要参数时抛出。 + tags: + - MCP工具 + /mcp/servers/delete: + post: + description: 删除指定的MCP服务器,删除前会检查服务器是否被引用,需要登录和管理员权限 + requestBody: + $ref: "#/components/requestBodies/Body15" + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 删除MCP服务器。 + + 删除指定的MCP服务器,删除前会检查服务器是否被引用。 + + Args: + id (int): 要删除的服务器ID。 + + Returns: + dict: 包含删除结果的字典。 + + Raises: + ValueError: 当输入参数不合法或服务器被引用时抛出。 + tags: + - MCP工具 + /mcp/servers/detail: + get: + description: 根据MCP服务器ID获取服务器的详细信息,需要登录 + parameters: + - description: MCP服务器ID + in: query + name: mcp_server_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 服务器描述 + type: string + enable: + description: 是否启用 + type: boolean + headers: + description: HTTP头 + type: object + http_url: + description: HTTP URL + type: string + icon: + description: 服务器图标 + type: string + id: + description: 服务器ID + type: integer + name: + description: 服务器名称 + type: string + publish: + description: 是否发布 + type: boolean + publish_at: + description: 发布时间 + format: date-time + type: string + publish_type: + description: 发布类型 + enum: + - group + - builtin + type: string + ref_status: + description: 引用状态 + type: boolean + stdio_arguments: + description: STDIO参数 + type: string + stdio_command: + description: STDIO命令 + type: string + stdio_env: + description: STDIO环境变量 + type: object + sync_tools_at: + description: 同步工具时间 + format: date-time + type: string + tags: + description: 标签列表 + items: + type: string + type: array + tenant_id: + description: 租户ID + type: string + test_state: + description: 测试状态 + enum: + - success + - error + - pending + type: string + timeout: + description: 超时时间 + type: integer + transport_type: + description: 传输类型 + enum: + - stdio + - http + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取MCP服务器详细信息。 + + 根据MCP服务器ID获取服务器的详细信息。 + + Args: + mcp_server_id (int): MCP服务器ID。 + + Returns: + dict: 包含MCP服务器详细信息的字典。 + + Raises: + ValueError: 当找不到指定的MCP服务器时抛出。 + ForbiddenError: 当用户没有读取权限时抛出。 + tags: + - MCP工具 + /mcp/servers/enable: + post: + description: 设置MCP服务器的启用状态,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + enable: + description: 是否启用服务器 + type: boolean + id: + description: 服务器ID + type: integer + required: + - id + - enable + type: object + description: 启用参数 + required: true + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 启用或禁用MCP服务器。 + + 设置MCP服务器的启用状态。 + + Args: + id (int): 服务器ID。 + enable (bool): 是否启用服务器。 + + Returns: + dict: 包含操作结果的字典。 + + Raises: + ValueError: 当输入参数不合法或缺少必要参数时抛出。 + tags: + - MCP工具 + /mcp/servers/publish: + post: + description: 将MCP服务器发布为可用状态,支持不同的发布类型,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + id: + description: 服务器ID + type: string + publish_type: + description: 发布类型:group(组) 或 builtin(内置) + enum: + - group + - builtin + type: string + required: + - id + - publish_type + type: object + description: 发布参数 + required: true + responses: + "200": + description: 发布成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 发布MCP服务器。 + + 将MCP服务器发布为可用状态,支持不同的发布类型。 + + Args: + id (str): 服务器ID。 + publish_type (str): 发布类型。 + + Returns: + dict: 包含发布结果的字典。 + + Raises: + ValueError: 当输入参数不合法时抛出。 + tags: + - MCP工具 + /mcp/servers/sync-tools: + post: + description: 从指定的MCP服务器同步工具,使用服务器端发送事件方式返回进度,需要登录和写入权限 + requestBody: + $ref: "#/components/requestBodies/Body15" + responses: + "200": + description: 同步成功(服务器端发送事件流) + content: + "*/*": + schema: + description: text/event-stream 格式的事件流 + type: string + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 同步MCP服务器的工具。 + + 从指定的MCP服务器同步工具,使用服务器端发送事件方式返回进度。 + + Args: + id (int): MCP服务器ID。 + + Returns: + Response: 服务器端发送事件流。 + + Raises: + ValueError: 当输入参数不合法或MCP服务器ID为空时抛出。 + ForbiddenError: 当用户没有写入权限时抛出。 + tags: + - MCP工具 + /mcp/tools: + post: + description: 根据MCP服务器ID获取对应的工具列表,需要登录 + requestBody: + content: + application/json: + schema: + properties: + mcp_server_id: + description: MCP服务器ID + type: integer + required: + - mcp_server_id + type: object + description: 查询参数 + required: true + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: MCP工具列表 + items: + properties: + additional_properties: + description: 附加属性 + type: object + annotations: + description: 注解 + type: object + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 工具描述 + type: string + id: + description: 工具ID + type: integer + input_schema: + description: 输入schema + type: object + mcp_server_id: + description: MCP服务器ID + type: integer + name: + description: 工具名称 + type: string + schema: + description: Schema + type: string + status: + description: 状态 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取MCP工具列表。 + + 根据MCP服务器ID获取对应的工具列表。 + + Args: + mcp_server_id (int): MCP服务器ID。 + + Returns: + dict: 包含MCP工具列表的字典。 + + Raises: + ValueError: 当输入参数不合法或MCP服务器ID为空时抛出。 + ForbiddenError: 当用户没有读取权限时抛出。 + tags: + - MCP工具 + /mcp/tools/detail: + get: + description: 根据工具ID获取MCP工具的详细信息,需要登录 + parameters: + - description: 工具ID + in: query + name: tool_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + additional_properties: + description: 附加属性 + type: object + annotations: + description: 注解 + type: object + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 工具描述 + type: string + id: + description: 工具ID + type: integer + input_schema: + description: 输入schema + type: object + mcp_server_id: + description: MCP服务器ID + type: integer + name: + description: 工具名称 + type: string + schema: + description: Schema + type: string + status: + description: 状态 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取MCP工具详细信息。 + + 根据工具ID获取MCP工具的详细信息。 + + Args: + tool_id (int): 工具ID。 + + Returns: + dict: 包含MCP工具详细信息的字典。 + + Raises: + ValueError: 当找不到指定的工具时抛出。 + tags: + - MCP工具 + /mcp/tools/test-tool: + post: + description: 使用指定的参数测试MCP工具的功能,并更新服务器的测试状态,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + mcp_server_id: + description: MCP服务器ID + type: integer + param: + description: 测试参数 + type: object + tool_id: + description: 工具ID + type: integer + required: + - mcp_server_id + - tool_id + type: object + description: 测试参数 + required: true + responses: + "200": + description: 测试成功 + content: + "*/*": + schema: + properties: + message: + description: 测试结果消息 + type: string + status: + example: 200 + type: integer + type: object + "400": + description: 测试失败 + content: + "*/*": + schema: + properties: + message: + description: 错误消息 + type: string + status: + example: 400 + type: integer + type: object + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 测试MCP工具。 + + 使用指定的参数测试MCP工具的功能,并更新服务器的测试状态。 + + Args: + mcp_server_id (int): MCP服务器ID。 + tool_id (int): 工具ID。 + param (dict, optional): 测试参数。 + + Returns: + dict: 包含测试结果的字典。 + + Raises: + ValueError: 当输入参数不合法或缺少必要参数时抛出。 + ForbiddenError: 当用户没有写入权限时抛出。 + tags: + - MCP工具 + /mh/check/model_name: + post: + description: 检查模型名称是否合法,验证名称是否已存在,需要登录 + requestBody: + content: + application/json: + schema: + properties: + model_from: + description: 模型来源 + type: string + model_name: + description: 模型名称(必需) + type: string + required: + - model_name + type: object + description: 检查参数 + required: true + responses: + "200": + description: 名称可用 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 检查模型名称是否合法。 + + Args: + model_name (str): 模型名称(必需)。 + model_from (str, optional): 模型来源。 + + Returns: + dict: 包含检查结果的字典。 + + Raises: + ValueError: 当模型名称已存在或模型已添加时抛出。 + tags: + - 模型仓库 + /mh/create: + post: + description: 创建新的模型,支持本地模型和在线模型,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + access_tokens: + description: 访问令牌 + type: string + description: + description: 模型描述 + type: string + model_brand: + description: 模型品牌 + type: string + model_dir: + description: 模型目录 + type: string + model_from: + description: 模型来源 + enum: + - localModel + - existModel + - hf + - ms + type: string + model_icon: + description: 模型图标路径 + type: string + model_key: + description: 模型密钥 + type: string + model_kind: + description: 模型种类 + type: string + model_list: + description: 模型列表 + type: string + model_name: + description: 模型名称 + type: string + model_type: + description: 模型类型(必需) + enum: + - local + - online + type: string + model_url: + description: 模型URL + type: string + prompt_keys: + description: 提示词密钥 + type: string + proxy_url: + description: 代理URL + type: string + tag_names: + description: 标签名称列表 + items: + type: string + type: array + required: + - model_type + type: object + description: 模型数据 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + api_key: + description: API密钥 + type: string + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 模型描述 + type: string + download_message: + description: 下载消息 + type: string + id: + description: 模型ID + type: string + model_brand: + description: 模型品牌 + type: string + model_dir: + description: 模型目录 + type: string + model_from: + description: 模型来源 + type: string + model_icon: + description: 模型图标 + type: string + model_key: + description: 模型密钥 + type: string + model_kind: + description: 模型种类 + type: string + model_kind_display: + description: 模型种类显示 + type: string + model_list: + description: 模型列表 + items: + properties: + is_finetune_model: + description: 是否为微调模型 + type: boolean + model_key: + description: 模型密钥 + type: string + model_name: + description: 模型名称 + type: string + type: object + type: array + model_name: + description: 模型名称 + type: string + model_path: + description: 模型路径 + type: string + model_status: + description: 模型状态 + type: string + model_type: + description: 模型类型 + type: string + model_url: + description: 模型URL + type: string + prompt_keys: + description: 提示词密钥 + type: string + tags: + description: 标签列表 + items: + type: string + type: array + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新模型。 + + Args: + model_type (str): 模型类型(必需)。 + model_icon (str, optional): 模型图标路径。 + model_name (str, optional): 模型名称。 + description (str, optional): 模型描述。 + model_from (str, optional): 模型来源。 + model_kind (str, optional): 模型种类。 + model_key (str, optional): 模型密钥。 + access_tokens (str, optional): 访问令牌。 + prompt_keys (str, optional): 提示词密钥。 + model_brand (str, optional): 模型品牌。 + model_url (str, optional): 模型URL。 + proxy_url (str, optional): 代理URL。 + model_list (str, optional): 模型列表。 + model_dir (str, optional): 模型目录。 + tag_names (list, optional): 标签名称列表。 + + Returns: + dict: 创建的模型信息,使用 model_fields 格式。 + + Raises: + CommonError: 当不支持的模型品牌时抛出。 + tags: + - 模型仓库 + /mh/create_finetune: + post: + description: 创建微调模型,基于指定的基础模型,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + access_tokens: + description: 访问令牌 + type: string + base_model_id: + description: 基础模型ID(必需) + type: integer + model_dir: + description: 模型目录 + type: string + model_from: + description: 模型来源(必需) + type: string + model_key: + description: 模型密钥 + type: string + model_name: + description: 模型名称 + type: string + model_type: + description: 模型类型 + type: string + prompt_keys: + description: 提示词密钥 + type: string + required: + - base_model_id + - model_from + type: object + description: 微调模型数据 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + api_key: + description: API密钥 + type: string + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 模型描述 + type: string + download_message: + description: 下载消息 + type: string + id: + description: 模型ID + type: string + model_brand: + description: 模型品牌 + type: string + model_dir: + description: 模型目录 + type: string + model_from: + description: 模型来源 + type: string + model_icon: + description: 模型图标 + type: string + model_key: + description: 模型密钥 + type: string + model_kind: + description: 模型种类 + type: string + model_kind_display: + description: 模型种类显示 + type: string + model_list: + description: 模型列表 + items: + properties: + is_finetune_model: + description: 是否为微调模型 + type: boolean + model_key: + description: 模型密钥 + type: string + model_name: + description: 模型名称 + type: string + type: object + type: array + model_name: + description: 模型名称 + type: string + model_path: + description: 模型路径 + type: string + model_status: + description: 模型状态 + type: string + model_type: + description: 模型类型 + type: string + model_url: + description: 模型URL + type: string + prompt_keys: + description: 提示词密钥 + type: string + tags: + description: 标签列表 + items: + type: string + type: array + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建微调模型。 + + Args: + base_model_id (int): 基础模型ID(必需)。 + model_from (str): 模型来源(必需)。 + model_key (str, optional): 模型密钥。 + access_tokens (str, optional): 访问令牌。 + prompt_keys (str, optional): 提示词密钥。 + model_type (str, optional): 模型类型。 + model_dir (str, optional): 模型目录。 + model_name (str, optional): 模型名称。 + + Returns: + dict: 创建的微调模型信息,使用 model_fields 格式。 + tags: + - 模型仓库 + /mh/create_online_model_list: + post: + description: 保存指定基础模型的在线模型列表,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + model_id: + description: 基础模型ID + type: integer + model_list: + description: 在线模型列表 + items: + properties: + can_finetune: + description: 是否可微调 + type: boolean + model_key: + description: 模型密钥 + type: string + type: object + type: array + required: + - model_id + - model_list + type: object + description: 在线模型列表数据 + required: true + responses: + "200": + description: 保存成功 + content: + "*/*": + schema: + properties: + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 保存在线模型列表。 + + Args: + model_id (int): 基础模型ID。 + model_list (list): 在线模型列表,每个元素包含 model_key 和 can_finetune 字段。 + + Returns: + dict: 保存操作的结果。 + + Raises: + ValueError: 当 model_id 或 model_list 为空时抛出。 + tags: + - 模型仓库 + /mh/default_icon_list: + get: + description: 获取系统默认的图标列表,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + items: + description: 图标路径 + type: string + type: array + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取默认图标列表。 + + Returns: + list: 默认图标列表。 + tags: + - 模型仓库 + /mh/delete: + post: + description: 删除指定的模型,删除前会检查模型是否被引用,需要登录和管理员权限 + parameters: + - description: 查询类型 + in: query + name: qtype + required: false + schema: + type: string + default: mine + requestBody: + content: + application/json: + schema: + properties: + model_id: + description: 模型ID(必需) + type: string + required: + - model_id + type: object + description: 删除参数 + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 删除模型。 + + Args: + model_id (str): 模型ID(必需)。 + qtype (str, optional): 查询类型。默认为"mine"。 + + Returns: + dict: 包含操作结果的字典。 + + Raises: + ValueError: 当模型被引用时抛出。 + tags: + - 模型仓库 + "/mh/delete_finetune_model/{model_id}/{finetune_model_id}": + delete: + description: 删除指定的微调模型,需要登录和管理员权限 + parameters: + - description: 模型ID + in: path + name: model_id + required: true + schema: + type: integer + - description: 微调模型ID + in: path + name: finetune_model_id + required: true + schema: + type: integer + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 删除微调模型。 + + Args: + model_id (int): 基础模型ID。 + finetune_model_id (int): 微调模型ID。 + + Returns: + dict: 删除操作的结果。 + tags: + - 模型仓库 + /mh/delete_online_model_list: + post: + description: 删除在线模型列表中的指定模型,需要登录和管理员权限 + requestBody: + content: + application/json: + schema: + properties: + model_id: + description: 基础模型ID + type: integer + model_keys: + description: 要删除的模型密钥列表 + items: + type: string + type: array + required: + - model_id + - model_keys + type: object + description: 删除参数 + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除在线模型列表中的指定模型。 + + Args: + model_id (int): 基础模型ID。 + model_keys (list): 要删除的模型密钥列表。 + + Returns: + dict: 删除操作的结果。 + + Raises: + ValueError: 当 model_id 或 model_keys 为空时抛出。 + CommonError: 当删除操作失败时抛出。 + tags: + - 模型仓库 + /mh/delete_uploaded_file: + post: + description: 删除上传但未被引用的模型文件或分片临时目录,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + file_dir: + description: 文件目录(必需) + type: string + filename: + description: 文件名(必需) + type: string + required: + - filename + - file_dir + type: object + description: 删除参数 + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除上传但未被引用的模型文件或分片临时目录。 + + Args: + filename (str): 文件名(必需)。 + file_dir (str): 文件目录(必需)。 + + Returns: + dict: 删除操作的结果。 + + Raises: + ValueError: 当 filename 或 file_dir 为空时抛出。 + Exception: 当删除操作失败时抛出。 + tags: + - 模型仓库 + /mh/exist_model_list: + get: + description: 获取已存在的第三方模型列表,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + items: + description: 已存在的模型信息 + type: object + type: array + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取已存在的第三方模型列表。 + + Returns: + list: 已存在的第三方模型列表。 + tags: + - 模型仓库 + /mh/finetune_model_page: + post: + description: 获取微调模型的分页列表,支持按模型ID筛选,需要登录 + requestBody: + content: + application/json: + schema: + properties: + model_id: + default: "0" + description: 模型ID筛选条件 + type: string + online_model_id: + default: "0" + description: 在线模型ID筛选条件 + type: string + page: + default: 1 + description: 页码 + type: integer + page_size: + default: 20 + description: 每页大小 + type: integer + qtype: + default: already + description: 查询类型 + enum: + - mine + - group + - builtin + - already + type: string + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 微调模型列表 + items: + properties: + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 模型描述 + type: string + finetune_task_id: + description: 微调任务ID + type: integer + id: + description: 模型ID + type: string + model_key: + description: 模型密钥 + type: string + model_name: + description: 模型名称 + type: string + model_status: + description: 模型状态 + type: string + source_info: + description: 来源信息 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + page: + description: 当前页码 + type: integer + page_size: + description: 每页数量 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取微调模型分页列表。 + + Args: + model_id (str, optional): 模型ID筛选条件。默认为0。 + online_model_id (str, optional): 在线模型ID筛选条件。默认为0。 + page (int, optional): 页码。默认为1。 + page_size (int, optional): 每页大小。默认为20。 + qtype (str, optional): 查询类型。默认为"already"。 + + Returns: + dict: 包含微调模型列表的分页数据,使用 finetune_pagination_fields 格式。 + tags: + - 模型仓库 + "/mh/finetune_retry_download/{model_id}/{finetune_model_id}": + get: + description: 重试下载指定的微调模型,只支持本地模型,需要登录和写入权限 + parameters: + - description: 模型ID + in: path + name: model_id + required: true + schema: + type: integer + - description: 微调模型ID + in: path + name: finetune_model_id + required: true + schema: + type: integer + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + example: true + type: boolean + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 重试下载微调模型。 + + Args: + model_id (int): 基础模型ID。 + finetune_model_id (int): 微调模型ID。 + + Returns: + bool: 操作成功返回True。 + + Raises: + CommonError: 当模型不支持重试下载或不是本地模型时抛出。 + tags: + - 模型仓库 + /mh/list: + post: + description: 根据传入的查询条件获取模型的分页列表,支持按模型类型、状态、标签、名称等条件进行筛选,需要登录 + requestBody: + content: + application/json: + schema: + properties: + available: + description: 可用性筛选条件 + type: integer + model_brand: + default: "" + description: 模型品牌筛选条件 + type: string + model_kind: + default: "" + description: 模型种类筛选条件 + type: string + model_type: + default: "" + description: 模型类型筛选条件 + type: string + page: + default: 1 + description: 页码,从 1 开始 + type: integer + page_size: + default: 20 + description: 每页大小 + type: integer + qtype: + default: already + description: 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + enum: + - mine + - group + - builtin + - already + type: string + search_name: + default: "" + description: 模型名称搜索条件 + type: string + search_tags: + default: [] + description: 标签搜索条件 + items: + type: string + type: array + status: + default: "" + description: 状态筛选条件 + type: string + tenant: + default: "" + description: 租户筛选条件 + type: string + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 模型列表 + items: + properties: + api_key: + description: API密钥 + type: string + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 模型描述 + type: string + download_message: + description: 下载消息 + type: string + id: + description: 模型ID + type: string + model_brand: + description: 模型品牌 + type: string + model_dir: + description: 模型目录 + type: string + model_from: + description: 模型来源 + type: string + model_icon: + description: 模型图标 + type: string + model_key: + description: 模型密钥 + type: string + model_kind: + description: 模型种类 + type: string + model_kind_display: + description: 模型种类显示 + type: string + model_list: + description: 模型列表 + items: + properties: + is_finetune_model: + description: 是否为微调模型 + type: boolean + model_key: + description: 模型密钥 + type: string + model_name: + description: 模型名称 + type: string + type: object + type: array + model_name: + description: 模型名称 + type: string + model_path: + description: 模型路径 + type: string + model_status: + description: 模型状态 + type: string + model_type: + description: 模型类型 + type: string + model_url: + description: 模型URL + type: string + prompt_keys: + description: 提示词密钥 + type: string + tags: + description: 标签列表 + items: + type: string + type: array + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + page: + description: 当前页码 + type: integer + page_size: + description: 每页数量 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查询模型翻页列表。 + + Args: + model_type (str, optional): 模型类型筛选条件。默认为空字符串。 + page (int, optional): 页码。默认为1。 + page_size (int, optional): 每页大小。默认为20。 + qtype (str, optional): 查询类型。默认为"already"。 + search_tags (list, optional): 标签搜索条件。默认为空列表。 + search_name (str, optional): 模型名称搜索条件。默认为空字符串。 + available (int, optional): 可用性筛选条件。 + status (str, optional): 状态筛选条件。默认为空字符串。 + model_kind (str, optional): 模型种类筛选条件。默认为空字符串。 + model_brand (str, optional): 模型品牌筛选条件。默认为空字符串。 + tenant (str, optional): 租户筛选条件。默认为空字符串。 + + Returns: + dict: 包含模型列表的分页数据,使用 model_pagination_fields 格式。 + tags: + - 模型仓库 + "/mh/model_info/{model_id}": + get: + description: 获取指定模型的详细信息,需要登录 + parameters: + - description: 模型ID + in: path + name: model_id + required: true + schema: + type: integer + - description: 查询类型 + in: query + name: qtype + required: false + schema: + type: string + default: mine + - description: 命名空间 + in: query + name: namespace + required: false + schema: + type: string + default: already + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + description: 模型详细信息 + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取模型详细信息。 + + Args: + model_id (int): 模型ID。 + qtype (str, optional): 查询类型。默认为"mine"。 + namespace (str, optional): 命名空间。默认为"already"。 + + Returns: + dict: 模型详细信息。 + tags: + - 模型仓库 + /mh/models_tree: + get: + description: 获取模型的树形结构数据,支持按模型类型、模型种类筛选,需要登录 + parameters: + - description: 查询类型 + in: query + name: qtype + required: true + schema: + type: string + enum: + - mine + - group + - builtin + - already + default: already + - description: 模型类型筛选条件 + in: query + name: model_type + required: false + schema: + type: string + default: "" + - description: 模型种类筛选条件 + in: query + name: model_kind + required: false + schema: + type: string + default: "" + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + description: 模型树结构数据 + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取模型树结构。 + + Args: + qtype (str, optional): 查询类型。默认为"already"。 + model_type (str, optional): 模型类型筛选条件。默认为空字符串。 + model_kind (str, optional): 模型种类筛选条件。默认为空字符串。 + + Returns: + dict: 模型树结构数据。 + tags: + - 模型仓库 + /mh/online_model_support_list: + get: + description: 获取系统支持的在线模型列表,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + items: + description: 在线模型信息 + type: object + type: array + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取支持的在线模型列表。 + + Returns: + list: 支持的在线模型列表。 + tags: + - 模型仓库 + "/mh/retry_download/{model_id}": + get: + description: 重试下载指定的模型,只支持从hf、ms导入的本地模型,需要登录 + parameters: + - description: 模型ID + in: path + name: model_id + required: true + schema: + type: integer + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + example: true + type: boolean + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 重试下载模型。 + + Args: + model_id (int): 模型ID。 + + Returns: + bool: 操作成功返回True。 + + Raises: + CommonError: 当模型不支持重试下载时抛出。 + tags: + - 模型仓库 + /mh/update: + post: + description: 更新模型的配置信息,主要是API密钥,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + api_key: + description: API密钥(必需) + type: string + model_id: + description: 模型ID(必需) + type: string + required: + - model_id + - api_key + type: object + description: 更新数据 + required: true + responses: + "200": + description: 更新成功 + content: + "*/*": + schema: + properties: + api_key: + description: API密钥 + type: string + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 模型描述 + type: string + download_message: + description: 下载消息 + type: string + id: + description: 模型ID + type: string + model_brand: + description: 模型品牌 + type: string + model_dir: + description: 模型目录 + type: string + model_from: + description: 模型来源 + type: string + model_icon: + description: 模型图标 + type: string + model_key: + description: 模型密钥 + type: string + model_kind: + description: 模型种类 + type: string + model_kind_display: + description: 模型种类显示 + type: string + model_list: + description: 模型列表 + items: + properties: + is_finetune_model: + description: 是否为微调模型 + type: boolean + model_key: + description: 模型密钥 + type: string + model_name: + description: 模型名称 + type: string + type: object + type: array + model_name: + description: 模型名称 + type: string + model_path: + description: 模型路径 + type: string + model_status: + description: 模型状态 + type: string + model_type: + description: 模型类型 + type: string + model_url: + description: 模型URL + type: string + prompt_keys: + description: 提示词密钥 + type: string + tags: + description: 标签列表 + items: + type: string + type: array + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 更新模型配置。 + + Args: + model_id (str): 模型ID(必需)。 + api_key (str): API密钥(必需)。 + + Returns: + dict: 更新后的模型信息,使用 model_fields 格式。 + + Raises: + CommonError: 当不支持的模型品牌时抛出。 + tags: + - 模型仓库 + /mh/update_apikey: + delete: + description: 清除数据库中的 api_key,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + model_brand: + description: 模型品牌(必需) + type: string + required: + - model_brand + type: object + description: 删除参数 + required: true + responses: + "200": + description: 清除成功 + content: + "*/*": + schema: + properties: + result: + type: object + status: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 清除数据库中的 api_key。 + + Args: + model_brand (str): 模型品牌(必需)。 + + Returns: + dict: 包含操作状态和结果的字典。 + tags: + - 模型仓库 + post: + description: 根据 model_brand 和 api_key 新增或更新 LazyModelConfigInfo 中的 api_key,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + api_key: + description: API密钥 + type: string + model_brand: + description: 模型品牌(必需) + type: string + proxy_auth_info: + description: 代理认证信息 + type: object + proxy_url: + description: 代理URL + type: string + required: + - model_brand + type: object + description: API密钥数据 + required: true + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + result: + type: object + status: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 根据 model_brand 和 api_key 新增或更新 LazyModelConfigInfo 中的 api_key。 + + Args: + model_brand (str): 模型品牌(必需)。 + api_key (str): API密钥(必需)。 + proxy_url (str, optional): 代理URL。 + proxy_auth_info (dict, optional): 代理认证信息。 + + Returns: + dict: 包含操作状态和结果的字典。 + tags: + - 模型仓库 + /mh/update_online_model_list: + post: + description: 更新指定基础模型的在线模型列表,需要登录和写入权限 + parameters: + - description: 查询类型 + in: query + name: qtype + required: false + schema: + type: string + default: already + requestBody: + content: + application/json: + schema: + properties: + base_model_id: + description: 基础模型ID + type: integer + required: + - base_model_id + type: object + description: 更新参数 + required: true + responses: + "200": + description: 更新成功 + content: + "*/*": + schema: + description: 更新操作的结果 + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 更新在线模型列表。 + + Args: + base_model_id (int): 基础模型ID。 + qtype (str, optional): 查询类型。默认为"already"。 + + Returns: + dict: 更新操作的结果。 + + Raises: + CommonError: 当模型不存在时抛出。 + tags: + - 模型仓库 + /mh/upload/chunk: + post: + description: 上传本地模型文件的分片,支持大文件分片上传,需要登录和写入权限 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 上传的文件分片 + type: string + format: binary + chunk_number: + description: 分片编号 + type: integer + total_chunks: + description: 总分片数 + type: integer + file_name: + description: 文件名 + type: string + file_dir: + description: 文件目录 + type: string + required: + - file + - chunk_number + - total_chunks + - file_name + - file_dir + responses: + "200": + description: 上传成功 + content: + "*/*": + schema: + properties: + message: + example: 当前分片 1/10 上传成功 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 上传本地模型文件分片。 + + Args: + file (FileStorage): 上传的文件分片。 + chunk_number (int): 分片编号。 + total_chunks (int): 总分片数。 + filename (str): 文件名。 + file_dir (str): 文件目录。 + + Returns: + dict: 包含上传结果的字典。 + + Raises: + ValueError: 当未上传文件或上传多个文件时抛出。 + tags: + - 模型仓库 + /mh/upload/icon: + post: + description: 上传模型图标文件,支持jpg、jpeg、png、gif、bmp格式,需要登录和写入权限 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 图标文件 + type: string + format: binary + required: + - file + responses: + "200": + description: 上传成功 + content: + "*/*": + schema: + properties: + file_path: + description: 文件路径 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 上传模型图标文件。 + + Args: + file (FileStorage): 上传的文件对象。 + + Returns: + dict: 包含文件路径的字典。 + + Raises: + ValueError: 当文件格式不支持或未上传文件时抛出。 + tags: + - 模型仓库 + /mh/upload/merge: + post: + description: 合并上传的本地模型文件分片,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + file_dir: + description: 文件目录(必需) + type: string + filename: + description: 文件名(必需) + type: string + required: + - filename + - file_dir + type: object + description: 合并参数 + required: true + responses: + "200": + description: 合并成功 + content: + "*/*": + schema: + properties: + id: + description: 文件ID + type: integer + name: + description: 文件名 + type: string + path: + description: 文件路径 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 合并本地模型文件分片。 + + Args: + filename (str): 文件名(必需)。 + file_dir (str): 文件目录(必需)。 + + Returns: + dict: 合并后的文件信息,使用 file_fields 格式。 + + Raises: + ValueError: 当文件名为空时抛出。 + tags: + - 模型仓库 + /model_evalution/all_model: + get: + description: 获取可用于评估的模型列表,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + result: + description: 模型列表 + items: + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取可用的评估模型列表。 + + Returns: + dict: 评估模型列表。 + tags: + - 模型评测 + /model_evalution/all_online_datasets: + get: + description: 获取可用的在线评估数据集列表,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + result: + description: 在线数据集列表 + items: + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取在线评估数据。 + + Returns: + dict: 在线评估数据列表。 + tags: + - 模型评测 + /model_evalution/create_task: + post: + description: 创建新的评估任务,支持人工测评和AI测评两种方式,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + ai_evaluator_name: + description: AI评估器名称(当evaluation_method为ai时必填) + type: string + dataset_id: + description: 数据集ID列表 + items: + type: integer + type: array + dimensions: + description: 评估维度列表 + items: + properties: + ai_base_score: + type: integer + dimension_description: + type: string + dimension_name: + type: string + options: + items: + properties: + option_description: + type: string + value: + type: integer + type: object + type: array + type: object + type: array + evaluation_method: + description: 评估方法:manual(人工测评)/ai(AI测评) + enum: + - manual + - ai + type: string + evaluation_type: + description: 评估类型:offline(离线)/online(在线) + enum: + - offline + - online + type: string + model_name: + description: 测评模型名称 + type: string + prompt: + description: AI评估prompt(当evaluation_method为ai时可选,需包含{scene}、{scene_descrp}、{standard}、{instruction}、{output}、{response}占位符) + type: string + task_name: + description: 任务名称 + type: string + required: + - task_name + - dataset_id + - evaluation_method + - model_name + - evaluation_type + - dimensions + type: object + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: 任务创建成功 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新的评估任务。 + + Args: + 通过JSON请求体传递参数: + name (str): 任务名称。 + description (str, optional): 任务描述。 + dataset_ids (list): 数据集ID列表。 + model_ids (list): 模型ID列表。 + evaluation_dimensions (list): 评估维度列表。 + + Returns: + dict: 创建结果信息,包含任务ID。 + + Raises: + ValueError: 当必要参数缺失时抛出异常。 + tags: + - 模型评测 + "/model_evalution/delete_task/{task_id}": + post: + description: 删除指定的评估任务,需要登录和管理员权限 + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: 任务删除成功 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除指定的评估任务。 + + Args: + task_id (str): 评估任务ID。 + + Returns: + dict: 删除结果信息。 + + Raises: + ValueError: 当任务ID为空或任务不存在时抛出异常。 + tags: + - 模型评测 + /model_evalution/evaluate_save: + post: + description: 提交评估结果,支持人工测评和AI测评,需要登录和管理员权限 + requestBody: + content: + application/json: + schema: + properties: + data_id: + description: 数据ID + type: integer + evaluations: + description: 评估数据列表 + items: + properties: + dimension_id: + description: 维度ID + type: integer + option_select_id: + description: 选项ID(人工测评) + type: integer + score: + description: 评分(AI测评) + type: integer + type: object + type: array + task_id: + description: 任务ID + type: integer + required: + - task_id + - data_id + - evaluations + type: object + required: true + responses: + "200": + description: 提交成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: 提交成功 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 执行评估任务。 + + Args: + 通过JSON请求体传递参数: + task_id (str): 评估任务ID。 + evaluation_data (list): 评估数据列表。 + + Returns: + dict: 评估结果信息。 + + Raises: + ValueError: 当必要参数缺失或任务不存在时抛出异常。 + tags: + - 模型评测 + "/model_evalution/evaluation_data/{task_id}": + get: + description: 分页获取指定任务的评估数据,支持按选项筛选,需要登录 + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: integer + - description: 页码 + in: query + name: page + required: false + schema: + type: integer + - description: 选项ID(用于报告查看) + in: query + name: option_select_id + required: false + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + result: + description: 评估数据分页结果 + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取评估数据分页列表。 + + Args: + task_id (str): 评估任务ID。 + 通过URL参数传递: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + + Returns: + dict: 分页结果,包含评估数据列表和分页信息。 + tags: + - 模型评测 + "/model_evalution/evaluation_datasettpl_download/{template_type}": + get: + description: 下载评估数据集的模板文件,支持xlsx、csv、json三种格式,不需要登录 + parameters: + - description: 模板类型:xlsx/csv/json + in: path + name: template_type + required: true + schema: + type: string + enum: + - xlsx + - csv + - json + responses: + "200": + description: 下载成功 + content: + "*/*": + schema: + type: string + format: binary + "400": + description: 参数错误 + "401": + description: 未授权 + "404": + description: 资源不存在 + summary: |- + 下载指定类型的评估数据集模板。 + + Args: + template_type (str): 模板类型。 + + Returns: + Response: 模板文件下载响应。 + + Raises: + ValueError: 当模板类型不支持时抛出异常。 + tags: + - 模型评测 + "/model_evalution/evaluation_summary/{task_id}": + get: + description: 获取指定任务的评估总结信息,包括各维度的统计信息,需要登录 + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + result: + properties: + created_by: + description: 创建者 + type: string + dimensions: + description: 维度总结列表 + items: + properties: + average_score: + description: 平均分 + type: number + dimension_name: + description: 维度名称 + type: string + indicators: + description: 指标列表(仅人工测评) + items: + properties: + name: + type: string + option_id: + type: integer + percentage: + type: string + score: + type: number + total_score: + type: number + type: object + type: array + std_dev: + description: 标准差 + type: number + total_score: + description: 总分 + type: number + type: object + type: array + evaluation_method: + description: 评估方法 + type: string + progress: + description: 任务进度 + type: string + task_name: + description: 任务名称 + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取指定任务的评估总结信息。 + + Args: + task_id (str): 评估任务ID。 + + Returns: + dict: 评估总结信息。 + + Raises: + ValueError: 当任务不存在时抛出异常。 + tags: + - 模型评测 + "/model_evalution/evaluation_summary_download/{task_id}": + get: + description: 下载评估任务的Excel报告文件,可通过token参数进行认证,不需要登录(通过token认证) + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: integer + - description: 认证令牌 + in: query + name: token + required: false + schema: + type: string + responses: + "200": + description: 下载成功 + content: + "*/*": + schema: + type: string + format: binary + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + summary: |- + 下载评估任务的Excel报告。 + + Args: + task_id (str): 评估任务ID。 + 通过URL参数传递: + token (str, optional): 认证令牌。 + + Returns: + Response: Excel文件下载响应。 + + Raises: + ValueError: 当任务不存在或认证失败时抛出异常。 + tags: + - 模型评测 + "/model_evalution/get_evaluation_dimensions/{task_id}": + get: + description: 获取指定任务的评估维度信息,包括维度选项,需要登录 + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + result: + description: 评估维度列表 + items: + properties: + ai_base_score: + description: AI基础分值 + type: integer + dimension_description: + description: 维度描述 + type: string + dimension_name: + description: 维度名称 + type: string + id: + description: 维度ID + type: integer + options: + description: 维度选项列表 + items: + properties: + id: + description: 选项ID + type: integer + option_description: + description: 选项描述 + type: string + value: + description: 选项分值 + type: integer + type: object + type: array + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取指定任务的评估维度信息。 + + Args: + task_id (str): 评估任务ID。 + + Returns: + dict: 评估维度信息。 + + Raises: + ValueError: 当任务不存在时抛出异常。 + tags: + - 模型评测 + /model_evalution/list: + get: + description: 分页获取评估任务列表,支持按关键词和查询类型筛选,需要登录 + parameters: + - description: 页码,从1开始 + in: query + name: page + schema: + type: integer + default: 1 + - description: 每页数量 + in: query + name: per_page + schema: + type: integer + default: 10 + - description: 搜索关键词 + in: query + name: keyword + required: false + schema: + type: string + - description: 查询类型 + in: query + name: qtype + required: false + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + result: + properties: + current_page: + description: 当前页码 + type: integer + pages: + description: 总页数 + type: integer + per_page: + description: 每页数量 + type: integer + tasks: + description: 任务列表 + items: + properties: + created_time: + format: date-time + type: string + creator: + description: 创建者 + type: string + evaluation_method: + description: 评估方法 + type: string + id: + description: 任务ID + type: integer + model_name: + description: 模型名称 + type: string + name: + description: 任务名称 + type: string + process: + description: 任务进度 + type: string + status: + description: 任务状态 + type: string + status_zh: + description: 任务状态(中文) + type: string + type: object + type: array + total: + description: 总记录数 + type: integer + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取评估任务分页列表。 + + Args: + 通过URL参数传递: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + + Returns: + dict: 分页结果,包含任务列表和分页信息。 + tags: + - 模型评测 + "/model_evalution/task_info/{task_id}": + get: + description: 获取指定评估任务的详细信息,需要登录 + parameters: + - description: 任务ID + in: path + name: task_id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + result: + properties: + task_info: + properties: + ai_eva_fail: + description: AI评估失败数 + type: integer + ai_eva_success: + description: AI评估成功数 + type: integer + ai_evaluator_name: + description: AI评估器名称 + type: string + created_time: + format: date-time + type: string + evaluation_method: + description: 评估方法(manual/ai) + type: string + id: + description: 任务ID + type: integer + model_name: + description: 模型名称 + type: string + name: + description: 任务名称 + type: string + process: + description: 任务进度 + type: string + status: + description: 任务状态 + type: string + status_zh: + description: 任务状态(中文) + type: string + username: + description: 创建者用户名 + type: string + type: object + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取指定评估任务的详细信息。 + + Args: + task_id (str): 评估任务ID。 + + Returns: + dict: 任务详细信息。 + + Raises: + ValueError: 当任务不存在时抛出异常。 + tags: + - 模型评测 + /model_evalution/upload_dataset: + post: + description: 上传评估数据集文件,支持格式:json、csv、xlsx、zip、tar.gz。单个文件最大1GB,需要登录 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + files: + description: 要上传的文件列表,支持格式:json、csv、xlsx、zip、tar.gz。单个文件最大1GB + type: string + format: binary + required: + - files + responses: + "200": + description: 上传成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: 上传文件成功 + type: string + result: + properties: + dataset_id: + description: 数据集ID + type: integer + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 上传评估数据集文件。 + + Args: + 通过multipart/form-data传递参数: + files: 要上传的文件列表。 + + Returns: + dict: 上传结果信息,包含数据集ID。 + + Raises: + Exception: 当文件上传、解压或处理失败时抛出异常。 + tags: + - 模型评测 + /notifications/create: + post: + description: 创建新的通知,支持多用户通知场景,创建包含用户通知和审批人通知的完整通知记录,需要登录 + requestBody: + content: + application/json: + schema: + properties: + created_at: + description: 创建时间 + type: string + module: + description: 模块名称,如"quota_request" + type: string + notify_user1_body: + description: 通知用户1的内容 + type: string + notify_user1_id: + description: 通知用户1的ID + type: string + notify_user1_read: + default: false + description: 通知用户1是否已读 + type: boolean + notify_user1_read_time: + description: 通知用户1的阅读时间 + type: string + notify_user2_body: + description: 通知用户2的内容 + type: string + notify_user2_id: + description: 通知用户2的ID + type: string + notify_user2_read: + default: false + description: 通知用户2是否已读 + type: boolean + notify_user2_read_time: + description: 通知用户2的阅读时间 + type: string + source_id: + description: 源对象ID + type: string + user_body: + description: 用户通知内容 + type: string + user_id: + description: 用户ID + type: string + user_read: + default: false + description: 用户是否已读 + type: boolean + user_read_time: + description: 用户阅读时间 + type: string + required: + - module + - source_id + - user_id + - user_body + - notify_user1_id + - notify_user1_body + type: object + description: 通知数据 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + created_at: + description: 创建时间 + type: string + id: + description: 通知ID + type: string + module: + description: 消息所属模块 + type: string + notify_user1_body: + description: 通知人1消息体 + type: string + notify_user1_id: + description: 通知人1的ID + type: string + notify_user1_read: + description: 通知人1是否已读 + type: boolean + notify_user1_read_time: + description: 通知人1已读时间 + type: string + notify_user2_body: + description: 通知人2消息体 + type: string + notify_user2_id: + description: 通知人2的ID + type: string + notify_user2_read: + description: 通知人2是否已读 + type: boolean + notify_user2_read_time: + description: 通知人2已读时间 + type: string + source_id: + description: 来源ID + type: string + user_body: + description: 用户回执消息体 + type: string + user_id: + description: 用户ID + type: string + user_read: + description: 用户是否已读回执消息 + type: boolean + user_read_time: + description: 用户已读回执时间 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新的通知。 + + 创建包含用户通知和审批人通知的完整通知记录。 + + Args: + module (str): 模块名称,如"quota_request"。 + source_id (str): 源对象ID。 + user_id (str): 用户ID。 + user_body (str): 用户通知内容。 + user_read (bool): 用户是否已读。 + user_read_time (str): 用户阅读时间。 + notify_user1_id (str): 通知用户1的ID。 + notify_user1_body (str): 通知用户1的内容。 + notify_user1_read (bool): 通知用户1是否已读。 + notify_user1_read_time (str): 通知用户1的阅读时间。 + notify_user2_id (str, optional): 通知用户2的ID。 + notify_user2_body (str, optional): 通知用户2的内容。 + notify_user2_read (bool, optional): 通知用户2是否已读。 + notify_user2_read_time (str, optional): 通知用户2的阅读时间。 + created_at (str): 创建时间。 + + Returns: + dict: 创建的通知信息字典。 + + Raises: + ValueError: 当必需参数缺失时。 + Exception: 当创建通知失败时。 + tags: + - 系统消息 + /notifications/detail: + get: + description: 获取指定通知的详细信息,只有管理员或通知所属用户才能查看,需要登录 + parameters: + - description: 通知ID + in: query + name: notification_id + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + created_at: + description: 创建时间 + type: string + id: + description: 通知ID + type: string + module: + description: 消息所属模块 + type: string + notify_user1_body: + description: 通知人1消息体 + type: string + notify_user1_id: + description: 通知人1的ID + type: string + notify_user1_read: + description: 通知人1是否已读 + type: boolean + notify_user1_read_time: + description: 通知人1已读时间 + type: string + notify_user2_body: + description: 通知人2消息体 + type: string + notify_user2_id: + description: 通知人2的ID + type: string + notify_user2_read: + description: 通知人2是否已读 + type: boolean + notify_user2_read_time: + description: 通知人2已读时间 + type: string + source_id: + description: 来源ID + type: string + user_body: + description: 用户回执消息体 + type: string + user_id: + description: 用户ID + type: string + user_read: + description: 用户是否已读回执消息 + type: boolean + user_read_time: + description: 用户已读回执时间 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取通知详情。 + + 获取指定通知的详细信息。 + + Args: + notification_id (str): 通知ID,通过查询参数传递。 + + Returns: + dict: 通知详细信息字典。 + + Raises: + ValueError: 当通知ID缺失或无权限查看时。 + Exception: 当获取通知详情失败时。 + tags: + - 系统消息 + /notifications/list: + post: + description: 支持分页、所有字段过滤、时间区间过滤的消息列表查询,需要登录 + requestBody: + content: + application/json: + schema: + properties: + created_at_end: + description: 创建时间结束 + type: string + created_at_start: + description: 创建时间开始 + type: string + module: + description: 模块名称过滤 + type: string + page: + default: 1 + description: 页码,从 1 开始 + type: integer + page_size: + default: 100 + description: 每页数量 + type: integer + source_id: + description: 来源ID过滤 + type: string + user_read: + default: false + description: 用户是否已读过滤 + type: boolean + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + items: + description: 通知列表 + items: + properties: + created_at: + description: 创建时间 + type: string + id: + description: 通知ID + type: string + module: + description: 消息所属模块 + type: string + notify_user1_body: + description: 通知人1消息体 + type: string + notify_user1_id: + description: 通知人1的ID + type: string + notify_user1_read: + description: 通知人1是否已读 + type: boolean + notify_user1_read_time: + description: 通知人1已读时间 + type: string + notify_user2_body: + description: 通知人2消息体 + type: string + notify_user2_id: + description: 通知人2的ID + type: string + notify_user2_read: + description: 通知人2是否已读 + type: boolean + notify_user2_read_time: + description: 通知人2已读时间 + type: string + source_id: + description: 来源ID + type: string + user_body: + description: 用户回执消息体 + type: string + user_id: + description: 用户ID + type: string + user_read: + description: 用户是否已读回执消息 + type: boolean + user_read_time: + description: 用户已读回执时间 + type: string + type: object + type: array + page: + description: 当前页码 + type: integer + page_size: + description: 每页数量 + type: integer + pages: + description: 总页数 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取通知列表。 + + 支持分页、所有字段过滤、时间区间过滤的消息列表查询。 + + Args: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页数量,默认为100。 + created_at_start (str, optional): 创建时间开始。 + created_at_end (str, optional): 创建时间结束。 + user_read (bool, optional): 用户是否已读过滤。 + **filters: 其他过滤条件。 + + Returns: + dict: 包含通知列表和分页信息的字典。 + + Raises: + Exception: 当查询失败时。 + tags: + - 系统消息 + /notifications/read: + post: + description: 通过通知ID和用户ID将通知标记为已读,需要登录 + requestBody: + content: + application/json: + schema: + properties: + notification_id: + description: 通知ID + type: string + required: + - notification_id + type: object + description: 标记参数 + required: true + responses: + "200": + description: 标记成功 + content: + "*/*": + schema: + properties: + created_at: + description: 创建时间 + type: string + id: + description: 通知ID + type: string + module: + description: 消息所属模块 + type: string + notify_user1_body: + description: 通知人1消息体 + type: string + notify_user1_id: + description: 通知人1的ID + type: string + notify_user1_read: + description: 通知人1是否已读 + type: boolean + notify_user1_read_time: + description: 通知人1已读时间 + type: string + notify_user2_body: + description: 通知人2消息体 + type: string + notify_user2_id: + description: 通知人2的ID + type: string + notify_user2_read: + description: 通知人2是否已读 + type: boolean + notify_user2_read_time: + description: 通知人2已读时间 + type: string + source_id: + description: 来源ID + type: string + user_body: + description: 用户回执消息体 + type: string + user_id: + description: 用户ID + type: string + user_read: + description: 用户是否已读回执消息 + type: boolean + user_read_time: + description: 用户已读回执时间 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 标记通知为已读。 + + 通过通知ID和用户ID将通知标记为已读。 + + Args: + notification_id (str): 通知ID。 + + Returns: + dict: 更新后的通知信息字典。 + + Raises: + ValueError: 当通知ID为空时。 + Exception: 当标记已读失败时。 + tags: + - 系统消息 + "/oauth/authorize/{provider}": + get: + description: 处理 OAuth 授权完成后的回调请求 + parameters: + - description: OAuth 提供商名称 + in: path + name: provider + required: true + schema: + type: string + enum: + - github + - description: OAuth 授权码 + in: query + name: code + required: true + schema: + type: string + responses: + "200": + description: 成功 + "302": + description: 重定向到绑定页面或登录成功页面 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 处理OAuth回调请求。 + + 处理OAuth授权完成后的回调,获取用户信息并进行登录或绑定流程。 + 如果用户账号不存在或未绑定手机号,将跳转到手机绑定页面。 + 如果账号已存在,则直接登录并返回访问令牌。 + + Args: + provider (str): OAuth提供商名称(如'github') + + Returns: + Response: 重定向响应,跳转到绑定页面或登录成功页面 + + Raises: + ValueError: 当提供商不存在时抛出 + HTTPError: 当OAuth授权失败时抛出 + tags: + - auth + post: + description: 完成 OAuth 账号与手机号的绑定 + parameters: + - description: OAuth 提供商名称 + in: path + name: provider + required: true + schema: + type: string + enum: + - github + requestBody: + content: + application/json: + schema: + properties: + openid: + description: OAuth 用户ID + type: string + phone: + description: 手机号 + type: string + verify_code: + description: 短信验证码 + type: string + required: + - openid + - phone + - verify_code + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 完成OAuth账号与手机号绑定。 + + 处理OAuth账号绑定手机号的请求,验证短信验证码后创建或关联账号。 + 支持以下场景: + 1. 手机号已存在账号:直接关联 + 2. 邮箱已存在账号:更新手机号 + 3. 全新用户:创建新账号 + + Args: + provider (str): OAuth提供商名称(如'github') + + Returns: + dict: 包含登录成功结果和访问令牌的字典 + + Raises: + ValueError: 当提供商不存在、信息过期或验证码错误时抛出 + tags: + - auth + "/oauth/login/{provider}": + get: + description: 启动 OAuth 登录流程,重定向到 OAuth 提供商授权页面 + parameters: + - description: OAuth 提供商名称 + in: path + name: provider + required: true + schema: + type: string + enum: + - github + responses: + "200": + description: 成功 + "302": + description: 重定向到 OAuth 授权页面 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 启动OAuth登录流程。 + + 生成OAuth授权URL并重定向用户到OAuth提供商的授权页面。 + + Args: + provider (str): OAuth提供商名称(如'github') + + Returns: + Response: 重定向响应,跳转到OAuth授权页面 + + Raises: + ValueError: 当提供商不存在或配置无效时抛出 + tags: + - auth + /prompt: + post: + description: 创建新的提示信息,支持包含名称、描述、内容和分类的提示信息,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + category: + default: null + description: 提示信息的分类 + type: string + content: + description: 提示信息的内容(必需) + type: string + describe: + default: "" + description: 提示信息的描述 + type: string + name: + description: 提示信息的名称(必需) + type: string + required: + - name + - content + type: object + description: 提示信息数据 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + id: + description: 创建的提示信息ID + type: integer + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新的提示信息。 + + 解析请求中的JSON数据,包括提示信息的名称、描述、内容和分类信息, + 调用PromptService创建新的提示信息并返回创建成功后的ID。 + + Args: + name (str): 提示信息的名称,必填。 + describe (str, optional): 提示信息的描述,默认为空字符串。 + content (str): 提示信息的内容,必填。 + category (str, optional): 提示信息的分类,默认为None。 + + Returns: + dict: 包含创建成功的提示信息ID的响应字典。 + + Raises: + ValueError: 当参数错误或名称为空时抛出。 + tags: + - Prompt + "/prompt/delete/{id}": + post: + description: 根据提示信息ID删除提示信息,内置提示信息需要超级管理员权限,需要登录和管理员权限 + parameters: + - description: 提示信息ID + in: path + name: id + required: true + schema: + type: integer + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: 删除成功 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 处理POST请求,删除指定ID的提示信息。 + + - 调用PromptService的delete_prompt方法删除提示信息。 + - 如果删除成功,记录日志并返回成功消息。 + - 如果提示信息不存在,记录错误日志并返回错误消息。 + tags: + - Prompt + /prompt/list: + post: + description: 分页获取所有提示信息的列表,支持按查询类型、标签、名称、用户ID等条件筛选,需要登录 + requestBody: + content: + application/json: + schema: + properties: + page: + default: 1 + description: 页码,从 1 开始 + type: integer + per_page: + default: 10 + description: 每页数量 + type: integer + qtype: + default: already + description: 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + enum: + - mine + - group + - builtin + - already + type: string + search_name: + default: "" + description: 名称搜索条件 + type: string + search_tags: + default: [] + description: 标签搜索条件 + items: + type: string + type: array + user_id: + default: [] + description: 用户ID筛选 + items: + type: string + type: array + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + current_page: + description: 当前页码 + type: integer + next_page: + description: 下一页页码 + type: integer + pages: + description: 总页数 + type: integer + prev_page: + description: 上一页页码 + type: integer + prompts: + description: 提示信息列表 + items: + properties: + category: + description: 提示信息分类 + type: string + content: + description: 提示信息内容 + type: string + created_at: + description: 创建时间 + format: date-time + type: string + describe: + description: 提示信息描述 + type: string + id: + description: 提示信息ID + type: integer + name: + description: 提示信息名称 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + type: object + type: array + total: + description: 总记录数 + type: integer + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 处理GET请求,分页获取所有提示信息。 + + - 解析请求中的分页参数,包括当前页码和每页数量。 + - 调用PromptService的list_prompt方法获取提示信息列表和分页信息。 + - 返回提示信息列表和分页信息。 + tags: + - Prompt + "/prompt/{id}": + get: + description: 根据提示信息ID获取其详细信息,包括名称、描述、内容、分类和时间戳等,需要登录 + parameters: + - description: 提示信息ID + in: path + name: id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + properties: + category: + description: 提示信息分类 + type: string + content: + description: 提示信息内容 + type: string + created_at: + description: 创建时间 + format: date-time + type: string + describe: + description: 提示信息描述 + type: string + id: + description: 提示信息ID + type: integer + name: + description: 提示信息名称 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + type: object + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 获取指定ID的提示信息。 + + 调用PromptService获取提示信息的详细内容,包括权限检查。 + 如果提示信息不存在则返回错误消息。 + + Args: + id (int): 提示信息的唯一标识符。 + + Returns: + dict: 包含提示信息详细内容的响应字典,包括id、name、describe、 + content、category、created_at、updated_at字段。 + + Raises: + ValueError: 当提示信息不存在时返回400状态码。 + tags: + - Prompt + post: + description: 根据提示信息ID和用户提交的数据更新提示信息,内置提示信息需要超级管理员权限,需要登录和写入权限 + parameters: + - description: 提示信息ID + in: path + name: id + required: true + schema: + type: integer + requestBody: + content: + application/json: + schema: + properties: + category: + description: 提示信息的分类 + type: string + content: + description: 提示信息的内容 + type: string + describe: + description: 提示信息的描述 + type: string + name: + description: 提示信息的名称 + type: string + template_id: + description: 模板ID + type: integer + type: object + description: 提示信息数据 + required: true + responses: + "200": + description: 更新成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: 修改成功 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 处理POST请求,更新指定ID的提示信息。 + + - 解析请求中的JSON数据,包括提示信息的名称、描述、内容和模板ID。 + - 调用PromptService的update_prompt方法更新提示信息。 + - 如果更新成功,返回成功消息。 + - 如果提示信息不存在,返回错误消息。 + tags: + - Prompt + /register: + post: + description: 注册新用户账号,需要提供加密后的用户信息和短信验证码 + requestBody: + content: + application/json: + schema: + properties: + encrypted_data: + description: 加密后的注册数据(Base64编码) + type: string + session_id: + description: 会话ID(从密钥交换接口获取) + format: uuid + type: string + required: + - encrypted_data + - session_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 注册新用户账号。 + + 接收 encrypted_data 和 session_id 参数,使用 ECDH 会话密钥解密。 + 请求数据应包含:name, email, phone, password, confirm_password, verify_code + + Returns: + dict: 登录成功后的令牌信息 + + Raises: + ValueError: 当输入信息无效或密码不一致时抛出 + tags: + - auth + /script/create: + post: + description: 创建新的脚本 + requestBody: + content: + application/json: + schema: + properties: + data_type: + description: 数据类型 + enum: + - doc + - pic + type: string + description: + description: 脚本描述 + type: string + icon: + description: 脚本图标 + type: string + name: + description: 脚本名称 + type: string + script_type: + description: 脚本类型 + type: string + script_url: + description: 脚本URL + type: string + required: + - name + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建新脚本。 + + Args: + 通过JSON请求体传递参数: + name (str): 脚本名称。 + description (str, optional): 脚本描述。 + icon (str, optional): 脚本图标,默认为"/app/upload/script.jpg"。 + script_url (str, optional): 脚本URL。 + script_type (str, optional): 脚本类型。 + data_type (str, optional): 数据类型。 + + Returns: + dict: 创建的脚本信息。 + + Raises: + ValueError: 当缺少必要参数时抛出异常。 + tags: + - 数据集 + /script/delete: + post: + description: 删除指定的脚本 + requestBody: + content: + application/json: + schema: + properties: + script_id: + description: 脚本ID + type: integer + required: + - script_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 删除指定脚本。 + + Args: + 通过JSON请求体传递参数: + script_id (int): 脚本ID。 + + Returns: + tuple: (响应数据, HTTP状态码) + + Raises: + ValueError: 当脚本ID为空时抛出异常。 + tags: + - 数据集 + /script/list: + post: + description: 获取脚本分页列表,支持按脚本类型、名称、标签等条件筛选 + requestBody: + content: + application/json: + schema: + properties: + name: + description: 脚本名称 + type: string + page: + default: 1 + description: 页码,从1开始 + minimum: 1 + type: integer + page_size: + default: 20 + description: 每页大小 + maximum: 100 + minimum: 1 + type: integer + qtype: + default: already + description: 查询类型 + type: string + script_type: + description: 脚本类型列表 + items: + type: string + type: array + search_name: + description: 搜索名称 + type: string + search_tags: + description: 搜索标签列表 + items: + type: string + type: array + user_id: + description: 用户ID列表 + items: + type: string + type: array + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取脚本分页列表。 + + Args: + 通过JSON请求体传递参数: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + script_type (list, optional): 脚本类型列表。 + name (str, optional): 脚本名称。 + qtype (str, optional): 查询类型,默认为"already"。 + search_tags (list, optional): 搜索标签列表。 + search_name (str, optional): 搜索名称。 + user_id (list, optional): 用户ID列表。 + + Returns: + dict: 分页结果,包含脚本列表和分页信息。 + tags: + - 数据集 + /script/list_by_type: + get: + description: 根据脚本类型获取脚本列表 + parameters: + - description: 脚本类型 + in: query + name: script_type + required: false + schema: + type: string + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 根据脚本类型获取脚本列表。 + + Args: + 通过URL参数传递: + script_type (str): 脚本类型。 + + Returns: + list: 指定类型的脚本列表。 + tags: + - 数据集 + /script/update: + post: + description: 更新指定脚本的信息 + requestBody: + content: + application/json: + schema: + properties: + data_type: + description: 数据类型 + enum: + - doc + - pic + type: string + description: + description: 脚本描述 + type: string + icon: + description: 脚本图标 + type: string + name: + description: 脚本名称 + type: string + script_id: + description: 脚本ID + type: integer + script_type: + description: 脚本类型 + type: string + script_url: + description: 脚本URL + type: string + required: + - script_id + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 更新指定脚本信息。 + + Args: + 通过JSON请求体传递参数: + script_id (int): 脚本ID。 + name (str, optional): 脚本名称。 + description (str, optional): 脚本描述。 + icon (str, optional): 脚本图标。 + script_url (str, optional): 脚本URL。 + script_type (str, optional): 脚本类型。 + data_type (str, optional): 数据类型。 + + Returns: + dict: 更新后的脚本信息。 + + Raises: + ValueError: 当脚本ID为空时抛出异常。 + tags: + - 数据集 + /script/upload: + post: + description: 上传脚本文件(.py格式),文件大小不能超过1MB + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + file: + description: 脚本文件(.py格式) + type: string + format: binary + required: + - file + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 上传脚本文件。 + + Args: + 通过multipart/form-data传递参数: + file: 上传的脚本文件,必须是.py格式。 + + Returns: + dict: 上传结果信息。 + + Raises: + ValueError: 当没有上传文件、文件类型不支持或上传多个文件时抛出异常。 + tags: + - 数据集 + /sendsms: + post: + description: 向指定手机号发送短信验证码 + requestBody: + content: + application/json: + schema: + properties: + operation: + description: 操作类型 + enum: + - login + - register + - reset + - relate + type: string + phone: + description: 手机号 + type: string + required: + - phone + - operation + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + security: [] + summary: |- + 发送短信验证码。 + + 根据指定的操作类型向手机号发送短信验证码。 + 支持的操作类型包括:login、register、reset、relate。 + + Returns: + dict: 发送成功的结果字典 + + Raises: + ValueError: 当发送频率过快或其他验证失败时抛出 + tags: + - auth + /tags: + get: + description: 根据标签类型和关键词查询标签列表 + parameters: + - description: 标签类型,必填 + in: query + name: type + required: true + schema: + type: string + enum: + - knowledgebase + - app + - model + - tool + - prompt + - dataset + - script + - mcp + - description: 搜索关键词,可选 + in: query + name: keyword + required: false + schema: + type: string + default: "" + responses: + "200": + description: 成功 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查询标签列表。 + + 根据指定的标签类型和可选的关键词查询标签列表。 + + Args: + type (str): 标签类型,必填,必须是预定义的标签类型之一。 + keyword (str, optional): 搜索关键词,默认为空字符串。 + + Returns: + list: 包含标签信息的列表。 + + Raises: + ValueError: 当标签类型不在允许的选项中时抛出。 + tags: + - 标签管理 + /tags/bindings/update: + post: + description: 更新目标对象与标签的绑定关系 + requestBody: + content: + application/json: + schema: + properties: + tag_names: + description: 标签名称列表 + items: + type: string + type: array + target_id: + description: 目标对象ID + type: string + type: + description: 标签类型 + enum: + - knowledgebase + - app + - model + - tool + - prompt + - dataset + - script + - mcp + type: string + required: + - type + - target_id + - tag_names + type: object + required: true + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 更新关系 + tags: + - 标签管理 + /tags/create: + post: + description: 创建一个新的内置标签,只有超级用户可以执行此操作 + requestBody: + $ref: "#/components/requestBodies/Body2" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 创建内置标签。 + + 创建一个新的内置标签,只有超级用户可以执行此操作。 + + Args: + name (str): 标签名称,必填。 + type (str): 标签类型,必填,必须是预定义的标签类型之一。 + + Returns: + dict: 包含新创建标签的id、name、type信息的字典。 + + Raises: + ValueError: 当参数错误或标签类型不合法时抛出。 + PermissionError: 当用户不是超级用户时抛出。 + tags: + - 标签管理 + /tags/delete: + post: + description: 删除指定的标签 + requestBody: + $ref: "#/components/requestBodies/Body2" + responses: + "200": + description: 成功 + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 删除标签 + tags: + - 标签管理 + /tool/auth: + get: + description: 处理OAuth授权回调,不需要登录 + parameters: + - description: 授权码 + in: query + name: code + required: false + schema: + type: string + - description: 状态 + in: query + name: state + required: false + schema: + type: string + responses: + "200": + description: 授权成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: [] + summary: 授权回调 + tags: + - 工具 + /tool/auth_share: + post: + description: 设置工具的授权分享状态,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + share_status: + description: 分享状态 + type: boolean + tool_id: + description: 工具ID + type: string + required: + - tool_id + - share_status + type: object + description: 分享参数 + required: true + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 授权分享 + tags: + - 工具 + /tool/cancel_publish: + post: + description: 取消工具的发布状态,需要登录和写入权限 + requestBody: + $ref: "#/components/requestBodies/Body4" + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 发布工具 + tags: + - 工具 + /tool/check_name: + post: + description: 验证指定的工具名称是否已经被使用,需要登录 + requestBody: + content: + application/json: + schema: + properties: + name: + description: 要检查的工具名称 + type: string + required: + - name + type: object + description: 检查参数 + required: true + responses: + "200": + description: 名称可用 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 检查名字重复 + tags: + - 工具 + /tool/copy_tool: + post: + description: 复制一份新的工具,需要登录和读取权限 + requestBody: + $ref: "#/components/requestBodies/Body4" + responses: + "200": + description: 复制成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 复制一份新的工具 + tags: + - 工具 + /tool/create_update_field: + post: + description: 创建或更新工具的字段(API+IDE两种模式都有),每次都是新增数据,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + fields: + description: 工具字段列表 + items: + properties: + default_value: + description: 默认值 + type: string + description: + description: 字段描述 + type: string + field_format: + description: 字段格式 + type: string + field_type: + description: 字段类型 + type: string + field_use_model: + description: 带入方法 + type: string + id: + description: 字段ID,如果提供则进行更新 + type: integer + name: + description: 字段名称 + type: string + required: + description: 是否必填 + type: boolean + tool_id: + description: 工具ID + type: string + visible: + description: 是否可见 + type: boolean + type: object + type: array + required: + - fields + type: object + description: 工具字段数据 + required: true + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + save_error: + description: 保存错误 + type: string + save_success_field: + description: 成功保存的字段列表 + items: + type: object + type: array + update_error: + description: 更新错误 + type: string + update_success_field: + description: 成功更新的字段列表 + items: + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: field部分的页面编辑(API+IDE两种模式都有,每次都是新增数据) + tags: + - 工具 + /tool/create_update_tool: + post: + description: 根据传入的数据创建新的工具或更新已存在的工具。如果数据中包含id字段则进行更新,否则创建新工具,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + description: + description: 工具描述 + type: string + icon: + description: 工具图标 + type: string + id: + description: 工具ID,如果提供则进行更新 + type: string + name: + description: 工具名称(必需) + type: string + tool_ide_code: + description: 工具IDE代码 + type: string + tool_ide_code_type: + description: 工具IDE代码类型 + type: string + tool_kind: + description: 工具类别 + type: string + tool_mode: + description: 工具模式:API 或 IDE + enum: + - API + - IDE + type: string + tool_type: + description: 工具类型 + enum: + - 官方内置 + - 自定义 + type: string + required: + - name + type: object + description: 工具数据 + required: true + responses: + "200": + description: 创建或更新成功 + content: + "*/*": + schema: + properties: + auth: + description: 是否授权 0-默认值 1-授权 2-未授权 3已过期 + type: integer + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 工具描述 + type: string + enable: + description: 是否启用 + type: boolean + icon: + description: 工具图标 + type: string + id: + description: 工具ID + type: string + name: + description: 工具名称 + type: string + need_share: + description: 是否展示共享按钮 + type: boolean + publish: + description: 是否发布 + type: boolean + publish_at: + description: 发布时间 + format: date-time + type: string + publish_type: + description: 发布类型 + type: string + ref_status: + description: 引用状态 + type: boolean + share: + description: 共享状态 + type: boolean + tags: + description: 标签列表 + items: + type: string + type: array + test_state: + description: 测试状态 + type: string + tool_api_id: + description: 工具API ID + type: string + tool_field_input_ids: + description: 工具字段输入ID列表 + items: + type: integer + type: array + tool_field_output_ids: + description: 工具字段输出ID列表 + items: + type: integer + type: array + tool_ide_code: + description: 工具IDE代码 + type: string + tool_ide_code_type: + description: 工具IDE代码类型 + type: string + tool_kind: + description: 工具类别 + type: string + tool_mode: + description: 工具模式 + type: string + tool_type: + description: 工具类型 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 创建与更新工具 + tags: + - 工具 + /tool/delete_auth_by_user: + post: + description: 删除工具的用户授权,需要登录和写入权限 + requestBody: + $ref: "#/components/requestBodies/Body6" + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 删除授权 + tags: + - 工具 + /tool/delete_tool: + post: + description: 删除指定的工具,需要登录和管理员权限 + requestBody: + $ref: "#/components/requestBodies/Body4" + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 删除工具 + tags: + - 工具 + /tool/enable_tool: + post: + description: 设置工具的启用状态,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + enable: + description: 是否启用工具 + type: boolean + id: + description: 工具ID + type: string + required: + - id + - enable + type: object + description: 启用参数 + required: true + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 启用工具 + tags: + - 工具 + /tool/export: + get: + description: 导出工具为JSON格式,支持直接返回JSON或下载文件,需要登录和读取权限 + parameters: + - description: 工具ID + in: query + name: id + required: true + schema: + type: integer + - description: 导出格式:json 或 file + in: query + name: format + required: false + schema: + type: string + responses: + "200": + description: 导出成功 + content: + "*/*": + schema: + description: 工具JSON数据或文件下载 + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 导出文件 + tags: + - 工具 + /tool/list: + post: + description: 根据传入的查询条件获取工具的分页列表,支持按工具类型、发布状态、启用状态、标签、名称等条件进行筛选,需要登录 + requestBody: + content: + application/json: + schema: + properties: + enabled: + description: 启用状态列表 + items: + type: boolean + type: array + is_draft: + default: true + description: 是否为草稿 + type: boolean + page: + default: 1 + description: 页码,从 1 开始 + type: integer + page_size: + default: 20 + description: 每页大小 + type: integer + published: + description: 发布状态列表 + items: + type: boolean + type: array + qtype: + default: already + description: 查询类型:mine(我的)、group(组)、builtin(内置)、already(已有) + enum: + - mine + - group + - builtin + - already + type: string + search_name: + default: "" + description: 名称搜索条件 + type: string + search_tags: + default: [] + description: 标签搜索条件 + items: + type: string + type: array + tool_mode: + default: [] + description: 工具模式列表 + items: + type: string + type: array + tool_type: + default: "" + description: 工具类型 + type: string + user_id: + default: [] + description: 用户ID列表 + items: + type: string + type: array + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 工具列表 + items: + properties: + auth: + description: 是否授权 0-默认值 1-授权 2-未授权 3已过期 + type: integer + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 工具描述 + type: string + enable: + description: 是否启用 + type: boolean + icon: + description: 工具图标 + type: string + id: + description: 工具ID + type: string + name: + description: 工具名称 + type: string + need_share: + description: 是否展示共享按钮 + type: boolean + publish: + description: 是否发布 + type: boolean + publish_at: + description: 发布时间 + format: date-time + type: string + publish_type: + description: 发布类型 + type: string + ref_status: + description: 引用状态 + type: boolean + share: + description: 共享状态 + type: boolean + tags: + description: 标签列表 + items: + type: string + type: array + test_state: + description: 测试状态 + type: string + tool_api_id: + description: 工具API ID + type: string + tool_field_input_ids: + description: 工具字段输入ID列表 + items: + type: integer + type: array + tool_field_output_ids: + description: 工具字段输出ID列表 + items: + type: integer + type: array + tool_ide_code: + description: 工具IDE代码 + type: string + tool_ide_code_type: + description: 工具IDE代码类型 + type: string + tool_kind: + description: 工具类别 + type: string + tool_mode: + description: 工具模式 + type: string + tool_type: + description: 工具类型 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + page: + description: 当前页码 + type: integer + page_size: + description: 每页数量 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: >- + 获取工具分页列表。 + + + 根据传入的查询条件获取工具的分页列表,支持按工具类型、发布状态、 + + 启用状态、标签、名称等条件进行筛选。 + + + Args: + page (int, optional): 页码,默认为1。 + page_size (int, optional): 每页大小,默认为20。 + tool_type (str, optional): 工具类型,默认为空字符串。 + published (list, optional): 发布状态列表。 + enabled (list, optional): 启用状态列表。 + qtype (str, optional): 查询类型,可选值:mine/group/builtin/already,默认为already。 + search_tags (list, optional): 搜索标签列表,默认为空列表。 + search_name (str, optional): 搜索名称,默认为空字符串。 + tool_mode (list, optional): 工具模式列表,默认为空列表。 + user_id (list, optional): 用户ID列表,默认为空列表。 + + Returns: + dict: 包含工具分页信息的字典。 + + Raises: + ValueError: 当请求参数不合法时抛出。 + tags: + - 工具 + /tool/publish_tool: + post: + description: 将工具发布为可用状态,支持不同的发布类型,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + id: + description: 工具ID + type: string + publish_type: + default: 正式发布 + description: 发布类型:预发布 或 正式发布 + enum: + - 预发布 + - 正式发布 + type: string + required: + - id + type: object + description: 发布参数 + required: true + responses: + "200": + description: 发布成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 发布工具 + tags: + - 工具 + /tool/reference-result: + get: + description: 获取引用指定工具的应用列表,不需要登录 + parameters: + - description: 工具ID + in: query + name: id + required: true + schema: + type: integer + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + items: + properties: + id: + description: 应用ID + type: string + is_public: + description: 是否公开 + type: boolean + name: + description: 应用名称 + type: string + type: object + type: array + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: [] + summary: 获取工具引用结果 + tags: + - 工具 + /tool/return_auth_url: + post: + description: 生成对应的授权URL,需要登录和写入权限 + requestBody: + $ref: "#/components/requestBodies/Body6" + responses: + "200": + description: 生成成功 + content: + "*/*": + schema: + properties: + url: + description: 授权URL + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 生成授权URL + tags: + - 工具 + /tool/test: + post: + description: 测试工具日志功能,需要登录和写入权限 + requestBody: + $ref: "#/components/requestBodies/Body4" + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + description: 日志信息 + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 测试工具日志 + tags: + - 工具 + /tool/test_tool: + post: + description: 使用指定的参数测试工具的功能,需要登录和写入权限,需要启用工具运行功能 + requestBody: + content: + application/json: + schema: + properties: + id: + description: 工具ID + type: string + input: + default: {} + description: 输入参数 + type: object + vars_for_code: + default: {} + description: 代码变量 + type: object + required: + - id + type: object + description: 测试参数 + required: true + responses: + "200": + description: 测试成功 + content: + "*/*": + schema: + description: 测试结果 + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 测试工具 + tags: + - 工具 + /tool/tool_api: + get: + description: 根据工具ID获取工具的详细信息,需要登录 + parameters: + - description: 工具ID + in: query + name: tool_id + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + auth: + description: 是否授权 0-默认值 1-授权 2-未授权 3已过期 + type: integer + created_at: + description: 创建时间 + format: date-time + type: string + description: + description: 工具描述 + type: string + enable: + description: 是否启用 + type: boolean + icon: + description: 工具图标 + type: string + id: + description: 工具ID + type: string + name: + description: 工具名称 + type: string + need_share: + description: 是否展示共享按钮 + type: boolean + publish: + description: 是否发布 + type: boolean + publish_at: + description: 发布时间 + format: date-time + type: string + publish_type: + description: 发布类型 + type: string + ref_status: + description: 引用状态 + type: boolean + share: + description: 共享状态 + type: boolean + tags: + description: 标签列表 + items: + type: string + type: array + test_state: + description: 测试状态 + type: string + tool_api_id: + description: 工具API ID + type: string + tool_field_input_ids: + description: 工具字段输入ID列表 + items: + type: integer + type: array + tool_field_output_ids: + description: 工具字段输出ID列表 + items: + type: integer + type: array + tool_ide_code: + description: 工具IDE代码 + type: string + tool_ide_code_type: + description: 工具IDE代码类型 + type: string + tool_kind: + description: 工具类别 + type: string + tool_mode: + description: 工具模式 + type: string + tool_type: + description: 工具类型 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + user_id: + description: 用户ID + type: string + user_name: + description: 用户名 + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 工具详情 + tags: + - 工具 + /tool/tool_api_info: + get: + description: 获取工具的HTTP API配置详情,需要登录 + parameters: + - description: API ID + in: query + name: api_id + required: false + schema: + type: integer + default: 0 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + api_key: + description: API密钥 + type: string + audience: + description: 受众 + type: string + auth_method: + description: 认证方法 + type: string + authorization_content_type: + description: 授权内容类型 + type: string + authorization_url: + description: 授权URL + type: string + client_id: + description: 客户端ID + type: string + client_secret: + description: 客户端密钥 + type: string + client_url: + description: 客户端URL + type: string + created_at: + description: 创建时间 + format: date-time + type: string + endpoint_url: + description: 端点URL + type: string + grant_type: + description: 授权类型 + type: string + header: + description: 请求头 + type: object + id: + description: API ID + type: string + location: + description: 位置 + type: string + param_name: + description: 参数名 + type: string + request_type: + description: 请求类型 + type: string + scope: + description: 作用域 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + url: + description: URL + type: string + user_id: + description: 用户ID + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: HTTP部分的数据详情 + tags: + - 工具 + /tool/tool_fields: + post: + description: 获取工具字段的数据详情(API+IDE两种模式都有),需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + fields: + default: [] + description: 字段ID列表 + items: + type: integer + type: array + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 工具字段列表 + items: + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: field部分的数据详情(API+IDE两种模式都有) + tags: + - 工具 + /tool/upsert_tool_api: + post: + description: 创建或更新工具的HTTP API配置,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + api_key: + description: API密钥 + type: string + auth_method: + description: 认证方法 + type: string + header: + description: 请求头 + type: object + id: + description: API ID,如果提供则进行更新 + type: string + request_type: + description: 请求类型 + type: string + tool_id: + description: 工具ID + type: string + url: + description: URL + type: string + type: object + description: API数据 + required: true + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + api_key: + description: API密钥 + type: string + audience: + description: 受众 + type: string + auth_method: + description: 认证方法 + type: string + authorization_content_type: + description: 授权内容类型 + type: string + authorization_url: + description: 授权URL + type: string + client_id: + description: 客户端ID + type: string + client_secret: + description: 客户端密钥 + type: string + client_url: + description: 客户端URL + type: string + created_at: + description: 创建时间 + format: date-time + type: string + endpoint_url: + description: 端点URL + type: string + grant_type: + description: 授权类型 + type: string + header: + description: 请求头 + type: object + id: + description: API ID + type: string + location: + description: 位置 + type: string + param_name: + description: 参数名 + type: string + request_type: + description: 请求类型 + type: string + scope: + description: 作用域 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + url: + description: URL + type: string + user_id: + description: 用户ID + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: HTTP部分的页面编辑(每次都是新增就很诡异) + tags: + - 工具 + /workspaces/account/tenants: + get: + description: 查看用户加入的租户,需要登录 + parameters: + - description: 账户ID + in: query + name: account_id + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + tenants: + description: 租户列表 + items: + properties: + created_at: + description: 创建时间 + type: integer + current: + description: 是否为当前租户 + type: boolean + enable_ai: + description: 是否启用AI + type: boolean + gpu_quota: + description: GPU配额 + type: integer + gpu_used: + description: 已使用GPU + type: integer + has_assets: + description: 是否有资产 + type: boolean + id: + description: 租户ID + type: string + name: + description: 租户名称 + type: string + role: + description: 角色 + type: string + status: + description: 状态 + type: string + storage_quota: + description: 存储配额 + type: integer + storage_used: + description: 已使用存储 + type: number + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查看用户加入的租户。 + + Returns: + dict: 用户加入的租户列表 + tags: + - 工作空间 + /workspaces/add: + post: + description: 创建新的租户,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + name: + description: 租户名称 + type: string + required: + - name + type: object + description: 租户数据 + required: true + responses: + "200": + description: 创建成功 + content: + "*/*": + schema: + properties: + created_at: + description: 创建时间 + type: integer + current: + description: 是否为当前租户 + type: boolean + enable_ai: + description: 是否启用AI + type: boolean + gpu_quota: + description: GPU配额 + type: integer + gpu_used: + description: 已使用GPU + type: integer + has_assets: + description: 是否有资产 + type: boolean + id: + description: 租户ID + type: string + name: + description: 租户名称 + type: string + role: + description: 角色 + type: string + status: + description: 状态 + type: string + storage_quota: + description: 存储配额 + type: integer + storage_used: + description: 已使用存储 + type: number + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 添加租户。 + + Returns: + dict: 创建的租户信息 + tags: + - 工作空间 + /workspaces/ai-tool/list: + get: + description: 获取租户的AI能力配置,需要登录 + parameters: + - description: 租户ID,为空则使用当前租户 + in: query + name: tenant_id + required: false + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + data: + description: JSON格式的配置数据 + type: string + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 获取租户的AI能力配置。 + + 该函数用于获取租户的AI工具配置信息。 + + Args: + 无直接参数。请求体中应包含以下JSON字段: + tenant_id (str): 租户ID,选填,为空就代表设定当前租户。 + + Returns: + - 若成功,返回({"message": "success", "code": 200, "data": 数据}, 200) + tags: + - 工作空间 + /workspaces/ai-tool/set: + post: + description: 设置租户的AI能力配置,需要登录和超级管理员权限 + requestBody: + content: + application/json: + schema: + properties: + data: + description: AI工具配置数据列表 + items: + type: object + type: array + tenant_id: + description: 租户ID + type: string + required: + - data + - tenant_id + type: object + description: AI工具配置数据 + required: true + responses: + "200": + description: 设置成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 设置租户的AI能力配置。 + + 该函数用于批量更新指定租户的AI工具配置信息。首先删除该租户现有的所有AI工具配置, + 然后根据提供的数据创建新的AI工具配置记录。 + + Args: + 无直接参数。请求体中应包含以下JSON字段: + data (list): AI工具配置数据列表,必填。 + tenant_id (str): 租户ID,必填。 + + Returns: + - 若成功,返回({"message": "success", "code": 200}, 200) + - 若失败,返回({"message": 错误信息, "code": 400}, 400) + + Raises: + 无直接抛出异常,所有异常均被捕获并返回错误信息。 + tags: + - 工作空间 + /workspaces/all/members: + get: + description: 查看所有的用户,支持分页和搜索,需要登录 + parameters: + - description: 页码,从 1 开始 + in: query + name: page + required: false + schema: + type: integer + default: 1 + - description: 每页数量 + in: query + name: limit + required: false + schema: + type: integer + default: 20 + - description: 名称搜索 + in: query + name: search_name + required: false + schema: + type: string + - description: 电话搜索 + in: query + name: search_phone + required: false + schema: + type: string + - description: 邮箱搜索 + in: query + name: search_email + required: false + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 账户列表 + items: + properties: + avatar: + description: 头像 + type: string + created_at: + description: 创建时间 + type: integer + email: + description: 邮箱 + type: string + id: + description: 账户ID + type: string + last_active_at: + description: 最后活跃时间 + type: integer + last_login_at: + description: 最后登录时间 + type: integer + name: + description: 账户名称 + type: string + phone: + description: 电话 + type: string + role: + description: 角色 + type: string + status: + description: 状态 + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + limit: + description: 每页数量 + type: integer + page: + description: 当前页码 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查看所有的用户。 + + Returns: + dict: 包含分页用户列表的响应数据 + tags: + - 工作空间 + /workspaces/all/tenants: + get: + description: 查看所有的租户,支持分页和搜索,需要登录 + parameters: + - description: 页码,从 1 开始 + in: query + name: page + required: false + schema: + type: integer + default: 1 + - description: 每页数量 + in: query + name: limit + required: false + schema: + type: integer + default: 20 + - description: 名称搜索 + in: query + name: search_name + required: false + schema: + type: string + - description: 用户搜索 + in: query + name: search_user + required: false + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 租户列表 + items: + properties: + created_at: + description: 创建时间 + type: integer + current: + description: 是否为当前租户 + type: boolean + enable_ai: + description: 是否启用AI + type: boolean + gpu_quota: + description: GPU配额 + type: integer + gpu_used: + description: 已使用GPU + type: integer + has_assets: + description: 是否有资产 + type: boolean + id: + description: 租户ID + type: string + name: + description: 租户名称 + type: string + role: + description: 角色 + type: string + status: + description: 状态 + type: string + storage_quota: + description: 存储配额 + type: integer + storage_used: + description: 已使用存储 + type: number + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + limit: + description: 每页数量 + type: integer + page: + description: 当前页码 + type: integer + total: + description: 总记录数 + type: integer + user_id: + description: 用户ID + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查看所有的租户。 + + Returns: + dict: 包含分页租户列表的响应数据 + tags: + - 工作空间 + /workspaces/coop/close: + post: + description: 关闭指定目标的协作功能,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + target_id: + description: 目标ID + type: string + target_type: + description: 目标类型 + enum: + - app + - dataset + - knowledge_base + - doc + type: string + required: + - target_type + - target_id + type: object + description: 关闭参数 + required: true + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + accounts: + description: 账户列表 + items: + type: string + type: array + created_by: + description: 创建者 + type: string + enable: + description: 是否启用 + type: boolean + target_id: + description: 目标ID + type: string + target_type: + description: 目标类型 + type: string + tenant_id: + description: 租户ID + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 关闭协作 + tags: + - 工作空间 + /workspaces/coop/joins: + get: + description: 查看自己被加入协作的列表,需要登录 + parameters: + - description: 目标类型 + in: query + name: target_type + required: true + schema: + type: string + enum: + - app + - dataset + - knowledge_base + - doc + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: ID列表 + items: + type: string + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 查看自己被加入协作的列表 + tags: + - 工作空间 + /workspaces/coop/open: + post: + description: 打开指定目标的协作功能,需要登录和写入权限 + requestBody: + content: + application/json: + schema: + properties: + accounts: + description: 账户ID列表 + items: + type: string + type: array + target_id: + description: 目标ID + type: string + target_type: + description: 目标类型 + enum: + - app + - dataset + - knowledge_base + - doc + type: string + required: + - target_type + - target_id + - accounts + type: object + description: 协作参数 + required: true + responses: + "200": + description: 操作成功 + content: + "*/*": + schema: + properties: + accounts: + description: 账户列表 + items: + type: string + type: array + created_by: + description: 创建者 + type: string + enable: + description: 是否启用 + type: boolean + target_id: + description: 目标ID + type: string + target_type: + description: 目标类型 + type: string + tenant_id: + description: 租户ID + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 打开协作 + tags: + - 工作空间 + /workspaces/coop/status: + get: + description: 查询协作的设置详情,需要登录 + parameters: + - description: 目标类型 + in: query + name: target_type + required: true + schema: + type: string + enum: + - app + - dataset + - knowledge_base + - doc + - description: 目标ID + in: query + name: target_id + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + accounts: + description: 账户列表 + items: + type: string + type: array + created_by: + description: 创建者 + type: string + enable: + description: 是否启用 + type: boolean + target_id: + description: 目标ID + type: string + target_type: + description: 目标类型 + type: string + tenant_id: + description: 租户ID + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 查询协作的设置详情 + tags: + - 工作空间 + /workspaces/current/list: + get: + description: 查看当前用户加入的租户,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + tenants: + description: 租户列表 + items: + properties: + created_at: + description: 创建时间 + type: integer + current: + description: 是否为当前租户 + type: boolean + enable_ai: + description: 是否启用AI + type: boolean + gpu_quota: + description: GPU配额 + type: integer + gpu_used: + description: 已使用GPU + type: integer + has_assets: + description: 是否有资产 + type: boolean + id: + description: 租户ID + type: string + name: + description: 租户名称 + type: string + role: + description: 角色 + type: string + status: + description: 状态 + type: string + storage_quota: + description: 存储配额 + type: integer + storage_used: + description: 已使用存储 + type: number + type: object + type: array + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查看当前用户加入的租户。 + + Returns: + dict: 当前用户加入的租户列表 + tags: + - 工作空间 + /workspaces/current/tenant: + get: + description: 查看当前租户ID,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + tenant_id: + description: 当前租户ID + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查看当前租户。 + + Returns: + dict: 当前租户ID + tags: + - 工作空间 + /workspaces/delete: + post: + description: 删除指定的租户,需要登录和超级管理员或创建者权限 + requestBody: + content: + application/json: + schema: + properties: + tenant_id: + description: 租户ID + type: string + required: + - tenant_id + type: object + description: 删除参数 + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + result: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 删除租户 + tags: + - 工作空间 + /workspaces/delete-account: + post: + description: 删除指定的账户,需要登录和超级管理员权限 + requestBody: + content: + application/json: + schema: + properties: + account_id: + description: 账户ID + type: string + required: + - account_id + type: object + description: 账户ID + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + result: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 删除账户 + tags: + - 工作空间 + /workspaces/delete-role: + post: + description: 从租户中删除用户,需要登录和管理员权限 + requestBody: + content: + application/json: + schema: + properties: + account_id: + description: 账户ID + type: string + tenant_id: + description: 租户ID + type: string + required: + - tenant_id + - account_id + type: object + description: 删除参数 + required: true + responses: + "200": + description: 删除成功 + content: + "*/*": + schema: + properties: + result: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 从租户中删除用户 + tags: + - 工作空间 + /workspaces/detail: + get: + description: 查看租户详细信息和用户列表,需要登录和写入权限 + parameters: + - description: 租户ID + in: query + name: tenant_id + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + accounts: + description: 账户列表 + items: + type: object + type: array + created_at: + description: 创建时间 + type: integer + current: + description: 是否为当前租户 + type: boolean + enable_ai: + description: 是否启用AI + type: boolean + gpu_quota: + description: GPU配额 + type: integer + gpu_used: + description: 已使用GPU + type: integer + has_assets: + description: 是否有资产 + type: boolean + id: + description: 租户ID + type: string + name: + description: 租户名称 + type: string + role: + description: 角色 + type: string + status: + description: 状态 + type: string + storage_quota: + description: 存储配额 + type: integer + storage_used: + description: 已使用存储 + type: number + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: |- + 查看租户用户详细。 + + Returns: + dict: 租户详细信息和用户列表 + tags: + - 工作空间 + /workspaces/exit: + post: + description: 退出指定的租户,超管和创建者不能退出,需要登录 + requestBody: + content: + application/json: + schema: + properties: + tenant_id: + description: 租户ID + type: string + required: + - tenant_id + type: object + description: 退出参数 + required: true + responses: + "200": + description: 退出成功 + content: + "*/*": + schema: + properties: + result: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 退出租户 + tags: + - 工作空间 + /workspaces/move-assets: + post: + description: 在租户内迁移用户资产,需要登录和超级管理员权限 + requestBody: + content: + application/json: + schema: + properties: + source_account_id: + description: 源账户ID + type: string + target_account_id: + description: 目标账户ID + type: string + tenant_id: + description: 租户ID + type: string + required: + - tenant_id + - source_account_id + - target_account_id + type: object + description: 迁移参数 + required: true + responses: + "200": + description: 迁移成功 + content: + "*/*": + schema: + properties: + result: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 迁移资产 + tags: + - 工作空间 + /workspaces/personal-space/resources: + get: + description: 获取个人空间资源配置信息,需要登录 + parameters: + - description: 账户ID + in: query + name: account_id + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + description: 资源配置信息 + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 获取个人空间资源配置信息 + tags: + - 工作空间 + post: + description: 修改个人空间GPU配额,需要登录和超级管理员权限 + requestBody: + content: + application/json: + schema: + properties: + gpu_quota: + description: GPU配额 + type: integer + storage_quota: + description: 存储配额(GB) + type: integer + tenant_id: + description: 租户ID + type: string + required: + - gpu_quota + - storage_quota + - tenant_id + type: object + description: 个人空间数据 + required: true + responses: + "200": + description: 修改成功 + content: + "*/*": + schema: + properties: + result: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 修改个人空间GPU配额 + tags: + - 工作空间 + /workspaces/quota-requests/details: + get: + description: 获取配额申请详情,需要登录和超级管理员权限 + parameters: + - description: 申请ID + in: query + name: request_id + required: true + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + account_id: + description: 账户ID + type: string + account_name: + description: 账户名称 + type: string + approved_amount: + description: 批准数量 + type: integer + created_at: + description: 创建时间 + format: date-time + type: string + id: + description: 申请ID + type: string + processed_at: + description: 处理时间 + format: date-time + type: string + reason: + description: 申请原因 + type: string + reject_reason: + description: 拒绝原因 + type: string + request_type: + description: 申请类型 + type: string + requested_amount: + description: 申请数量 + type: integer + status: + description: 状态 + type: string + tenant_id: + description: 租户ID + type: string + tenant_name: + description: 租户名称 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + "404": + description: 资源不存在 + security: + - Bearer: [] + summary: 获取配额申请详情 + tags: + - 工作空间 + /workspaces/quota-requests/list: + post: + description: 获取工作空间配额申请列表,需要登录和超级管理员权限 + requestBody: + content: + application/json: + schema: + properties: + account_name: + description: 账户名称 + type: string + page: + default: 1 + description: 页码,从 1 开始 + type: integer + page_size: + default: 20 + description: 每页数量 + type: integer + request_type: + default: "" + description: 申请类型 + enum: + - storage + - gpu + type: string + status: + description: 状态 + enum: + - pending + - approved + - rejected + type: string + tenant_name: + default: "" + description: 租户名称 + type: string + type: object + description: 查询参数 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 配额申请列表 + items: + properties: + account_id: + description: 账户ID + type: string + account_name: + description: 账户名称 + type: string + approved_amount: + description: 批准数量 + type: integer + created_at: + description: 创建时间 + format: date-time + type: string + id: + description: 申请ID + type: string + processed_at: + description: 处理时间 + format: date-time + type: string + reason: + description: 申请原因 + type: string + reject_reason: + description: 拒绝原因 + type: string + request_type: + description: 申请类型 + type: string + requested_amount: + description: 申请数量 + type: integer + status: + description: 状态 + type: string + tenant_id: + description: 租户ID + type: string + tenant_name: + description: 租户名称 + type: string + updated_at: + description: 更新时间 + format: date-time + type: string + type: object + type: array + has_next: + description: 是否有下一页 + type: boolean + has_prev: + description: 是否有上一页 + type: boolean + page: + description: 当前页码 + type: integer + page_size: + description: 每页数量 + type: integer + pages: + description: 总页数 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 获取配额申请列表 + tags: + - 工作空间 + /workspaces/quota-requests/process: + post: + description: 管理员处理配额申请(批准或拒绝),需要登录和超级管理员权限 + requestBody: + content: + application/json: + schema: + properties: + action: + description: 操作类型:approve 或 reject + enum: + - approve + - reject + type: string + amount: + description: 批准数量(仅当 action 为 approve 时必需) + type: integer + reason: + description: 拒绝原因(仅当 action 为 reject 时必需) + type: string + request_id: + description: 申请ID + type: string + required: + - request_id + - action + type: object + description: 处理参数 + required: true + responses: + "200": + description: 处理成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 处理配额申请 + tags: + - 工作空间 + /workspaces/quota-requests/requests: + post: + description: 提交配额申请(存储或GPU),需要登录和管理员权限 + requestBody: + content: + application/json: + schema: + properties: + amount: + description: 申请数量 + type: integer + reason: + description: 申请原因 + type: string + tenant_id: + description: 租户ID + type: string + type: + description: 申请类型:storage 或 gpu + enum: + - storage + - gpu + type: string + required: + - type + - amount + - reason + - tenant_id + type: object + description: 申请数据 + required: true + responses: + "200": + description: 提交成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 提交配额申请 + tags: + - 工作空间 + /workspaces/select/members: + get: + description: 查看所有的用户(仅在选择用户列表中使用),支持分页和搜索,需要登录 + parameters: + - description: 页码,从 1 开始 + in: query + name: page + required: false + schema: + type: integer + default: 1 + - description: 每页数量 + in: query + name: limit + required: false + schema: + type: integer + default: 20 + - description: 名称搜索 + in: query + name: search_name + required: false + schema: + type: string + - description: 电话搜索 + in: query + name: search_phone + required: false + schema: + type: string + - description: 邮箱搜索 + in: query + name: search_email + required: false + schema: + type: string + - description: 租户ID + in: query + name: tenant_id + required: false + schema: + type: string + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 账户列表 + items: + properties: + avatar: + description: 头像 + type: string + created_at: + description: 创建时间 + type: integer + email: + description: 邮箱 + type: string + id: + description: 账户ID + type: string + last_active_at: + description: 最后活跃时间 + type: integer + last_login_at: + description: 最后登录时间 + type: integer + name: + description: 账户名称 + type: string + phone: + description: 电话 + type: string + role: + description: 角色 + type: string + status: + description: 状态 + type: string + type: object + type: array + has_more: + description: 是否有更多数据 + type: boolean + limit: + description: 每页数量 + type: integer + page: + description: 当前页码 + type: integer + total: + description: 总记录数 + type: integer + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 查看所有的用户(仅在选择用户列表中使用)。 + + Returns: + dict: 包含分页用户列表的响应数据 + tags: + - 工作空间 + /workspaces/storage/check: + get: + description: 查看当前工作组的存储空间使用情况,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + properties: + data: + description: 是否有可用空间 + type: boolean + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 查看当前工作组的存储空间使用情况 + tags: + - 工作空间 + /workspaces/switch: + post: + description: 切换当前用户的租户,需要登录 + requestBody: + content: + application/json: + schema: + properties: + tenant_id: + description: 租户ID + type: string + required: + - tenant_id + type: object + description: 切换参数 + required: true + responses: + "200": + description: 切换成功 + content: + "*/*": + schema: + properties: + result: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 切换租户。 + + Returns: + dict: 切换成功的响应消息 + tags: + - 工作空间 + /workspaces/tenant/enable_ai: + post: + description: 设置是否开启租户的AI能力,需要登录和超级管理员权限 + requestBody: + content: + application/json: + schema: + properties: + enable: + description: 是否启用AI + type: boolean + tenant_id: + description: 租户ID + type: string + required: + - enable + - tenant_id + type: object + description: 启用参数 + required: true + responses: + "200": + description: 设置成功 + content: + "*/*": + schema: + properties: + code: + example: 200 + type: integer + message: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 设置是否开启租户的AI能力。 + + Args: + 无直接参数。请求体中应包含以下JSON字段: + enable (bool): 是否开启,必填。 + tenant_id (str): 租户ID,必填。 + + Returns: + - 若成功,返回({"message": "success", "code": 200, "data": 数据}, 200) + tags: + - 工作空间 + /workspaces/tenant/user_list: + get: + description: 查询当前租户下全部用户列表,需要登录 + responses: + "200": + description: 获取成功 + content: + "*/*": + schema: + description: 用户列表 + items: + type: object + type: array + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: 查询当前租户下全部用户列表 + tags: + - 工作空间 + /workspaces/update-roles: + post: + description: 修改租户内的用户身份和配额,需要登录和管理员权限 + requestBody: + content: + application/json: + schema: + properties: + data_list: + description: 用户角色列表 + items: + properties: + account_id: + type: string + name: + type: string + role: + type: string + type: object + type: array + gpu_quota: + description: GPU配额 + type: integer + storage_quota: + default: 0 + description: 存储配额(GB) + type: integer + tenant_id: + description: 租户ID + type: string + tenant_name: + description: 租户名称 + type: string + required: + - tenant_id + - storage_quota + type: object + description: 角色数据 + required: true + responses: + "200": + description: 更新成功 + content: + "*/*": + schema: + properties: + result: + example: success + type: string + type: object + "400": + description: 参数错误 + "401": + description: 未授权 + "403": + description: 无权限 + security: + - Bearer: [] + summary: |- + 修改租户内的用户身份 + "data_list": [ + { + "account_id": "87079ad4-5bce-4f28-972c-644084d939e7", + "name": "名字", + "role": "owner" + }, + ] + tags: + - 工作空间 +security: + - Bearer: [] +tags: + - description: 应用商店相关的 API + name: 应用商店 + - description: 资源库-数据库管理相关的 API(数据库、表、数据管理等) + name: 数据库管理 + - description: 资源库-知识库管理相关的 API(知识库、文件管理等) + name: 知识库管理 + - description: 资源库-知识库-文档管理相关的 API(文档CRUD、发布、图片上传等) + name: 文档管理 + - description: Prompt相关的 API + name: Prompt + - description: 模型仓库-模型管理相关的 API(模型管理、创建、更新、删除、上传、微调模型管理等) + name: 模型仓库 + - description: 模型仓库-模型评测相关的 API(评估任务管理、数据集上传、评估执行、报告下载等) + name: 模型评测 + - description: 推理服务相关的 API + name: 推理服务 + - description: 模型微调相关的 API + name: 模型微调 + - description: 工具相关的 API + name: 工具 + - description: 工具-MCP工具相关的 API(MCP服务器管理、工具管理等) + name: MCP工具 + - description: 数据集相关的 API(数据集管理、脚本管理、数据回流等) + name: 数据集 + - description: 标签相关的 API + name: 标签管理 + - description: API Key 管理相关的 API + name: API Key + - description: 认证相关的 API(登录、注册、OAuth等) + name: auth + - description: 对话相关的 API(会话管理、对话交互等) + name: conversation + - description: 成本审计相关的 API(token统计、应用统计等) + name: cost_audit + - description: 操作日志相关的 API(日志查询等) + name: 操作日志 + - description: 系统消息相关的 API(通知创建、查询、已读标记等) + name: 系统消息 + - description: 文件管理相关的 API(文件上传等) + name: 文件管理 + - description: 工作空间相关的 API(租户管理、用户管理、协作、配额管理等) + name: 工作空间 +servers: + - url: http://localhost:30382/console/api + - url: https://localhost:30382/console/api +components: + requestBodies: + Body: + content: + application/json: + schema: + properties: + app_id: + description: 应用ID + format: uuid + type: string + required: + - app_id + type: object + required: true + Body2: + content: + application/json: + schema: + properties: + name: + description: 标签名称 + type: string + type: + description: 标签类型 + enum: + - knowledgebase + - app + - model + - tool + - prompt + - dataset + - script + - mcp + type: string + required: + - name + - type + type: object + required: true + Body3: + content: + application/json: + schema: + properties: + files: + description: 文件列表 + items: + type: string + type: array + inputs: + description: 输入内容列表 + items: + type: string + type: array + required: + - inputs + type: object + required: true + Body4: + content: + application/json: + schema: + properties: + id: + description: 工具ID + type: string + required: + - id + type: object + description: 工具ID + required: true + Body5: + content: + application/json: + schema: + properties: + email: + description: 邮箱(可选) + format: email + type: string + name: + description: 用户名(可选) + type: string + phone: + description: 手机号(可选) + type: string + type: object + required: true + Body6: + content: + application/json: + schema: + properties: + tool_id: + description: 工具ID + type: string + required: + - tool_id + type: object + description: 授权参数 + required: true + Body7: + content: + application/json: + schema: + properties: + categories: + description: 应用分类 + items: + type: string + type: array + description: + description: 应用描述 + type: string + icon: + description: 应用图标 + type: string + icon_background: + description: 图标背景色 + type: string + name: + description: 应用名称 + type: string + required: + - name + type: object + required: true + Body8: + content: + application/json: + schema: + properties: + name: + description: 产商名称 + type: string + type: + description: 产商类型 + enum: + - llm + - embedding + - reranker + type: string + required: + - name + - type + type: object + required: true + Body9: + content: + application/json: + schema: + properties: + data_set_version_ids: + description: 数据集版本ID列表 + items: + type: string + type: array + required: + - data_set_version_ids + type: object + required: true + Body10: + content: + application/json: + schema: + properties: + data_set_version_id: + description: 数据集版本ID + type: string + required: + - data_set_version_id + type: object + required: true + Body11: + content: + application/json: + schema: + properties: + data_set_script_id: + description: 数据集脚本ID + type: string + data_set_version_id: + description: 数据集版本ID + type: string + data_set_version_name: + description: 数据集版本名称 + type: string + script_agent: + default: script + description: 脚本代理类型 + enum: + - script + type: string + script_type: + description: 脚本类型 + enum: + - 数据过滤 + - 数据增强 + - 数据去噪 + - 数据标注 + - 智能处理 + type: string + required: + - data_set_version_id + - data_set_script_id + type: object + required: true + Body12: + content: + application/json: + schema: + properties: + group_id: + description: 服务组ID + type: integer + required: + - group_id + type: object + description: 服务组ID + required: true + Body13: + content: + application/json: + schema: + properties: + service_id: + description: 服务ID + type: integer + required: + - service_id + type: object + description: 服务ID + required: true + Body14: + content: + application/json: + schema: + properties: + encrypted_data: + description: 加密后的登录数据(Base64编码) + type: string + session_id: + description: 会话ID(从密钥交换接口获取) + format: uuid + type: string + required: + - encrypted_data + - session_id + type: object + required: true + Body15: + content: + application/json: + schema: + properties: + id: + description: MCP服务器ID + type: integer + required: + - id + type: object + description: MCP服务器ID + required: true + securitySchemes: + Bearer: + description: "JWT Token 认证,格式: Bearer " + in: header + name: Authorization + type: apiKey diff --git a/front/package.json b/front/package.json index e6b65ba..c08160e 100644 --- a/front/package.json +++ b/front/package.json @@ -20,11 +20,12 @@ "uglify-embed": "node ./bin/uglify-embed", "remote": "evf2e-deploy setup:docker --config=./docker/deploy && evf2e-deploy build:docker-cloud && evf2e-deploy remote:docker-compose", "remote:arm": "evf2e-deploy setup:docker --config=./docker/deploy_arm && evf2e-deploy build:docker-cloud && evf2e-deploy remote:docker", - "prepare": "node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || (test -d ../.git && husky install ../.git || true)", + "prepare": "node -e \"try { require('fs').accessSync('../.git'); require('husky').install('../.git'); } catch (e) {}\"", "test": "jest", "test:watch": "jest --watch", "test:coverage": "jest --coverage", - "test:ci": "jest --ci --coverage --maxWorkers=2" + "test:ci": "jest --ci --coverage --maxWorkers=2", + "generate:api": "npx openapi-typescript-codegen --input ./openapi.yaml --output ./infrastructure/api/generated --client fetch" }, "dependencies": { "@ahooksjs/use-url-state": "^3.5.1", @@ -159,6 +160,7 @@ "jest": "^30.2.0", "jest-environment-jsdom": "^30.2.0", "lint-staged": "^13.2.2", + "openapi-typescript-codegen": "^0.30.0", "postcss": "^8.4.31", "sass": "^1.61.0", "tailwindcss": "^3.4.4", diff --git a/front/shared/hooks/use-validate-space.ts b/front/shared/hooks/use-validate-space.ts index ac46808..6237a1e 100644 --- a/front/shared/hooks/use-validate-space.ts +++ b/front/shared/hooks/use-validate-space.ts @@ -1,6 +1,6 @@ // 校验算力是否还有存储,如无则无法进行上传文件的相关操作 import { useCallback, useState } from 'react' -import { getValidateStatu } from '@/infrastructure/api//prompt' +import { Service } from '@/infrastructure/api/generated' import Toast, { ToastTypeEnum } from '@/app/components/base/flash-notice' /** @@ -70,9 +70,7 @@ const useStorageValidation = (): UseStorageValidationReturn => { setState(prev => ({ ...prev, isValidating: true, validationError: null })) try { - const response = await getValidateStatu({ - url: '/workspaces/storage/check', - }) + const response = await Service.getWorkspacesStorageCheck() const hasSpace = Boolean(response?.data) diff --git a/front/yarn.lock b/front/yarn.lock index 30a9e41..950a90f 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -149,6 +149,13 @@ jsonc-eslint-parser "^2.1.0" yaml-eslint-parser "^1.1.0" +"@apidevtools/json-schema-ref-parser@^14.2.1": + version "14.2.1" + resolved "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-14.2.1.tgz" + integrity sha512-HmdFw9CDYqM6B25pqGBpNeLCKvGPlIx1EbLrVL0zPvj50CJQUHyBNBw45Muk0kEIkogo1VZvOKHajdMuAzSxRg== + dependencies: + js-yaml "^4.1.0" + "@asamuzakjp/css-color@^3.2.0": version "3.2.0" resolved "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-3.2.0.tgz" @@ -1384,7 +1391,7 @@ "@reactflow/background@11.3.14": version "11.3.14" - resolved "https://registry.npmmirror.com/@reactflow/background/-/background-11.3.14.tgz" + resolved "https://registry.npmjs.org/@reactflow/background/-/background-11.3.14.tgz" integrity sha512-Gewd7blEVT5Lh6jqrvOgd4G6Qk17eGKQfsDXgyRSqM+CTwDqRldG2LsWN4sNeno6sbqVIC2fZ+rAUBFA9ZEUDA== dependencies: "@reactflow/core" "11.11.4" @@ -1393,7 +1400,7 @@ "@reactflow/controls@11.2.14": version "11.2.14" - resolved "https://registry.npmmirror.com/@reactflow/controls/-/controls-11.2.14.tgz" + resolved "https://registry.npmjs.org/@reactflow/controls/-/controls-11.2.14.tgz" integrity sha512-MiJp5VldFD7FrqaBNIrQ85dxChrG6ivuZ+dcFhPQUwOK3HfYgX2RHdBua+gx+40p5Vw5It3dVNp/my4Z3jF0dw== dependencies: "@reactflow/core" "11.11.4" @@ -1402,7 +1409,7 @@ "@reactflow/core@11.11.4": version "11.11.4" - resolved "https://registry.npmmirror.com/@reactflow/core/-/core-11.11.4.tgz" + resolved "https://registry.npmjs.org/@reactflow/core/-/core-11.11.4.tgz" integrity sha512-H4vODklsjAq3AMq6Np4LE12i1I4Ta9PrDHuBR9GmL8uzTt2l2jh4CiQbEMpvMDcp7xi4be0hgXj+Ysodde/i7Q== dependencies: "@types/d3" "^7.4.0" @@ -1417,7 +1424,7 @@ "@reactflow/minimap@11.7.14": version "11.7.14" - resolved "https://registry.npmmirror.com/@reactflow/minimap/-/minimap-11.7.14.tgz" + resolved "https://registry.npmjs.org/@reactflow/minimap/-/minimap-11.7.14.tgz" integrity sha512-mpwLKKrEAofgFJdkhwR5UQ1JYWlcAAL/ZU/bctBkuNTT1yqV+y0buoNVImsRehVYhJwffSWeSHaBR5/GJjlCSQ== dependencies: "@reactflow/core" "11.11.4" @@ -1430,7 +1437,7 @@ "@reactflow/node-resizer@2.2.14": version "2.2.14" - resolved "https://registry.npmmirror.com/@reactflow/node-resizer/-/node-resizer-2.2.14.tgz" + resolved "https://registry.npmjs.org/@reactflow/node-resizer/-/node-resizer-2.2.14.tgz" integrity sha512-fwqnks83jUlYr6OHcdFEedumWKChTHRGw/kbCxj0oqBd+ekfs+SIp4ddyNU0pdx96JIm5iNFS0oNrmEiJbbSaA== dependencies: "@reactflow/core" "11.11.4" @@ -1441,7 +1448,7 @@ "@reactflow/node-toolbar@1.3.14": version "1.3.14" - resolved "https://registry.npmmirror.com/@reactflow/node-toolbar/-/node-toolbar-1.3.14.tgz" + resolved "https://registry.npmjs.org/@reactflow/node-toolbar/-/node-toolbar-1.3.14.tgz" integrity sha512-rbynXQnH/xFNu4P9H+hVqlEUafDCkEoCy0Dg9mG22Sg+rY/0ck6KkrAQrYrTgXusd+cEJOMK0uOOFCK2/5rSGQ== dependencies: "@reactflow/core" "11.11.4" @@ -1609,7 +1616,7 @@ "@tisoap/react-flow-smart-edge@^3.0.0": version "3.0.0" - resolved "https://registry.npmmirror.com/@tisoap/react-flow-smart-edge/-/react-flow-smart-edge-3.0.0.tgz" + resolved "https://registry.npmjs.org/@tisoap/react-flow-smart-edge/-/react-flow-smart-edge-3.0.0.tgz" integrity sha512-XtEQT0IrOqPwJvCzgEoj3Y16/EK4SOcjZO7FmOPU+qJWmgYjeTyv7J35CGm6dFeJYdZ2gHDrvQ1zwaXuo23/8g== dependencies: pathfinding "0.4.18" @@ -1748,21 +1755,21 @@ "@types/d3-axis@*": version "3.0.6" - resolved "https://registry.npmmirror.com/@types/d3-axis/-/d3-axis-3.0.6.tgz" + resolved "https://registry.npmjs.org/@types/d3-axis/-/d3-axis-3.0.6.tgz" integrity sha512-pYeijfZuBd87T0hGn0FO1vQ/cgLk6E1ALJjfkC0oJ8cbwkZl3TpgS8bVBLZN+2jjGgg38epgxb2zmoGtSfvgMw== dependencies: "@types/d3-selection" "*" "@types/d3-brush@*": version "3.0.6" - resolved "https://registry.npmmirror.com/@types/d3-brush/-/d3-brush-3.0.6.tgz" + resolved "https://registry.npmjs.org/@types/d3-brush/-/d3-brush-3.0.6.tgz" integrity sha512-nH60IZNNxEcrh6L1ZSMNA28rj27ut/2ZmI3r96Zd+1jrZD++zD3LsMIjWlvg4AYrHn/Pqz4CF3veCxGjtbqt7A== dependencies: "@types/d3-selection" "*" "@types/d3-chord@*": version "3.0.6" - resolved "https://registry.npmmirror.com/@types/d3-chord/-/d3-chord-3.0.6.tgz" + resolved "https://registry.npmjs.org/@types/d3-chord/-/d3-chord-3.0.6.tgz" integrity sha512-LFYWWd8nwfwEmTZG9PfQxd17HbNPksHBiJHaKuY1XeqscXacsS2tyoo6OdRsjf+NQYeB6XrNL3a25E3gH69lcg== "@types/d3-color@*": @@ -1772,7 +1779,7 @@ "@types/d3-contour@*": version "3.0.6" - resolved "https://registry.npmmirror.com/@types/d3-contour/-/d3-contour-3.0.6.tgz" + resolved "https://registry.npmjs.org/@types/d3-contour/-/d3-contour-3.0.6.tgz" integrity sha512-BjzLgXGnCWjUSYGfH1cpdo41/hgdWETu4YxpezoztawmqsvCeep+8QGfiY6YbDvfgHz/DkjeIkkZVJavB4a3rg== dependencies: "@types/d3-array" "*" @@ -1780,24 +1787,24 @@ "@types/d3-delaunay@*": version "6.0.4" - resolved "https://registry.npmmirror.com/@types/d3-delaunay/-/d3-delaunay-6.0.4.tgz" + resolved "https://registry.npmjs.org/@types/d3-delaunay/-/d3-delaunay-6.0.4.tgz" integrity sha512-ZMaSKu4THYCU6sV64Lhg6qjf1orxBthaC161plr5KuPHo3CNm8DTHiLw/5Eq2b6TsNP0W0iJrUOFscY6Q450Hw== "@types/d3-dispatch@*": version "3.0.7" - resolved "https://registry.npmmirror.com/@types/d3-dispatch/-/d3-dispatch-3.0.7.tgz" + resolved "https://registry.npmjs.org/@types/d3-dispatch/-/d3-dispatch-3.0.7.tgz" integrity sha512-5o9OIAdKkhN1QItV2oqaE5KMIiXAvDWBDPrD85e58Qlz1c1kI/J0NcqbEG88CoTwJrYe7ntUCVfeUl2UJKbWgA== "@types/d3-drag@*", "@types/d3-drag@^3.0.1": version "3.0.7" - resolved "https://registry.npmmirror.com/@types/d3-drag/-/d3-drag-3.0.7.tgz" + resolved "https://registry.npmjs.org/@types/d3-drag/-/d3-drag-3.0.7.tgz" integrity sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ== dependencies: "@types/d3-selection" "*" "@types/d3-dsv@*": version "3.0.7" - resolved "https://registry.npmmirror.com/@types/d3-dsv/-/d3-dsv-3.0.7.tgz" + resolved "https://registry.npmjs.org/@types/d3-dsv/-/d3-dsv-3.0.7.tgz" integrity sha512-n6QBF9/+XASqcKK6waudgL0pf/S5XHPPI8APyMLLUHd8NqouBGLsU8MgtO7NINGtPBtk9Kko/W4ea0oAspwh9g== "@types/d3-ease@*", "@types/d3-ease@^3.0.0": @@ -1807,31 +1814,31 @@ "@types/d3-fetch@*": version "3.0.7" - resolved "https://registry.npmmirror.com/@types/d3-fetch/-/d3-fetch-3.0.7.tgz" + resolved "https://registry.npmjs.org/@types/d3-fetch/-/d3-fetch-3.0.7.tgz" integrity sha512-fTAfNmxSb9SOWNB9IoG5c8Hg6R+AzUHDRlsXsDZsNp6sxAEOP0tkP3gKkNSO/qmHPoBFTxNrjDprVHDQDvo5aA== dependencies: "@types/d3-dsv" "*" "@types/d3-force@*": version "3.0.10" - resolved "https://registry.npmmirror.com/@types/d3-force/-/d3-force-3.0.10.tgz" + resolved "https://registry.npmjs.org/@types/d3-force/-/d3-force-3.0.10.tgz" integrity sha512-ZYeSaCF3p73RdOKcjj+swRlZfnYpK1EbaDiYICEEp5Q6sUiqFaFQ9qgoshp5CzIyyb/yD09kD9o2zEltCexlgw== "@types/d3-format@*": version "3.0.4" - resolved "https://registry.npmmirror.com/@types/d3-format/-/d3-format-3.0.4.tgz" + resolved "https://registry.npmjs.org/@types/d3-format/-/d3-format-3.0.4.tgz" integrity sha512-fALi2aI6shfg7vM5KiR1wNJnZ7r6UuggVqtDA+xiEdPZQwy/trcQaHnwShLuLdta2rTymCNpxYTiMZX/e09F4g== "@types/d3-geo@*": version "3.1.0" - resolved "https://registry.npmmirror.com/@types/d3-geo/-/d3-geo-3.1.0.tgz" + resolved "https://registry.npmjs.org/@types/d3-geo/-/d3-geo-3.1.0.tgz" integrity sha512-856sckF0oP/diXtS4jNsiQw/UuK5fQG8l/a9VVLeSouf1/PPbBE1i1W852zVwKwYCBkFJJB7nCFTbk6UMEXBOQ== dependencies: "@types/geojson" "*" "@types/d3-hierarchy@*": version "3.1.7" - resolved "https://registry.npmmirror.com/@types/d3-hierarchy/-/d3-hierarchy-3.1.7.tgz" + resolved "https://registry.npmjs.org/@types/d3-hierarchy/-/d3-hierarchy-3.1.7.tgz" integrity sha512-tJFtNoYBtRtkNysX1Xq4sxtjK8YgoWUNpIiUee0/jHGRwqvzYxkq0hGVbbOGSz+JgFxxRu4K8nb3YpG3CMARtg== "@types/d3-interpolate@*", "@types/d3-interpolate@^3.0.1": @@ -1848,17 +1855,17 @@ "@types/d3-polygon@*": version "3.0.2" - resolved "https://registry.npmmirror.com/@types/d3-polygon/-/d3-polygon-3.0.2.tgz" + resolved "https://registry.npmjs.org/@types/d3-polygon/-/d3-polygon-3.0.2.tgz" integrity sha512-ZuWOtMaHCkN9xoeEMr1ubW2nGWsp4nIql+OPQRstu4ypeZ+zk3YKqQT0CXVe/PYqrKpZAi+J9mTs05TKwjXSRA== "@types/d3-quadtree@*": version "3.0.6" - resolved "https://registry.npmmirror.com/@types/d3-quadtree/-/d3-quadtree-3.0.6.tgz" + resolved "https://registry.npmjs.org/@types/d3-quadtree/-/d3-quadtree-3.0.6.tgz" integrity sha512-oUzyO1/Zm6rsxKRHA1vH0NEDG58HrT5icx/azi9MF1TWdtttWl0UIUsjEQBBh+SIkrpd21ZjEv7ptxWys1ncsg== "@types/d3-random@*": version "3.0.3" - resolved "https://registry.npmmirror.com/@types/d3-random/-/d3-random-3.0.3.tgz" + resolved "https://registry.npmjs.org/@types/d3-random/-/d3-random-3.0.3.tgz" integrity sha512-Imagg1vJ3y76Y2ea0871wpabqp613+8/r0mCLEBfdtqC7xMSfj9idOnmBYyMoULfHePJyxMAw3nWhJxzc+LFwQ== "@types/d3-scale-chromatic@*", "@types/d3-scale-chromatic@^3.0.0": @@ -1874,9 +1881,9 @@ "@types/d3-time" "*" "@types/d3-selection@*", "@types/d3-selection@^3.0.3": - version "3.0.10" - resolved "https://registry.npmmirror.com/@types/d3-selection/-/d3-selection-3.0.10.tgz" - integrity sha512-cuHoUgS/V3hLdjJOLTT691+G2QoqAjCVLmr4kJXR4ha56w1Zdu8UUQ5TxLRqudgNjwXeQxKMq4j+lyf9sWuslg== + version "3.0.11" + resolved "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-3.0.11.tgz" + integrity sha512-bhAXu23DJWsrI45xafYpkQ4NtcKMwWnAC/vKrd2l+nxMFuvOT3XMYTIj2opv8vq8AO5Yh7Qac/nSeP/3zjTK0w== "@types/d3-shape@*", "@types/d3-shape@^3.1.0": version "3.1.6" @@ -1887,7 +1894,7 @@ "@types/d3-time-format@*": version "4.0.3" - resolved "https://registry.npmmirror.com/@types/d3-time-format/-/d3-time-format-4.0.3.tgz" + resolved "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-4.0.3.tgz" integrity sha512-5xg9rC+wWL8kdDj153qZcsJ0FWiFt0J5RB6LYUNZjwSnesfblqrI/bJ1wBdJ8OQfncgbJG5+2F+qfqnqyzYxyg== "@types/d3-time@*", "@types/d3-time@^3.0.0": @@ -1902,14 +1909,14 @@ "@types/d3-transition@*": version "3.0.9" - resolved "https://registry.npmmirror.com/@types/d3-transition/-/d3-transition-3.0.9.tgz" + resolved "https://registry.npmjs.org/@types/d3-transition/-/d3-transition-3.0.9.tgz" integrity sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg== dependencies: "@types/d3-selection" "*" "@types/d3-zoom@*", "@types/d3-zoom@^3.0.1": version "3.0.8" - resolved "https://registry.npmmirror.com/@types/d3-zoom/-/d3-zoom-3.0.8.tgz" + resolved "https://registry.npmjs.org/@types/d3-zoom/-/d3-zoom-3.0.8.tgz" integrity sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw== dependencies: "@types/d3-interpolate" "*" @@ -1917,7 +1924,7 @@ "@types/d3@^7.4.0": version "7.4.3" - resolved "https://registry.npmmirror.com/@types/d3/-/d3-7.4.3.tgz" + resolved "https://registry.npmjs.org/@types/d3/-/d3-7.4.3.tgz" integrity sha512-lZXZ9ckh5R8uiFVt8ogUNf+pIrK4EsWrx2Np75WvF/eTpJ0FMHNhjXk8CKEx/+gpHbNQyJWehbFaTvqmHWB3ww== dependencies: "@types/d3-array" "*" @@ -1993,7 +2000,7 @@ "@types/geojson@*": version "7946.0.16" - resolved "https://registry.npmmirror.com/@types/geojson/-/geojson-7946.0.16.tgz" + resolved "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz" integrity sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg== "@types/hast@^2.0.0": @@ -3290,7 +3297,7 @@ class-variance-authority@^0.7.1: classcat@^5.0.3, classcat@^5.0.4: version "5.0.5" - resolved "https://registry.npmmirror.com/classcat/-/classcat-5.0.5.tgz" + resolved "https://registry.npmjs.org/classcat/-/classcat-5.0.5.tgz" integrity sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w== classnames@^2.2.1, classnames@^2.2.3, classnames@^2.2.5, classnames@^2.2.6, classnames@^2.3.1, classnames@^2.3.2, classnames@^2.5.1, classnames@2.x: @@ -3416,6 +3423,11 @@ comma-separated-tokens@^2.0.0: resolved "https://registry.npmmirror.com/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz" integrity sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg== +commander@^14.0.2: + version "14.0.2" + resolved "https://registry.npmjs.org/commander/-/commander-14.0.2.tgz" + integrity sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ== + commander@^2.20.0: version "2.20.3" resolved "https://registry.npmmirror.com/commander/-/commander-2.20.3.tgz" @@ -5049,6 +5061,15 @@ fs-constants@^1.0.0: resolved "https://registry.npmmirror.com/fs-constants/-/fs-constants-1.0.0.tgz" integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== +fs-extra@^11.3.3: + version "11.3.3" + resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.3.tgz" + integrity sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz" @@ -5256,7 +5277,7 @@ gopd@^1.0.1, gopd@^1.2.0: resolved "https://registry.npmmirror.com/gopd/-/gopd-1.2.0.tgz" integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== -graceful-fs@^4.1.2, graceful-fs@^4.2.0, graceful-fs@^4.2.11, graceful-fs@^4.2.2, graceful-fs@^4.2.4: +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.11, graceful-fs@^4.2.2, graceful-fs@^4.2.4: version "4.2.11" resolved "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.11.tgz" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -5266,6 +5287,18 @@ graphemer@^1.4.0: resolved "https://registry.npmmirror.com/graphemer/-/graphemer-1.4.0.tgz" integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== +handlebars@^4.7.8: + version "4.7.8" + resolved "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz" + integrity sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ== + dependencies: + minimist "^1.2.5" + neo-async "^2.6.2" + source-map "^0.6.1" + wordwrap "^1.0.0" + optionalDependencies: + uglify-js "^3.1.4" + harmony-reflect@^1.4.6: version "1.6.2" resolved "https://registry.npmjs.org/harmony-reflect/-/harmony-reflect-1.6.2.tgz" @@ -5441,7 +5474,7 @@ heap@^0.2.6: heap@0.2.5: version "0.2.5" - resolved "https://registry.npmmirror.com/heap/-/heap-0.2.5.tgz" + resolved "https://registry.npmjs.org/heap/-/heap-0.2.5.tgz" integrity sha512-G7HLD+WKcrOyJP5VQwYZNC3Z6FcQ7YYjEFiFoIj8PfEr73mu421o8B1N5DKUcc8K37EsJ2XXWA8DtrDz/2dReg== highlight.js@^10.4.1, highlight.js@~10.7.0: @@ -6542,6 +6575,15 @@ jsoneditor@^10.1.0: picomodal "^3.0.0" vanilla-picker "^2.12.3" +jsonfile@^6.0.1: + version "6.2.0" + resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz" + integrity sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + jsonrepair@^3.8.0: version "3.8.1" resolved "https://registry.npmmirror.com/jsonrepair/-/jsonrepair-3.8.1.tgz" @@ -7656,7 +7698,7 @@ minimatch@^9.0.1: dependencies: brace-expansion "^2.0.1" -minimist@^1.2.0, minimist@^1.2.6: +minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6: version "1.2.8" resolved "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== @@ -7915,6 +7957,17 @@ onetime@^6.0.0: dependencies: mimic-fn "^4.0.0" +openapi-typescript-codegen@^0.30.0: + version "0.30.0" + resolved "https://registry.npmjs.org/openapi-typescript-codegen/-/openapi-typescript-codegen-0.30.0.tgz" + integrity sha512-NO24vrOYEEREkuEwtLemXiV0/3wUj1HvS+0UuAinVNWKJOyNlXTj5hehdW9Dyob4u5YGrRG9dc9TBZW7/UszGw== + dependencies: + "@apidevtools/json-schema-ref-parser" "^14.2.1" + camelcase "^6.3.0" + commander "^14.0.2" + fs-extra "^11.3.3" + handlebars "^4.7.8" + optionator@^0.9.3: version "0.9.4" resolved "https://registry.npmmirror.com/optionator/-/optionator-0.9.4.tgz" @@ -8088,7 +8141,7 @@ path-type@^4.0.0: pathfinding@0.4.18: version "0.4.18" - resolved "https://registry.npmmirror.com/pathfinding/-/pathfinding-0.4.18.tgz" + resolved "https://registry.npmjs.org/pathfinding/-/pathfinding-0.4.18.tgz" integrity sha512-R0TGEQ9GRcFCDvAWlJAWC+KGJ9SLbW4c0nuZRcioVlXVTlw+F5RvXQ8SQgSqI9KXWC1ew95vgmIiyaWTlCe9Ag== dependencies: heap "0.2.5" @@ -9006,7 +9059,7 @@ react@*, "react@^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^15.0.0 || >=1 reactflow@^11.11.3, reactflow@>=11: version "11.11.4" - resolved "https://registry.npmmirror.com/reactflow/-/reactflow-11.11.4.tgz" + resolved "https://registry.npmjs.org/reactflow/-/reactflow-11.11.4.tgz" integrity sha512-70FOtJkUWH3BAOsN+LU9lCrKoKbtOPnz2uq0CV2PLdNSwxTXOhCbsZr50GmZ+Rtw3jx8Uv7/vBFtCGixLfd4Og== dependencies: "@reactflow/background" "11.3.14" @@ -9726,6 +9779,11 @@ source-map@^0.6.0: resolved "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + source-map@^0.7.0: version "0.7.4" resolved "https://registry.npmmirror.com/source-map/-/source-map-0.7.4.tgz" @@ -10423,9 +10481,14 @@ typed-array-length@^1.0.7: typescript@>=2.7, "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta", typescript@>=3.3.1, typescript@>=3.9, typescript@>=4.6, typescript@4.9.5: version "4.9.5" - resolved "https://registry.npmmirror.com/typescript/-/typescript-4.9.5.tgz" + resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== +uglify-js@^3.1.4: + version "3.19.3" + resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz" + integrity sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ== + unbox-primitive@^1.1.0: version "1.1.0" resolved "https://registry.npmmirror.com/unbox-primitive/-/unbox-primitive-1.1.0.tgz" @@ -10522,6 +10585,11 @@ unist-util-visit@^4.0.0: unist-util-is "^5.0.0" unist-util-visit-parents "^5.1.1" +universalify@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz" + integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== + unrs-resolver@^1.7.11: version "1.11.1" resolved "https://registry.npmjs.org/unrs-resolver/-/unrs-resolver-1.11.1.tgz" @@ -10895,6 +10963,11 @@ word-wrap@^1.2.5: resolved "https://registry.npmmirror.com/word-wrap/-/word-wrap-1.2.5.tgz" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== +wordwrap@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz" + integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== + "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz"