mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: 【应用】用户对话时可以设置显示知识来源(#45)
This commit is contained in:
parent
72f43cff51
commit
38f2208639
|
|
@ -53,6 +53,7 @@
|
|||
<img src="@/assets/icon_robot.svg" style="width: 75%" alt="" />
|
||||
</AppAvatar>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="flex" v-if="!item.answer_text">
|
||||
<el-card
|
||||
|
|
@ -72,7 +73,9 @@
|
|||
|
||||
<el-card v-else shadow="always" class="dialog-card">
|
||||
<MdRenderer :source="item.answer_text"></MdRenderer>
|
||||
<div v-if="(id && !props.appId && item.write_ed) || log">
|
||||
<div
|
||||
v-if="(id && item.write_ed) || (props.data?.show_source && item.write_ed) || log"
|
||||
>
|
||||
<el-divider> <el-text type="info">知识来源</el-text> </el-divider>
|
||||
<div class="mb-8">
|
||||
<el-space wrap>
|
||||
|
|
@ -271,7 +274,7 @@ function openParagraph(row: any, id?: string) {
|
|||
}
|
||||
|
||||
function quickProblemHandle(val: string) {
|
||||
if (!props.log && !loading.value) {
|
||||
if (!props.log && !loading.value && props.data?.name && props.data?.model_id) {
|
||||
// inputValue.value = val
|
||||
// nextTick(() => {
|
||||
// quickInputRef.value?.focus()
|
||||
|
|
@ -488,7 +491,7 @@ function chatMessage(chat?: any, problem?: string, re_chat?: boolean) {
|
|||
}
|
||||
})
|
||||
.then(() => {
|
||||
return !props.appId && getSourceDetail(chat)
|
||||
return (id || props.data?.show_source) && getSourceDetail(chat)
|
||||
})
|
||||
.finally(() => {
|
||||
ChatManagement.close(chat.id)
|
||||
|
|
@ -505,14 +508,16 @@ function regenerationChart(item: chatType) {
|
|||
}
|
||||
|
||||
function getSourceDetail(row: any) {
|
||||
logApi.getRecordDetail(id, chartOpenId.value, row.record_id, loading).then((res) => {
|
||||
const exclude_keys = ['answer_text', 'id']
|
||||
Object.keys(res.data).forEach((key) => {
|
||||
if (!exclude_keys.includes(key)) {
|
||||
row[key] = res.data[key]
|
||||
}
|
||||
logApi
|
||||
.getRecordDetail(id || props.appId, chartOpenId.value, row.record_id, loading)
|
||||
.then((res) => {
|
||||
const exclude_keys = ['answer_text', 'id']
|
||||
Object.keys(res.data).forEach((key) => {
|
||||
if (!exclude_keys.includes(key)) {
|
||||
row[key] = res.data[key]
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
<template>
|
||||
<el-dialog title="访问限制" v-model="dialogVisible">
|
||||
<el-form label-position="top" ref="limitFormRef" :model="form">
|
||||
<el-form-item label="显示知识来源" @click.prevent>
|
||||
<el-switch size="small" v-model="form.show_source"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="客户端提问限制">
|
||||
<el-input-number
|
||||
v-model="form.access_num"
|
||||
|
|
@ -51,6 +54,7 @@ const emit = defineEmits(['refresh'])
|
|||
|
||||
const limitFormRef = ref()
|
||||
const form = ref<any>({
|
||||
show_source: false,
|
||||
access_num: 0,
|
||||
white_active: true,
|
||||
white_list: ''
|
||||
|
|
@ -62,6 +66,7 @@ const loading = ref(false)
|
|||
watch(dialogVisible, (bool) => {
|
||||
if (!bool) {
|
||||
form.value = {
|
||||
show_source: false,
|
||||
access_num: 0,
|
||||
white_active: true,
|
||||
white_list: ''
|
||||
|
|
@ -70,6 +75,7 @@ watch(dialogVisible, (bool) => {
|
|||
})
|
||||
|
||||
const open = (data: any) => {
|
||||
form.value.show_source = data.show_source
|
||||
form.value.access_num = data.access_num
|
||||
form.value.white_active = data.white_active
|
||||
form.value.white_list = data.white_list?.length ? data.white_list?.join('\n') : ''
|
||||
|
|
@ -81,6 +87,7 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
await formEl.validate((valid, fields) => {
|
||||
if (valid) {
|
||||
const obj = {
|
||||
show_source: form.value.show_source,
|
||||
white_list: form.value.white_list ? form.value.white_list.split('\n') : [],
|
||||
white_active: form.value.white_active,
|
||||
access_num: form.value.access_num
|
||||
|
|
|
|||
Loading…
Reference in New Issue