Commit 28b16207 authored by linpeiqin's avatar linpeiqin

Merge branch 'master' of http://218.76.0.69:3000/lmp/lmp_web

parents ebd649e2 affb3abc
This diff is collapsed.
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
// import projectConfig from '@/core/config'; // import projectConfig from '@/core/config';
import { getToken } from '@/utils'; import { getToken } from '@/utils';
class GetStreaming { class GetStreaming {
constructor (url, param, onmessage = () => {}) { constructor (url, param, onmessage = () => {}, success = () => {}) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
this.tokrn = getToken() this.tokrn = getToken()
this.param = param this.param = param
this.url = url this.url = url
this.es = null; this.es = null;
this.onmessage = onmessage this.onmessage = onmessage
this.success = success
} }
// 初始化weosocket // 初始化weosocket
initeventSource () { initeventSource () {
...@@ -36,6 +37,7 @@ class GetStreaming { ...@@ -36,6 +37,7 @@ class GetStreaming {
return reader.read().then(({ done, value }) => { return reader.read().then(({ done, value }) => {
if (done) { if (done) {
console.log('Stream ended'); console.log('Stream ended');
this.success()
return; return;
} }
const chunk = new TextDecoder().decode(value); const chunk = new TextDecoder().decode(value);
......
<!--导入 --> <!--导入 -->
<template> <template>
<el-form label-position="left" ref="form" label-width="120px" :model="form" :size="defaultFormItemSize"> <el-form label-position="left" ref="form" label-width="100px" :model="form" :size="defaultFormItemSize" :rules="rules" v-loading.fullscreen.lock="fullscreenLoading">
<!-- <el-form-item label="数据标注状态:"> <!-- <el-form-item label="数据标注状态:">
<el-radio v-for="item in DataAnnotationState.getList()" :key="item.id" v-model="form.dimensionType" <el-radio v-for="item in DataAnnotationState.getList()" :key="item.id" v-model="form.dimensionType"
...@@ -10,8 +10,14 @@ ...@@ -10,8 +10,14 @@
<el-radio v-for="item in ImportFormat.getList()" :key="item.id" v-model="form.dimensionType" <el-radio v-for="item in ImportFormat.getList()" :key="item.id" v-model="form.dimensionType"
:label="item.id">{{ item.name }}</el-radio> :label="item.id">{{ item.name }}</el-radio>
</el-form-item> --> </el-form-item> -->
<el-form-item label="上传jsonl文件:"> <el-form-item label="上传jsonl文件:" prop="importFile">
<input type="file" accept="application/json" @change="fileinfo($event.target.files)">
<el-button @click="clickUp" :size="defaultFormItemSize" type="primary">上传<i class="el-icon-upload el-icon--right"></i></el-button>
<input style="display:none" ref="upFile" type="file" accept="application/json" @change="fileinfo($event.target.files)" >
<div class="itemFile" v-if="form.importFile">{{ form.importFile?.name }}
<i class="el-icon-circle-close" style="color:#0092FF;cursor: pointer;" @click="clearFile()"></i>
</div>
</el-form-item> </el-form-item>
<el-row type="flex" justify="end" class="dialog-btn-layer mt20"> <el-row type="flex" justify="end" class="dialog-btn-layer mt20">
...@@ -27,9 +33,13 @@ ...@@ -27,9 +33,13 @@
export default { export default {
data () { data () {
return { return {
fullscreenLoading: false,
form: { form: {
importFile: '' importFile: undefined
},
rules: {
importFile: [{ required: true, message: '请上传文件', trigger: 'blur' }]
} }
}; };
...@@ -47,9 +57,14 @@ export default { ...@@ -47,9 +57,14 @@ export default {
methods: { methods: {
fileinfo (files) { fileinfo (files) {
console.log(files[0]);
this.form.importFile = files[0] this.form.importFile = files[0]
console.log(this.form.importFile); this.$refs.upFile.value = ''
},
clickUp () {
this.$refs.upFile.click()
}, },
intFrom () { intFrom () {
this.form = { ...this.form, datasetId: this.row.datasetId, versionId: this.row.versionId } this.form = { ...this.form, datasetId: this.row.datasetId, versionId: this.row.versionId }
}, },
...@@ -62,14 +77,17 @@ export default { ...@@ -62,14 +77,17 @@ export default {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (valid) { if (valid) {
this.fullscreenLoading = true
let params = {}; let params = {};
params = { ...this.form }; params = { ...this.form };
console.log(this.fetchUpload);
this.upload('/admin/app/datasetVersion/import', params).then(res => { this.upload('/admin/app/datasetVersion/import', params).then(res => {
resolve(res); resolve(res);
this.$message.success('上传成功'); this.$message.success('上传成功');
this.onCancel(true); this.onCancel(true);
this.fullscreenLoading = false
}).catch(e => { }).catch(e => {
this.fullscreenLoading = false
reject(e); reject(e);
}); });
// if (this.isEdit) { // if (this.isEdit) {
...@@ -94,6 +112,9 @@ export default { ...@@ -94,6 +112,9 @@ export default {
} }
}); });
}); });
},
clearFile () {
this.form.importFile = undefined
} }
} }
}; };
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<!-- <vxe-column field="index" title="序号"></vxe-column> --> <!-- <vxe-column field="index" title="序号"></vxe-column> -->
<vxe-column :field="'data.'+item" :title="item" v-for="item in columnList" :key="item"> <vxe-column :field="'data.'+item" :title="item" v-for="item in columnList" :key="item">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input style="height: 100%;" type="textarea" placeholder="请输入内容" v-model="scope.row.data[item]" :rows="10"> <el-input style="height: 100%;" type="textarea" placeholder="请输入内容" v-model="scope.row[item]" :rows="10">
</el-input> </el-input>
</template> </template>
</vxe-column> </vxe-column>
...@@ -36,10 +36,11 @@ export default { ...@@ -36,10 +36,11 @@ export default {
computed: {}, computed: {},
mounted () { mounted () {
console.log(this.row);
this.form._id = this.row._id this.form._id = this.row._id
this.form.versionId = this.row.versionId this.form.versionId = this.row.versionId
this.form.data = JSON.parse(JSON.stringify(this.row)) this.form.data = this.row.data
delete this.form.data._X_ROW_KEY
console.log(this.form.data);
}, },
methods: { methods: {
...@@ -50,8 +51,8 @@ export default { ...@@ -50,8 +51,8 @@ export default {
}, },
onSubmit () { onSubmit () {
let params = {}; let params = {};
params.datasetMongoDto = { ...this.form.data}; params.datasetMongoDto = this.form;
console.log(params);
DatasetData.update(this, params).then(res => { DatasetData.update(this, params).then(res => {
this.$message.success('编辑成功'); this.$message.success('编辑成功');
this.onCancel(true); this.onCancel(true);
......
...@@ -90,7 +90,13 @@ export default { ...@@ -90,7 +90,13 @@ export default {
} }
} }
} }
dataList.forEach(element => {
for (const key in element.data) {
if (Object.hasOwnProperty.call(element.data, key)) {
element.data[key] = JSON.stringify(element.data[key])
}
}
});
resolve({ resolve({
dataList, dataList,
totalCount: res.data.totalCount totalCount: res.data.totalCount
...@@ -109,9 +115,10 @@ export default { ...@@ -109,9 +115,10 @@ export default {
}); });
}, },
label (row) { // 标注 label (row) { // 标注
let newRow = JSON.parse(JSON.stringify(row))
this.$dialog.show('标注', label, { this.$dialog.show('标注', label, {
area: ['70%', '50%'] area: ['70%', '50%']
}, { row: row, columnList: this.columnList, refresh: this.refresh}).then(res => { }, { row: newRow, columnList: this.columnList, refresh: this.refresh}).then(res => {
this.refresh() this.refresh()
}).catch(e => { }); }).catch(e => { });
}, },
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
更多<i class="el-icon-arrow-down el-icon--right"></i> 更多<i class="el-icon-arrow-down el-icon--right"></i>
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item v-if="scope.row.releaseStatus!==1" @click.native="putOut(scope.row)">发布</el-dropdown-item>
<el-dropdown-item @click.native="derived(scope.row)">导出</el-dropdown-item> <el-dropdown-item @click.native="derived(scope.row)">导出</el-dropdown-item>
<el-dropdown-item @click.native="analyse(scope.row)">分析</el-dropdown-item> <el-dropdown-item @click.native="analyse(scope.row)">分析</el-dropdown-item>
<el-dropdown-item @click.native="enhance(scope.row)">增强</el-dropdown-item> <el-dropdown-item @click.native="enhance(scope.row)">增强</el-dropdown-item>
...@@ -77,7 +78,7 @@ export default { ...@@ -77,7 +78,7 @@ export default {
methods: { methods: {
dataImport (data) { dataImport (data) {
this.$dialog.show('导入', dataImport, { this.$dialog.show('导入', dataImport, {
area: ['600px', 'auto'] area: ['600px', '200px']
}, { row: data }).then(res => { }, { row: data }).then(res => {
this.refresh() this.refresh()
}).catch(e => { }); }).catch(e => { });
...@@ -120,6 +121,9 @@ export default { ...@@ -120,6 +121,9 @@ export default {
}, },
enhance (data) { // 增强 enhance (data) { // 增强
},
putOut (data) {
console.log(data);
} }
} }
} }
......
<!-- 文件预览 -->
<template>
<div style="height: calc(100vh - 100px);position: relative;" v-loading.fullscreen.lock="fullscreenLoading" >
<div class="down"><a :href="url" >下载文件</a></div>
<div class="image" v-if="['jpg','gif','jpeg','png'].indexOf(fileType)>-1&&url">
<el-image :src="url"> </el-image>
</div>
<vue-office-docx v-if="['docx','doc'].indexOf(fileType)>-1&&url" :src="url" style="height: 100%;" @rendered="rendered" @error="fullscreenLoading=false"/>
<vue-office-excel v-else-if="['xlsx','xls'].indexOf(fileType)>-1&&url" :src="url" style="height: 100%;" @rendered="rendered" @error="fullscreenLoading=false" />
<template v-else-if="['pdf'].indexOf(fileType)>-1&&url" >
<div class="pagination" >
{{pageCount}}
<!-- <el-button size="mini" type="primary" @click="changePdfPage(0)" class="turn" :disabled=" currentPage==1" >上一页</el-button>
<el-button size="mini" type="primary" @click="changePdfPage(1)" class="turn" :disabled="currentPage==pageCount" >下一页</el-button> -->
当前第 &nbsp; &nbsp;<el-input-number v-model="currentPage" size="mini" :min="1" ></el-input-number >&nbsp; &nbsp;
</div>
<pdf :page="currentPage" :src="url" class="pdf"></pdf>
</template>
<div class="txt" v-else-if="['txt'].indexOf(fileType)>-1" v-html="txtContent">
</div>
</div>
</template>
<script>
// 引入VueOfficeDocx组件
import VueOfficeDocx from '@vue-office/docx'
// 引入相关样式
import '@vue-office/docx/lib/index.css'
// 引入VueOfficeExcel组件
import VueOfficeExcel from '@vue-office/excel'
// 引入相关样式
import '@vue-office/excel/lib/index.css'
import pdf from 'vue-pdf'
export default {
data () {
return {
fullscreenLoading: true,
txtContent: '',
pageCount: 0, // pdf文件总页数
currentPage: 1 // pdf文件页码
};
},
components: {
VueOfficeDocx,
VueOfficeExcel,
pdf
},
props: ['url'],
computed: {
fileType () {
return this.url.split('.').pop().toLowerCase();
}
},
mounted () {
if (this.fileType === 'txt') {
this.getFileFromUrl(this.file.url, 'txt.txt').then((res) => {
const fileReader = new FileReader();
fileReader.addEventListener('load', () => {
const fileContent = fileReader.result;
// 处理文件内容
this.txtContent = fileContent.replace(/\n/g, '<br/>')
});
fileReader.readAsText(res, 'gb2312');
})
}
this.getNumPages(this.url)
},
methods: {
getNumPages (url) {
var loadingTask = pdf.createLoadingTask(url)
// var loadingTask = this.pdf.default.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.pageCount = pdf.numPages
this.fullscreenLoading = false
}).catch((e) => {
console.log(e);
this.fullscreenLoading = false
})
},
changePdfPage (val) {
if (val === 0 && this.currentPage > 1) {
this.currentPage--
}
if (val === 1 && this.currentPage < this.pageCount) {
this.currentPage++
}
},
getFileFromUrl (url, fileName) {
return new Promise((resolve, reject) => {
var blob = null;
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.overrideMimeType('text/xml;charset=' + 'gb2312')
// 此处类型依据具体情况设置
xhr.setRequestHeader('Accept', 'text/plain');
xhr.responseType = 'blob';
// 加载时处理
xhr.onload = () => { // 获取返回结果
blob = xhr.response;
// 此处类型依据具体情况设置,同上
let file = new File([blob], fileName, { type: 'text/plain' });
// 返回结果
resolve(file);
this.fullscreenLoading = false
};
xhr.onerror = (e) => {
this.fullscreenLoading = false
reject(e)
};
// 发送
xhr.send();
});
},
rendered () {
this.fullscreenLoading = false
console.log('渲染完成')
}
}
}
</script>
<style scoped>
.txt{
height: 100%;
overflow: auto;
}
.pagination{
font-size: 14px;
display: flex;
align-items: center;
justify-content: flex-end;
position: absolute;
top: 0px;
right: 10px;
z-index: 10;
}
.down{
width: 100%;
}
.down a{
background-color: #0092FF;
color: #FFFFFF;
display: inline-block;
line-height: 1;
white-space: nowrap;
cursor: pointer;
background: #FFFFFF;
border: 1px solid #0092FF;
border-color: #0092FF;
text-align: center;
box-sizing: border-box;
outline: none;
margin: 0;
transition: .1s;
font-weight: 500;
padding: 12px 20px;
font-size: 14px;
border-radius: 4px;
z-index: 100;
}
</style>
<!-- 答案内容预览 --> <!-- 答案内容预览 -->
<template> <template>
<vue-markdown :source="content" v-highlight class="markdown-body" > <vue-markdown :source="content" v-highlight class="markdown-body" :id="'myContainer'+index" >
</vue-markdown> </vue-markdown>
</template> </template>
...@@ -10,13 +10,14 @@ import hljs from 'highlight.js' // 代码块高亮 ...@@ -10,13 +10,14 @@ import hljs from 'highlight.js' // 代码块高亮
// import 'highlight.js/styles/github.css' // 代码块高亮样式 // import 'highlight.js/styles/github.css' // 代码块高亮样式
import 'github-markdown-css' // 整体 markdown 样式 import 'github-markdown-css' // 整体 markdown 样式
import VueMarkdown from 'vue-markdown' import VueMarkdown from 'vue-markdown'
import filePreview from './filePreview'
export default { export default {
data () { data () {
return { return {
result: undefined result: undefined
}; };
}, },
props: ['content'], props: ['content', 'index', 'isSuccess'],
components: {VueMarkdown}, components: {VueMarkdown},
computed: {}, computed: {},
...@@ -38,8 +39,41 @@ export default { ...@@ -38,8 +39,41 @@ export default {
mounted () { mounted () {
}, },
watch: {
'isSuccess' () {
if (this.isSuccess) {
let that = this
const anchorTags = document.querySelectorAll(`#myContainer${this.index} a`);
// 遍历并输出链接的 href 属性
anchorTags.forEach((aTag) => {
aTag.addEventListener('click', function (event) {
let tagUrl = aTag.getAttribute('href')
let url;
// alert(aTag.getAttribute('href'))
if (['jpg', 'gif', 'jpeg', 'png', 'docx', 'doc', 'xlsx', 'xls'].indexOf(tagUrl.split('.').pop().toLowerCase()) !== -1) {
// 阻止默认点击事件
event.preventDefault();
if (tagUrl.indexOf('https') !== -1) {
url = tagUrl.replace(/^https:\/\/[^/]+\//, `https://${window.location.hostname}:${window.location.port}/`);
} else {
url = tagUrl.replace(/^http:\/\/[^/]+\//, `http://${window.location.hostname}:${window.location.port}/`);
}
that.$dialog.show('文件预览', filePreview, {
area: ['100%', '100%']
}, {url}).then(res => {
}).catch(e => { });
}
});
});
}
}
},
methods: {
methods: {} }
} }
</script> </script>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
GPT GPT
</div> </div>
<div class="content"> <div class="content">
<contentView :content="item.answer" /> <contentView :content="item.answer" ref="contentView" :index="index" :isSuccess="isSuccess" />
</div> </div>
</div> </div>
...@@ -49,6 +49,7 @@ import contentView from '../contentView'; ...@@ -49,6 +49,7 @@ import contentView from '../contentView';
export default { export default {
data () { data () {
return { return {
isSuccess: false,
templateController: undefined, templateController: undefined,
isPromptTemplate: true, isPromptTemplate: true,
inputContent: null, inputContent: null,
...@@ -89,6 +90,7 @@ export default { ...@@ -89,6 +90,7 @@ export default {
this.myHistory = [] this.myHistory = []
}, },
submit () { submit () {
this.isSuccess = false
this.param.model_name = this.chatForm.model_name this.param.model_name = this.chatForm.model_name
this.param.temperature = this.chatForm.temperature this.param.temperature = this.chatForm.temperature
this.heistoryRotate = this.chatForm.heistoryRotate this.heistoryRotate = this.chatForm.heistoryRotate
...@@ -118,9 +120,13 @@ export default { ...@@ -118,9 +120,13 @@ export default {
}) })
this.$emit('submit') this.$emit('submit')
let getData = new GetStreaming(apiUrl, this.param, this.onmessage) let getData = new GetStreaming(apiUrl, this.param, this.onmessage, this.success)
getData.initeventSource() getData.initeventSource()
}, },
success () {
console.log(1111);
this.isSuccess = true
},
onmessage (data) { onmessage (data) {
let nowChat = this.myHistory[this.myHistory.length - 1] let nowChat = this.myHistory[this.myHistory.length - 1]
if (this.chatForm.pattern === 'LLM 对话') { if (this.chatForm.pattern === 'LLM 对话') {
......
...@@ -112,7 +112,8 @@ export default { ...@@ -112,7 +112,8 @@ export default {
methods: { methods: {
init () { init () {
Object.assign(this.$data, this.$options.data()) Object.assign(this.$data, this.$options.data());
this.$emit('input', undefined)
}, },
changeInput (data) { changeInput (data) {
this.prompt = data this.prompt = data
...@@ -127,7 +128,7 @@ export default { ...@@ -127,7 +128,7 @@ export default {
return item.label + ':' + item.value + '\n' return item.label + ':' + item.value + '\n'
} }
}).join('') }).join('')
console.log(promptsString);
this.$emit('input', [1, 2, 3].indexOf(this.templateFramework) === -1 ? this.prompt : promptsString) this.$emit('input', [1, 2, 3].indexOf(this.templateFramework) === -1 ? this.prompt : promptsString)
}, },
add (item) { add (item) {
......
...@@ -13,6 +13,17 @@ module.exports = {// ...@@ -13,6 +13,17 @@ module.exports = {//
pathRewrite: { pathRewrite: {
'^/2api': '' '^/2api': ''
} }
},
'/knowledge_base': {
/* 目标代理服务器地址 */
target: 'http://192.168.0.36:7861', //
// target: "http://192.168.1.102:8888", //
/* 允许跨域 */
changeOrigin: true,
ws: true
// pathRewrite: {
// '^/api': ''
// }
} }
} }
} }
......
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