@copilotkit/react-ui 1.10.0-next.8 → 1.10.0-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/{chunk-3DVMCBME.mjs → chunk-2KG77MAY.mjs} +61 -8
- package/dist/chunk-2KG77MAY.mjs.map +1 -0
- package/dist/{chunk-APLX7E54.mjs → chunk-6C3YVF5W.mjs} +2 -2
- package/dist/{chunk-BPU3FDT4.mjs → chunk-7K2X77PW.mjs} +24 -5
- package/dist/chunk-7K2X77PW.mjs.map +1 -0
- package/dist/{chunk-KLV4ERV6.mjs → chunk-TW4LLLTE.mjs} +2 -2
- package/dist/components/chat/Chat.d.ts +12 -1
- package/dist/components/chat/Chat.js +60 -7
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +1 -1
- package/dist/components/chat/Modal.js +76 -10
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +2 -2
- package/dist/components/chat/Popup.js +76 -10
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +3 -3
- package/dist/components/chat/Sidebar.js +76 -10
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +3 -3
- package/dist/components/chat/index.js +76 -10
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +4 -4
- package/dist/components/chat/props.d.ts +6 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.js +76 -10
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/index.js +78 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +94 -7
- package/src/components/chat/Modal.tsx +24 -3
- package/src/components/chat/props.ts +7 -1
- package/dist/chunk-3DVMCBME.mjs.map +0 -1
- package/dist/chunk-BPU3FDT4.mjs.map +0 -1
- /package/dist/{chunk-APLX7E54.mjs.map → chunk-6C3YVF5W.mjs.map} +0 -0
- /package/dist/{chunk-KLV4ERV6.mjs.map → chunk-TW4LLLTE.mjs.map} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "../../chunk-SC6JRFAJ.mjs";
|
|
2
2
|
import {
|
|
3
3
|
CopilotSidebar
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-TW4LLLTE.mjs";
|
|
5
5
|
import "../../chunk-WB3YULQ4.mjs";
|
|
6
6
|
import {
|
|
7
7
|
CopilotPopup
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-6C3YVF5W.mjs";
|
|
9
|
+
import "../../chunk-7K2X77PW.mjs";
|
|
10
10
|
import "../../chunk-C3GSYRC3.mjs";
|
|
11
11
|
import "../../chunk-GDSZGYCE.mjs";
|
|
12
12
|
import "../../chunk-V7W6IM2V.mjs";
|
|
@@ -19,7 +19,7 @@ import "../../chunk-BH6PCAAL.mjs";
|
|
|
19
19
|
import "../../chunk-UFN2VWSR.mjs";
|
|
20
20
|
import {
|
|
21
21
|
CopilotChat
|
|
22
|
-
} from "../../chunk-
|
|
22
|
+
} from "../../chunk-2KG77MAY.mjs";
|
|
23
23
|
import "../../chunk-JHUTTP5C.mjs";
|
|
24
24
|
import {
|
|
25
25
|
AssistantMessage
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message, UserMessage, AIMessage, ImageData } from '@copilotkit/shared';
|
|
1
|
+
import { CopilotErrorEvent, Message, UserMessage, AIMessage, ImageData } from '@copilotkit/shared';
|
|
2
2
|
import { CopilotChatSuggestion } from '../../types/suggestions.js';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
@@ -39,6 +39,11 @@ interface CopilotObservabilityHooks {
|
|
|
39
39
|
* Called when chat generation stops
|
|
40
40
|
*/
|
|
41
41
|
onChatStopped?: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Called when an error occurs in the chat
|
|
44
|
+
* This enables chat-specific error handling UX while preserving system-wide error monitoring
|
|
45
|
+
*/
|
|
46
|
+
onError?: (errorEvent: CopilotErrorEvent) => void;
|
|
42
47
|
}
|
|
43
48
|
interface ButtonProps {
|
|
44
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/chat/props.ts"],"sourcesContent":["import { AIMessage, Message, UserMessage } from \"@copilotkit/shared\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { ReactNode } from \"react\";\nimport { ImageData } from \"@copilotkit/shared\";\n\n/**\n * Event hooks for CopilotKit chat events.\n * These hooks only work when publicApiKey is provided.\n */\nexport interface CopilotObservabilityHooks {\n /**\n * Called when a message is sent by the user\n */\n onMessageSent?: (message: string) => void;\n\n /**\n * Called when the chat is minimized/closed\n */\n onChatMinimized?: () => void;\n\n /**\n * Called when the chat is expanded/opened\n */\n onChatExpanded?: () => void;\n\n /**\n * Called when a message is regenerated\n */\n onMessageRegenerated?: (messageId: string) => void;\n\n /**\n * Called when a message is copied\n */\n onMessageCopied?: (content: string) => void;\n\n /**\n * Called when feedback is given (thumbs up/down)\n */\n onFeedbackGiven?: (messageId: string, type: \"thumbsUp\" | \"thumbsDown\") => void;\n\n /**\n * Called when chat generation starts\n */\n onChatStarted?: () => void;\n\n /**\n * Called when chat generation stops\n */\n onChatStopped?: () => void;\n}\n\nexport interface ButtonProps {}\n\nexport interface WindowProps {\n clickOutsideToClose: boolean;\n hitEscapeToClose: boolean;\n shortcut: string;\n children?: React.ReactNode;\n}\n\nexport interface HeaderProps {}\n\nexport interface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: (message: string) => void;\n}\n\nexport type ComponentsMap<T extends Record<string, object> = Record<string, object>> = {\n [K in keyof T]: React.FC<{ children?: ReactNode } & T[K]>;\n};\n\nexport interface MessagesProps {\n messages: Message[];\n inProgress: boolean;\n children?: React.ReactNode;\n AssistantMessage: React.ComponentType<AssistantMessageProps>;\n UserMessage: React.ComponentType<UserMessageProps>;\n RenderMessage: React.ComponentType<RenderMessageProps>;\n ImageRenderer: React.ComponentType<ImageRendererProps>;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n}\n\nexport interface Renderer {\n content: string;\n}\n\nexport interface UserMessageProps {\n message?: UserMessage;\n ImageRenderer: React.ComponentType<ImageRendererProps>;\n}\n\nexport interface AssistantMessageProps {\n /**\n * The message content from the assistant\n */\n\n message?: AIMessage;\n\n /**\n * Indicates if this is the last message\n */\n isCurrentMessage?: boolean;\n\n /**\n * Whether a response is loading, this is when the LLM is thinking of a response but hasn't finished yet.\n */\n isLoading: boolean;\n\n /**\n * Whether a response is generating, this is when the LLM is actively generating and streaming content.\n */\n isGenerating: boolean;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: () => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n\n /**\n * A custom image rendering component to use instead of the default.\n */\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n}\n\nexport interface RenderMessageProps {\n message: Message;\n inProgress: boolean;\n index: number;\n isCurrentMessage: boolean;\n actionResult?: string;\n AssistantMessage?: React.ComponentType<AssistantMessageProps>;\n UserMessage?: React.ComponentType<UserMessageProps>;\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n}\n\nexport interface InputProps {\n inProgress: boolean;\n onSend: (text: string) => Promise<Message>;\n isVisible?: boolean;\n onStop?: () => void;\n onUpload?: () => void;\n hideStopButton?: boolean;\n}\n\nexport interface RenderSuggestionsListProps {\n suggestions: CopilotChatSuggestion[];\n onSuggestionClick: (message: string) => void;\n}\n\nexport interface ImageRendererProps {\n /**\n * The image data containing format and bytes\n */\n image: ImageData;\n\n /**\n * Optional content to display alongside the image\n */\n content?: string;\n\n /**\n * Additional CSS class name for styling\n */\n className?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chat/props.ts"],"sourcesContent":["import { AIMessage, Message, UserMessage, CopilotErrorEvent } from \"@copilotkit/shared\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { ReactNode } from \"react\";\nimport { ImageData } from \"@copilotkit/shared\";\n\n/**\n * Event hooks for CopilotKit chat events.\n * These hooks only work when publicApiKey is provided.\n */\nexport interface CopilotObservabilityHooks {\n /**\n * Called when a message is sent by the user\n */\n onMessageSent?: (message: string) => void;\n\n /**\n * Called when the chat is minimized/closed\n */\n onChatMinimized?: () => void;\n\n /**\n * Called when the chat is expanded/opened\n */\n onChatExpanded?: () => void;\n\n /**\n * Called when a message is regenerated\n */\n onMessageRegenerated?: (messageId: string) => void;\n\n /**\n * Called when a message is copied\n */\n onMessageCopied?: (content: string) => void;\n\n /**\n * Called when feedback is given (thumbs up/down)\n */\n onFeedbackGiven?: (messageId: string, type: \"thumbsUp\" | \"thumbsDown\") => void;\n\n /**\n * Called when chat generation starts\n */\n onChatStarted?: () => void;\n\n /**\n * Called when chat generation stops\n */\n onChatStopped?: () => void;\n\n /**\n * Called when an error occurs in the chat\n * This enables chat-specific error handling UX while preserving system-wide error monitoring\n */\n onError?: (errorEvent: CopilotErrorEvent) => void;\n}\n\nexport interface ButtonProps {}\n\nexport interface WindowProps {\n clickOutsideToClose: boolean;\n hitEscapeToClose: boolean;\n shortcut: string;\n children?: React.ReactNode;\n}\n\nexport interface HeaderProps {}\n\nexport interface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: (message: string) => void;\n}\n\nexport type ComponentsMap<T extends Record<string, object> = Record<string, object>> = {\n [K in keyof T]: React.FC<{ children?: ReactNode } & T[K]>;\n};\n\nexport interface MessagesProps {\n messages: Message[];\n inProgress: boolean;\n children?: React.ReactNode;\n AssistantMessage: React.ComponentType<AssistantMessageProps>;\n UserMessage: React.ComponentType<UserMessageProps>;\n RenderMessage: React.ComponentType<RenderMessageProps>;\n ImageRenderer: React.ComponentType<ImageRendererProps>;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n}\n\nexport interface Renderer {\n content: string;\n}\n\nexport interface UserMessageProps {\n message?: UserMessage;\n ImageRenderer: React.ComponentType<ImageRendererProps>;\n}\n\nexport interface AssistantMessageProps {\n /**\n * The message content from the assistant\n */\n\n message?: AIMessage;\n\n /**\n * Indicates if this is the last message\n */\n isCurrentMessage?: boolean;\n\n /**\n * Whether a response is loading, this is when the LLM is thinking of a response but hasn't finished yet.\n */\n isLoading: boolean;\n\n /**\n * Whether a response is generating, this is when the LLM is actively generating and streaming content.\n */\n isGenerating: boolean;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: () => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n\n /**\n * A custom image rendering component to use instead of the default.\n */\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n}\n\nexport interface RenderMessageProps {\n message: Message;\n inProgress: boolean;\n index: number;\n isCurrentMessage: boolean;\n actionResult?: string;\n AssistantMessage?: React.ComponentType<AssistantMessageProps>;\n UserMessage?: React.ComponentType<UserMessageProps>;\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n}\n\nexport interface InputProps {\n inProgress: boolean;\n onSend: (text: string) => Promise<Message>;\n isVisible?: boolean;\n onStop?: () => void;\n onUpload?: () => void;\n hideStopButton?: boolean;\n}\n\nexport interface RenderSuggestionsListProps {\n suggestions: CopilotChatSuggestion[];\n onSuggestionClick: (message: string) => void;\n}\n\nexport interface ImageRendererProps {\n /**\n * The image data containing format and bytes\n */\n image: ImageData;\n\n /**\n * Optional content to display alongside the image\n */\n content?: string;\n\n /**\n * Additional CSS class name for styling\n */\n className?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/components/index.js
CHANGED
|
@@ -2326,17 +2326,20 @@ function CopilotChat({
|
|
|
2326
2326
|
imageUploadsEnabled,
|
|
2327
2327
|
inputFileAccept = "image/*",
|
|
2328
2328
|
hideStopButton,
|
|
2329
|
-
observabilityHooks
|
|
2329
|
+
observabilityHooks,
|
|
2330
|
+
renderError
|
|
2330
2331
|
}) {
|
|
2331
2332
|
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
|
|
2333
|
+
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2332
2334
|
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2335
|
+
const [chatError, setChatError] = (0, import_react14.useState)(null);
|
|
2333
2336
|
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2334
2337
|
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2335
2338
|
(hookName, ...args) => {
|
|
2336
|
-
if (
|
|
2339
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2337
2340
|
observabilityHooks[hookName](...args);
|
|
2338
2341
|
}
|
|
2339
|
-
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !
|
|
2342
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2340
2343
|
setBannerError(
|
|
2341
2344
|
new import_shared3.CopilotKitError({
|
|
2342
2345
|
message: "observabilityHooks requires a publicApiKey to function.",
|
|
@@ -2348,7 +2351,50 @@ function CopilotChat({
|
|
|
2348
2351
|
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2349
2352
|
}
|
|
2350
2353
|
},
|
|
2351
|
-
[
|
|
2354
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2355
|
+
);
|
|
2356
|
+
const triggerChatError = (0, import_react14.useCallback)(
|
|
2357
|
+
(error, operation, originalError) => {
|
|
2358
|
+
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2359
|
+
setChatError({
|
|
2360
|
+
message: errorMessage,
|
|
2361
|
+
operation,
|
|
2362
|
+
timestamp: Date.now()
|
|
2363
|
+
});
|
|
2364
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
|
|
2365
|
+
const errorEvent = {
|
|
2366
|
+
type: "error",
|
|
2367
|
+
timestamp: Date.now(),
|
|
2368
|
+
context: {
|
|
2369
|
+
source: "ui",
|
|
2370
|
+
request: {
|
|
2371
|
+
operation,
|
|
2372
|
+
url: chatApiEndpoint,
|
|
2373
|
+
startTime: Date.now()
|
|
2374
|
+
},
|
|
2375
|
+
technical: {
|
|
2376
|
+
environment: "browser",
|
|
2377
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2378
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2379
|
+
}
|
|
2380
|
+
},
|
|
2381
|
+
error
|
|
2382
|
+
};
|
|
2383
|
+
observabilityHooks.onError(errorEvent);
|
|
2384
|
+
}
|
|
2385
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
|
|
2386
|
+
setBannerError(
|
|
2387
|
+
new import_shared3.CopilotKitError({
|
|
2388
|
+
message: "observabilityHooks.onError requires a publicApiKey to function.",
|
|
2389
|
+
code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2390
|
+
severity: import_shared3.Severity.CRITICAL,
|
|
2391
|
+
visibility: import_shared3.ErrorVisibility.BANNER
|
|
2392
|
+
})
|
|
2393
|
+
);
|
|
2394
|
+
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
|
|
2395
|
+
}
|
|
2396
|
+
},
|
|
2397
|
+
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2352
2398
|
);
|
|
2353
2399
|
(0, import_react14.useEffect)(() => {
|
|
2354
2400
|
if (!imageUploadsEnabled)
|
|
@@ -2389,12 +2435,13 @@ function CopilotChat({
|
|
|
2389
2435
|
const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
|
|
2390
2436
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2391
2437
|
} catch (error) {
|
|
2438
|
+
triggerChatError(error, "processClipboardImages", error);
|
|
2392
2439
|
console.error("Error processing pasted images:", error);
|
|
2393
2440
|
}
|
|
2394
2441
|
});
|
|
2395
2442
|
document.addEventListener("paste", handlePaste);
|
|
2396
2443
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2397
|
-
}, [imageUploadsEnabled]);
|
|
2444
|
+
}, [imageUploadsEnabled, triggerChatError]);
|
|
2398
2445
|
(0, import_react14.useEffect)(() => {
|
|
2399
2446
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2400
2447
|
setChatInstructions(instructions || "");
|
|
@@ -2485,6 +2532,7 @@ function CopilotChat({
|
|
|
2485
2532
|
const loadedImages = yield Promise.all(fileReadPromises);
|
|
2486
2533
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2487
2534
|
} catch (error) {
|
|
2535
|
+
triggerChatError(error, "processUploadedImages", error);
|
|
2488
2536
|
console.error("Error reading files:", error);
|
|
2489
2537
|
}
|
|
2490
2538
|
});
|
|
@@ -2504,6 +2552,12 @@ function CopilotChat({
|
|
|
2504
2552
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2505
2553
|
};
|
|
2506
2554
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2555
|
+
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2556
|
+
onDismiss: () => setChatError(null),
|
|
2557
|
+
onRetry: () => {
|
|
2558
|
+
setChatError(null);
|
|
2559
|
+
}
|
|
2560
|
+
})),
|
|
2507
2561
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2508
2562
|
Messages2,
|
|
2509
2563
|
{
|
|
@@ -2737,8 +2791,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2737
2791
|
stableContext,
|
|
2738
2792
|
messagesContext.messages,
|
|
2739
2793
|
appendMessage,
|
|
2740
|
-
runChatCompletion
|
|
2741
|
-
hint
|
|
2794
|
+
runChatCompletion
|
|
2742
2795
|
);
|
|
2743
2796
|
}
|
|
2744
2797
|
});
|
|
@@ -2808,6 +2861,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2808
2861
|
|
|
2809
2862
|
// src/components/chat/Modal.tsx
|
|
2810
2863
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2864
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2811
2865
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2812
2866
|
var CopilotModalInner = (_a) => {
|
|
2813
2867
|
var _b = _a, {
|
|
@@ -2833,14 +2887,26 @@ var CopilotModalInner = (_a) => {
|
|
|
2833
2887
|
"Button",
|
|
2834
2888
|
"Header"
|
|
2835
2889
|
]);
|
|
2836
|
-
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2890
|
+
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
2891
|
+
const { publicApiKey } = copilotApiConfig;
|
|
2837
2892
|
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2838
2893
|
(hookName, ...args) => {
|
|
2839
|
-
if (
|
|
2894
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2840
2895
|
observabilityHooks[hookName](...args);
|
|
2841
2896
|
}
|
|
2897
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2898
|
+
setBannerError(
|
|
2899
|
+
new import_shared5.CopilotKitError({
|
|
2900
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
2901
|
+
code: import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2902
|
+
severity: import_shared5.Severity.CRITICAL,
|
|
2903
|
+
visibility: import_shared5.ErrorVisibility.BANNER
|
|
2904
|
+
})
|
|
2905
|
+
);
|
|
2906
|
+
import_shared5.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2907
|
+
}
|
|
2842
2908
|
},
|
|
2843
|
-
[
|
|
2909
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2844
2910
|
);
|
|
2845
2911
|
const { open } = useChatContext();
|
|
2846
2912
|
const prevOpen = (0, import_react15.useRef)(open);
|