Skip to content

Commit bdc5c36

Browse files
authored
knowledge: fix document id generation in synchronous mode (#730)
1 parent bd32622 commit bdc5c36

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

knowledge/default.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ func convertToInt(value any) (int, bool) {
11561156
}
11571157
}
11581158

1159-
// generateDocumentID generates a unique document ID based on source name, content, chunk index and source metadata.
1159+
// generateDocumentID generates a unique document ID based on source name, URI, content, chunk index and source metadata.
11601160
// Uses SHA256 hash to ensure uniqueness and avoid collisions.
11611161
func generateDocumentID(sourceName, uri, content string, chunkIndex int, sourceMetadata map[string]any) string {
11621162
hasher := sha256.New()
@@ -1165,6 +1165,10 @@ func generateDocumentID(sourceName, uri, content string, chunkIndex int, sourceM
11651165
hasher.Write([]byte(sourceName))
11661166
hasher.Write([]byte(":"))
11671167

1168+
// Write URI
1169+
hasher.Write([]byte(uri))
1170+
hasher.Write([]byte(":"))
1171+
11681172
// Write content
11691173
hasher.Write([]byte(content))
11701174
hasher.Write([]byte(":"))

0 commit comments

Comments
 (0)