Skip to content

Commit

Permalink
perf: Optimize duplicate files and style
Browse files Browse the repository at this point in the history
  • Loading branch information
wangdan-fit2cloud committed Dec 31, 2024
1 parent c785dfa commit 154cc72
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 321 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
</div>
<div class="ml-12 lighter">
<p>提示词中的 {data} 为分段内容的占位符,执行时替换为分段内容发送给 AI 模型;</p>
<p>AI 模型根据分段内容生成相关问题,请将生成的问题放至&lt;question&gt;&lt;/question&gt;标签中,系统会自动关联标签中的问题;</p>
<p>
AI
模型根据分段内容生成相关问题,请将生成的问题放至&lt;question&gt;&lt;/question&gt;标签中,系统会自动关联标签中的问题;
</p>
<p>生成效果依赖于所选模型和提示词,用户可自行调整至最佳效果。</p>
</div>
</div>
Expand All @@ -45,16 +48,13 @@
class="flex-between"
>
<div class="flex align-center">
<span
v-html="relatedObject(providerOptions, label, 'provider')?.icon"
class="model-icon mr-8"
></span>
<span
v-html="relatedObject(providerOptions, label, 'provider')?.icon"
class="model-icon mr-8"
></span>
<span>{{ item.name }}</span>
<el-tag
v-if="item.permission_type === 'PUBLIC'"
type="info"
class="info-tag ml-8"
>公用
<el-tag v-if="item.permission_type === 'PUBLIC'" type="info" class="info-tag ml-8"
>公用
</el-tag>
</div>
<el-icon class="check-icon" v-if="item.id === form.model_id">
Expand All @@ -71,14 +71,14 @@
disabled
>
<div class="flex">
<span
v-html="relatedObject(providerOptions, label, 'provider')?.icon"
class="model-icon mr-8"
></span>
<span
v-html="relatedObject(providerOptions, label, 'provider')?.icon"
class="model-icon mr-8"
></span>
<span>{{ item.name }}</span>
<span class="danger">{{
$t('views.application.applicationForm.form.aiModel.unavailable')
}}</span>
$t('views.application.applicationForm.form.aiModel.unavailable')
}}</span>
</div>
<el-icon class="check-icon" v-if="item.id === form.model_id">
<Check />
Expand All @@ -88,16 +88,9 @@
</el-select>
</el-form-item>
<el-form-item label="提示词" prop="prompt">
<el-input
v-model="form.prompt"
placeholder="请输入提示词"
:rows="7"
type="textarea"
/>
<el-input v-model="form.prompt" placeholder="请输入提示词" :rows="7" type="textarea" />
</el-form-item>
</el-form>


</div>
<template #footer>
<span class="dialog-footer">
Expand All @@ -113,48 +106,47 @@
import { reactive, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import documentApi from '@/api/document'
import paragraphApi from '@/api/paragraph'
import datasetApi from '@/api/dataset'
import useStore from '@/stores'
import { relatedObject } from '@/utils/utils'
import type { Provider } from '@/api/type/model'
import datasetApi from '@/api/dataset'
import { groupBy } from 'lodash'
import { MsgSuccess } from '@/utils/message'
import { t } from '@/locales'
import type { FormInstance } from 'element-plus'
const route = useRoute()
const {
params: { id } // id为datasetID
params: { id, documentId } // id为datasetID
} = route as any
const { model, prompt, user } = useStore()
const emit = defineEmits(['refresh'])
const loading = ref<boolean>(false)
const dialogVisible = ref<boolean>(false)
const modelOptions = ref<any>(null)
const providerOptions = ref<Array<Provider>>([])
const documentIdList = ref<string[]>([])
const idList = ref<string[]>([])
const apiType = ref('') // 文档document或段落paragraph
const FormRef = ref()
const userId = user.userInfo?.id as string
const form = ref(prompt.get(userId))
const rules = reactive({
model_id: [{ required: true, message: '请选择AI 模型', trigger: 'blur' }],
prompt: [{ required: true, message: '请输入提示词', trigger: 'blur' }]
})
const open = (document_ids: string[]) => {
const open = (ids: string[], type: string) => {
getProvider()
getModel()
documentIdList.value = document_ids
idList.value = ids
apiType.value = type
dialogVisible.value = true
}
Expand All @@ -166,17 +158,25 @@ const submitHandle = async (formEl: FormInstance) => {
if (valid) {
// 保存提示词
prompt.save(user.userInfo?.id as string, form.value)
const data = { ...form.value, document_id_list: documentIdList.value }
documentApi.batchGenerateRelated(id, data).then(() => {
MsgSuccess('生成问题成功')
emit('refresh')
dialogVisible.value = false
})
if (apiType.value === 'paragraph') {
const data = { ...form.value, paragraph_id_list: idList.value }
paragraphApi.batchGenerateRelated(id, documentId, data).then(() => {
MsgSuccess('生成问题成功')
emit('refresh')
dialogVisible.value = false
})
} else if (apiType.value === 'document') {
const data = { ...form.value, document_id_list: idList.value }
documentApi.batchGenerateRelated(id, data).then(() => {
MsgSuccess('生成问题成功')
emit('refresh')
dialogVisible.value = false
})
}
}
})
}
function getModel() {
loading.value = true
datasetApi
Expand All @@ -203,26 +203,9 @@ function getProvider() {
})
}
defineExpose({ open })
</script>
<style lang="scss" scope>
.select-dataset-dialog {
padding: 10px;
.el-dialog__header {
padding: 24px 24px 0 8px;
}
.el-dialog__body {
padding: 8px !important;
}
.el-dialog__footer {
padding: 0 24px 24px;
}
}
.update-info {
background: #d6e2ff;
line-height: 25px;
Expand Down
32 changes: 23 additions & 9 deletions ui/src/views/application-workflow/component/DropdownMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<component :is="iconComponent(`function-lib-node-icon`)" class="mr-8 mt-4" :size="32" />
<div class="pre-wrap">
<div class="lighter">{{ functionNode.label }}</div>
<el-text type="info" size="small" >{{ functionNode.text }}</el-text>
<el-text type="info" size="small">{{ functionNode.text }}</el-text>
</div>
</div>

Expand All @@ -51,14 +51,19 @@
@click.stop="clickNodes(functionLibNode, item, 'function')"
@mousedown.stop="onmousedown(functionLibNode, item, 'function')"
>
<component
:is="iconComponent(`function-lib-node-icon`)"
class="mr-8"
:size="32"
/>
<component :is="iconComponent(`function-lib-node-icon`)" class="mr-8" :size="32" />
<div class="pre-wrap">
<div class="lighter">{{ item.name }}</div>
<el-text type="info" size="small" v-if="item.desc">{{ item.desc }}</el-text>
<div class="lighter ellipsis-1" :title="item.name">{{ item.name }}</div>
<p>
<el-text
class="ellipsis-1"
type="info"
size="small"
:title="item.desc"
v-if="item.desc"
>{{ item.desc }}</el-text
>
</p>
</div>
</div>
</template>
Expand All @@ -83,7 +88,16 @@
<div class="lighter ellipsis" :title="item.name">
{{ item.name }}
</div>
<el-text type="info" size="small" style="width: 80%" v-if="item.desc">{{ item.desc }}</el-text>
<p>
<el-text
class="ellipsis"
type="info"
size="small"
:title="item.desc"
v-if="item.desc"
>{{ item.desc }}</el-text
>
</p>
</div>
<div class="status-tag" style="margin-left: auto">
<el-tag type="warning" v-if="isWorkFlow(item.type)" style="height: 22px"
Expand Down
19 changes: 2 additions & 17 deletions ui/src/views/document/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ import { hitHandlingMethod } from '@/enums/document'
import { MsgSuccess, MsgConfirm, MsgError } from '@/utils/message'
import useStore from '@/stores'
import StatusVlue from '@/views/document/component/Status.vue'
import GenerateRelatedDialog from '@/views/document/component/GenerateRelatedDialog.vue'
import GenerateRelatedDialog from '@/components/generate-related-dialog/index.vue'
import { TaskType, State } from '@/utils/status'
const router = useRouter()
const route = useRoute()
Expand Down Expand Up @@ -562,9 +562,6 @@ const cancelTask = (row: any, task_type: number) => {
MsgSuccess('发送成功')
})
}
function syncDataset() {
SyncWebDialogRef.value.open(id)
}
function importDoc() {
title.value = '导入文档'
Expand Down Expand Up @@ -706,18 +703,6 @@ function batchRefresh() {
})
}
function batchGenerateRelated() {
const arr: string[] = []
multipleSelection.value.map((v) => {
if (v) {
arr.push(v.id)
}
})
documentApi.batchGenerateRelated(id, arr, loading).then(() => {
MsgSuccess('批量生成问题成功')
multipleTableRef.value?.clearSelection()
})
}
function deleteDocument(row: any) {
MsgConfirm(
Expand Down Expand Up @@ -827,7 +812,7 @@ function openGenerateDialog(row?: any) {
})
}
GenerateRelatedDialogRef.value.open(arr)
GenerateRelatedDialogRef.value.open(arr, 'document')
}
onMounted(() => {
Expand Down
Loading

0 comments on commit 154cc72

Please sign in to comment.