feat: 创建应用
This commit is contained in:
parent
ee310ef636
commit
89d692583d
@ -34,20 +34,7 @@ const getApplication: (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建应用
|
* 创建应用
|
||||||
* @param 参数
|
* @param 参数
|
||||||
* {
|
|
||||||
"name": "string",
|
|
||||||
"desc": "string",
|
|
||||||
"model_id": "string",
|
|
||||||
"multiple_rounds_dialogue": true,
|
|
||||||
"prologue": "string",
|
|
||||||
"example": [
|
|
||||||
"string"
|
|
||||||
],
|
|
||||||
"dataset_id_list": [
|
|
||||||
"string"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
const postApplication: (
|
const postApplication: (
|
||||||
data: ApplicationFormType,
|
data: ApplicationFormType,
|
||||||
@ -59,19 +46,7 @@ const postApplication: (
|
|||||||
/**
|
/**
|
||||||
* 修改应用
|
* 修改应用
|
||||||
* @param 参数
|
* @param 参数
|
||||||
* {
|
|
||||||
"name": "string",
|
|
||||||
"desc": "string",
|
|
||||||
"model_id": "string",
|
|
||||||
"multiple_rounds_dialogue": true,
|
|
||||||
"prologue": "string",
|
|
||||||
"example": [
|
|
||||||
"string"
|
|
||||||
],
|
|
||||||
"dataset_id_list": [
|
|
||||||
"string"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
const putApplication: (
|
const putApplication: (
|
||||||
applicaiton_id: String,
|
applicaiton_id: String,
|
||||||
@ -168,12 +143,7 @@ const getProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
|
|||||||
/**
|
/**
|
||||||
* 获得临时回话Id
|
* 获得临时回话Id
|
||||||
* @param 参数
|
* @param 参数
|
||||||
* {
|
|
||||||
"model_id": "string",
|
|
||||||
"multiple_rounds_dialogue": true,
|
|
||||||
"dataset_id_list": [
|
|
||||||
"string"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const postChatOpen: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
|
const postChatOpen: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
|
||||||
|
|||||||
@ -3,11 +3,19 @@ import { type Ref } from 'vue'
|
|||||||
interface ApplicationFormType {
|
interface ApplicationFormType {
|
||||||
name?: string
|
name?: string
|
||||||
desc?: string
|
desc?: string
|
||||||
model_id: string
|
model_id?: string
|
||||||
multiple_rounds_dialogue: boolean
|
multiple_rounds_dialogue?: boolean
|
||||||
prologue?: string
|
prologue?: string
|
||||||
example?: string[]
|
dataset_id_list?: string[]
|
||||||
dataset_id_list: string[]
|
dataset_setting?: {
|
||||||
|
top_n: number
|
||||||
|
similarity: number
|
||||||
|
max_paragraph_char_number: number
|
||||||
|
}
|
||||||
|
model_setting?: {
|
||||||
|
prompt: string
|
||||||
|
}
|
||||||
|
problem_optimization?: boolean
|
||||||
}
|
}
|
||||||
interface chatType {
|
interface chatType {
|
||||||
id: string
|
id: string
|
||||||
|
|||||||
@ -191,7 +191,7 @@ const isDisabledChart = computed(
|
|||||||
|
|
||||||
const prologueList = computed(() => {
|
const prologueList = computed(() => {
|
||||||
const temp = props.data?.prologue
|
const temp = props.data?.prologue
|
||||||
const lines = temp.split('\n')
|
const lines = temp?.split('\n')
|
||||||
return lines
|
return lines
|
||||||
})
|
})
|
||||||
const isMdArray = (val: string) => val.match(/^-\s.*/m)
|
const isMdArray = (val: string) => val.match(/^-\s.*/m)
|
||||||
@ -240,11 +240,7 @@ const startChat = (chat: chatType) => {
|
|||||||
*/
|
*/
|
||||||
function getChartOpenId() {
|
function getChartOpenId() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const obj = {
|
const obj = props.data
|
||||||
model_id: props.data.model_id,
|
|
||||||
dataset_id_list: props.data.dataset_id_list,
|
|
||||||
multiple_rounds_dialogue: props.data.multiple_rounds_dialogue
|
|
||||||
}
|
|
||||||
if (props.appId) {
|
if (props.appId) {
|
||||||
applicationApi
|
applicationApi
|
||||||
.getChatOpen(props.appId)
|
.getChatOpen(props.appId)
|
||||||
|
|||||||
@ -49,7 +49,7 @@
|
|||||||
<div class="flex-between">
|
<div class="flex-between">
|
||||||
<span>AI 模型 <span class="danger">*</span></span>
|
<span>AI 模型 <span class="danger">*</span></span>
|
||||||
|
|
||||||
<el-button type="primary" link>提示词</el-button>
|
<el-button type="primary" link @click="promptChange('open')">提示词</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-select
|
<el-select
|
||||||
@ -106,8 +106,8 @@
|
|||||||
>参数设置</el-button
|
>参数设置</el-button
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
<div class="set-rules__form">
|
<div class="dataset_setting">
|
||||||
<div class="form-item mb-16">
|
<div class="form-item mb-16 p-8">
|
||||||
<div class="title flex align-center mb-8">
|
<div class="title flex align-center mb-8">
|
||||||
<span style="margin-right: 4px">相似度</span>
|
<span style="margin-right: 4px">相似度</span>
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
@ -123,22 +123,23 @@
|
|||||||
<div @click.stop>
|
<div @click.stop>
|
||||||
高于
|
高于
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="formInline.similarity"
|
v-model="applicationForm.dataset_setting.similarity"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="1"
|
:max="1"
|
||||||
:precision="3"
|
:precision="3"
|
||||||
:step="0.1"
|
:step="0.1"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
style="width: 100px"
|
style="width: 100px"
|
||||||
|
size="small"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-item mb-16">
|
<div class="form-item mb-16 p-8">
|
||||||
<div class="title mb-8">引用分段数</div>
|
<div class="title mb-8">引用分段数</div>
|
||||||
<div @click.stop>
|
<div @click.stop>
|
||||||
TOP
|
TOP
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="formInline.top_number"
|
v-model="applicationForm.dataset_setting.top_n"
|
||||||
:min="1"
|
:min="1"
|
||||||
:max="10"
|
:max="10"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
@ -149,16 +150,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-item mb-16">
|
<div class="form-item mb-16 p-8">
|
||||||
<div class="title mb-8">最多引用字符数</div>
|
<div class="title mb-8">最多引用字符数</div>
|
||||||
<div class="flex align-center">
|
<div class="flex align-center">
|
||||||
<el-slider
|
<el-slider
|
||||||
v-model="formInline.top_number"
|
v-model="applicationForm.dataset_setting.max_paragraph_char_number"
|
||||||
show-input
|
show-input
|
||||||
:show-input-controls="false"
|
:show-input-controls="false"
|
||||||
:min="500"
|
:min="500"
|
||||||
:max="10000"
|
:max="10000"
|
||||||
style="width: 220px"
|
style="width: 200px"
|
||||||
size="small"
|
size="small"
|
||||||
/>
|
/>
|
||||||
<span class="ml-4">个字符</span>
|
<span class="ml-4">个字符</span>
|
||||||
@ -166,7 +167,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<el-button @click="popoverVisible = false" size="small">取消</el-button>
|
|
||||||
<el-button type="primary" @click="popoverVisible = false" size="small"
|
<el-button type="primary" @click="popoverVisible = false" size="small"
|
||||||
>确认</el-button
|
>确认</el-button
|
||||||
>
|
>
|
||||||
@ -220,21 +220,6 @@
|
|||||||
:toolbars="[]"
|
:toolbars="[]"
|
||||||
:footers="[]"
|
:footers="[]"
|
||||||
/>
|
/>
|
||||||
<!-- <el-input
|
|
||||||
v-model="applicationForm.prologue"
|
|
||||||
type="textarea"
|
|
||||||
placeholder="开始对话的欢迎语。您可以这样写:您好,我是 MaxKB 智能小助手,您可以向我提出 MaxKB 产品使用中遇到的任何问题。"
|
|
||||||
:rows="4"
|
|
||||||
/> -->
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="示例">
|
|
||||||
<template v-for="(item, index) in exampleList" :key="index">
|
|
||||||
<el-input
|
|
||||||
v-model="exampleList[index]"
|
|
||||||
:placeholder="`用户提问 示例${index + 1}`"
|
|
||||||
class="mb-8"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
@ -256,6 +241,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-dialog v-model="dialogFormVisible" title="提示词">
|
||||||
|
<el-alert type="info" show-icon class="mb-16" :closable="false">
|
||||||
|
<p>通过调整提示词内容,可以引导大模型聊天方向,该提示词会被固定在上下文的开头。</p>
|
||||||
|
<p>可以使用变量:{data} 是携带知识库中已知信息;{question}是用户提出的问题。</p>
|
||||||
|
</el-alert>
|
||||||
|
<el-input v-model="model_setting_prompt" :rows="13" type="textarea" />
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogFormVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="promptChange('close')"> 确认 </el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
<AddDatasetDialog
|
<AddDatasetDialog
|
||||||
ref="AddDatasetDialogRef"
|
ref="AddDatasetDialogRef"
|
||||||
@addData="addDataset"
|
@addData="addDataset"
|
||||||
@ -274,7 +272,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref, watch, onMounted } from 'vue'
|
import { reactive, ref, watch, onMounted } from 'vue'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { groupBy } from 'lodash'
|
import { groupBy, cloneDeep } from 'lodash'
|
||||||
import AddDatasetDialog from './components/AddDatasetDialog.vue'
|
import AddDatasetDialog from './components/AddDatasetDialog.vue'
|
||||||
import CreateModelDialog from '@/views/template/component/CreateModelDialog.vue'
|
import CreateModelDialog from '@/views/template/component/CreateModelDialog.vue'
|
||||||
import SelectProviderDialog from '@/views/template/component/SelectProviderDialog.vue'
|
import SelectProviderDialog from '@/views/template/component/SelectProviderDialog.vue'
|
||||||
@ -295,6 +293,31 @@ const {
|
|||||||
params: { id }
|
params: { id }
|
||||||
} = route as any
|
} = route as any
|
||||||
|
|
||||||
|
const defaultPrompt = `已知信息:
|
||||||
|
|
||||||
|
{data}
|
||||||
|
|
||||||
|
回答要求:
|
||||||
|
|
||||||
|
- 请简洁和专业的来回答用户的问题。
|
||||||
|
|
||||||
|
- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。
|
||||||
|
|
||||||
|
- 避免提及你是从已知信息中获得的知识。
|
||||||
|
|
||||||
|
- 请保证答案与已知信息中描述的一致。
|
||||||
|
|
||||||
|
- 请使用 Markdown 语法优化答案的格式。
|
||||||
|
|
||||||
|
- 已知信息中的图片、链接地址和脚本语言请直接返回。
|
||||||
|
|
||||||
|
- 请使用与问题相同的语言来回答。
|
||||||
|
|
||||||
|
问题:
|
||||||
|
|
||||||
|
{question}
|
||||||
|
`
|
||||||
|
|
||||||
const createModelRef = ref<InstanceType<typeof CreateModelDialog>>()
|
const createModelRef = ref<InstanceType<typeof CreateModelDialog>>()
|
||||||
const selectProviderRef = ref<InstanceType<typeof SelectProviderDialog>>()
|
const selectProviderRef = ref<InstanceType<typeof SelectProviderDialog>>()
|
||||||
|
|
||||||
@ -303,7 +326,6 @@ const AddDatasetDialogRef = ref()
|
|||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const datasetLoading = ref(false)
|
const datasetLoading = ref(false)
|
||||||
const exampleList = ref(['', ''])
|
|
||||||
const applicationForm = ref<ApplicationFormType>({
|
const applicationForm = ref<ApplicationFormType>({
|
||||||
name: '',
|
name: '',
|
||||||
desc: '',
|
desc: '',
|
||||||
@ -313,14 +335,18 @@ const applicationForm = ref<ApplicationFormType>({
|
|||||||
- MaxKB 主要功能有什么?
|
- MaxKB 主要功能有什么?
|
||||||
- MaxKB 支持哪些大语言模型?
|
- MaxKB 支持哪些大语言模型?
|
||||||
- MaxKB 支持哪些文档类型?`,
|
- MaxKB 支持哪些文档类型?`,
|
||||||
example: [],
|
dataset_id_list: [],
|
||||||
dataset_id_list: []
|
dataset_setting: {
|
||||||
|
top_n: 3,
|
||||||
|
similarity: 0.6,
|
||||||
|
max_paragraph_char_number: 5000
|
||||||
|
},
|
||||||
|
model_setting: {
|
||||||
|
prompt: defaultPrompt
|
||||||
|
},
|
||||||
|
problem_optimization: true
|
||||||
})
|
})
|
||||||
|
|
||||||
const formInline = reactive({
|
|
||||||
similarity: 0.6,
|
|
||||||
top_number: 5
|
|
||||||
})
|
|
||||||
const popoverVisible = ref(false)
|
const popoverVisible = ref(false)
|
||||||
|
|
||||||
const rules = reactive<FormRules<ApplicationFormType>>({
|
const rules = reactive<FormRules<ApplicationFormType>>({
|
||||||
@ -336,14 +362,19 @@ const rules = reactive<FormRules<ApplicationFormType>>({
|
|||||||
const modelOptions = ref<any>(null)
|
const modelOptions = ref<any>(null)
|
||||||
const providerOptions = ref<Array<Provider>>([])
|
const providerOptions = ref<Array<Provider>>([])
|
||||||
const datasetList = ref([])
|
const datasetList = ref([])
|
||||||
|
const dialogFormVisible = ref(false)
|
||||||
|
|
||||||
watch(
|
const model_setting_prompt = ref('')
|
||||||
() => exampleList.value,
|
|
||||||
(val) => {
|
function promptChange(val: string) {
|
||||||
applicationForm.value.example = val.filter((v) => v)
|
if (val === 'open') {
|
||||||
},
|
dialogFormVisible.value = true
|
||||||
{ deep: true }
|
model_setting_prompt.value = applicationForm.value.model_setting.prompt
|
||||||
)
|
} else if (val === 'close') {
|
||||||
|
dialogFormVisible.value = false
|
||||||
|
applicationForm.value.model_setting.prompt = model_setting_prompt.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const submit = async (formEl: FormInstance | undefined) => {
|
const submit = async (formEl: FormInstance | undefined) => {
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
@ -387,11 +418,6 @@ function getDetail() {
|
|||||||
application.asyncGetApplicationDetail(id, loading).then((res: any) => {
|
application.asyncGetApplicationDetail(id, loading).then((res: any) => {
|
||||||
applicationForm.value = res.data
|
applicationForm.value = res.data
|
||||||
applicationForm.value.model_id = res.data.model
|
applicationForm.value.model_id = res.data.model
|
||||||
if (res.data?.example.length === 2) {
|
|
||||||
exampleList.value = res.data?.example
|
|
||||||
} else if (res.data?.example.length === 1) {
|
|
||||||
exampleList.value = [res.data?.example[0], '']
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,4 +501,9 @@ onMounted(() => {
|
|||||||
.prologue-md-editor {
|
.prologue-md-editor {
|
||||||
height: 150px;
|
height: 150px;
|
||||||
}
|
}
|
||||||
|
.dataset_setting {
|
||||||
|
.form-item {
|
||||||
|
background: var(--app-layout-bg-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
<el-form-item label="选择器" v-if="detail.type === '1'">
|
<el-form-item label="选择器" v-if="detail.type === '1'">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.selector"
|
v-model="form.selector"
|
||||||
placeholder="请输入选择器"
|
placeholder="默认为 body,可输入 .classname/#idname/tagname"
|
||||||
@blur="form.selector = form.selector.trim()"
|
@blur="form.selector = form.selector.trim()"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
@ -75,7 +75,7 @@
|
|||||||
<ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" />
|
<ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" />
|
||||||
</LayoutContainer>
|
</LayoutContainer>
|
||||||
<div class="hit-test__operate p-24 pt-0">
|
<div class="hit-test__operate p-24 pt-0">
|
||||||
<el-popover :visible="popoverVisible" placement="top-start" :width="600" trigger="click">
|
<el-popover :visible="popoverVisible" placement="top-start" :width="500" trigger="click">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button icon="Setting" class="mb-8" @click="popoverVisible = !popoverVisible"
|
<el-button icon="Setting" class="mb-8" @click="popoverVisible = !popoverVisible"
|
||||||
>参数设置</el-button
|
>参数设置</el-button
|
||||||
@ -106,8 +106,8 @@
|
|||||||
/>
|
/>
|
||||||
个分段
|
个分段
|
||||||
</div>
|
</div>
|
||||||
<el-button class="ml-16" @click="popoverVisible = false">取消</el-button>
|
<!-- <el-button class="ml-16" @click="popoverVisible = false">取消</el-button> -->
|
||||||
<el-button type="primary" @click="popoverVisible = false">确认</el-button>
|
<el-button class="ml-16" type="primary" @click="popoverVisible = false">确认</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
<div class="operate-textarea flex">
|
<div class="operate-textarea flex">
|
||||||
@ -157,7 +157,7 @@ const paragraphDetail = ref<any[]>([])
|
|||||||
const title = ref('')
|
const title = ref('')
|
||||||
const inputValue = ref('')
|
const inputValue = ref('')
|
||||||
const formInline = reactive({
|
const formInline = reactive({
|
||||||
similarity: 0.600,
|
similarity: 0.6,
|
||||||
top_number: 5
|
top_number: 5
|
||||||
})
|
})
|
||||||
const popoverVisible = ref(false)
|
const popoverVisible = ref(false)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user