Commit c2b8165a authored by pengxin's avatar pengxin

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

parents 1c211948 b7558ad7
This diff is collapsed.
module.exports = { module.exports = {
// baseUrl: 'http://218.76.0.69:8082/', // baseUrl: 'http://218.76.0.69:8082/',
// baseUrl: 'http://192.168.0.34:8082/', baseUrl: 'http://192.168.0.34:8082/',
// baseUrl: 'http://192.168.0.36:8082/', // baseUrl: 'http://192.168.0.36:8082/',
baseUrl: 'http://192.168.0.168:8082/', // baseUrl: 'http://192.168.0.168:8082/',
wsUrl: 'ws://218.76.0.69:7860/', wsUrl: 'ws://218.76.0.69:7860/',
projectName: '灵境大模型平台' projectName: '灵境大模型平台'
} }
// import { Message } from 'element-ui'; // import { Message } from 'element-ui';
// import projectConfig from '@/core/config'; // import projectConfig from '@/core/config';
import { getToken } from '@/utils'; // import { getToken } from '@/utils';
class GetStreaming {
constructor (url, param, onmessage = () => {}, success = () => {}) {
// eslint-disable-next-line no-unused-vars
this.tokrn = getToken()
this.param = param
this.url = url
this.es = null;
this.onmessage = onmessage
this.success = success
}
// 初始化weosocket
initeventSource () {
fetch(this.url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.param)
})
.then(response => {
if (response.ok) {
const reader = response.body.getReader();
return this.readStream(reader);
} else {
throw new Error(`Unexpected status code: ${response.status}`);
}
})
.catch(error => {
console.error(`Error: ${error.message}`);
});
}
readStream (reader) { import { fetchEventSource } from '@microsoft/fetch-event-source';
return reader.read().then(({ done, value }) => { // class GetStreaming {
if (done) { // constructor (url, param, onmessage = () => {}, success = () => {}) {
console.log('Stream ended'); // // eslint-disable-next-line no-unused-vars
this.success() // this.tokrn = getToken()
return; // this.param = param
} // this.url = url
const chunk = new TextDecoder().decode(value); // this.es = null;
this.onmessage(chunk) // this.onmessage = onmessage
// Continue reading the next chunk // this.success = success
return this.readStream(reader); // }
}); // // 初始化weosocket
} // initeventSource () {
} // fetch(this.url, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify(this.param)
// })
// .then(response => {
// if (response.ok) {
// const reader = response.body.getReader();
// return this.readStream(reader);
// } else {
// throw new Error(`Unexpected status code: ${response.status}`);
// }
// })
// .catch(error => {
// console.error(`Error: ${error.message}`);
// });
// }
export { GetStreaming } // readStream (reader) {
// return reader.read().then(({ done, value }) => {
// if (done) {
// console.log('Stream ended');
// this.success()
// return;
// }
// const chunk = new TextDecoder().decode(value);
// this.onmessage(chunk)
// // Continue reading the next chunk
// return this.readStream(reader);
// });
// }
// }
// export { GetStreaming }
// import { fetchEventSource } from '@microsoft/fetch-event-source'; // import { fetchEventSource } from '@microsoft/fetch-event-source';
// submit () { // submit () {
...@@ -73,3 +75,42 @@ export { GetStreaming } ...@@ -73,3 +75,42 @@ export { GetStreaming }
// } // }
// }); // });
// } // }
class GetStreaming {
constructor(url, param, onmessage = () => { }, success = () => { }) {
// eslint-disable-next-line no-unused-vars
// this.tokrn = getToken()
this.param = param
this.url = url
this.es = null;
this.onmessage = onmessage
this.success = success
}
// 初始化weosocket
initeventSource() {
const that = this
fetchEventSource(this.url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.param),
onmessage(event) {
let data
try {
data = JSON.parse(event.data);
} catch {
console.error('onmessage error');
}
that.onmessage(data)
console.info(data);
if (data.status === 0) {
that.success()
}
},
onerror(error) {
throw error;
}
})
}
}
export { GetStreaming }
...@@ -70,7 +70,7 @@ export default { ...@@ -70,7 +70,7 @@ export default {
taskId: undefined, taskId: undefined,
trainMethod: 'full', trainMethod: 'full',
trainMode: '', trainMode: '',
datasetVersionIds: undefined, datasetVersionIds: [],
modelVersionId: undefined modelVersionId: undefined
}, },
tuningTaskDto: { tuningTaskDto: {
...@@ -81,7 +81,6 @@ export default { ...@@ -81,7 +81,6 @@ export default {
}, },
rules: { rules: {
'tuningTaskDto.taskName': [{ required: true, message: '请输入任务名称', trigger: 'blur' }], 'tuningTaskDto.taskName': [{ required: true, message: '请输入任务名称', trigger: 'blur' }],
'tuningRunDto.modelVersionId': [{ required: true, message: '请选择基础模型版', trigger: 'blur' }], 'tuningRunDto.modelVersionId': [{ required: true, message: '请选择基础模型版', trigger: 'blur' }],
'tuningRunDto.datasetVersionIds': [{ required: true, message: '请选择数据集版本', trigger: 'blur' }] 'tuningRunDto.datasetVersionIds': [{ required: true, message: '请选择数据集版本', trigger: 'blur' }]
} }
...@@ -107,6 +106,7 @@ export default { ...@@ -107,6 +106,7 @@ export default {
...this.form.tuningRunDto, ...this.form.tuningRunDto,
...this.item.tuningRunDto ...this.item.tuningRunDto
} }
this.form.tuningRunDto.datasetVersionIds = this.item.tuningRunDto.datasetVersionIds.split(',')
} }
if (this.existingTask) { if (this.existingTask) {
this.form.tuningRunDto.taskId = this.item.tuningTaskDto.taskId this.form.tuningRunDto.taskId = this.item.tuningTaskDto.taskId
...@@ -125,6 +125,7 @@ export default { ...@@ -125,6 +125,7 @@ export default {
if (valid) { if (valid) {
let params = {} let params = {}
params = this.existingTask ? { tuningRunDto: this.form.tuningRunDto } : { ...this.form } params = this.existingTask ? { tuningRunDto: this.form.tuningRunDto } : { ...this.form }
params.tuningRunDto.datasetVersionIds = params.tuningRunDto.datasetVersionIds.join() params.tuningRunDto.datasetVersionIds = params.tuningRunDto.datasetVersionIds.join()
if (this.isEdit) { if (this.isEdit) {
apiFunction apiFunction
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</el-card> </el-card>
<el-card class="box-card"> <el-card class="box-card">
<el-descriptions title="数据配置"> <el-descriptions title="数据配置">
<el-descriptions-item label="数据集:">{{item.datasetVersionId}}</el-descriptions-item> <el-descriptions-item label="数据集:">{{item.datasetVersionIds}}</el-descriptions-item>
<el-descriptions-item label="拆分比例:">{{item.splitRatio}}</el-descriptions-item> <el-descriptions-item label="拆分比例:">{{item.splitRatio}}</el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-card> </el-card>
...@@ -29,36 +29,28 @@ ...@@ -29,36 +29,28 @@
<script> <script>
// import { MyModel } from '@/api/gptController.js'; // import { MyModel } from '@/api/gptController.js';
export default { export default {
data () { data() {
return { return {}
};
}, },
props: ['item'], props: ['item'],
components: {}, components: {},
computed: { computed: {},
},
mounted () { mounted() {},
}, methods: {}
}
methods: {
}
};
</script> </script>
<style scoped> <style scoped>
div /deep/ .el-descriptions__title{ div /deep/ .el-descriptions__title {
font-size: 18px; font-size: 18px;
} }
div /deep/.el-descriptions__table{ div /deep/.el-descriptions__table {
width: 100%; width: 100%;
line-height: 30px; line-height: 30px;
} }
div /deep/ .el-card{ div /deep/ .el-card {
margin-bottom: 20px; margin-bottom: 20px;
} }
</style> </style>
...@@ -147,47 +147,47 @@ export default { ...@@ -147,47 +147,47 @@ export default {
onmessage(data) { onmessage(data) {
console.log(data) console.log(data)
let nowChat = this.myHistory[this.myHistory.length - 1] // let nowChat = this.myHistory[this.myHistory.length - 1]
if (this.chatForm.pattern === 0) { // if (this.chatForm.pattern === 0) {
// 通用智能问答 // // 通用智能问答
// data = data.replace(/^data:\s+|\s+$/g, '') // // data = data.replace(/^data:\s+|\s+$/g, '')
nowChat.excludeReferenceAnswer += data // nowChat.excludeReferenceAnswer += data
nowChat.answer += data // nowChat.answer += data
} else if (this.chatForm.pattern === 1) { // } else if (this.chatForm.pattern === 1) {
// 专业知识库问答 // // 专业知识库问答
// console.log(data) // // console.log(data)
let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{')) // let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
temporary.forEach((item) => { // temporary.forEach((item) => {
this.modifyContent(item) // 修改返回内容 // this.modifyContent(item) // 修改返回内容
nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容 // nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
nowChat.answer += item.answer || '\n' + item.docs // nowChat.answer += item.answer || '\n' + item.docs
}) // })
} else if (this.chatForm.pattern === 2) { // } else if (this.chatForm.pattern === 2) {
// 搜索引擎问答 // // 搜索引擎问答
} else if (this.chatForm.pattern === 3) { // } else if (this.chatForm.pattern === 3) {
// 基于文件问答 // // 基于文件问答
let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{')) // let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
temporary.forEach((item) => { // temporary.forEach((item) => {
this.modifyContent(item) // 修改返回内容 // this.modifyContent(item) // 修改返回内容
nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容 // nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
nowChat.answer += item.answer || '\n' + item.docs // nowChat.answer += item.answer || '\n' + item.docs
}) // })
} else if (this.chatForm.pattern === 4) { // } else if (this.chatForm.pattern === 4) {
let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{')) // let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
temporary.forEach((item) => { // temporary.forEach((item) => {
console.log(item) // console.log(item)
this.modifyContent(item) // 修改返回内容 // this.modifyContent(item) // 修改返回内容
nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容 // nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
nowChat.answer += item.answer || '\n' + item.docs.join() // nowChat.answer += item.answer || '\n' + item.docs.join()
// nowChat.answer += item.answer += '\n' + item.docs.join() // // nowChat.answer += item.answer += '\n' + item.docs.join()
}) // })
} // }
this.$nextTick(() => { // this.$nextTick(() => {
this.$refs.contentBox.scrollTo(0, this.$refs.contentBox.scrollHeight) // this.$refs.contentBox.scrollTo(0, this.$refs.contentBox.scrollHeight)
}) // })
}, },
modifyContent(item) { modifyContent(item) {
// 修改返回内容 // 修改返回内容
......
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