Skip to content

Commit f797fd0

Browse files
committed
更新
1 parent 4a82f8e commit f797fd0

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

src/view/pages/chatHome/chatwindow.vue

+35-17
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export default {
229229
this.sendText()
230230
}
231231
},
232-
readStream(reader,_this, currentResLocation) {
232+
readStream(reader,_this, currentResLocation,type) {
233233
return reader.read().then(({ done, value }) => {
234234
if ( done ) {
235235
return;
@@ -246,12 +246,19 @@ export default {
246246
if(decoded.trim()==="[DONE]"){
247247
return;
248248
}else{
249-
const response = JSON.parse(decoded).choices[0].delta.content?JSON.parse(decoded).choices[0].delta.content:"";
250-
_this.chatList[currentResLocation].msg=_this.chatList[currentResLocation].msg+response
249+
console.log(type)
250+
if(type==="chat"){
251+
const response = JSON.parse(decoded).choices[0].delta.content ? JSON.parse(decoded).choices[0].delta.content : "";
252+
_this.chatList[currentResLocation].msg = _this.chatList[currentResLocation].msg + response
253+
_this.scrollBottom();
254+
}else{
255+
const response = JSON.parse(decoded).choices[0].text;
256+
_this.chatList[currentResLocation].msg = _this.chatList[currentResLocation].msg + response
257+
}
251258
}
252259
}
253260
})
254-
return this.readStream(reader,_this, currentResLocation);
261+
return this.readStream(reader,_this, currentResLocation,type);
255262
});
256263
},
257264
//导入当前内容json触发的方法
@@ -532,14 +539,14 @@ export default {
532539
} else {
533540
//如果是文字模式则进入
534541
params.model = this.frinedInfo.id,
535-
params.max_tokens = this.settingInfo.chat.MaxTokens,
536-
params.temperature = this.settingInfo.chat.Temperature,
537-
params.top_p = this.settingInfo.chat.TopP,
538-
params.n = this.settingInfo.chat.n,
539-
params.stream = this.settingInfo.chat.stream,
540-
params.stop = this.settingInfo.chat.stop,
541-
params.presence_penalty = this.settingInfo.chat.PresencePenalty,
542-
params.frequency_penalty = this.settingInfo.chat.FrequencyPenalty
542+
params.max_tokens = this.settingInfo.chat.MaxTokens,
543+
params.temperature = this.settingInfo.chat.Temperature,
544+
params.top_p = this.settingInfo.chat.TopP,
545+
params.n = this.settingInfo.chat.n,
546+
params.stream = this.settingInfo.chat.stream,
547+
params.stop = this.settingInfo.chat.stop,
548+
params.presence_penalty = this.settingInfo.chat.PresencePenalty,
549+
params.frequency_penalty = this.settingInfo.chat.FrequencyPenalty
543550
544551
let chatBeforResMsg = {
545552
headImg: AI_HEAD_IMG_URL,
@@ -552,7 +559,19 @@ export default {
552559
if (this.frinedInfo.id === "gpt-3.5-turbo" || this.frinedInfo.id === "gpt-3.5-turbo-0301") {
553560
this.chatCompletion(params, chatBeforResMsg)
554561
} else {
555-
this.completion(params, chatBeforResMsg)
562+
if(this.settingInfo.cutSetting===0){
563+
if(this.frinedInfo.id === "text-davinci-003" ){
564+
this.completion(params, chatBeforResMsg)
565+
}else{
566+
this.$message.error("暂时不支持gpt-3.5-turbo、gpt-3.5-turbo-0301、text-davinci-003以外的模型聊天~")
567+
this.$nextTick(() => {
568+
this.acqStatus = true
569+
})
570+
}
571+
}else{
572+
this.completion(params, chatBeforResMsg)
573+
}
574+
556575
}
557576
}
558577
if (this.storeStatu == 0) {
@@ -637,8 +656,7 @@ export default {
637656
638657
const currentResLocation = this.chatList.length - 1
639658
let _this = this
640-
641-
try {
659+
try {
642660
if ( this.settingInfo.chat.stream ){
643661
await fetch(
644662
base.baseUrl+'/v1/chat/completions',{
@@ -654,7 +672,7 @@ export default {
654672
}
655673
).then(response=>{
656674
const reader = response.body.getReader();
657-
this.readStream(reader,_this, currentResLocation);
675+
this.readStream(reader,_this, currentResLocation,"chat");
658676
});
659677
}else{
660678
await fetch(
@@ -726,7 +744,7 @@ export default {
726744
this.acqStatus = true
727745
});
728746
// _this.chatList[currentResLocation].msg = _this.chatList[currentResLocation].msg + ":grinning:"
729-
this.readStream(reader,_this, currentResLocation);
747+
this.readStream(reader,_this, currentResLocation,"completion");
730748
})
731749
} catch (error) {
732750

src/view/pages/chatHome/index.vue

+5-10
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ export default {
656656
batch_sizeStr: "",
657657
//全部的设置参数
658658
SettingInfo: {
659+
cutSetting : 1,
659660
KeyMsg: process.env.VUE_APP_OPENAI_API_KEY,
660661
readefile: false,
661662
inputStatus: true,
@@ -1019,16 +1020,6 @@ export default {
10191020
this.showSetupList = true;
10201021
};
10211022
},
1022-
// // 更新当前余额
1023-
// updateMoneyInfo() {
1024-
// getMoneyInfo(this.SettingInfo.KeyMsg).then((res) => {
1025-
// this.$nextTick(() => {
1026-
// this.moneryInfo.totalGranted = res.total_granted;
1027-
// this.moneryInfo.totalUsed = res.total_used;
1028-
// this.moneryInfo.totalAvailable = res.total_available;
1029-
// })
1030-
// })
1031-
// },
10321023
//创建会话
10331024
newSession() {
10341025
//获取当前会话长度
@@ -1070,6 +1061,7 @@ export default {
10701061
this.fineTuningInfo = {};
10711062
this.SettingStatus = 0
10721063
this.cutSetting = 0
1064+
this.SettingInfo.cutSetting = 0
10731065
// this.showChatWindow = false;
10741066
},
10751067
//会话列表被点击
@@ -1078,6 +1070,7 @@ export default {
10781070
this.clearCurrent()
10791071
this.SettingStatus = 5
10801072
this.cutSetting = 1
1073+
this.SettingInfo.cutSetting = 1
10811074
this.chatWindowInfo = {
10821075
img: "",
10831076
name: "ChatGPT",
@@ -1107,6 +1100,7 @@ export default {
11071100
this.clearCurrent()
11081101
this.SettingStatus = 3;
11091102
this.cutSetting = 2
1103+
this.SettingInfo.cutSetting = 2
11101104
// this.showChatWindow = false;
11111105
//获取微调模型列表
11121106
this.getFineTunessList(this.SettingInfo.KeyMsg)
@@ -1128,6 +1122,7 @@ export default {
11281122
this.fineTuningInfo = {};
11291123
this.SettingStatus = 4;
11301124
this.cutSetting = 3
1125+
this.SettingInfo.cutSetting = 3
11311126
//获取微调模型列表
11321127
this.getFilessList(this.SettingInfo.KeyMsg)
11331128
},

0 commit comments

Comments
 (0)