Skip to content

Commit

Permalink
vertexai-chat | lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicn committed Aug 22, 2023
1 parent db5b418 commit 3612dc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions textsplitter/split_documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func joinDocs(docs []string, separator string) string {
}

// mergeSplits merges smaller splits into splits that are closer to the chunkSize.
func mergeSplits(splits []string, separator string, chunkSize int, chunkOverlap int) []string {
func mergeSplits(splits []string, separator string, chunkSize int, chunkOverlap int) []string { //nolint:cyclop
docs := make([]string, 0)
currentDoc := make([]string, 0)
total := 0
Expand All @@ -87,11 +87,14 @@ func mergeSplits(splits []string, separator string, chunkSize int, chunkOverlap
}

for shouldPop(chunkOverlap, chunkSize, total, len(split), len(separator), len(currentDoc)) {
if len(currentDoc) == 0 {
continue
}

total -= len(currentDoc[0])

Check failure on line 94 in textsplitter/split_documents.go

View workflow job for this annotation

GitHub Actions / lint

G602: Potentially accessing slice out of bounds (gosec)
if len(currentDoc) > 1 {
total -= len(separator)
}

currentDoc = currentDoc[1:]

Check failure on line 98 in textsplitter/split_documents.go

View workflow job for this annotation

GitHub Actions / lint

G602: Potentially accessing slice out of bounds (gosec)
}
}
Expand Down

0 comments on commit 3612dc5

Please sign in to comment.