on main help sign in
chore: make consts private
commit7bfd0469acc8bb5cdbed13787f7c04fcaa12f660 authorKujtim Hoxha <kujtimii.h@gmail.com> dateFri 1 Aug 2025, 08:06 (1 year ago) parentfcbe966
1 file changed+13−13
internal/llm/tools/tools.go+13−13
internal/llm/tools/tools.go+13−13
@@ -28,9 +28,9 @@ const (
2828 SessionIDContextKey sessionIDContextKey = "session_id"
2929 MessageIDContextKey messageIDContextKey = "message_id"
3030
31− MaxResponseWidth = 3000
32− MaxResponseHeight = 5000
33− MaxResponseChars = 50000
31+ maxResponseWidth = 3000
32+ maxResponseHeight = 5000
33+ maxResponseChars = 50000
3434)
3535
3636type ToolResponse struct {
@@ -48,13 +48,13 @@ func NewTextResponse(content string) ToolResponse {
4848}
4949
5050func truncateContent(content string) string {
51− if len(content) <= MaxResponseChars {
51+ if len(content) <= maxResponseChars {
5252 return truncateWidthAndHeight(content)
5353 }
5454
55− truncated := content[:MaxResponseChars]
55+ truncated := content[:maxResponseChars]
5656
57− if lastNewline := strings.LastIndex(truncated, "\n"); lastNewline > MaxResponseChars/2 {
57+ if lastNewline := strings.LastIndex(truncated, "\n"); lastNewline > maxResponseChars/2 {
5858 truncated = truncated[:lastNewline]
5959 }
6060
@@ -67,12 +67,12 @@ func truncateWidthAndHeight(content string) string {
6767 lines := strings.Split(content, "\n")
6868
6969 heightTruncated := false
70− if len(lines) > MaxResponseHeight {
71− keepLines := MaxResponseHeight - 3
70+ if len(lines) > maxResponseHeight {
71+ keepLines := maxResponseHeight - 3
7272 firstHalf := keepLines / 2
7373 secondHalf := keepLines - firstHalf
7474
75− truncatedLines := make([]string, 0, MaxResponseHeight)
75+ truncatedLines := make([]string, 0, maxResponseHeight)
7676 truncatedLines = append(truncatedLines, lines[:firstHalf]...)
7777 truncatedLines = append(truncatedLines, "")
7878 truncatedLines = append(truncatedLines, fmt.Sprintf("... [%d lines truncated] ...", len(lines)-keepLines))
@@ -85,14 +85,14 @@ func truncateWidthAndHeight(content string) string {
8585
8686 widthTruncated := false
8787 for i, line := range lines {
88− if len(line) > MaxResponseWidth {
89− if MaxResponseWidth > 20 {
90− keepChars := MaxResponseWidth - 10
88+ if len(line) > maxResponseWidth {
89+ if maxResponseWidth > 20 {
90+ keepChars := maxResponseWidth - 10
9191 firstHalf := keepChars / 2
9292 secondHalf := keepChars - firstHalf
9393 lines[i] = line[:firstHalf] + " ... " + line[len(line)-secondHalf:]
9494 } else {
95− lines[i] = line[:MaxResponseWidth]
95+ lines[i] = line[:maxResponseWidth]
9696 }
9797 widthTruncated = true
9898 }