Commit 6b9ec22e authored by mhw's avatar mhw

预览修复 以及 提示词修改

parent 4e1ec2bb
...@@ -55,14 +55,10 @@ export default { ...@@ -55,14 +55,10 @@ export default {
// 遍历并输出链接的 href 属性 // 遍历并输出链接的 href 属性
anchorTags.forEach((aTag) => { anchorTags.forEach((aTag) => {
console.log(aTag);
let tagUrl = aTag.getAttribute('href') || '' let tagUrl = aTag.getAttribute('href') || ''
let isFile = ['pdf', 'jpg', 'gif', 'jpeg', 'png', 'docx', 'doc', 'xlsx', 'xls', 'mp4', 'webm', 'ogg', 'ogv', 'txt'].indexOf(tagUrl.split('.').pop().toLowerCase()) !== -1 let isFile = ['pdf', 'jpg', 'gif', 'jpeg', 'png', 'docx', 'doc', 'xlsx', 'xls', 'mp4', 'webm', 'ogg', 'ogv', 'txt'].indexOf(tagUrl.split('.').pop().toLowerCase()) !== -1
console.log(isFile);
let isFile2 = ['html', 'md', 'json', 'jsonl', 'csv', 'pdf', 'png', 'jpg', 'jpeg', 'bmp', 'eml', 'msg', 'epub', 'xlsx', 'xlsd', 'ipynb', 'odt', 'py', 'rst', 'rtf', 'srt', 'toml', 'tsv', 'docx', 'doc', 'xml', 'ppt', 'pptx', 'txt', 'htm'].indexOf(tagUrl.split('.').pop().toLowerCase()) !== -1 let isFile2 = ['html', 'md', 'json', 'jsonl', 'csv', 'pdf', 'png', 'jpg', 'jpeg', 'bmp', 'eml', 'msg', 'epub', 'xlsx', 'xlsd', 'ipynb', 'odt', 'py', 'rst', 'rtf', 'srt', 'toml', 'tsv', 'docx', 'doc', 'xml', 'ppt', 'pptx', 'txt', 'htm'].indexOf(tagUrl.split('.').pop().toLowerCase()) !== -1
if (isFile2 || aTag.id === 'show_detail') { // 判断知识库以及文件对话 的文件类型,并添加dom以及样式 || 添加特殊a标签展示详情内容 if (isFile2 || aTag.id === 'show_detail') { // 判断知识库以及文件对话 的文件类型,并添加dom以及样式 || 添加特殊a标签展示详情内容
console.log(aTag);
this.setDescribeStyle(aTag) this.setDescribeStyle(aTag)
} }
aTag.addEventListener('click', function (event) { aTag.addEventListener('click', function (event) {
...@@ -82,44 +78,16 @@ export default { ...@@ -82,44 +78,16 @@ export default {
// let describeDom = aTag.nextElementSibling // let describeDom = aTag.nextElementSibling
// 在当前元素前插入新的 HTML 内容 // 在当前元素前插入新的 HTML 内容
aTag.insertAdjacentHTML('afterend', ` aTag.insertAdjacentHTML('afterend', `
<button style="margin-bottom:10px" type="button" class="el-button el-button--primary el-button--mini is-round"> <button style="margin-top:10px" type="button" class="el-button el-button--primary el-button--mini is-round">
<span style="margin-right:5px">详情</span> <span style="margin-right:5px">详情</span>
<i class="el-icon-arrow-down"></i> <i class="el-icon-arrow-down"></i>
</button> </button>
`); `);
// 获取当前元素的父元素 var buttonDom = aTag.nextElementSibling;// 下拉按钮
var parentElement = aTag.parentNode; let describeDom = aTag.parentNode.nextElementSibling// 详情
// 获取当前元素在父元素中的索引
// var currentIndex = Array.from(parentElement.children).indexOf(aTag);
// 获取当前元素的同级后面的所有内容(包括文本节点)
var siblingNodesAfter = [];
var twoSibling = aTag.nextElementSibling;
var nextSibling = twoSibling.nextSibling;
while (nextSibling) {
if (nextSibling.nodeType === 1 || nextSibling.nodeType === 3) {
// 添加元素节点和文本节点
siblingNodesAfter.push(nextSibling);
}
nextSibling = nextSibling.nextSibling;
}
// 创建外层的 <div> 元素
var wrapperDiv = document.createElement('div');
wrapperDiv.classList.add('describe-view')
// 将获取的同级元素放入外层的 <div>
siblingNodesAfter.forEach(function (node) {
wrapperDiv.appendChild(node);
});
parentElement.appendChild(wrapperDiv);
// describeDom.classList.add('describe-view')
let describeDom = aTag.nextElementSibling.nextElementSibling
let height = describeDom.scrollHeight let height = describeDom.scrollHeight
describeDom.setAttribute('style', 'height:0px;') describeDom.setAttribute('style', 'height:0px;')
twoSibling.addEventListener('click', function (event) { buttonDom.addEventListener('click', function (event) {
if (height > 0 && (describeDom.style.height !== '0px' && describeDom.style.height !== '')) { if (height > 0 && (describeDom.style.height !== '0px' && describeDom.style.height !== '')) {
describeDom.setAttribute('style', 'height:0px;') describeDom.setAttribute('style', 'height:0px;')
} else { } else {
......
...@@ -181,7 +181,6 @@ export default { ...@@ -181,7 +181,6 @@ export default {
if (item.docs) { if (item.docs) {
item.docs = item.docs.map((item2) => { item.docs = item.docs.map((item2) => {
let tagUrl = ((item2?.match(/\]\((.*?)\)/g) || [])[0] || '').slice(2, -1) let tagUrl = ((item2?.match(/\]\((.*?)\)/g) || [])[0] || '').slice(2, -1)
console.log(tagUrl);
let url = '' let url = ''
item2 = item2.replace(/\n/g, '<br>') item2 = item2.replace(/\n/g, '<br>')
if (tagUrl.indexOf('https') !== -1) { if (tagUrl.indexOf('https') !== -1) {
...@@ -191,7 +190,28 @@ export default { ...@@ -191,7 +190,28 @@ export default {
url = tagUrl.replace(/^http:\/\/[^/]+\//, `http://${window.location.hostname}:${window.location.port}/`); url = tagUrl.replace(/^http:\/\/[^/]+\//, `http://${window.location.hostname}:${window.location.port}/`);
item2 = item2.replace(/\]\((.*?)\)/g, `](${url})`) item2 = item2.replace(/\]\((.*?)\)/g, `](${url})`)
} }
/// ////////出处内容包装div
var match = (item2.match(/出处(.*)\)/) || [])[0]
// 查找指定字符串的位置
var indexOfSpecifiedString = item2.indexOf(match);
if (indexOfSpecifiedString !== -1) {
// 使用 slice 获取指定字符串后面的所有内容
var contentAfterSpecifiedString = item2.slice(indexOfSpecifiedString + match.length);
item2 = item2.replace(contentAfterSpecifiedString, `<div class="describe-view">${contentAfterSpecifiedString}</div>`)
} else {
console.log('未找到匹配的指定字符串');
}
/// ////////特殊标签后包装div
var specifiedString = '<a id="show_detail"></a>';
var match2 = item2.match(new RegExp(specifiedString + '(.*)')) || [];
if (match2 && match2.length > 1) {
var textAfterSpecifiedString = match2[1];
// 修改文本内容
textAfterSpecifiedString = `<div class="describe-view">${textAfterSpecifiedString}</div>`
item2 = item2.replace(match2[1], textAfterSpecifiedString)
}
return item2.replace('出处', '知识溯源') return item2.replace('出处', '知识溯源')
}) })
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="场景类型:" > <el-form-item label="场景类型:" >
<el-radio v-model="form.scenarioType" v-for="item in ScenarioTypeDict.getList()" :label="item.id" :size="defaultFormItemSize" :key="item.id">{{ item.name }}</el-radio> <el-radio v-model="form.scenarioType" v-for="item in ScenarioTypeDict.getList()" :label="item.id" :size="defaultFormItemSize" :key="item.id" @input="changeScenarioType">{{ item.name }}</el-radio>
</el-form-item> </el-form-item>
<el-form-item label="变量识别符:"> <el-form-item label="变量识别符:">
<el-select v-model="form.parameterFormat" placeholder="请选择" :size="defaultFormItemSize" class="inputWidth"> <el-select v-model="form.parameterFormat" placeholder="请选择" :size="defaultFormItemSize" class="inputWidth">
...@@ -25,17 +25,17 @@ ...@@ -25,17 +25,17 @@
<el-radio v-model="form.templateFramework" @input="$refs.promptInput.init()" :label="item.id">{{ item.symbol }}</el-radio> <el-radio v-model="form.templateFramework" @input="$refs.promptInput.init()" :label="item.id">{{ item.symbol }}</el-radio>
</el-tooltip> </el-tooltip>
</el-form-item> </el-form-item>
<el-form-item label="Prompt:" prop="templateContent"> <el-form-item label="Prompt:" prop="templateContent" key="templateContent1">
<promptInput ref="promptInput" v-model="form.templateContent" :templateFramework="form.templateFramework" :isEdit="isEdit" /> <promptInput ref="promptInput" v-model="form.templateContent" :templateFramework="form.templateFramework" :isEdit="isEdit" />
</el-form-item> </el-form-item>
</template> </template>
<template v-else> <template v-else>
<el-form-item label="正向Prompt:"> <el-form-item label="正向Prompt:" prop="templateContent" key="templateContent2">
<el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="form.templateContent" class="inputWidth"> <el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="form.templateContent" class="inputWidth">
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="负向Prompt:"> <el-form-item label="负向Prompt:" prop="negativeTemplateContent" key="negativeTemplateContent1">
<el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="form.negativeTemplateContent" class="inputWidth"> <el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="form.negativeTemplateContent" class="inputWidth">
</el-input> </el-input>
...@@ -70,7 +70,8 @@ export default { ...@@ -70,7 +70,8 @@ export default {
}, },
rules: { rules: {
'templateName': [{ required: true, message: '请选输入名称', trigger: 'blur' }], 'templateName': [{ required: true, message: '请选输入名称', trigger: 'blur' }],
'templateContent': [{ required: true, message: '请选输入Prompt', trigger: 'blur' }] 'templateContent': [{ required: true, message: '请选输入Prompt', trigger: 'blur' }],
'negativeTemplateContent': [{ required: true, message: '请选输入负向Prompt', trigger: 'blur' }]
} }
}; };
...@@ -129,6 +130,14 @@ export default { ...@@ -129,6 +130,14 @@ export default {
} }
}); });
}); });
},
changeScenarioType () {
console.log(this.$refs.promptInput);
if (this.$refs.promptInput) {
this.$refs.promptInput.init()
}
this.form.templateContent = ''
this.form.negativeTemplateContent = ''
} }
} }
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="topBox"> <div class="topBox">
<div class="title">Prompt 模板</div> <div class="title">Prompt 模板</div>
<div class="instructions"> <div class="instructions">
集中管理平台训练、压缩及预置的生成式大模型,支持对模型进行评估、压缩及部署 管理和查看prompt模板,支持在服务调用时组合prompt输入推理
</div> </div>
</div> </div>
<div class="topButtonBox"> <div class="topButtonBox">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment