char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Clean up contexts, remove prop drilling from Chat Form Actions (#26951)d86c7d62d

char/aliceai-t5-moe
730 B21 linesraw
1import { CONTEXT_KEY_CHAT_MESSAGE_ACTIONS } from '$lib/constants';
2import type { ChatMessageActionsContext } from '$lib/types';
3import { getContext, setContext } from 'svelte';
4
5const CHAT_MESSAGE_ACTIONS_KEY = Symbol.for(CONTEXT_KEY_CHAT_MESSAGE_ACTIONS);
6
7/**
8 * Sets the per-message actions context. Call this in the parent component (ChatMessage.svelte).
9 */
10export function setChatMessageActionsContext(
11	ctx: ChatMessageActionsContext
12): ChatMessageActionsContext {
13	return setContext(CHAT_MESSAGE_ACTIONS_KEY, ctx);
14}
15
16/**
17 * Gets the per-message actions context. Call this in child components.
18 */
19export function getChatMessageActionsContext(): ChatMessageActionsContext {
20	return getContext(CHAT_MESSAGE_ACTIONS_KEY);
21}