| | |
| | | AppMeta, |
| | | ConversationItem, |
| | | } from '@/models/share' |
| | | import { noop } from 'lodash-es' |
| | | |
| | | export type ChatWithHistoryContextValue = { |
| | | appInfoError?: any |
| | |
| | | appPrevChatTree: ChatItemInTree[] |
| | | pinnedConversationList: AppConversationData['data'] |
| | | conversationList: AppConversationData['data'] |
| | | showConfigPanelBeforeChat: boolean |
| | | newConversationInputs: Record<string, any> |
| | | newConversationInputsRef: RefObject<Record<string, any>> |
| | | handleNewConversationInputsChange: (v: Record<string, any>) => void |
| | | inputsForms: any[] |
| | | handleNewConversation: () => void |
| | | handleStartChat: (callback?: any) => void |
| | | handleStartChat: () => void |
| | | handleChangeConversation: (conversationId: string) => void |
| | | handlePinConversation: (conversationId: string) => void |
| | | handleUnpinConversation: (conversationId: string) => void |
| | |
| | | handleFeedback: (messageId: string, feedback: Feedback) => void |
| | | currentChatInstanceRef: RefObject<{ handleStop: () => void }> |
| | | themeBuilder?: ThemeBuilder |
| | | sidebarCollapseState?: boolean |
| | | handleSidebarCollapse: (state: boolean) => void |
| | | clearChatList?: boolean |
| | | setClearChatList: (state: boolean) => void |
| | | isResponding?: boolean |
| | | setIsResponding: (state: boolean) => void, |
| | | currentConversationInputs: Record<string, any> | null, |
| | | setCurrentConversationInputs: (v: Record<string, any>) => void, |
| | | } |
| | | |
| | | export const ChatWithHistoryContext = createContext<ChatWithHistoryContextValue>({ |
| | |
| | | appPrevChatTree: [], |
| | | pinnedConversationList: [], |
| | | conversationList: [], |
| | | showConfigPanelBeforeChat: false, |
| | | newConversationInputs: {}, |
| | | newConversationInputsRef: { current: {} }, |
| | | handleNewConversationInputsChange: noop, |
| | | handleNewConversationInputsChange: () => {}, |
| | | inputsForms: [], |
| | | handleNewConversation: noop, |
| | | handleStartChat: noop, |
| | | handleChangeConversation: noop, |
| | | handlePinConversation: noop, |
| | | handleUnpinConversation: noop, |
| | | handleDeleteConversation: noop, |
| | | handleNewConversation: () => {}, |
| | | handleStartChat: () => {}, |
| | | handleChangeConversation: () => {}, |
| | | handlePinConversation: () => {}, |
| | | handleUnpinConversation: () => {}, |
| | | handleDeleteConversation: () => {}, |
| | | conversationRenaming: false, |
| | | handleRenameConversation: noop, |
| | | handleNewConversationCompleted: noop, |
| | | handleRenameConversation: () => {}, |
| | | handleNewConversationCompleted: () => {}, |
| | | chatShouldReloadKey: '', |
| | | isMobile: false, |
| | | isInstalledApp: false, |
| | | handleFeedback: noop, |
| | | currentChatInstanceRef: { current: { handleStop: noop } }, |
| | | sidebarCollapseState: false, |
| | | handleSidebarCollapse: noop, |
| | | clearChatList: false, |
| | | setClearChatList: noop, |
| | | isResponding: false, |
| | | setIsResponding: noop, |
| | | currentConversationInputs: {}, |
| | | setCurrentConversationInputs: noop, |
| | | handleFeedback: () => {}, |
| | | currentChatInstanceRef: { current: { handleStop: () => {} } }, |
| | | }) |
| | | export const useChatWithHistoryContext = () => useContext(ChatWithHistoryContext) |