Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
202252197 committed Apr 11, 2023
1 parent 4a82f8e commit f797fd0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 27 deletions.
52 changes: 35 additions & 17 deletions src/view/pages/chatHome/chatwindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default {
this.sendText()
}
},
readStream(reader,_this, currentResLocation) {
readStream(reader,_this, currentResLocation,type) {
return reader.read().then(({ done, value }) => {
if ( done ) {
return;
Expand All @@ -246,12 +246,19 @@ export default {
if(decoded.trim()==="[DONE]"){
return;
}else{
const response = JSON.parse(decoded).choices[0].delta.content?JSON.parse(decoded).choices[0].delta.content:"";
_this.chatList[currentResLocation].msg=_this.chatList[currentResLocation].msg+response
console.log(type)
if(type==="chat"){
const response = JSON.parse(decoded).choices[0].delta.content ? JSON.parse(decoded).choices[0].delta.content : "";
_this.chatList[currentResLocation].msg = _this.chatList[currentResLocation].msg + response
_this.scrollBottom();
}else{
const response = JSON.parse(decoded).choices[0].text;
_this.chatList[currentResLocation].msg = _this.chatList[currentResLocation].msg + response
}
}
}
})
return this.readStream(reader,_this, currentResLocation);
return this.readStream(reader,_this, currentResLocation,type);
});
},
//导入当前内容json触发的方法
Expand Down Expand Up @@ -532,14 +539,14 @@ export default {
} else {
//如果是文字模式则进入
params.model = this.frinedInfo.id,
params.max_tokens = this.settingInfo.chat.MaxTokens,
params.temperature = this.settingInfo.chat.Temperature,
params.top_p = this.settingInfo.chat.TopP,
params.n = this.settingInfo.chat.n,
params.stream = this.settingInfo.chat.stream,
params.stop = this.settingInfo.chat.stop,
params.presence_penalty = this.settingInfo.chat.PresencePenalty,
params.frequency_penalty = this.settingInfo.chat.FrequencyPenalty
params.max_tokens = this.settingInfo.chat.MaxTokens,
params.temperature = this.settingInfo.chat.Temperature,
params.top_p = this.settingInfo.chat.TopP,
params.n = this.settingInfo.chat.n,
params.stream = this.settingInfo.chat.stream,
params.stop = this.settingInfo.chat.stop,
params.presence_penalty = this.settingInfo.chat.PresencePenalty,
params.frequency_penalty = this.settingInfo.chat.FrequencyPenalty
let chatBeforResMsg = {
headImg: AI_HEAD_IMG_URL,
Expand All @@ -552,7 +559,19 @@ export default {
if (this.frinedInfo.id === "gpt-3.5-turbo" || this.frinedInfo.id === "gpt-3.5-turbo-0301") {
this.chatCompletion(params, chatBeforResMsg)
} else {
this.completion(params, chatBeforResMsg)
if(this.settingInfo.cutSetting===0){
if(this.frinedInfo.id === "text-davinci-003" ){
this.completion(params, chatBeforResMsg)
}else{
this.$message.error("暂时不支持gpt-3.5-turbo、gpt-3.5-turbo-0301、text-davinci-003以外的模型聊天~")
this.$nextTick(() => {
this.acqStatus = true
})
}
}else{
this.completion(params, chatBeforResMsg)
}
}
}
if (this.storeStatu == 0) {
Expand Down Expand Up @@ -637,8 +656,7 @@ export default {
const currentResLocation = this.chatList.length - 1
let _this = this
try {
try {
if ( this.settingInfo.chat.stream ){
await fetch(
base.baseUrl+'/v1/chat/completions',{
Expand All @@ -654,7 +672,7 @@ export default {
}
).then(response=>{
const reader = response.body.getReader();
this.readStream(reader,_this, currentResLocation);
this.readStream(reader,_this, currentResLocation,"chat");
});
}else{
await fetch(
Expand Down Expand Up @@ -726,7 +744,7 @@ export default {
this.acqStatus = true
});
// _this.chatList[currentResLocation].msg = _this.chatList[currentResLocation].msg + ":grinning:"
this.readStream(reader,_this, currentResLocation);
this.readStream(reader,_this, currentResLocation,"completion");
})
} catch (error) {
Expand Down
15 changes: 5 additions & 10 deletions src/view/pages/chatHome/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ export default {
batch_sizeStr: "",
//全部的设置参数
SettingInfo: {
cutSetting : 1,
KeyMsg: process.env.VUE_APP_OPENAI_API_KEY,
readefile: false,
inputStatus: true,
Expand Down Expand Up @@ -1019,16 +1020,6 @@ export default {
this.showSetupList = true;
};
},
// // 更新当前余额
// updateMoneyInfo() {
// getMoneyInfo(this.SettingInfo.KeyMsg).then((res) => {
// this.$nextTick(() => {
// this.moneryInfo.totalGranted = res.total_granted;
// this.moneryInfo.totalUsed = res.total_used;
// this.moneryInfo.totalAvailable = res.total_available;
// })
// })
// },
//创建会话
newSession() {
//获取当前会话长度
Expand Down Expand Up @@ -1070,6 +1061,7 @@ export default {
this.fineTuningInfo = {};
this.SettingStatus = 0
this.cutSetting = 0
this.SettingInfo.cutSetting = 0
// this.showChatWindow = false;
},
//会话列表被点击
Expand All @@ -1078,6 +1070,7 @@ export default {
this.clearCurrent()
this.SettingStatus = 5
this.cutSetting = 1
this.SettingInfo.cutSetting = 1
this.chatWindowInfo = {
img: "",
name: "ChatGPT",
Expand Down Expand Up @@ -1107,6 +1100,7 @@ export default {
this.clearCurrent()
this.SettingStatus = 3;
this.cutSetting = 2
this.SettingInfo.cutSetting = 2
// this.showChatWindow = false;
//获取微调模型列表
this.getFineTunessList(this.SettingInfo.KeyMsg)
Expand All @@ -1128,6 +1122,7 @@ export default {
this.fineTuningInfo = {};
this.SettingStatus = 4;
this.cutSetting = 3
this.SettingInfo.cutSetting = 3
//获取微调模型列表
this.getFilessList(this.SettingInfo.KeyMsg)
},
Expand Down

1 comment on commit f797fd0

@4everland
Copy link

@4everland 4everland bot commented on f797fd0 Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following parameters

parameters Value
IPFS CID bafybeiavwplzqjbhajnalkek37mrcttw3fjl7asvmadnfdwyc66dtsge74
Assigned domain https://chatgpt_jcm-yfkdnbtr-202252197.4everland.app
https://chatgpt_jcm-92.4everland.app
Custom domain

Please sign in to comment.