Spaces:
Running
Running
Download src/lib/stores/convTree.ts from huggingchat/chat-ui: direct link, hf CLI and curl.
- Browser
- Download file 724 Bytes
-
https://huggingface.co/spaces/huggingchat/chat-ui/resolve/refs%2Fpr%2F511/src/lib/stores/convTree.ts
- Command line
-
hf download hf://spaces/huggingchat/chat-ui@refs/pr/511/src/lib/stores/convTree.ts
-
curl -L -o convTree.ts https://huggingface.co/spaces/huggingchat/chat-ui/resolve/refs%2Fpr%2F511/src/lib/stores/convTree.ts
724 Bytes
| import type { Message } from "$lib/types/Message"; | |
| import { getContext, setContext } from "svelte"; | |
| import { writable, type Writable } from "svelte/store"; | |
| // used to store the id of the message that is the currently displayed leaf of the conversation tree | |
| // (that is the last message in the current branch of the conversation tree) | |
| interface ConvTreeStore { | |
| leaf: Message["id"] | null; | |
| editing: Message["id"] | null; | |
| } | |
| export function useConvTreeStore() { | |
| return getContext<Writable<ConvTreeStore>>("convTreeStore"); | |
| } | |
| export function createConvTreeStore() { | |
| const convTreeStore = writable<ConvTreeStore>({ | |
| leaf: null, | |
| editing: null, | |
| }); | |
| setContext("convTreeStore", convTreeStore); | |
| return convTreeStore; | |
| } | |