diff --git a/ui/src/api/image.ts b/ui/src/api/image.ts new file mode 100644 index 000000000..425e8c6c3 --- /dev/null +++ b/ui/src/api/image.ts @@ -0,0 +1,15 @@ +import { Result } from '@/request/Result' +import { get, post, del, put } from '@/request/index' + +const prefix = '/image' +/** + * 上传图片 + * @param 参数 file:file + */ +const postImage: (data: any) => Promise> = (data) => { + return post(`${prefix}`, data) +} + +export default { + postImage +} diff --git a/ui/src/api/knowledge/paragraph.ts b/ui/src/api/knowledge/paragraph.ts new file mode 100644 index 000000000..4a7d29b8a --- /dev/null +++ b/ui/src/api/knowledge/paragraph.ts @@ -0,0 +1,256 @@ +import { Result } from '@/request/Result' +import { get, post, del, put } from '@/request/index' +import type { pageRequest } from '@/api/type/common' +import type { Ref } from 'vue' +const prefix = '/dataset' + +/** + * 段落列表 + * @param 参数 dataset_id document_id + * page { + "current_page": "string", + "page_size": "string", + } + * param { + "title": "string", + "content": "string", + } + */ +const getParagraph: ( + dataset_id: string, + document_id: string, + page: pageRequest, + param: any, + loading?: Ref +) => Promise> = (dataset_id, document_id, page, param, loading) => { + return get( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/${page.current_page}/${page.page_size}`, + param, + loading + ) +} + +/** + * 删除段落 + * @param 参数 dataset_id, document_id, paragraph_id + */ +const delParagraph: ( + dataset_id: string, + document_id: string, + paragraph_id: string, + loading?: Ref +) => Promise> = (dataset_id, document_id, paragraph_id, loading) => { + return del( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}`, + undefined, + {}, + loading + ) +} + +/** + * 批量删除段落 + * @param 参数 dataset_id, document_id + */ +const delMulParagraph: ( + dataset_id: string, + document_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, document_id, data, loading) => { + return del( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/_batch`, + undefined, + { id_list: data }, + loading + ) +} + +/** + * 创建段落 + * @param 参数 + * dataset_id, document_id + * { + "content": "string", + "title": "string", + "is_active": true, + "problem_list": [ + { + "id": "string", + "content": "string" + } + ] + } + */ +const postParagraph: ( + dataset_id: string, + document_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, document_id, data, loading) => { + return post(`${prefix}/${dataset_id}/document/${document_id}/paragraph`, data, undefined, loading) +} + +/** + * 修改段落 + * @param 参数 + * dataset_id, document_id, paragraph_id + * { + "content": "string", + "title": "string", + "is_active": true, + "problem_list": [ + { + "id": "string", + "content": "string" + } + ] + } + */ +const putParagraph: ( + dataset_id: string, + document_id: string, + paragraph_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, document_id, paragraph_id, data, loading) => { + return put( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}`, + data, + undefined, + loading + ) +} + +/** + * 批量迁移段落 + * @param 参数 dataset_id,target_dataset_id, + */ +const putMigrateMulParagraph: ( + dataset_id: string, + document_id: string, + target_dataset_id: string, + target_document_id: string, + data: any, + loading?: Ref +) => Promise> = ( + dataset_id, + document_id, + target_dataset_id, + target_document_id, + data, + loading +) => { + return put( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/migrate/dataset/${target_dataset_id}/document/${target_document_id}`, + data, + undefined, + loading + ) +} + +/** + * 问题列表 + * @param 参数 dataset_id,document_id,paragraph_id + */ +const getProblem: ( + dataset_id: string, + document_id: string, + paragraph_id: string +) => Promise> = (dataset_id, document_id, paragraph_id: string) => { + return get(`${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}/problem`) +} + +/** + * 创建问题 + * @param 参数 + * dataset_id, document_id, paragraph_id + * { + "id": "string", + content": "string" + } + */ +const postProblem: ( + dataset_id: string, + document_id: string, + paragraph_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, document_id, paragraph_id, data: any, loading) => { + return post( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}/problem`, + data, + {}, + loading + ) +} +/** + * + * @param dataset_id 数据集id + * @param document_id 文档id + * @param paragraph_id 段落id + * @param problem_id 问题id + * @param loading 加载器 + * @returns + */ +const associationProblem: ( + dataset_id: string, + document_id: string, + paragraph_id: string, + problem_id: string, + loading?: Ref +) => Promise> = (dataset_id, document_id, paragraph_id, problem_id, loading) => { + return put( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}/problem/${problem_id}/association`, + {}, + {}, + loading + ) +} +/** + * 解除关联问题 + * @param 参数 dataset_id, document_id, paragraph_id,problem_id + */ +const disassociationProblem: ( + dataset_id: string, + document_id: string, + paragraph_id: string, + problem_id: string, + loading?: Ref +) => Promise> = (dataset_id, document_id, paragraph_id, problem_id, loading) => { + return put( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}/problem/${problem_id}/un_association`, + {}, + {}, + loading + ) +} + +const batchGenerateRelated: ( + dataset_id: string, + document_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, document_id, data, loading) => { + return put( + `${prefix}/${dataset_id}/document/${document_id}/paragraph/batch_generate_related`, + data, + undefined, + loading + ) +} + + +export default { + getParagraph, + delParagraph, + putParagraph, + postParagraph, + getProblem, + postProblem, + disassociationProblem, + associationProblem, + delMulParagraph, + putMigrateMulParagraph, + batchGenerateRelated +} diff --git a/ui/src/api/knowledge/problem.ts b/ui/src/api/knowledge/problem.ts new file mode 100644 index 000000000..4625d6de6 --- /dev/null +++ b/ui/src/api/knowledge/problem.ts @@ -0,0 +1,124 @@ +import { Result } from '@/request/Result' +import { get, post, del, put } from '@/request/index' +import type { Ref } from 'vue' +import type { KeyValue } from '@/api/type/common' +import type { pageRequest } from '@/api/type/common' +const prefix = '/dataset' + +/** + * 文档分页列表 + * @param 参数 dataset_id, + * page { + "current_page": "string", + "page_size": "string", + } +* query { + "content": "string", + } + */ + +const getProblems: ( + dataset_id: string, + page: pageRequest, + param: any, + loading?: Ref +) => Promise> = (dataset_id, page, param, loading) => { + return get( + `${prefix}/${dataset_id}/problem/${page.current_page}/${page.page_size}`, + param, + loading + ) +} + +/** + * 创建问题 + * @param 参数 dataset_id + * data: array[string] + */ +const postProblems: ( + dataset_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, data, loading) => { + return post(`${prefix}/${dataset_id}/problem`, data, undefined, loading) +} + +/** + * 删除问题 + * @param 参数 dataset_id, problem_id, + */ +const delProblems: ( + dataset_id: string, + problem_id: string, + loading?: Ref +) => Promise> = (dataset_id, problem_id, loading) => { + return del(`${prefix}/${dataset_id}/problem/${problem_id}`, loading) +} + +/** + * 批量删除问题 + * @param 参数 dataset_id, + */ +const delMulProblem: ( + dataset_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, data, loading) => { + return del(`${prefix}/${dataset_id}/problem/_batch`, undefined, data, loading) +} + +/** + * 修改问题 + * @param 参数 + * dataset_id, problem_id, + * { + "content": "string", + } + */ +const putProblems: ( + dataset_id: string, + problem_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, problem_id, data: any, loading) => { + return put(`${prefix}/${dataset_id}/problem/${problem_id}`, data, undefined, loading) +} + +/** + * 问题详情 + * @param 参数 + * dataset_id, problem_id, + */ +const getDetailProblems: ( + dataset_id: string, + problem_id: string, + loading?: Ref +) => Promise> = (dataset_id, problem_id, loading) => { + return get(`${prefix}/${dataset_id}/problem/${problem_id}/paragraph`, undefined, loading) +} + +/** + * 批量关联段落 + * @param 参数 dataset_id, + * { + "problem_id_list": "Array", + "paragraph_list": "Array", + } + */ +const postMulAssociationProblem: ( + dataset_id: string, + data: any, + loading?: Ref +) => Promise> = (dataset_id, data, loading) => { + return post(`${prefix}/${dataset_id}/problem/_batch`, data, undefined, loading) +} + +export default { + getProblems, + postProblems, + delProblems, + putProblems, + getDetailProblems, + delMulProblem, + postMulAssociationProblem +} diff --git a/ui/src/assets/hit-test-empty.png b/ui/src/assets/hit-test-empty.png new file mode 100644 index 000000000..83a2c9a06 Binary files /dev/null and b/ui/src/assets/hit-test-empty.png differ diff --git a/ui/src/components/app-icon/icons/knowledge.ts b/ui/src/components/app-icon/icons/knowledge.ts index 6f0ac81b5..c421f68f0 100644 --- a/ui/src/components/app-icon/icons/knowledge.ts +++ b/ui/src/components/app-icon/icons/knowledge.ts @@ -54,4 +54,67 @@ export default { ]) }, }, + 'app-problems': { + iconReader: () => { + return h('i', [ + h( + 'svg', + { + style: { height: '100%', width: '100%' }, + viewBox: '0 0 1024 1024', + version: '1.1', + xmlns: 'http://www.w3.org/2000/svg' + }, + [ + h('path', { + d: 'M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768z m0 85.333333C252.8 981.333333 42.666667 771.2 42.666667 512S252.8 42.666667 512 42.666667s469.333333 210.133333 469.333333 469.333333-210.133333 469.333333-469.333333 469.333333z m-21.333333-298.666666h42.666666a21.333333 21.333333 0 0 1 21.333334 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333334 21.333333h-42.666666a21.333333 21.333333 0 0 1-21.333334-21.333333v-42.666667a21.333333 21.333333 0 0 1 21.333334-21.333333zM343.466667 396.032c0.554667-4.778667 1.109333-8.746667 1.664-11.946667 8.32-46.293333 29.397333-80.341333 63.189333-102.144 26.453333-17.28 59.008-25.941333 97.621333-25.941333 50.730667 0 92.842667 12.288 126.378667 36.864 33.578667 24.533333 50.346667 60.928 50.346667 109.141333 0 29.568-7.253333 54.485333-21.888 74.752-8.533333 12.245333-24.917333 27.946667-49.152 47.061334l-23.893334 18.773333c-13.013333 10.24-21.632 22.186667-25.898666 35.84-1.152 3.712-2.176 10.624-3.072 20.736a21.333333 21.333333 0 0 1-21.248 19.498667h-47.786667a21.333333 21.333333 0 0 1-21.248-23.296c2.773333-29.696 5.717333-48.469333 8.832-56.362667 5.845333-14.677333 20.906667-31.573333 45.141333-50.688l24.533334-19.413333c8.106667-6.144 49.749333-35.456 49.749333-61.44 0-25.941333-4.522667-35.498667-17.578667-49.749334-13.013333-14.208-42.368-18.773333-68.864-18.773333-26.026667 0-48.256 6.869333-59.136 24.405333-5.034667 8.106667-9.173333 16.768-12.117333 25.6a89.472 89.472 0 0 0-3.114667 13.098667 21.333333 21.333333 0 0 1-21.034666 17.706667H364.672a21.333333 21.333333 0 0 1-21.205333-23.722667z', + fill: 'currentColor' + }) + ] + ) + ]) + } + }, + 'app-hit-test': { + iconReader: () => { + return h('i', [ + h( + 'svg', + { + style: { height: '100%', width: '100%' }, + viewBox: '0 0 20 20', + version: '1.1', + xmlns: 'http://www.w3.org/2000/svg' + }, + + [ + h('path', { + d: 'M1.6665 9.99986C1.6665 5.3975 5.39748 1.66653 9.99984 1.66653H10.8332V3.3332H9.99984C6.31795 3.3332 3.33317 6.31797 3.33317 9.99986C3.33317 13.6818 6.31795 16.6665 9.99984 16.6665C13.6817 16.6665 16.6665 13.6818 16.6665 9.99986V9.16653H18.3332V9.99986C18.3332 14.6022 14.6022 18.3332 9.99984 18.3332C5.39748 18.3332 1.6665 14.6022 1.6665 9.99986Z', + fill: 'currentColor', + fillRule: 'evenodd', + clipRule: 'evenodd' + }), + h('path', { + d: 'M5.4165 9.99986C5.4165 7.46854 7.46852 5.41653 9.99984 5.41653H10.8332V7.0832H9.99984C8.38899 7.0832 7.08317 8.38902 7.08317 9.99986C7.08317 11.6107 8.38899 12.9165 9.99984 12.9165C11.6107 12.9165 12.9165 11.6107 12.9165 9.99986V9.16653H14.5832V9.99986C14.5832 12.5312 12.5312 14.5832 9.99984 14.5832C7.46852 14.5832 5.4165 12.5312 5.4165 9.99986Z', + fill: 'currentColor', + fillRule: 'evenodd', + clipRule: 'evenodd' + }), + h('path', { + d: 'M13.2138 6.78296C13.5394 7.10825 13.5397 7.63588 13.2144 7.96147L10.5894 10.5889C10.2641 10.9145 9.73644 10.9147 9.41085 10.5894C9.08527 10.2641 9.08502 9.73651 9.41031 9.41092L12.0353 6.7835C12.3606 6.45792 12.8882 6.45767 13.2138 6.78296Z', + fill: 'currentColor', + fillRule: 'evenodd', + clipRule: 'evenodd' + }), + h('path', { + d: 'M15.1942 1.72962C15.506 1.8584 15.7095 2.16249 15.7095 2.49986V4.29161H17.4998C17.8365 4.29161 18.1401 4.49423 18.2693 4.80516C18.3985 5.11608 18.3279 5.47421 18.0904 5.71284L15.8508 7.96276C15.6944 8.11987 15.4819 8.2082 15.2602 8.2082H12.6248C12.1645 8.2082 11.7914 7.8351 11.7914 7.37486V4.76086C11.7914 4.54046 11.8787 4.32904 12.0342 4.17287L14.2856 1.91186C14.5237 1.6728 14.8824 1.60085 15.1942 1.72962ZM13.4581 5.105V6.54153H14.9139L15.4945 5.95828H14.8761C14.4159 5.95828 14.0428 5.58518 14.0428 5.12495V4.51779L13.4581 5.105Z', + fill: 'currentColor', + fillRule: 'evenodd', + clipRule: 'evenodd' + }) + ] + ) + ]) + } + }, } diff --git a/ui/src/locales/lang/zh-CN/views/index.ts b/ui/src/locales/lang/zh-CN/views/index.ts index c82250f94..53e7964f7 100644 --- a/ui/src/locales/lang/zh-CN/views/index.ts +++ b/ui/src/locales/lang/zh-CN/views/index.ts @@ -7,6 +7,7 @@ import system from './system' import userManage from './user-manage' import resourceAuthorization from './resource-authorization' import application from './application' +import problem from './problem' // import notFound from './404' // import applicationOverview from './application-overview' @@ -15,7 +16,7 @@ import application from './application' // import team from './team' // import paragraph from './paragraph' -// import problem from './problem' + // import log from './log' // import applicationWorkflow from './application-workflow' @@ -30,6 +31,7 @@ export default { userManage, resourceAuthorization, application, + problem, // notFound, // applicationOverview, @@ -37,7 +39,7 @@ export default { // user, // team, // paragraph, - // problem, + // log, // applicationWorkflow, diff --git a/ui/src/locales/lang/zh-CN/views/problem.ts b/ui/src/locales/lang/zh-CN/views/problem.ts new file mode 100644 index 000000000..bb53275aa --- /dev/null +++ b/ui/src/locales/lang/zh-CN/views/problem.ts @@ -0,0 +1,37 @@ +export default { + title: '问题', + createProblem: '创建问题', + detailProblem: '问题详情', + quickCreateProblem: '快速创建问题', + quickCreateName: '问题', + tip: { + placeholder: '请输入问题,支持输入多个,一行一个。', + errorMessage: '问题不能为空!', + requiredMessage: '请输入问题', + relatedSuccess:'批量关联分段成功' + }, + + setting: { + batchDelete: '批量删除', + cancelRelated: '取消关联' + }, + searchBar: { + placeholder: '按名称搜索' + }, + table: { + paragraph_count: '关联分段数', + updateTime: '更新时间' + }, + delete: { + confirmTitle: '是否删除问题:', + confirmMessage1: '删除问题关联的', + confirmMessage2: '个分段会被取消关联,请谨慎操作。' + }, + relateParagraph: { + title: '关联分段', + selectDocument: '选择文档', + placeholder: '按 文档名称 搜索', + selectedParagraph: '已选分段', + count: '个' + }, +} diff --git a/ui/src/router/modules/document.ts b/ui/src/router/modules/document.ts index 4cf813446..7eeb59815 100644 --- a/ui/src/router/modules/document.ts +++ b/ui/src/router/modules/document.ts @@ -1,6 +1,6 @@ const ModelRouter = { path: '/knowledge/:id', - name: 'DatasetDetail', + name: 'KnowledgeDetail', meta: { title: 'common.fileUpload.document', activeMenu: '/knowledge', breadcrumb: true }, component: () => import('@/layout/layout-template/MainLayout.vue'), hidden: true, @@ -14,35 +14,35 @@ const ModelRouter = { title: 'common.fileUpload.document', active: 'document', parentPath: '/knowledge/:id', - parentName: 'DatasetDetail', + parentName: 'KnowledgeDetail', }, component: () => import('@/views/document/index.vue'), }, - // { - // path: 'problem', - // name: 'Problem', - // meta: { - // icon: 'app-problems', - // iconActive: 'QuestionFilled', - // title: 'views.problem.title', - // active: 'problem', - // parentPath: '/dataset/:id', - // parentName: 'DatasetDetail' - // }, - // component: () => import('@/views/problem/index.vue') - // }, - // { - // path: 'hit-test', - // name: 'DatasetHitTest', - // meta: { - // icon: 'app-hit-test', - // title: 'views.application.hitTest.title', - // active: 'hit-test', - // parentPath: '/dataset/:id', - // parentName: 'DatasetDetail' - // }, - // component: () => import('@/views/hit-test/index.vue') - // }, + { + path: 'problem', + name: 'Problem', + meta: { + icon: 'app-problems', + iconActive: 'QuestionFilled', + title: 'views.problem.title', + active: 'problem', + parentPath: '/knowledge/:id', + parentName: 'KnowledgeDetail' + }, + component: () => import('@/views/problem/index.vue') + }, + { + path: 'hit-test', + name: 'DatasetHitTest', + meta: { + icon: 'app-hit-test', + title: 'views.application.hitTest.title', + active: 'hit-test', + parentPath: '/knowledge/:id', + parentName: 'KnowledgeDetail' + }, + component: () => import('@/views/hit-test/index.vue') + }, // { // path: 'setting', // name: 'DatasetSetting', diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.ts index 31dd2dfe4..7a6fb7289 100644 --- a/ui/src/utils/common.ts +++ b/ui/src/utils/common.ts @@ -1,3 +1,9 @@ +// 排序 +export function arraySort(list: Array, property: any, desc?: boolean) { + return list.sort((a: any, b: any) => { + return desc ? b[property] - a[property] : a[property] - b[property] + }) +} /** * 拆分数组 每n个拆分为一个数组 * @param sourceDataList 资源数据 diff --git a/ui/src/views/hit-test/index.vue b/ui/src/views/hit-test/index.vue new file mode 100644 index 000000000..a150101e8 --- /dev/null +++ b/ui/src/views/hit-test/index.vue @@ -0,0 +1,440 @@ + + + diff --git a/ui/src/views/paragraph/component/ParagraphDialog.vue b/ui/src/views/paragraph/component/ParagraphDialog.vue new file mode 100644 index 000000000..6c44b33ae --- /dev/null +++ b/ui/src/views/paragraph/component/ParagraphDialog.vue @@ -0,0 +1,153 @@ + + + diff --git a/ui/src/views/paragraph/component/ParagraphForm.vue b/ui/src/views/paragraph/component/ParagraphForm.vue new file mode 100644 index 000000000..70d500e50 --- /dev/null +++ b/ui/src/views/paragraph/component/ParagraphForm.vue @@ -0,0 +1,174 @@ + + + diff --git a/ui/src/views/paragraph/component/ProblemComponent.vue b/ui/src/views/paragraph/component/ProblemComponent.vue new file mode 100644 index 000000000..f10bacf20 --- /dev/null +++ b/ui/src/views/paragraph/component/ProblemComponent.vue @@ -0,0 +1,204 @@ + + + diff --git a/ui/src/views/paragraph/component/SelectDocumentDialog.vue b/ui/src/views/paragraph/component/SelectDocumentDialog.vue new file mode 100644 index 000000000..36cf57e0c --- /dev/null +++ b/ui/src/views/paragraph/component/SelectDocumentDialog.vue @@ -0,0 +1,181 @@ + + + diff --git a/ui/src/views/paragraph/index.vue b/ui/src/views/paragraph/index.vue new file mode 100644 index 000000000..2db750959 --- /dev/null +++ b/ui/src/views/paragraph/index.vue @@ -0,0 +1,438 @@ + + + diff --git a/ui/src/views/problem/component/CreateProblemDialog.vue b/ui/src/views/problem/component/CreateProblemDialog.vue new file mode 100644 index 000000000..9d3691696 --- /dev/null +++ b/ui/src/views/problem/component/CreateProblemDialog.vue @@ -0,0 +1,92 @@ + + + diff --git a/ui/src/views/problem/component/DetailProblemDrawer.vue b/ui/src/views/problem/component/DetailProblemDrawer.vue new file mode 100644 index 000000000..caf36be15 --- /dev/null +++ b/ui/src/views/problem/component/DetailProblemDrawer.vue @@ -0,0 +1,206 @@ + + + + diff --git a/ui/src/views/problem/component/RelateProblemDialog.vue b/ui/src/views/problem/component/RelateProblemDialog.vue new file mode 100644 index 000000000..963ec1713 --- /dev/null +++ b/ui/src/views/problem/component/RelateProblemDialog.vue @@ -0,0 +1,301 @@ + + + diff --git a/ui/src/views/problem/index.vue b/ui/src/views/problem/index.vue new file mode 100644 index 000000000..b90de814f --- /dev/null +++ b/ui/src/views/problem/index.vue @@ -0,0 +1,362 @@ + + +