Skip to content

Commit 12e8242

Browse files
feat: shared
1 parent 2364bd2 commit 12e8242

File tree

13 files changed

+61
-45
lines changed

13 files changed

+61
-45
lines changed

ui/src/api/system-shared/document.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ import type { pageRequest } from '@/api/type/common'
66

77
const prefix = '/system/shared/knowledge'
88

9+
/**
10+
* 文档列表(无分页)
11+
* @param 参数 knowledge_id,
12+
* param {
13+
" name": "string",
14+
}
15+
*/
16+
17+
const getDocumentList: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
18+
knowledge_id,
19+
loading,
20+
) => {
21+
return get(`${prefix}/${knowledge_id}/document`, undefined, loading)
22+
}
23+
24+
925
/**
1026
* 文档分页列表
1127
* @param 参数 knowledge_id,
@@ -506,14 +522,9 @@ const importLarkDocument: (
506522
return post(`${prefix}/lark/${knowledge_id}/import`, data, null, loading)
507523
}
508524

509-
const getAllDocument: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
510-
knowledge_id,
511-
loading,
512-
) => {
513-
return get(`${prefix}/${knowledge_id}/document`, undefined, loading)
514-
}
515525

516526
export default {
527+
getDocumentList,
517528
getDocumentPage,
518529
getDocumentDetail,
519530
putDocument,

ui/src/stores/modules/model.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
import {defineStore} from 'pinia'
2-
import {type Ref} from 'vue'
3-
import ModelApi from '@/api/model/model'
1+
import { defineStore } from 'pinia'
2+
import { type Ref } from 'vue'
43
import ProviderApi from '@/api/model/provider'
5-
import type {ListModelRequest} from '@/api/type/model'
4+
import type { ListModelRequest } from '@/api/type/model'
5+
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
66

77
const useModelStore = defineStore('model', {
88
state: () => ({}),
99
actions: {
10-
async asyncGetModel(data?: ListModelRequest, loading?: Ref<boolean>) {
10+
async asyncGetModel(
11+
data?: ListModelRequest,
12+
systemType: 'systemShare' | 'workspace' | 'systemManage' = 'workspace',
13+
loading?: Ref<boolean>,
14+
) {
1115
return new Promise((resolve, reject) => {
12-
ModelApi.getModel(data, loading)
13-
.then((res) => {
16+
loadSharedApi({ type: 'model', systemType })
17+
.getModel(data, loading)
18+
.then((res: any) => {
1419
resolve(res)
1520
})
16-
.catch((error) => {
21+
.catch((error: any) => {
1722
reject(error)
1823
})
1924
})

ui/src/stores/modules/paragraph.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const useParagraphStore = defineStore('paragraph', {
5050
) {
5151
return new Promise((resolve, reject) => {
5252
const obj = {
53-
paragraphId,
54-
problemId,
53+
paragraph_id: paragraphId,
54+
problem_id: problemId,
5555
}
5656
paragraphApi
5757
.putDisassociationProblem(knowledgeId, documentId, obj, loading)
@@ -72,8 +72,8 @@ const useParagraphStore = defineStore('paragraph', {
7272
) {
7373
return new Promise((resolve, reject) => {
7474
const obj = {
75-
paragraphId,
76-
problemId,
75+
paragraph_id: paragraphId,
76+
problem_id: problemId,
7777
}
7878
paragraphApi
7979
.putAssociationProblem(knowledgeId, documentId, obj, loading)

ui/src/views/chat-log/component/EditContentDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function changeDocument(document_id: string) {
217217
}
218218
219219
function getDocument(knowledge_id: string) {
220-
document.asyncGetAllDocument(knowledge_id, loading).then((res: any) => {
220+
document.asyncGetKnowledgeDocument(knowledge_id, loading).then((res: any) => {
221221
documentList.value = res.data
222222
if (localStorage.getItem(id + 'chat_document_id')) {
223223
form.value.document_id = localStorage.getItem(id + 'chat_document_id') as string

ui/src/views/chat-log/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ function saveCleanTime() {
569569
function changeKnowledge(knowledge_id: string) {
570570
localStorage.setItem(id + 'chat_knowledge_id', knowledge_id)
571571
form.value.document_id = ''
572-
getDocumentPage(knowledge_id)
572+
getDocument(knowledge_id)
573573
}
574574
575575
function changeDocument(document_id: string) {
@@ -617,7 +617,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
617617
}
618618
619619
function getDocument(knowledge_id: string) {
620-
document.asyncGetAllDocument(knowledge_id, documentLoading).then((res: any) => {
620+
document.asyncGetKnowledgeDocument(knowledge_id, documentLoading).then((res: any) => {
621621
documentList.value = res.data
622622
if (localStorage.getItem(id + 'chat_document_id')) {
623623
form.value.document_id = localStorage.getItem(id + 'chat_document_id') as string

ui/src/views/knowledge/KnowledgeSetting.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<h4 class="title-decoration-1 mb-16">
99
{{ $t('common.info') }}
1010
</h4>
11-
<BaseForm ref="BaseFormRef" :data="detail" />
11+
<BaseForm ref="BaseFormRef" :data="detail" :apiType="apiType" />
1212

1313
<el-form
1414
ref="webFormRef"

ui/src/views/knowledge/component/BaseForm.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@
4242
</el-form>
4343
</template>
4444
<script setup lang="ts">
45-
import {ref, reactive, onMounted, onUnmounted, computed, watch} from 'vue'
46-
import {groupBy} from 'lodash'
45+
import { ref, reactive, onMounted, onUnmounted, computed, watch } from 'vue'
46+
import { groupBy } from 'lodash'
4747
import useStore from '@/stores'
48-
import type {knowledgeData} from '@/api/type/knowledge'
49-
import {t} from '@/locales'
48+
import type { knowledgeData } from '@/api/type/knowledge'
49+
import { t } from '@/locales'
5050
51-
const props = defineProps({
51+
const props = defineProps<{
5252
data: {
53-
type: Object,
54-
default: () => {
55-
},
56-
},
57-
})
58-
const {model} = useStore()
53+
type: Object
54+
default: () => {}
55+
}
56+
apiType: 'systemShare' | 'workspace' | 'systemManage'
57+
}>()
58+
const { model } = useStore()
5959
const form = ref<knowledgeData>({
6060
name: '',
6161
desc: '',
@@ -92,7 +92,7 @@ const modelOptions = ref<any>([])
9292
9393
watch(
9494
() => props.data,
95-
(value) => {
95+
(value: any) => {
9696
if (value && JSON.stringify(value) !== '{}') {
9797
form.value.name = value.name
9898
form.value.desc = value.desc
@@ -117,7 +117,7 @@ function validate() {
117117
function getModel() {
118118
loading.value = true
119119
model
120-
.asyncGetModel({model_type: 'EMBEDDING'})
120+
.asyncGetModel({ model_type: 'EMBEDDING' }, props.apiType)
121121
.then((res: any) => {
122122
modelOptions.value = groupBy(res?.data, 'provider')
123123
loading.value = false

ui/src/views/knowledge/create-component/CreateKnowledgeDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:close-on-press-escape="false"
99
>
1010
<!-- 基本信息 -->
11-
<BaseForm ref="BaseFormRef" v-if="dialogVisible" />
11+
<BaseForm ref="BaseFormRef" v-if="dialogVisible" :apiType="apiType" />
1212

1313
<template #footer>
1414
<span class="dialog-footer">

ui/src/views/knowledge/create-component/CreateLarkKnowledgeDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:close-on-press-escape="false"
99
>
1010
<!-- 基本信息 -->
11-
<BaseForm ref="BaseFormRef" v-if="dialogVisible" />
11+
<BaseForm ref="BaseFormRef" v-if="dialogVisible" :apiType="apiType" />
1212
<el-form
1313
ref="knowledgeFormRef"
1414
:rules="rules"

ui/src/views/knowledge/create-component/CreateWebKnowledgeDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:close-on-press-escape="false"
99
>
1010
<!-- 基本信息 -->
11-
<BaseForm ref="BaseFormRef" v-if="dialogVisible" />
11+
<BaseForm ref="BaseFormRef" v-if="dialogVisible" :apiType="apiType" />
1212
<el-form
1313
ref="KnowledgeFormRef"
1414
:rules="rules"

0 commit comments

Comments
 (0)