@@ -229,7 +229,7 @@ export default {
229
229
this .sendText ()
230
230
}
231
231
},
232
- readStream (reader ,_this , currentResLocation ) {
232
+ readStream (reader ,_this , currentResLocation , type ) {
233
233
return reader .read ().then (({ done, value }) => {
234
234
if ( done ) {
235
235
return ;
@@ -246,12 +246,19 @@ export default {
246
246
if (decoded .trim ()=== " [DONE]" ){
247
247
return ;
248
248
}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
+ }
251
258
}
252
259
}
253
260
})
254
- return this .readStream (reader,_this, currentResLocation);
261
+ return this .readStream (reader,_this, currentResLocation,type );
255
262
});
256
263
},
257
264
// 导入当前内容json触发的方法
@@ -532,14 +539,14 @@ export default {
532
539
} else {
533
540
// 如果是文字模式则进入
534
541
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
543
550
544
551
let chatBeforResMsg = {
545
552
headImg: AI_HEAD_IMG_URL ,
@@ -552,7 +559,19 @@ export default {
552
559
if (this .frinedInfo .id === " gpt-3.5-turbo" || this .frinedInfo .id === " gpt-3.5-turbo-0301" ) {
553
560
this .chatCompletion (params, chatBeforResMsg)
554
561
} 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
+
556
575
}
557
576
}
558
577
if (this .storeStatu == 0 ) {
@@ -637,8 +656,7 @@ export default {
637
656
638
657
const currentResLocation = this .chatList .length - 1
639
658
let _this = this
640
-
641
- try {
659
+ try {
642
660
if ( this .settingInfo .chat .stream ){
643
661
await fetch (
644
662
base .baseUrl + ' /v1/chat/completions' ,{
@@ -654,7 +672,7 @@ export default {
654
672
}
655
673
).then (response => {
656
674
const reader = response .body .getReader ();
657
- this .readStream (reader,_this, currentResLocation);
675
+ this .readStream (reader,_this, currentResLocation, " chat " );
658
676
});
659
677
}else {
660
678
await fetch (
@@ -726,7 +744,7 @@ export default {
726
744
this .acqStatus = true
727
745
});
728
746
// _this.chatList[currentResLocation].msg = _this.chatList[currentResLocation].msg + ":grinning:"
729
- this .readStream (reader,_this, currentResLocation);
747
+ this .readStream (reader,_this, currentResLocation, " completion " );
730
748
})
731
749
} catch (error) {
732
750
0 commit comments