@copilotkit/react-ui 1.10.0-next.3 → 1.10.0-next.5
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 +20 -0
- package/dist/{chunk-O7KTFUAN.mjs → chunk-226ZMOE3.mjs} +2 -2
- package/dist/{chunk-PF3QW6U5.mjs → chunk-BXX6RM44.mjs} +2 -2
- package/dist/chunk-BXX6RM44.mjs.map +1 -0
- package/dist/chunk-BY42E5VF.mjs +203 -0
- package/dist/chunk-BY42E5VF.mjs.map +1 -0
- package/dist/{chunk-SGFUVPDB.mjs → chunk-FFJHOZX6.mjs} +2 -2
- package/dist/{chunk-GVKA7RQQ.mjs → chunk-GDSZGYCE.mjs} +2 -2
- package/dist/{chunk-QN7T3GWI.mjs → chunk-JY2CSDKN.mjs} +4 -6
- package/dist/chunk-JY2CSDKN.mjs.map +1 -0
- package/dist/{chunk-7L34XQRL.mjs → chunk-K344MVUT.mjs} +61 -8
- package/dist/chunk-K344MVUT.mjs.map +1 -0
- package/dist/{chunk-QNG5G23E.mjs → chunk-MYWIJSW6.mjs} +2 -2
- package/dist/chunk-MYWIJSW6.mjs.map +1 -0
- package/dist/{chunk-WHDNKXMP.mjs → chunk-U5ATIGWH.mjs} +2 -2
- package/dist/chunk-U5ATIGWH.mjs.map +1 -0
- package/dist/{chunk-Q2467VHZ.mjs → chunk-W26XFBEG.mjs} +2 -2
- package/dist/chunk-W26XFBEG.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +19 -12
- package/dist/components/chat/Chat.js +57 -10
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +4 -4
- package/dist/components/chat/Header.js +6 -8
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +3 -3
- package/dist/components/chat/Messages.js +1 -1
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +2 -2
- package/dist/components/chat/Modal.js +179 -76
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +8 -8
- package/dist/components/chat/Popup.d.ts +1 -1
- package/dist/components/chat/Popup.js +179 -76
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +9 -9
- package/dist/components/chat/Sidebar.d.ts +1 -1
- package/dist/components/chat/Sidebar.js +179 -76
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +9 -9
- package/dist/components/chat/Suggestion.js +1 -1
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +1 -1
- package/dist/components/chat/Suggestions.js +1 -1
- package/dist/components/chat/Suggestions.js.map +1 -1
- package/dist/components/chat/Suggestions.mjs +2 -2
- package/dist/components/chat/index.d.ts +2 -2
- package/dist/components/chat/index.js +179 -76
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +10 -10
- package/dist/components/chat/props.d.ts +39 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.d.ts +1 -0
- package/dist/components/dev-console/console.js +6 -8
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +2 -2
- package/dist/components/dev-console/index.d.ts +1 -3
- package/dist/components/dev-console/index.js +7 -9
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +2 -2
- package/dist/components/dev-console/utils.d.ts +2 -2
- package/dist/components/dev-console/utils.js +2 -4
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/index.d.ts +3 -5
- package/dist/components/index.js +180 -77
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -10
- package/dist/index.d.ts +3 -5
- package/dist/index.js +184 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/package.json +5 -5
- package/src/components/chat/Chat.tsx +99 -5
- package/src/components/chat/Messages.tsx +2 -2
- package/src/components/chat/Modal.tsx +107 -41
- package/src/components/chat/Popup.tsx +20 -0
- package/src/components/chat/Sidebar.tsx +22 -0
- package/src/components/chat/Suggestion.tsx +1 -1
- package/src/components/chat/props.ts +46 -0
- package/src/components/dev-console/utils.ts +1 -6
- package/dist/chunk-7L34XQRL.mjs.map +0 -1
- package/dist/chunk-DNSSBMAS.mjs +0 -144
- package/dist/chunk-DNSSBMAS.mjs.map +0 -1
- package/dist/chunk-PF3QW6U5.mjs.map +0 -1
- package/dist/chunk-Q2467VHZ.mjs.map +0 -1
- package/dist/chunk-QN7T3GWI.mjs.map +0 -1
- package/dist/chunk-QNG5G23E.mjs.map +0 -1
- package/dist/chunk-WHDNKXMP.mjs.map +0 -1
- /package/dist/{chunk-O7KTFUAN.mjs.map → chunk-226ZMOE3.mjs.map} +0 -0
- /package/dist/{chunk-SGFUVPDB.mjs.map → chunk-FFJHOZX6.mjs.map} +0 -0
- /package/dist/{chunk-GVKA7RQQ.mjs.map → chunk-GDSZGYCE.mjs.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Messages.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\nimport { MessagesProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { Message } from \"@copilotkit/shared\";\nimport { useCopilotChatInternal as useCopilotChat } from \"@copilotkit/react-core\";\n\nexport const Messages = ({\n inProgress,\n children,\n RenderMessage,\n AssistantMessage,\n UserMessage,\n onRegenerate,\n onCopy,\n onThumbsUp,\n onThumbsDown,\n markdownTagRenderers,\n}: MessagesProps) => {\n const { labels } = useChatContext();\n const { visibleMessages, interrupt } = useCopilotChat();\n const initialMessages = useMemo(() => makeInitialMessages(labels.initial), [labels.initial]);\n const messages = [...initialMessages, ...visibleMessages];\n const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);\n\n return (\n <div className=\"copilotKitMessages\" ref={messagesContainerRef}>\n <div className=\"copilotKitMessagesContainer\">\n {messages.map((message, index) => {\n const isCurrentMessage = index === messages.length - 1;\n return (\n <RenderMessage\n key={index}\n message={message}\n inProgress={inProgress}\n index={index}\n isCurrentMessage={isCurrentMessage}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n onRegenerate={onRegenerate}\n onCopy={onCopy}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n markdownTagRenderers={markdownTagRenderers}\n />\n );\n })}\n {interrupt}\n </div>\n <footer className=\"copilotKitMessagesFooter\" ref={messagesEndRef}>\n {children}\n </footer>\n </div>\n );\n};\n\nfunction makeInitialMessages(initial: string | string[] | undefined): Message[] {\n if (!initial) return [];\n\n if (Array.isArray(initial)) {\n return initial.map((message) => {\n return {\n id: message,\n role: \"assistant\",\n content: message,\n };\n });\n }\n\n return [\n {\n id: initial,\n role: \"system\",\n content: initial,\n },\n ];\n}\n\nexport function useScrollToBottom(messages: Message[]) {\n const messagesEndRef = useRef<HTMLDivElement>(null);\n const messagesContainerRef = useRef<HTMLDivElement | null>(null);\n const isProgrammaticScrollRef = useRef(false);\n const isUserScrollUpRef = useRef(false);\n\n const scrollToBottom = () => {\n if (messagesContainerRef.current && messagesEndRef.current) {\n isProgrammaticScrollRef.current = true;\n messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight;\n }\n };\n\n const handleScroll = () => {\n if (isProgrammaticScrollRef.current) {\n isProgrammaticScrollRef.current = false;\n return;\n }\n\n if (messagesContainerRef.current) {\n const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;\n isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;\n }\n };\n\n useEffect(() => {\n const container = messagesContainerRef.current;\n if (container) {\n container.addEventListener(\"scroll\", handleScroll);\n }\n return () => {\n if (container) {\n container.removeEventListener(\"scroll\", handleScroll);\n }\n };\n }, []);\n\n useEffect(() => {\n const container = messagesContainerRef.current;\n if (!container) {\n return;\n }\n\n const mutationObserver = new MutationObserver(() => {\n if (!isUserScrollUpRef.current) {\n scrollToBottom();\n }\n });\n\n mutationObserver.observe(container, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n return () => {\n mutationObserver.disconnect();\n };\n }, []);\n\n useEffect(() => {\n isUserScrollUpRef.current = false;\n scrollToBottom();\n }, [messages.filter((m) => m.role === \"user\").length]);\n\n return { messagesEndRef, messagesContainerRef };\n}\n"],"mappings":";;;;;AAAA,SAAS,WAAW,SAAS,cAAc;AAI3C,SAAS,0BAA0B,sBAAsB;AAsBnD,SAIM,KAJN;AApBC,IAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqB;AACnB,QAAM,EAAE,OAAO,IAAI,eAAe;AAClC,QAAM,EAAE,iBAAiB,UAAU,IAAI,eAAe;AACtD,QAAM,kBAAkB,QAAQ,MAAM,oBAAoB,OAAO,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC;AAC3F,QAAM,WAAW,CAAC,GAAG,iBAAiB,GAAG,eAAe;AACxD,QAAM,EAAE,sBAAsB,eAAe,IAAI,kBAAkB,QAAQ;AAE3E,SACE,qBAAC,SAAI,WAAU,sBAAqB,KAAK,sBACvC;AAAA,yBAAC,SAAI,WAAU,+BACZ;AAAA,eAAS,IAAI,CAAC,SAAS,UAAU;AAChC,cAAM,mBAAmB,UAAU,SAAS,SAAS;AACrD,eACE;AAAA,UAAC;AAAA;AAAA,YAEC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,UAXK;AAAA,QAYP;AAAA,MAEJ,CAAC;AAAA,MACA;AAAA,OACH;AAAA,IACA,oBAAC,YAAO,WAAU,4BAA2B,KAAK,gBAC/C,UACH;AAAA,KACF;AAEJ;AAEA,SAAS,oBAAoB,SAAmD;AAC9E,MAAI,CAAC;AAAS,WAAO,CAAC;AAEtB,MAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,WAAO,QAAQ,IAAI,CAAC,YAAY;AAC9B,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEO,SAAS,kBAAkB,UAAqB;AACrD,QAAM,iBAAiB,OAAuB,IAAI;AAClD,QAAM,uBAAuB,OAA8B,IAAI;AAC/D,QAAM,0BAA0B,OAAO,KAAK;AAC5C,QAAM,oBAAoB,OAAO,KAAK;AAEtC,QAAM,iBAAiB,MAAM;AAC3B,QAAI,qBAAqB,WAAW,eAAe,SAAS;AAC1D,8BAAwB,UAAU;AAClC,2BAAqB,QAAQ,YAAY,qBAAqB,QAAQ;AAAA,IACxE;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AACzB,QAAI,wBAAwB,SAAS;AACnC,8BAAwB,UAAU;AAClC;AAAA,IACF;AAEA,QAAI,qBAAqB,SAAS;AAChC,YAAM,EAAE,WAAW,cAAc,aAAa,IAAI,qBAAqB;AACvE,wBAAkB,UAAU,YAAY,eAAe;AAAA,IACzD;AAAA,EACF;AAEA,YAAU,MAAM;AACd,UAAM,YAAY,qBAAqB;AACvC,QAAI,WAAW;AACb,gBAAU,iBAAiB,UAAU,YAAY;AAAA,IACnD;AACA,WAAO,MAAM;AACX,UAAI,WAAW;AACb,kBAAU,oBAAoB,UAAU,YAAY;AAAA,MACtD;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,UAAM,YAAY,qBAAqB;AACvC,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AAEA,UAAM,mBAAmB,IAAI,iBAAiB,MAAM;AAClD,UAAI,CAAC,kBAAkB,SAAS;AAC9B,uBAAe;AAAA,MACjB;AAAA,IACF,CAAC;AAED,qBAAiB,QAAQ,WAAW;AAAA,MAClC,WAAW;AAAA,MACX,SAAS;AAAA,MACT,eAAe;AAAA,IACjB,CAAC;AAED,WAAO,MAAM;AACX,uBAAiB,WAAW;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,sBAAkB,UAAU;AAC5B,mBAAe;AAAA,EACjB,GAAG,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,MAAM,CAAC;AAErD,SAAO,EAAE,gBAAgB,qBAAqB;AAChD;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-XWG3L6QC.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/chat/Suggestion.tsx
|
|
6
|
-
import { useCopilotChat } from "@copilotkit/react-core";
|
|
6
|
+
import { useCopilotChatInternal as useCopilotChat } from "@copilotkit/react-core";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
function Suggestion({ title, onClick, partial, className }) {
|
|
9
9
|
if (!title)
|
|
@@ -27,4 +27,4 @@ function Suggestion({ title, onClick, partial, className }) {
|
|
|
27
27
|
export {
|
|
28
28
|
Suggestion
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-W26XFBEG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Suggestion.tsx"],"sourcesContent":["import { useCopilotChatInternal as useCopilotChat } from \"@copilotkit/react-core\";\nimport { SmallSpinnerIcon } from \"./Icons\";\n\ninterface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: () => void;\n}\n\nexport function Suggestion({ title, onClick, partial, className }: SuggestionsProps) {\n if (!title) return null;\n const { isLoading } = useCopilotChat();\n\n return (\n <button\n disabled={partial || isLoading}\n onClick={(e) => {\n e.preventDefault();\n onClick();\n }}\n className={className || (partial ? \"suggestion loading\" : \"suggestion\")}\n data-test-id=\"suggestion\"\n >\n {partial ? SmallSpinnerIcon : <span>{title}</span>}\n </button>\n );\n}\n"],"mappings":";;;;;AAAA,SAAS,0BAA0B,sBAAsB;AAyBrB;AAd7B,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,UAAU,GAAqB;AACnF,MAAI,CAAC;AAAO,WAAO;AACnB,QAAM,EAAE,UAAU,IAAI,eAAe;AAErC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,WAAW;AAAA,MACrB,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ;AAAA,MACV;AAAA,MACA,WAAW,cAAc,UAAU,uBAAuB;AAAA,MAC1D,gBAAa;AAAA,MAEZ,oBAAU,mBAAmB,oBAAC,UAAM,iBAAM;AAAA;AAAA,EAC7C;AAEJ;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _copilotkit_react_core_dist_types_coagent_state from '@copilotkit/react-core/dist/types/coagent-state';
|
|
2
2
|
import * as _copilotkit_react_core_dist_hooks_use_tree from '@copilotkit/react-core/dist/hooks/use-tree';
|
|
3
3
|
import * as _copilotkit_shared from '@copilotkit/shared';
|
|
4
|
-
import { Message } from '@copilotkit/shared';
|
|
5
|
-
import * as
|
|
4
|
+
import { Message, CopilotKitError } from '@copilotkit/shared';
|
|
5
|
+
import * as _copilotkit_react_core_dist_copilot_context_78fc727c from '@copilotkit/react-core/dist/copilot-context-78fc727c';
|
|
6
6
|
import * as _copilotkit_react_core_dist_types_coagent_action from '@copilotkit/react-core/dist/types/coagent-action';
|
|
7
7
|
import * as _copilotkit_react_core from '@copilotkit/react-core';
|
|
8
8
|
import { SuggestionItem, SystemMessageFunction, HintFunction } from '@copilotkit/react-core';
|
|
@@ -10,7 +10,7 @@ import * as _copilotkit_runtime_client_gql from '@copilotkit/runtime-client-gql'
|
|
|
10
10
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
11
|
import { CopilotChatIcons, CopilotChatLabels } from './ChatContext.js';
|
|
12
12
|
import React__default from 'react';
|
|
13
|
-
import { ComponentsMap, AssistantMessageProps, UserMessageProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, InputProps, ImageRendererProps } from './props.js';
|
|
13
|
+
import { ComponentsMap, AssistantMessageProps, UserMessageProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, InputProps, ImageRendererProps, CopilotObservabilityHooks } from './props.js';
|
|
14
14
|
import '../../types/suggestions.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -155,6 +155,11 @@ interface CopilotChatProps {
|
|
|
155
155
|
*/
|
|
156
156
|
children?: React__default.ReactNode;
|
|
157
157
|
hideStopButton?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Event hooks for CopilotKit chat events.
|
|
160
|
+
* These hooks only work when publicApiKey is provided.
|
|
161
|
+
*/
|
|
162
|
+
observabilityHooks?: CopilotObservabilityHooks;
|
|
158
163
|
}
|
|
159
164
|
interface OnStopGenerationArguments {
|
|
160
165
|
/**
|
|
@@ -202,7 +207,7 @@ type ImageUpload = {
|
|
|
202
207
|
contentType: string;
|
|
203
208
|
bytes: string;
|
|
204
209
|
};
|
|
205
|
-
declare function CopilotChat({ instructions, suggestions, onSubmitMessage, makeSystemMessage, onInProgress, onStopGeneration, onReloadMessages, onRegenerate, onCopy, onThumbsUp, onThumbsDown, markdownTagRenderers, Messages, RenderMessage, RenderSuggestionsList, Input, className, icons, labels, AssistantMessage, UserMessage, ImageRenderer, imageUploadsEnabled, inputFileAccept, hideStopButton, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
|
|
210
|
+
declare function CopilotChat({ instructions, suggestions, onSubmitMessage, makeSystemMessage, onInProgress, onStopGeneration, onReloadMessages, onRegenerate, onCopy, onThumbsUp, onThumbsDown, markdownTagRenderers, Messages, RenderMessage, RenderSuggestionsList, Input, className, icons, labels, AssistantMessage, UserMessage, ImageRenderer, imageUploadsEnabled, inputFileAccept, hideStopButton, observabilityHooks, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
|
|
206
211
|
declare function WrappedCopilotChat({ children, icons, labels, className, }: {
|
|
207
212
|
children: React__default.ReactNode;
|
|
208
213
|
icons?: CopilotChatIcons;
|
|
@@ -230,7 +235,7 @@ declare const useCopilotChatLogic: (chatSuggestions: ChatSuggestions, makeSystem
|
|
|
230
235
|
coAgentStateRenders: Record<string, _copilotkit_react_core_dist_types_coagent_action.CoAgentStateRender<any>>;
|
|
231
236
|
setCoAgentStateRender: (id: string, stateRender: _copilotkit_react_core_dist_types_coagent_action.CoAgentStateRender<any>) => void;
|
|
232
237
|
removeCoAgentStateRender: (id: string) => void;
|
|
233
|
-
chatComponentsCache: React__default.RefObject<
|
|
238
|
+
chatComponentsCache: React__default.RefObject<_copilotkit_react_core_dist_copilot_context_78fc727c.j>;
|
|
234
239
|
getFunctionCallHandler: (customEntryPoints?: Record<string, _copilotkit_react_core.FrontendAction<any>>) => _copilotkit_shared.FunctionCallHandler;
|
|
235
240
|
addContext: (context: string, parentId?: string, categories?: string[]) => _copilotkit_react_core_dist_hooks_use_tree.TreeNodeId;
|
|
236
241
|
removeContext: (id: _copilotkit_react_core_dist_hooks_use_tree.TreeNodeId) => void;
|
|
@@ -256,8 +261,8 @@ declare const useCopilotChatLogic: (chatSuggestions: ChatSuggestions, makeSystem
|
|
|
256
261
|
setCoagentStates: React__default.Dispatch<React__default.SetStateAction<Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState>>>;
|
|
257
262
|
coagentStatesRef: React__default.RefObject<Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState>>;
|
|
258
263
|
setCoagentStatesWithRef: (value: Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState> | ((prev: Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState>) => Record<string, _copilotkit_react_core_dist_types_coagent_state.CoagentState>)) => void;
|
|
259
|
-
agentSession:
|
|
260
|
-
setAgentSession: React__default.Dispatch<React__default.SetStateAction<
|
|
264
|
+
agentSession: _copilotkit_react_core_dist_copilot_context_78fc727c.A | null;
|
|
265
|
+
setAgentSession: React__default.Dispatch<React__default.SetStateAction<_copilotkit_react_core_dist_copilot_context_78fc727c.A | null>>;
|
|
261
266
|
agentLock: string | null;
|
|
262
267
|
threadId: string;
|
|
263
268
|
setThreadId: React__default.Dispatch<React__default.SetStateAction<string>>;
|
|
@@ -267,20 +272,22 @@ declare const useCopilotChatLogic: (chatSuggestions: ChatSuggestions, makeSystem
|
|
|
267
272
|
runtimeClient: _copilotkit_runtime_client_gql.CopilotRuntimeClient;
|
|
268
273
|
forwardedParameters?: Partial<Pick<_copilotkit_runtime_client_gql.ForwardedParametersInput, "temperature">>;
|
|
269
274
|
availableAgents: _copilotkit_runtime_client_gql.Agent[];
|
|
270
|
-
authStates_c?: Record<
|
|
271
|
-
setAuthStates_c?: React__default.Dispatch<React__default.SetStateAction<Record<
|
|
275
|
+
authStates_c?: Record<_copilotkit_react_core_dist_copilot_context_78fc727c.k, _copilotkit_react_core_dist_copilot_context_78fc727c.f>;
|
|
276
|
+
setAuthStates_c?: React__default.Dispatch<React__default.SetStateAction<Record<_copilotkit_react_core_dist_copilot_context_78fc727c.k, _copilotkit_react_core_dist_copilot_context_78fc727c.f>>>;
|
|
272
277
|
authConfig_c?: {
|
|
273
278
|
SignInComponent: React__default.ComponentType<{
|
|
274
|
-
onSignInComplete: (authState:
|
|
279
|
+
onSignInComplete: (authState: _copilotkit_react_core_dist_copilot_context_78fc727c.f) => void;
|
|
275
280
|
}>;
|
|
276
281
|
};
|
|
277
282
|
extensions: _copilotkit_runtime_client_gql.ExtensionsInput;
|
|
278
283
|
setExtensions: React__default.Dispatch<React__default.SetStateAction<_copilotkit_runtime_client_gql.ExtensionsInput>>;
|
|
279
|
-
langGraphInterruptAction:
|
|
280
|
-
setLangGraphInterruptAction:
|
|
284
|
+
langGraphInterruptAction: _copilotkit_react_core_dist_copilot_context_78fc727c.L | null;
|
|
285
|
+
setLangGraphInterruptAction: _copilotkit_react_core_dist_copilot_context_78fc727c.d;
|
|
281
286
|
removeLangGraphInterruptAction: () => void;
|
|
282
287
|
onError?: _copilotkit_shared.CopilotErrorHandler;
|
|
283
288
|
suggestions: SuggestionItem[];
|
|
289
|
+
bannerError: CopilotKitError | null;
|
|
290
|
+
setBannerError: React__default.Dispatch<React__default.SetStateAction<CopilotKitError | null>>;
|
|
284
291
|
setSuggestions: React__default.Dispatch<React__default.SetStateAction<SuggestionItem[]>>;
|
|
285
292
|
};
|
|
286
293
|
actions: Record<string, _copilotkit_react_core.FrontendAction<any>>;
|
|
@@ -411,7 +411,7 @@ var Messages = ({
|
|
|
411
411
|
markdownTagRenderers
|
|
412
412
|
}) => {
|
|
413
413
|
const { labels } = useChatContext();
|
|
414
|
-
const { visibleMessages, interrupt } = (0, import_react_core.
|
|
414
|
+
const { visibleMessages, interrupt } = (0, import_react_core.useCopilotChatInternal)();
|
|
415
415
|
const initialMessages = (0, import_react2.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
|
|
416
416
|
const messages = [...initialMessages, ...visibleMessages];
|
|
417
417
|
const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
|
|
@@ -1538,6 +1538,7 @@ function RenderMessage(_a) {
|
|
|
1538
1538
|
var import_react10 = __toESM(require("react"));
|
|
1539
1539
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
1540
1540
|
var import_shared = require("@copilotkit/shared");
|
|
1541
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
1541
1542
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
1542
1543
|
|
|
1543
1544
|
// src/components/chat/ImageUploadQueue.tsx
|
|
@@ -1624,7 +1625,7 @@ var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
|
1624
1625
|
function Suggestion({ title, onClick, partial, className }) {
|
|
1625
1626
|
if (!title)
|
|
1626
1627
|
return null;
|
|
1627
|
-
const { isLoading } = (0, import_react_core4.
|
|
1628
|
+
const { isLoading } = (0, import_react_core4.useCopilotChatInternal)();
|
|
1628
1629
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1629
1630
|
"button",
|
|
1630
1631
|
{
|
|
@@ -1683,11 +1684,31 @@ function CopilotChat({
|
|
|
1683
1684
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
1684
1685
|
imageUploadsEnabled,
|
|
1685
1686
|
inputFileAccept = "image/*",
|
|
1686
|
-
hideStopButton
|
|
1687
|
+
hideStopButton,
|
|
1688
|
+
observabilityHooks
|
|
1687
1689
|
}) {
|
|
1688
|
-
const { additionalInstructions, setChatInstructions } = (0, import_react_core5.useCopilotContext)();
|
|
1690
|
+
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core5.useCopilotContext)();
|
|
1689
1691
|
const [selectedImages, setSelectedImages] = (0, import_react10.useState)([]);
|
|
1690
1692
|
const fileInputRef = (0, import_react10.useRef)(null);
|
|
1693
|
+
const triggerObservabilityHook = (0, import_react10.useCallback)(
|
|
1694
|
+
(hookName, ...args) => {
|
|
1695
|
+
if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
1696
|
+
observabilityHooks[hookName](...args);
|
|
1697
|
+
}
|
|
1698
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !copilotApiConfig.publicApiKey) {
|
|
1699
|
+
setBannerError(
|
|
1700
|
+
new import_shared.CopilotKitError({
|
|
1701
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
1702
|
+
code: import_shared.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
1703
|
+
severity: import_shared.Severity.CRITICAL,
|
|
1704
|
+
visibility: import_shared.ErrorVisibility.BANNER
|
|
1705
|
+
})
|
|
1706
|
+
);
|
|
1707
|
+
import_shared.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
1708
|
+
}
|
|
1709
|
+
},
|
|
1710
|
+
[copilotApiConfig.publicApiKey, observabilityHooks]
|
|
1711
|
+
);
|
|
1691
1712
|
(0, import_react10.useEffect)(() => {
|
|
1692
1713
|
if (!imageUploadsEnabled)
|
|
1693
1714
|
return;
|
|
@@ -1760,12 +1781,24 @@ function CopilotChat({
|
|
|
1760
1781
|
onStopGeneration,
|
|
1761
1782
|
onReloadMessages
|
|
1762
1783
|
);
|
|
1784
|
+
const prevIsLoading = (0, import_react10.useRef)(isLoading);
|
|
1785
|
+
(0, import_react10.useEffect)(() => {
|
|
1786
|
+
if (prevIsLoading.current !== isLoading) {
|
|
1787
|
+
if (isLoading) {
|
|
1788
|
+
triggerObservabilityHook("onChatStarted");
|
|
1789
|
+
} else {
|
|
1790
|
+
triggerObservabilityHook("onChatStopped");
|
|
1791
|
+
}
|
|
1792
|
+
prevIsLoading.current = isLoading;
|
|
1793
|
+
}
|
|
1794
|
+
}, [isLoading, triggerObservabilityHook]);
|
|
1763
1795
|
const handleSendMessage = (text) => {
|
|
1764
1796
|
const images = selectedImages;
|
|
1765
1797
|
setSelectedImages([]);
|
|
1766
1798
|
if (fileInputRef.current) {
|
|
1767
1799
|
fileInputRef.current.value = "";
|
|
1768
1800
|
}
|
|
1801
|
+
triggerObservabilityHook("onMessageSent", text);
|
|
1769
1802
|
return sendMessage(text, images);
|
|
1770
1803
|
};
|
|
1771
1804
|
const chatContext = import_react10.default.useContext(ChatContext);
|
|
@@ -1774,12 +1807,14 @@ function CopilotChat({
|
|
|
1774
1807
|
if (onRegenerate) {
|
|
1775
1808
|
onRegenerate(messageId);
|
|
1776
1809
|
}
|
|
1810
|
+
triggerObservabilityHook("onMessageRegenerated", messageId);
|
|
1777
1811
|
reloadMessages(messageId);
|
|
1778
1812
|
};
|
|
1779
1813
|
const handleCopy = (message) => {
|
|
1780
1814
|
if (onCopy) {
|
|
1781
1815
|
onCopy(message);
|
|
1782
1816
|
}
|
|
1817
|
+
triggerObservabilityHook("onMessageCopied", message);
|
|
1783
1818
|
};
|
|
1784
1819
|
const handleImageUpload = (event) => __async(this, null, function* () {
|
|
1785
1820
|
if (!event.target.files || event.target.files.length === 0) {
|
|
@@ -1815,6 +1850,18 @@ function CopilotChat({
|
|
|
1815
1850
|
const removeSelectedImage = (index) => {
|
|
1816
1851
|
setSelectedImages((prev) => prev.filter((_, i) => i !== index));
|
|
1817
1852
|
};
|
|
1853
|
+
const handleThumbsUp = (message) => {
|
|
1854
|
+
if (onThumbsUp) {
|
|
1855
|
+
onThumbsUp(message);
|
|
1856
|
+
}
|
|
1857
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
|
|
1858
|
+
};
|
|
1859
|
+
const handleThumbsDown = (message) => {
|
|
1860
|
+
if (onThumbsDown) {
|
|
1861
|
+
onThumbsDown(message);
|
|
1862
|
+
}
|
|
1863
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
1864
|
+
};
|
|
1818
1865
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
1819
1866
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1820
1867
|
Messages2,
|
|
@@ -1826,8 +1873,8 @@ function CopilotChat({
|
|
|
1826
1873
|
inProgress: isLoading,
|
|
1827
1874
|
onRegenerate: handleRegenerate,
|
|
1828
1875
|
onCopy: handleCopy,
|
|
1829
|
-
onThumbsUp,
|
|
1830
|
-
onThumbsDown,
|
|
1876
|
+
onThumbsUp: handleThumbsUp,
|
|
1877
|
+
onThumbsDown: handleThumbsDown,
|
|
1831
1878
|
markdownTagRenderers,
|
|
1832
1879
|
ImageRenderer: ImageRenderer2,
|
|
1833
1880
|
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
@@ -1897,7 +1944,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
1897
1944
|
generateSuggestions,
|
|
1898
1945
|
resetSuggestions: resetSuggestionsFromHook,
|
|
1899
1946
|
isLoadingSuggestions
|
|
1900
|
-
} = (0, import_react_core5.
|
|
1947
|
+
} = (0, import_react_core5.useCopilotChatInternal)({
|
|
1901
1948
|
makeSystemMessage
|
|
1902
1949
|
});
|
|
1903
1950
|
const generalContext = (0, import_react_core5.useCopilotContext)();
|
|
@@ -1983,7 +2030,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
1983
2030
|
let firstMessage = null;
|
|
1984
2031
|
if (messageContent.trim().length > 0) {
|
|
1985
2032
|
const textMessage = {
|
|
1986
|
-
id: (0,
|
|
2033
|
+
id: (0, import_shared2.randomId)(),
|
|
1987
2034
|
role: "user",
|
|
1988
2035
|
content: messageContent
|
|
1989
2036
|
};
|
|
@@ -2005,7 +2052,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2005
2052
|
if (images.length > 0) {
|
|
2006
2053
|
for (let i = 0; i < images.length; i++) {
|
|
2007
2054
|
const imageMessage = {
|
|
2008
|
-
id: (0,
|
|
2055
|
+
id: (0, import_shared2.randomId)(),
|
|
2009
2056
|
role: "user",
|
|
2010
2057
|
image: {
|
|
2011
2058
|
format: images[i].contentType.replace("image/", ""),
|
|
@@ -2019,7 +2066,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2019
2066
|
}
|
|
2020
2067
|
}
|
|
2021
2068
|
if (!firstMessage) {
|
|
2022
|
-
return { role: "user", content: "", id: (0,
|
|
2069
|
+
return { role: "user", content: "", id: (0, import_shared2.randomId)() };
|
|
2023
2070
|
}
|
|
2024
2071
|
return firstMessage;
|
|
2025
2072
|
});
|