UNPKG

@restnfeel/agentc-starter-kit

Version:

한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템

56 lines (51 loc) 1.24 kB
/** * @fileoverview Main chatbot hook providing unified access to all chatbot functionality * @module hooks/useChatbot */ import { useContext } from "react"; import { ChatbotContext, type ChatbotContextType, } from "../core/contexts/ChatbotContext"; /** * Re-export the main chatbot hook from the context * This provides a unified interface to all chatbot functionality * * @returns {ChatbotContextType} Chatbot state and methods * * @example * ```typescript * function MyComponent() { * const { * isInitialized, * config, * initialize, * sendMessage, * uploadDocument, * searchSimilarDocuments, * lastError, * clearError * } = useChatbot(); * * useEffect(() => { * if (!isInitialized) { * initialize(); * } * }, [isInitialized, initialize]); * * return ( * <div> * {lastError && <div className="error">{lastError.message}</div>} * {isInitialized ? <ChatInterface /> : <Loading />} * </div> * ); * } * ``` */ export function useChatbot(): ChatbotContextType { const context = useContext(ChatbotContext); if (!context) { throw new Error("useChatbot must be used within a ChatbotProvider"); } return context; }