Skip to content

Commit

Permalink
add context
Browse files Browse the repository at this point in the history
  • Loading branch information
jwlee64 committed Nov 4, 2024
1 parent 264ce7a commit e781a8f
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {createContext, useContext} from 'react';

// Create a new context for the isPlayground value, and the playground chat functions
// isPlayground is the only required value
export const PlaygroundContext = createContext<{
isPlayground: boolean;
deleteMessage?: (messageIndex: number) => void;
editMessage?: (messageIndex: number, newMessage: any) => void;
deleteChoice?: (choiceIndex: number) => void;
editChoice?: (choiceIndex: number, newChoice: any) => void;
addMessage?: (newMessage: any) => void;
retry?: (messageIndex: number, isChoice?: boolean) => void;
sendMessage?: (
role: 'assistant' | 'user' | 'tool',
content: string,
toolCallId?: string
) => void;
}>({isPlayground: false});

// Create a custom hook to use the PlaygroundContext
export const usePlaygroundContext = () => useContext(PlaygroundContext);

0 comments on commit e781a8f

Please sign in to comment.