using System.Security.Cryptography; using System.Text; namespace AIStudio.Tools.Databases.IndexStore; /// /// The hash of the text of a chunk, exactly as it was embedded. /// /// /// A vector depends on nothing but the text it was made from and the embedding signature, and all /// vectors of one store share that signature. So two chunks of a store with the same hash may share /// a vector, which is what spares a document the embedding provider for every chunk that did not /// change. The text is hashed with its overlap and its heading line, as the provider received it. /// internal static class ChunkTextHash { /// /// SHA-256 over the UTF-8 bytes of the text, as lowercase hex. /// /// The text of the chunk. /// The hash. public static string Of(string text) => Convert.ToHexStringLower(SHA256.HashData(Encoding.UTF8.GetBytes(text))); }