UNPKG

@copilotkit/react-core

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

85 lines (83 loc) 2.2 kB
import { useCopilotChat } from "./chunk-QHCLJODF.mjs"; import { useCopilotContext } from "./chunk-EUX2P2E7.mjs"; import { __async } from "./chunk-SKC7AJIV.mjs"; // src/hooks/use-copilot-chat-headless_c.ts import { useEffect } from "react"; import { ErrorVisibility, Severity, CopilotKitError, CopilotKitErrorCode, styledConsole } from "@copilotkit/shared"; var createNonFunctionalReturn = () => ({ visibleMessages: [], messages: [], sendMessage: () => __async(void 0, null, function* () { }), appendMessage: () => __async(void 0, null, function* () { }), setMessages: () => { }, deleteMessage: () => { }, reloadMessages: () => __async(void 0, null, function* () { }), stopGeneration: () => { }, reset: () => { }, isLoading: false, runChatCompletion: () => __async(void 0, null, function* () { return []; }), mcpServers: [], setMcpServers: () => { }, suggestions: [], setSuggestions: () => { }, generateSuggestions: () => __async(void 0, null, function* () { }), resetSuggestions: () => { }, isLoadingSuggestions: false, interrupt: null }); function useCopilotChatHeadless_c(options = {}) { const { copilotApiConfig, setBannerError } = useCopilotContext(); const hasPublicApiKey = Boolean(copilotApiConfig.publicApiKey); const internalResult = useCopilotChat(options); useEffect(() => { if (!hasPublicApiKey) { setBannerError( new CopilotKitError({ message: ( // add link to documentation here "You're using useCopilotChatHeadless_c, a premium-only feature, which offers extensive headless chat capabilities. To continue, you'll need to provide a free public license key." ), code: CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR, severity: Severity.WARNING, visibility: ErrorVisibility.BANNER }) ); styledConsole.logCopilotKitPlatformMessage(); } else { setBannerError(null); } }, [hasPublicApiKey]); if (hasPublicApiKey) { return internalResult; } return createNonFunctionalReturn(); } export { useCopilotChatHeadless_c }; //# sourceMappingURL=chunk-4BHIQMN6.mjs.map