Download apps/readest-app/src/app/reader/hooks/useOpenAIInNotebook.ts from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/app/reader/hooks/useOpenAIInNotebook.ts
- Command line
-
hf download hf://datasets/echodict/readest/apps/readest-app/src/app/reader/hooks/useOpenAIInNotebook.ts
-
curl -L -o useOpenAIInNotebook.ts https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/app/reader/hooks/useOpenAIInNotebook.ts
1.37 kB
| import { useCallback } from 'react'; | |
| import { useNotebookStore } from '@/store/notebookStore'; | |
| import { useAIChatStore } from '@/store/aiChatStore'; | |
| // Hook to open the Notebook panel with the AI tab and optionally load a specific conversation | |
| export function useOpenAIInNotebook() { | |
| const { setNotebookVisible, setNotebookActiveTab } = useNotebookStore(); | |
| const { setActiveConversation, createConversation } = useAIChatStore(); | |
| const openAIInNotebook = useCallback( | |
| async (options?: { | |
| conversationId?: string; | |
| bookHash?: string; | |
| newConversationTitle?: string; | |
| }) => { | |
| // Open notebook and switch to AI tab | |
| setNotebookVisible(true); | |
| setNotebookActiveTab('ai'); | |
| if (options?.conversationId) { | |
| // Load existing conversation | |
| await setActiveConversation(options.conversationId); | |
| } else if (options?.bookHash && options?.newConversationTitle) { | |
| // Create new conversation | |
| await createConversation(options.bookHash, options.newConversationTitle); | |
| } | |
| }, | |
| [setNotebookVisible, setNotebookActiveTab, setActiveConversation, createConversation], | |
| ); | |
| const closeAIInNotebook = useCallback(() => { | |
| setNotebookActiveTab('notes'); | |
| }, [setNotebookActiveTab]); | |
| return { | |
| openAIInNotebook, | |
| closeAIInNotebook, | |
| }; | |
| } | |
| export default useOpenAIInNotebook; | |