@@ -124,6 +124,7 @@ Component({
124124 feedbackType : "" ,
125125 textareaHeight : 50 ,
126126 curLineCount : 1 ,
127+ defaultErrorMsg : "网络繁忙,请稍后重试!" ,
127128 } ,
128129 attached : async function ( ) {
129130 const chatMode = this . data . chatMode ;
@@ -151,7 +152,7 @@ Component({
151152
152153 // 初始化第一条记录为welcomeMessage
153154 const record = {
154- content : bot . welcomeMessage ,
155+ content : bot . welcomeMessage || "您好,有什么需要帮助您的?" ,
155156 record_id : "record_id" + String ( + new Date ( ) + 10 ) ,
156157 role : "assistant" ,
157158 hiddenBtnGround : true ,
@@ -183,6 +184,14 @@ Component({
183184 } ) ;
184185 } ,
185186 methods : {
187+ showErrorMsg : function ( e ) {
188+ const { content } = e . currentTarget . dataset ;
189+ console . log ( "content" , content ) ;
190+ wx . showModal ( {
191+ title : "错误原因" ,
192+ content : typeof content === "string" ? content : JSON . stringify ( { content } ) ,
193+ } ) ;
194+ } ,
186195 handleLineChange : function ( e ) {
187196 console . log ( "linechange" , e . detail . lineCount ) ;
188197 // 查foot-function height
@@ -389,6 +398,9 @@ Component({
389398 fileSize : item . bytes ,
390399 } ) ) ;
391400 }
401+ if ( item . role === "assistant" && item . content === "" ) {
402+ transformItem . content = this . data . defaultErrorMsg ;
403+ }
392404 return transformItem ;
393405 } ) ;
394406 this . setData ( {
@@ -420,7 +432,7 @@ Component({
420432 return ;
421433 }
422434 const record = {
423- content : bot . welcomeMessage ,
435+ content : bot . welcomeMessage || "您好,有什么需要帮助您的?" ,
424436 record_id : "record_id" + String ( + new Date ( ) + 10 ) ,
425437 role : "assistant" ,
426438 hiddenBtnGround : true ,
@@ -495,6 +507,13 @@ Component({
495507 } ) ;
496508 return ;
497509 }
510+ if ( this . data . useWebSearch ) {
511+ wx . showModal ( {
512+ title : "提示" ,
513+ content : "联网搜索不支持上传文件/图片" ,
514+ } ) ;
515+ return ;
516+ }
498517 const self = this ;
499518 const isCurSendFile = this . data . sendFileList . find ( ( item ) => item . rawType === "file" ) ;
500519 if ( isCurSendFile ) {
@@ -608,7 +627,7 @@ Component({
608627 if ( this . data . useWebSearch ) {
609628 wx . showModal ( {
610629 title : "提示" ,
611- content : "联网搜索不支持上传附件 " ,
630+ content : "联网搜索不支持上传文件/图片 " ,
612631 } ) ;
613632 return ;
614633 }
@@ -760,6 +779,9 @@ Component({
760779 this . toBottom ( 40 ) ;
761780 }
762781 const { data } = event ;
782+ if ( data === "[DONE]" ) {
783+ break ;
784+ }
763785 try {
764786 const dataJson = JSON . parse ( data ) ;
765787 const {
@@ -773,6 +795,7 @@ Component({
773795 knowledge_base,
774796 finish_reason,
775797 search_results,
798+ error,
776799 } = dataJson ;
777800 const newValue = [ ...this . data . chatRecords ] ;
778801 // 取最后一条消息更新
@@ -785,7 +808,13 @@ Component({
785808 lastValue . search_info = null ;
786809 lastValue . reasoning_content = "" ;
787810 lastValue . knowledge_meta = [ ] ;
788- lastValue . content = "网络繁忙,请稍后重试!" ;
811+ lastValue . content = this . data . defaultErrorMsg ;
812+ if ( error && error . message ) {
813+ lastValue . error = error . message ;
814+ this . setData ( {
815+ [ `chatRecords[${ lastValueIndex } ].error` ] : lastValue . error ,
816+ } ) ;
817+ }
789818 this . setData ( {
790819 [ `chatRecords[${ lastValueIndex } ].search_info` ] : lastValue . search_info ,
791820 [ `chatRecords[${ lastValueIndex } ].reasoning_content` ] : lastValue . reasoning_content ,
@@ -851,7 +880,7 @@ Component({
851880 } ) ;
852881 }
853882 } catch ( e ) {
854- // console.log(' err' , event, e)
883+ console . log ( " err" , event , e ) ;
855884 break ;
856885 }
857886 index ++ ;
@@ -862,6 +891,12 @@ Component({
862891 // 取最后一条消息更新
863892 const lastValue = newValue [ lastValueIndex ] ;
864893 lastValue . hiddenBtnGround = isManuallyPaused ;
894+ if ( lastValue . content === "" ) {
895+ lastValue . content = this . data . defaultErrorMsg ;
896+ this . setData ( {
897+ [ `chatRecords[${ lastValueIndex } ].content` ] : lastValue . content ,
898+ } ) ;
899+ }
865900 this . setData ( {
866901 chatStatus : 0 ,
867902 [ `chatRecords[${ lastValueIndex } ].hiddenBtnGround` ] : isManuallyPaused ,
0 commit comments