Commit 4ae944c9 authored by mhw's avatar mhw

bug修復

parent 19a96dcb
This diff is collapsed.
module.exports = {
// 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.168:8082/',
// baseUrl: 'http://192.168.0.168:8082/',
wsUrl: 'ws://218.76.0.69:7860/',
projectName: '灵境大模型平台'
}
// import { Message } from 'element-ui';
// import projectConfig from '@/core/config';
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}`);
});
}
// import { getToken } from '@/utils';
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);
});
}
}
import { fetchEventSource } from '@microsoft/fetch-event-source';
// 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}`);
// });
// }
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';
// submit () {
......@@ -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 {
taskId: undefined,
trainMethod: 'full',
trainMode: '',
datasetVersionIds: undefined,
datasetVersionIds: [],
modelVersionId: undefined
},
tuningTaskDto: {
......@@ -81,7 +81,6 @@ export default {
},
rules: {
'tuningTaskDto.taskName': [{ required: true, message: '请输入任务名称', trigger: 'blur' }],
'tuningRunDto.modelVersionId': [{ required: true, message: '请选择基础模型版', trigger: 'blur' }],
'tuningRunDto.datasetVersionIds': [{ required: true, message: '请选择数据集版本', trigger: 'blur' }]
}
......@@ -107,6 +106,7 @@ export default {
...this.form.tuningRunDto,
...this.item.tuningRunDto
}
this.form.tuningRunDto.datasetVersionIds = this.item.tuningRunDto.datasetVersionIds.split(',')
}
if (this.existingTask) {
this.form.tuningRunDto.taskId = this.item.tuningTaskDto.taskId
......@@ -125,6 +125,7 @@ export default {
if (valid) {
let params = {}
params = this.existingTask ? { tuningRunDto: this.form.tuningRunDto } : { ...this.form }
params.tuningRunDto.datasetVersionIds = params.tuningRunDto.datasetVersionIds.join()
if (this.isEdit) {
apiFunction
......
<!-- 运行详情 -->
<template>
<div>
<el-card class="box-card">
<el-descriptions title="基本信息">
<el-descriptions-item label="运行名称:">{{item.runName}}</el-descriptions-item>
<el-descriptions-item label="运行ID:">{{item.runId}}</el-descriptions-item>
<el-descriptions-item label="创建人:">{{ item.createUserIdDictMap.name }}</el-descriptions-item>
<el-descriptions-item label="创建时间:">{{item.createTime }}</el-descriptions-item>
</el-descriptions>
</el-card>
<el-card class="box-card">
<el-descriptions title="数据配置">
<el-descriptions-item label="数据集:">{{item.datasetVersionId}}</el-descriptions-item>
<el-descriptions-item label="拆分比例:">{{item.splitRatio}}</el-descriptions-item>
</el-descriptions>
</el-card>
<el-card class="box-card">
<el-descriptions title="训练配置">
<el-descriptions-item label="基础模型:">{{item.modelId}}</el-descriptions-item>
<el-descriptions-item label="训练模式:">{{item.trainMode}}</el-descriptions-item>
<el-descriptions-item label="训练方法:">{{ item.trainMethod }}</el-descriptions-item>
<el-descriptions-item label="参数配置:">{{item.configuration}}</el-descriptions-item>
</el-descriptions>
</el-card>
</div>
<div>
<el-card class="box-card">
<el-descriptions title="基本信息">
<el-descriptions-item label="运行名称:">{{item.runName}}</el-descriptions-item>
<el-descriptions-item label="运行ID:">{{item.runId}}</el-descriptions-item>
<el-descriptions-item label="创建人:">{{ item.createUserIdDictMap.name }}</el-descriptions-item>
<el-descriptions-item label="创建时间:">{{item.createTime }}</el-descriptions-item>
</el-descriptions>
</el-card>
<el-card class="box-card">
<el-descriptions title="数据配置">
<el-descriptions-item label="数据集:">{{item.datasetVersionIds}}</el-descriptions-item>
<el-descriptions-item label="拆分比例:">{{item.splitRatio}}</el-descriptions-item>
</el-descriptions>
</el-card>
<el-card class="box-card">
<el-descriptions title="训练配置">
<el-descriptions-item label="基础模型:">{{item.modelId}}</el-descriptions-item>
<el-descriptions-item label="训练模式:">{{item.trainMode}}</el-descriptions-item>
<el-descriptions-item label="训练方法:">{{ item.trainMethod }}</el-descriptions-item>
<el-descriptions-item label="参数配置:">{{item.configuration}}</el-descriptions-item>
</el-descriptions>
</el-card>
</div>
</template>
<script>
// import { MyModel } from '@/api/gptController.js';
export default {
data () {
return {
};
data() {
return {}
},
props: ['item'],
components: {},
computed: {
},
computed: {},
mounted () {
mounted() {},
},
methods: {
}
};
methods: {}
}
</script>
<style scoped>
div /deep/ .el-descriptions__title{
font-size: 18px;
div /deep/ .el-descriptions__title {
font-size: 18px;
}
div /deep/.el-descriptions__table{
width: 100%;
line-height: 30px;
div /deep/.el-descriptions__table {
width: 100%;
line-height: 30px;
}
div /deep/ .el-card{
margin-bottom: 20px;
div /deep/ .el-card {
margin-bottom: 20px;
}
</style>
......@@ -147,47 +147,47 @@ export default {
onmessage(data) {
console.log(data)
let nowChat = this.myHistory[this.myHistory.length - 1]
if (this.chatForm.pattern === 0) {
// 通用智能问答
// data = data.replace(/^data:\s+|\s+$/g, '')
nowChat.excludeReferenceAnswer += data
nowChat.answer += data
} else if (this.chatForm.pattern === 1) {
// 专业知识库问答
// console.log(data)
let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
temporary.forEach((item) => {
this.modifyContent(item) // 修改返回内容
nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
nowChat.answer += item.answer || '\n' + item.docs
})
} else if (this.chatForm.pattern === 2) {
// 搜索引擎问答
} else if (this.chatForm.pattern === 3) {
// 基于文件问答
let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
// let nowChat = this.myHistory[this.myHistory.length - 1]
// if (this.chatForm.pattern === 0) {
// // 通用智能问答
// // data = data.replace(/^data:\s+|\s+$/g, '')
// nowChat.excludeReferenceAnswer += data
// nowChat.answer += data
// } else if (this.chatForm.pattern === 1) {
// // 专业知识库问答
// // console.log(data)
// let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
// temporary.forEach((item) => {
// this.modifyContent(item) // 修改返回内容
// nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
// nowChat.answer += item.answer || '\n' + item.docs
// })
// } else if (this.chatForm.pattern === 2) {
// // 搜索引擎问答
// } else if (this.chatForm.pattern === 3) {
// // 基于文件问答
// let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
temporary.forEach((item) => {
this.modifyContent(item) // 修改返回内容
nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
nowChat.answer += item.answer || '\n' + item.docs
})
} else if (this.chatForm.pattern === 4) {
let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
// temporary.forEach((item) => {
// this.modifyContent(item) // 修改返回内容
// nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
// nowChat.answer += item.answer || '\n' + item.docs
// })
// } else if (this.chatForm.pattern === 4) {
// let temporary = JSON.parse(`[${data}]`.replace(/}{/g, '},{'))
temporary.forEach((item) => {
console.log(item)
this.modifyContent(item) // 修改返回内容
nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
nowChat.answer += item.answer || '\n' + item.docs.join()
// nowChat.answer += item.answer += '\n' + item.docs.join()
})
}
// temporary.forEach((item) => {
// console.log(item)
// this.modifyContent(item) // 修改返回内容
// nowChat.excludeReferenceAnswer += item.answer || '' // 排除回答中的引用内容
// nowChat.answer += item.answer || '\n' + item.docs.join()
// // nowChat.answer += item.answer += '\n' + item.docs.join()
// })
// }
this.$nextTick(() => {
this.$refs.contentBox.scrollTo(0, this.$refs.contentBox.scrollHeight)
})
// this.$nextTick(() => {
// this.$refs.contentBox.scrollTo(0, this.$refs.contentBox.scrollHeight)
// })
},
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