File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -280,16 +280,14 @@ package Evalbot;
280
280
my $format_len = length (encode_utf8(sprintf $format_res , $prefix , ' ' ));
281
281
if (length (encode_utf8($response )) + $format_len > $max_output_len ){
282
282
my $target = $max_output_len - 3 - $format_len ;
283
- $response =~ s / ^.{0,$target}(?![^\x00 -\x7F\xC0 -\xFF ])\K .*// s ;
284
- $response .= " …" ;
285
- # my $cut_res = '';
286
- # while ($response =~ /(\X)/g) {
287
- # my $grapheme_bytes = encode_utf8($1);
288
- # $target -= length($grapheme_bytes);
289
- # last if $target < 0;
290
- # $cut_res .= $grapheme_bytes;
291
- # }
292
- # $response = $cut_res.'…';
283
+ my $cut_res = ' ' ;
284
+ while ($response =~ / (\X )/g ) {
285
+ my $grapheme_bytes = encode_utf8($1 );
286
+ $target -= length ($grapheme_bytes );
287
+ last if $target < 0;
288
+ $cut_res .= $1 ;
289
+ }
290
+ $response = $cut_res .' …' ;
293
291
}
294
292
return sprintf $format_res , $prefix , $response ;
295
293
}
You can’t perform that action at this time.
0 commit comments