🔧 fix(stream_scanner): improve resource management and error handling in StreamScannerHandler

This commit is contained in:
CaIon
2025-06-11 00:18:16 +08:00
parent 2509f644bc
commit f124404f07
2 changed files with 130 additions and 27 deletions

View File

@@ -68,8 +68,8 @@ func getTokenNum(tokenEncoder tokenizer.Codec, text string) int {
if text == "" {
return 0
}
ids, _, _ := tokenEncoder.Encode(text)
return len(ids)
tkm, _ := tokenEncoder.Count(text)
return tkm
}
func getImageToken(info *relaycommon.RelayInfo, imageUrl *dto.MessageImageUrl, model string, stream bool) (int, error) {