fix: another UTF-8 string index bug in debug output
Build and Deploy / build (push) Successful in 2m44s
Build and Deploy / deploy (push) Successful in 9s

This commit is contained in:
2026-07-17 12:54:32 +00:00
parent e17549c508
commit 588f0a846b
+5 -1
View File
@@ -327,7 +327,11 @@ func (h *Handler) Math(imageBase64 string) (result string, err error) {
maxIdx = c
}
}
fmt.Printf("DEBUG: Position 0 argmax = %d (char: %s)\n", maxIdx, string("0123456789+-*/÷×=?."[maxIdx-1]))
// 【注意】这里用 string 索引访问多字节字符可能有问题,仅用于调试
debugChars := []string{"", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "÷", "×", "=", "?"}
if maxIdx >= 0 && maxIdx < len(debugChars) {
fmt.Printf("DEBUG: Position 0 argmax = %d (char: %s)\n", maxIdx, debugChars[maxIdx])
}
if len(output) == 0 {
return "", fmt.Errorf("模型输出为空")