yari icon indicating copy to clipboard operation
yari copied to clipboard

enhance(ai-help): hash markdown to identify formatting updates

Open caugner opened this issue 1 year ago • 0 comments

Summary

Problem

The scripts/ai-help-macros.ts script updates the document content if the document hash changes, but this hash also changes when building the content from another yari branch (e.g. next), because the branch name is included in the source property:

image

Solution

Use the hash of the markdown content to determine whether the content has changed.

Note: We still use the text content to determine whether the embedding needs to be regenerated.


How did you test this change?

Ran the following query on the Supabase dev project to populate the new markdown_hash column:

update mdn_doc_macro set markdown_hash = encode(digest (markdown, 'sha256'), 'base64');

Then ran yarn ai-help-macros update-index locally.

caugner avatar Mar 04 '24 17:03 caugner