@@ -723,6 +723,7 @@ function checkResult(result: AxiosResponse, refreshToken: string) {
723
723
* @param stream 消息流
724
724
*/
725
725
async function receiveStream ( model : string , convId : string , stream : any ) {
726
+ let webSearchCount = 0 ;
726
727
return new Promise ( ( resolve , reject ) => {
727
728
// 消息初始化
728
729
const data = {
@@ -756,8 +757,10 @@ async function receiveStream(model: string, convId: string, stream: any) {
756
757
resolve ( data ) ;
757
758
}
758
759
// 处理联网搜索
759
- else if ( ! silentSearch && result . event == 'search_plus' && result . msg && result . msg . type == 'get_res' )
760
- refContent += `${ result . msg . title } - ${ result . msg . url } \n` ;
760
+ else if ( ! silentSearch && result . event == 'search_plus' && result . msg && result . msg . type == 'get_res' ) {
761
+ webSearchCount += 1 ;
762
+ refContent += `【检索 ${ webSearchCount } 】 [${ result . msg . title } ](${ result . msg . url } )\n\n` ;
763
+ }
761
764
// else
762
765
// logger.warn(result.event, result);
763
766
}
@@ -788,6 +791,7 @@ function createTransStream(model: string, convId: string, stream: any, endCallba
788
791
const created = util . unixTimestamp ( ) ;
789
792
// 创建转换流
790
793
const transStream = new PassThrough ( ) ;
794
+ let webSearchCount = 0 ;
791
795
let searchFlag = false ;
792
796
const silentSearch = model . indexOf ( 'silent_search' ) != - 1 ;
793
797
! transStream . closed && transStream . write ( `data: ${ JSON . stringify ( {
@@ -847,14 +851,15 @@ function createTransStream(model: string, convId: string, stream: any, endCallba
847
851
else if ( ! silentSearch && result . event == 'search_plus' && result . msg && result . msg . type == 'get_res' ) {
848
852
if ( ! searchFlag )
849
853
searchFlag = true ;
854
+ webSearchCount += 1 ;
850
855
const data = `data: ${ JSON . stringify ( {
851
856
id : convId ,
852
857
model,
853
858
object : 'chat.completion.chunk' ,
854
859
choices : [
855
860
{
856
861
index : 0 , delta : {
857
- content : `检索 ${ result . msg . title } - ${ result . msg . url } ... \n`
862
+ content : `【 检索 ${ webSearchCount } 】 [ ${ result . msg . title } ]( ${ result . msg . url } ) \n`
858
863
} , finish_reason : null
859
864
}
860
865
] ,
0 commit comments