File size: 450 Bytes
faca43f
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import type { Conversation } from "$lib/types/Conversation";
import { sha256 } from "./sha256";

export async function hashConv(conv: Conversation) {
	// messages contains the conversation message but only the immutable part
	const messages = conv.messages.map((message) => {
		return (({ from, id, content, webSearchId }) => ({ from, id, content, webSearchId }))(message);
	});

	const hash = await sha256(JSON.stringify(messages));
	return hash;
}