Spaces:
Running
Running
Download src/lib/utils/hashConv.ts from huggingchat/chat-ui: direct link, hf CLI and curl.
- Browser
- Download file 450 Bytes
-
https://huggingface.co/spaces/huggingchat/chat-ui/resolve/refs%2Fpr%2F511/src/lib/utils/hashConv.ts
- Command line
-
hf download hf://spaces/huggingchat/chat-ui@refs/pr/511/src/lib/utils/hashConv.ts
-
curl -L -o hashConv.ts https://huggingface.co/spaces/huggingchat/chat-ui/resolve/refs%2Fpr%2F511/src/lib/utils/hashConv.ts
450 Bytes
| 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; | |
| } | |