@copilotkit/react-ui 1.3.14-fix-handle-execute-agent-error.0 → 1.3.15
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 +15 -5
- package/dist/{chunk-47OPG5FM.mjs → chunk-3EYL2DRG.mjs} +3 -3
- package/dist/{chunk-KCAVDFB6.mjs → chunk-3JNDMHS4.mjs} +2 -2
- package/dist/{chunk-JTINVYPK.mjs → chunk-4LUMV4YO.mjs} +11 -2
- package/dist/{chunk-JTINVYPK.mjs.map → chunk-4LUMV4YO.mjs.map} +1 -1
- package/dist/{chunk-SWADR6EH.mjs → chunk-AX7CAT7V.mjs} +2 -2
- package/dist/{chunk-3KBQXU44.mjs → chunk-NLIDKNNS.mjs} +5 -5
- package/dist/{chunk-6BL5C56L.mjs → chunk-OMTPWC7T.mjs} +10 -2
- package/dist/chunk-OMTPWC7T.mjs.map +1 -0
- package/dist/{chunk-KFQYJ5R5.mjs → chunk-RJCZRKTV.mjs} +3 -3
- package/dist/chunk-RJCZRKTV.mjs.map +1 -0
- package/dist/chunk-RU73BEZM.mjs +41 -0
- package/dist/chunk-RU73BEZM.mjs.map +1 -0
- package/dist/components/chat/Chat.js +39 -6
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +5 -5
- package/dist/components/chat/Input.js +10 -1
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +1 -1
- package/dist/components/chat/Modal.js +39 -6
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +6 -6
- package/dist/components/chat/Popup.js +39 -6
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +7 -7
- package/dist/components/chat/Sidebar.js +39 -6
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +7 -7
- package/dist/components/chat/Suggestion.js +2 -2
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +1 -1
- package/dist/components/chat/index.js +39 -6
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +8 -8
- package/dist/components/chat/messages/RenderActionExecutionMessage.js +9 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderTextMessage.js +18 -2
- package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderTextMessage.mjs +1 -1
- package/dist/components/index.js +39 -6
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +8 -8
- package/dist/index.js +39 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/package.json +7 -7
- package/src/components/chat/Input.tsx +6 -1
- package/src/components/chat/Suggestion.tsx +7 -3
- package/src/components/chat/messages/RenderActionExecutionMessage.tsx +5 -1
- package/src/components/chat/messages/RenderTextMessage.tsx +10 -2
- package/dist/chunk-6BL5C56L.mjs.map +0 -1
- package/dist/chunk-KFQYJ5R5.mjs.map +0 -1
- package/dist/chunk-WYMTXCQU.mjs +0 -25
- package/dist/chunk-WYMTXCQU.mjs.map +0 -1
- /package/dist/{chunk-47OPG5FM.mjs.map → chunk-3EYL2DRG.mjs.map} +0 -0
- /package/dist/{chunk-KCAVDFB6.mjs.map → chunk-3JNDMHS4.mjs.map} +0 -0
- /package/dist/{chunk-SWADR6EH.mjs.map → chunk-AX7CAT7V.mjs.map} +0 -0
- /package/dist/{chunk-3KBQXU44.mjs.map → chunk-NLIDKNNS.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 1.3.
|
|
3
|
+
## 1.3.15
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- pass description for array and object action parameters in langchain adapter
|
|
8
8
|
- Updated dependencies
|
|
9
|
-
- @copilotkit/react-core@1.3.
|
|
10
|
-
- @copilotkit/runtime-client-gql@1.3.
|
|
11
|
-
- @copilotkit/shared@1.3.
|
|
9
|
+
- @copilotkit/react-core@1.3.15
|
|
10
|
+
- @copilotkit/runtime-client-gql@1.3.15
|
|
11
|
+
- @copilotkit/shared@1.3.15
|
|
12
|
+
|
|
13
|
+
## 1.3.14
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Add data-test-id to some elements for testing
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @copilotkit/react-core@1.3.14
|
|
20
|
+
- @copilotkit/runtime-client-gql@1.3.14
|
|
21
|
+
- @copilotkit/shared@1.3.14
|
|
12
22
|
|
|
13
23
|
## 1.3.13
|
|
14
24
|
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
} from "./chunk-RQNJNK2W.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotChat
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NLIDKNNS.mjs";
|
|
13
13
|
import {
|
|
14
14
|
Input
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4LUMV4YO.mjs";
|
|
16
16
|
import {
|
|
17
17
|
Messages
|
|
18
18
|
} from "./chunk-CPMIEVKK.mjs";
|
|
@@ -88,4 +88,4 @@ var CopilotModal = ({
|
|
|
88
88
|
export {
|
|
89
89
|
CopilotModal
|
|
90
90
|
};
|
|
91
|
-
//# sourceMappingURL=chunk-
|
|
91
|
+
//# sourceMappingURL=chunk-3EYL2DRG.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3EYL2DRG.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
|
|
|
27
27
|
export {
|
|
28
28
|
CopilotSidebar
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-3JNDMHS4.mjs.map
|
|
@@ -72,7 +72,16 @@ var Input = ({ inProgress, onSend, isVisible = false }) => {
|
|
|
72
72
|
children: context.icons.pushToTalkIcon
|
|
73
73
|
}
|
|
74
74
|
),
|
|
75
|
-
/* @__PURE__ */ jsx(
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
"button",
|
|
77
|
+
{
|
|
78
|
+
disabled: sendDisabled,
|
|
79
|
+
onClick: send,
|
|
80
|
+
"data-copilotkit-in-progress": !!inProgress,
|
|
81
|
+
"data-testid": inProgress ? "copilot-chat-request-in-progress" : void 0,
|
|
82
|
+
children: sendIcon
|
|
83
|
+
}
|
|
84
|
+
)
|
|
76
85
|
] })
|
|
77
86
|
] });
|
|
78
87
|
};
|
|
@@ -80,4 +89,4 @@ var Input = ({ inProgress, onSend, isVisible = false }) => {
|
|
|
80
89
|
export {
|
|
81
90
|
Input
|
|
82
91
|
};
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
92
|
+
//# sourceMappingURL=chunk-4LUMV4YO.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat/Input.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { InputProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport AutoResizingTextarea from \"./Textarea\";\nimport { usePushToTalk } from \"../../hooks/use-push-to-talk\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\n\nexport const Input = ({ inProgress, onSend, isVisible = false }: InputProps) => {\n const context = useChatContext();\n const copilotContext = useCopilotContext();\n\n const pushToTalkConfigured =\n copilotContext.copilotApiConfig.textToSpeechUrl !== undefined &&\n copilotContext.copilotApiConfig.transcribeAudioUrl !== undefined;\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const handleDivClick = (event: React.MouseEvent<HTMLDivElement>) => {\n // Check if the clicked element is not the textarea itself\n if (event.target !== event.currentTarget) return;\n\n textareaRef.current?.focus();\n };\n\n const [text, setText] = useState(\"\");\n const send = () => {\n if (inProgress) return;\n onSend(text);\n setText(\"\");\n\n textareaRef.current?.focus();\n };\n\n useEffect(() => {\n if (isVisible) {\n textareaRef.current?.focus();\n }\n }, [isVisible]);\n\n const { pushToTalkState, setPushToTalkState } = usePushToTalk({\n sendFunction: onSend,\n inProgress,\n });\n\n const sendIcon =\n inProgress || pushToTalkState === \"transcribing\"\n ? context.icons.activityIcon\n : context.icons.sendIcon;\n const showPushToTalk =\n pushToTalkConfigured &&\n (pushToTalkState === \"idle\" || pushToTalkState === \"recording\") &&\n !inProgress;\n const sendDisabled = inProgress || text.length === 0 || pushToTalkState !== \"idle\";\n\n return (\n <div className=\"copilotKitInput\" onClick={handleDivClick}>\n <AutoResizingTextarea\n ref={textareaRef}\n placeholder={context.labels.placeholder}\n autoFocus={true}\n maxRows={5}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n send();\n }\n }}\n />\n <div className=\"copilotKitInputControls\">\n {showPushToTalk && (\n <button\n onClick={() =>\n setPushToTalkState(pushToTalkState === \"idle\" ? \"recording\" : \"transcribing\")\n }\n className={pushToTalkState === \"recording\" ? \"copilotKitPushToTalkRecording\" : \"\"}\n >\n {context.icons.pushToTalkIcon}\n </button>\n )}\n <button
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Input.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { InputProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport AutoResizingTextarea from \"./Textarea\";\nimport { usePushToTalk } from \"../../hooks/use-push-to-talk\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\n\nexport const Input = ({ inProgress, onSend, isVisible = false }: InputProps) => {\n const context = useChatContext();\n const copilotContext = useCopilotContext();\n\n const pushToTalkConfigured =\n copilotContext.copilotApiConfig.textToSpeechUrl !== undefined &&\n copilotContext.copilotApiConfig.transcribeAudioUrl !== undefined;\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const handleDivClick = (event: React.MouseEvent<HTMLDivElement>) => {\n // Check if the clicked element is not the textarea itself\n if (event.target !== event.currentTarget) return;\n\n textareaRef.current?.focus();\n };\n\n const [text, setText] = useState(\"\");\n const send = () => {\n if (inProgress) return;\n onSend(text);\n setText(\"\");\n\n textareaRef.current?.focus();\n };\n\n useEffect(() => {\n if (isVisible) {\n textareaRef.current?.focus();\n }\n }, [isVisible]);\n\n const { pushToTalkState, setPushToTalkState } = usePushToTalk({\n sendFunction: onSend,\n inProgress,\n });\n\n const sendIcon =\n inProgress || pushToTalkState === \"transcribing\"\n ? context.icons.activityIcon\n : context.icons.sendIcon;\n const showPushToTalk =\n pushToTalkConfigured &&\n (pushToTalkState === \"idle\" || pushToTalkState === \"recording\") &&\n !inProgress;\n const sendDisabled = inProgress || text.length === 0 || pushToTalkState !== \"idle\";\n\n return (\n <div className=\"copilotKitInput\" onClick={handleDivClick}>\n <AutoResizingTextarea\n ref={textareaRef}\n placeholder={context.labels.placeholder}\n autoFocus={true}\n maxRows={5}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n send();\n }\n }}\n />\n <div className=\"copilotKitInputControls\">\n {showPushToTalk && (\n <button\n onClick={() =>\n setPushToTalkState(pushToTalkState === \"idle\" ? \"recording\" : \"transcribing\")\n }\n className={pushToTalkState === \"recording\" ? \"copilotKitPushToTalkRecording\" : \"\"}\n >\n {context.icons.pushToTalkIcon}\n </button>\n )}\n <button\n disabled={sendDisabled}\n onClick={send}\n data-copilotkit-in-progress={!!inProgress}\n data-testid={inProgress ? \"copilot-chat-request-in-progress\" : undefined}\n >\n {sendIcon}\n </button>\n </div>\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UAAU,QAAQ,MAAM,OAAO,KAAK;AAAA,QAC/C,WAAW,CAAC,UAAU;AACpB,cAAI,MAAM,QAAQ,WAAW,CAAC,MAAM,UAAU;AAC5C,kBAAM,eAAe;AACrB,iBAAK;AAAA,UACP;AAAA,QACF;AAAA;AAAA,IACF;AAAA,IACA,qBAAC,SAAI,WAAU,2BACZ;AAAA,wBACC;AAAA,QAAC;AAAA;AAAA,UACC,SAAS,MACP,mBAAmB,oBAAoB,SAAS,cAAc,cAAc;AAAA,UAE9E,WAAW,oBAAoB,cAAc,kCAAkC;AAAA,UAE9E,kBAAQ,MAAM;AAAA;AAAA,MACjB;AAAA,MAEF;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UACV,SAAS;AAAA,UACT,+BAA6B,CAAC,CAAC;AAAA,UAC/B,eAAa,aAAa,qCAAqC;AAAA,UAE9D;AAAA;AAAA,MACH;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3EYL2DRG.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
|
|
|
18
18
|
export {
|
|
19
19
|
CopilotPopup
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-AX7CAT7V.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RenderActionExecutionMessage
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OMTPWC7T.mjs";
|
|
4
4
|
import {
|
|
5
5
|
RenderAgentStateMessage
|
|
6
6
|
} from "./chunk-ZABXREBH.mjs";
|
|
@@ -9,17 +9,17 @@ import {
|
|
|
9
9
|
} from "./chunk-6INMITFA.mjs";
|
|
10
10
|
import {
|
|
11
11
|
RenderTextMessage
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RU73BEZM.mjs";
|
|
13
13
|
import {
|
|
14
14
|
Suggestion,
|
|
15
15
|
reloadSuggestions
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RJCZRKTV.mjs";
|
|
17
17
|
import {
|
|
18
18
|
CopilotDevConsole
|
|
19
19
|
} from "./chunk-RS6UPR5N.mjs";
|
|
20
20
|
import {
|
|
21
21
|
Input
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-4LUMV4YO.mjs";
|
|
23
23
|
import {
|
|
24
24
|
Messages
|
|
25
25
|
} from "./chunk-CPMIEVKK.mjs";
|
|
@@ -198,4 +198,4 @@ export {
|
|
|
198
198
|
WrappedCopilotChat,
|
|
199
199
|
useCopilotChatLogic
|
|
200
200
|
};
|
|
201
|
-
//# sourceMappingURL=chunk-
|
|
201
|
+
//# sourceMappingURL=chunk-NLIDKNNS.mjs.map
|
|
@@ -47,7 +47,15 @@ function RenderActionExecutionMessage(props) {
|
|
|
47
47
|
toRender
|
|
48
48
|
] }, index);
|
|
49
49
|
} else {
|
|
50
|
-
return /* @__PURE__ */ jsx(
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
"data-message-type": "action-render",
|
|
54
|
+
className: "copilotKitCustomAssistantMessage",
|
|
55
|
+
children: toRender
|
|
56
|
+
},
|
|
57
|
+
index
|
|
58
|
+
);
|
|
51
59
|
}
|
|
52
60
|
} catch (e) {
|
|
53
61
|
console.error(`Error executing render function for action ${message.name}: ${e}`);
|
|
@@ -73,4 +81,4 @@ function RenderActionExecutionMessage(props) {
|
|
|
73
81
|
export {
|
|
74
82
|
RenderActionExecutionMessage
|
|
75
83
|
};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
84
|
+
//# sourceMappingURL=chunk-OMTPWC7T.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/messages/RenderActionExecutionMessage.tsx"],"sourcesContent":["import { ActionExecutionMessage, MessageStatusCode } from \"@copilotkit/runtime-client-gql\";\nimport { RenderMessageProps } from \"../props\";\nimport { useChatContext } from \"../ChatContext\";\nimport { RenderFunctionStatus, useCopilotContext } from \"@copilotkit/react-core\";\n\nexport function RenderActionExecutionMessage(props: RenderMessageProps) {\n const { message, inProgress, index, isCurrentMessage, actionResult } = props;\n const { chatComponentsCache } = useCopilotContext();\n const { icons } = useChatContext();\n\n if (message.isActionExecutionMessage()) {\n if (chatComponentsCache.current !== null && chatComponentsCache.current.actions[message.name]) {\n const render = chatComponentsCache.current.actions[message.name];\n // render a static string\n if (typeof render === \"string\") {\n // when render is static, we show it only when in progress\n if (isCurrentMessage && inProgress) {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {icons.spinnerIcon} <span className=\"inProgressLabel\">{render}</span>\n </div>\n );\n }\n // Done - silent by default to avoid a series of \"done\" messages\n else {\n return null;\n }\n }\n // render is a function\n else {\n const args = message.arguments;\n\n let status: RenderFunctionStatus = \"inProgress\";\n\n if (actionResult !== undefined) {\n status = \"complete\";\n } else if (message.status.code !== MessageStatusCode.Pending) {\n status = \"executing\";\n }\n\n try {\n const toRender = render({\n status: status as any,\n args,\n result: actionResult,\n });\n // No result and complete: stay silent\n if (!toRender && status === \"complete\") {\n return null;\n }\n if (typeof toRender === \"string\") {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && icons.spinnerIcon} {toRender}\n </div>\n );\n } else {\n return (\n <div\n key={index}\n data-message-type=\"action-render\"\n className=\"copilotKitCustomAssistantMessage\"\n >\n {toRender}\n </div>\n );\n }\n } catch (e) {\n console.error(`Error executing render function for action ${message.name}: ${e}`);\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && icons.spinnerIcon}\n <b>❌ Error executing render: {message.name}</b>\n <br />\n {e instanceof Error ? e.message : String(e)}\n </div>\n );\n }\n }\n }\n // No render function found- show the default message\n else if (!inProgress || !isCurrentMessage) {\n // Done - silent by default to avoid a series of \"done\" messages\n return null;\n } else {\n // In progress\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {icons.spinnerIcon}\n </div>\n );\n }\n }\n}\n"],"mappings":";;;;;AAAA,SAAiC,yBAAyB;AAG1D,SAA+B,yBAAyB;AAe5C,SACsB,KADtB;AAbL,SAAS,6BAA6B,OAA2B;AACtE,QAAM,EAAE,SAAS,YAAY,OAAO,kBAAkB,aAAa,IAAI;AACvE,QAAM,EAAE,oBAAoB,IAAI,kBAAkB;AAClD,QAAM,EAAE,MAAM,IAAI,eAAe;AAEjC,MAAI,QAAQ,yBAAyB,GAAG;AACtC,QAAI,oBAAoB,YAAY,QAAQ,oBAAoB,QAAQ,QAAQ,QAAQ,IAAI,GAAG;AAC7F,YAAM,SAAS,oBAAoB,QAAQ,QAAQ,QAAQ,IAAI;AAE/D,UAAI,OAAO,WAAW,UAAU;AAE9B,YAAI,oBAAoB,YAAY;AAClC,iBACE,qBAAC,SAAgB,WAAW,gDACzB;AAAA,kBAAM;AAAA,YAAY;AAAA,YAAC,oBAAC,UAAK,WAAU,mBAAmB,kBAAO;AAAA,eADtD,KAEV;AAAA,QAEJ,OAEK;AACH,iBAAO;AAAA,QACT;AAAA,MACF,OAEK;AACH,cAAM,OAAO,QAAQ;AAErB,YAAI,SAA+B;AAEnC,YAAI,iBAAiB,QAAW;AAC9B,mBAAS;AAAA,QACX,WAAW,QAAQ,OAAO,SAAS,kBAAkB,SAAS;AAC5D,mBAAS;AAAA,QACX;AAEA,YAAI;AACF,gBAAM,WAAW,OAAO;AAAA,YACtB;AAAA,YACA;AAAA,YACA,QAAQ;AAAA,UACV,CAAC;AAED,cAAI,CAAC,YAAY,WAAW,YAAY;AACtC,mBAAO;AAAA,UACT;AACA,cAAI,OAAO,aAAa,UAAU;AAChC,mBACE,qBAAC,SAAgB,WAAW,gDACzB;AAAA,kCAAoB,cAAc,MAAM;AAAA,cAAY;AAAA,cAAE;AAAA,iBAD/C,KAEV;AAAA,UAEJ,OAAO;AACL,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEC,qBAAkB;AAAA,gBAClB,WAAU;AAAA,gBAET;AAAA;AAAA,cAJI;AAAA,YAKP;AAAA,UAEJ;AAAA,QACF,SAAS,GAAP;AACA,kBAAQ,MAAM,8CAA8C,QAAQ,SAAS,GAAG;AAChF,iBACE,qBAAC,SAAgB,WAAW,gDACzB;AAAA,gCAAoB,cAAc,MAAM;AAAA,YACzC,qBAAC,OAAE;AAAA;AAAA,cAA2B,QAAQ;AAAA,eAAK;AAAA,YAC3C,oBAAC,QAAG;AAAA,YACH,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AAAA,eAJlC,KAKV;AAAA,QAEJ;AAAA,MACF;AAAA,IACF,WAES,CAAC,cAAc,CAAC,kBAAkB;AAEzC,aAAO;AAAA,IACT,OAAO;AAEL,aACE,oBAAC,SAAgB,WAAW,gDACzB,gBAAM,eADC,KAEV;AAAA,IAEJ;AAAA,EACF;AACF;","names":[]}
|
|
@@ -44,8 +44,8 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
44
44
|
const numOfSuggestionsInstructions = config.minSuggestions === 0 ? `Produce up to ${config.maxSuggestions} suggestions. If there are no highly relevant suggestions you can think of, provide an empty array.` : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
|
|
45
45
|
const result = yield extract({
|
|
46
46
|
context,
|
|
47
|
-
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. "
|
|
48
|
-
data: "
|
|
47
|
+
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
|
|
48
|
+
data: config.instructions + "\n\n" + numOfSuggestionsInstructions + "\n\nAvailable tools: " + tools + "\n\n",
|
|
49
49
|
requestType: CopilotRequestType.Task,
|
|
50
50
|
parameters: [
|
|
51
51
|
{
|
|
@@ -103,4 +103,4 @@ export {
|
|
|
103
103
|
Suggestion,
|
|
104
104
|
reloadSuggestions
|
|
105
105
|
};
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-RJCZRKTV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Suggestion.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n CopilotMessagesContextParams,\n} from \"@copilotkit/react-core\";\nimport { SuggestionsProps } from \"./props\";\nimport { SmallSpinnerIcon } from \"./Icons\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\n\nexport function Suggestion({ title, message, onClick, partial, className }: SuggestionsProps) {\n return (\n <button\n disabled={partial}\n onClick={(e) => {\n e.preventDefault();\n onClick(message);\n }}\n className={className || \"suggestion\"}\n >\n {partial && SmallSpinnerIcon}\n <span>{title}</span>\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n) => {\n const abortController = abortControllerRef.current;\n\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: CopilotChatSuggestion[] = [];\n\n for (const config of Object.values(chatSuggestionConfiguration)) {\n try {\n const numOfSuggestionsInstructions =\n config.minSuggestions === 0\n ? `Produce up to ${config.maxSuggestions} suggestions. ` +\n `If there are no highly relevant suggestions you can think of, provide an empty array.`\n : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;\n\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data:\n config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions +\n \"\\n\\n\" +\n \"Available tools: \" +\n tools +\n \"\\n\\n\",\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }) => {\n const suggestions = args.suggestions || [];\n const newSuggestions: CopilotChatSuggestion[] = [];\n for (let i = 0; i < suggestions.length; i++) {\n // if GPT provides too many suggestions, limit the number of suggestions\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n const { title, message } = suggestions[i];\n\n // If this is the last suggestion and the status is not complete, mark it as partial\n const partial = i == suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title,\n message,\n partial,\n className: config.className,\n });\n }\n setCurrentSuggestions([...allSuggestions, ...newSuggestions]);\n },\n });\n allSuggestions.push(...result.suggestions);\n } catch (error) {\n console.error(\"Error loading suggestions\", error);\n }\n }\n\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n};\n"],"mappings":";;;;;;;;AAAA;AAAA,EAEE;AAAA,OAGK;AAIP,SAAS,oCAAoC;AAC7C,SAAS,0BAA0B;AAI/B,SASE,KATF;AAFG,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,SAAS,UAAU,GAAqB;AAC5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,S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zC,gBAAM,iBAA0C,CAAC;AACjD,mBAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AAE3C,gBAAI,OAAO,mBAAmB,UAAa,KAAK,OAAO,gBAAgB;AACrE;AAAA,YACF;AACA,kBAAM,EAAE,OAAO,QAAQ,IAAI,YAAY,CAAC;AAGxC,kBAAM,UAAU,KAAK,YAAY,SAAS,KAAK,WAAW;AAE1D,2BAAe,KAAK;AAAA,cAClB;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAW,OAAO;AAAA,YACpB,CAAC;AAAA,UACH;AACA,gCAAsB,CAAC,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAAA,QAC9D;AAAA,MACF,CAAC;AACD,qBAAe,KAAK,GAAG,OAAO,WAAW;AAAA,IAC3C,SAAS,OAAP;AACA,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AAEA,MAAI,mBAAmB,YAAY,iBAAiB;AAClD,uBAAmB,UAAU;AAAA,EAC/B;AACF;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Markdown
|
|
3
|
+
} from "./chunk-YQ3D5IQV.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useChatContext
|
|
6
|
+
} from "./chunk-CBBFRI3Q.mjs";
|
|
7
|
+
|
|
8
|
+
// src/components/chat/messages/RenderTextMessage.tsx
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
function RenderTextMessage(props) {
|
|
11
|
+
const { message, inProgress, index, isCurrentMessage } = props;
|
|
12
|
+
const { icons } = useChatContext();
|
|
13
|
+
if (message.isTextMessage()) {
|
|
14
|
+
if (message.role === "user") {
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
"data-message-role": "user",
|
|
19
|
+
className: "copilotKitMessage copilotKitUserMessage",
|
|
20
|
+
children: message.content
|
|
21
|
+
},
|
|
22
|
+
index
|
|
23
|
+
);
|
|
24
|
+
} else if (message.role == "assistant") {
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
"data-message-role": "assistant",
|
|
29
|
+
className: `copilotKitMessage copilotKitAssistantMessage`,
|
|
30
|
+
children: isCurrentMessage && inProgress && !message.content ? icons.spinnerIcon : /* @__PURE__ */ jsx(Markdown, { content: message.content })
|
|
31
|
+
},
|
|
32
|
+
index
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
RenderTextMessage
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-RU73BEZM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/messages/RenderTextMessage.tsx"],"sourcesContent":["import { TextMessage } from \"@copilotkit/runtime-client-gql\";\nimport { RenderMessageProps } from \"../props\";\nimport { Markdown } from \"../Markdown\";\nimport { useChatContext } from \"../ChatContext\";\n\nexport function RenderTextMessage(props: RenderMessageProps) {\n const { message, inProgress, index, isCurrentMessage } = props;\n const { icons } = useChatContext();\n if (message.isTextMessage()) {\n if (message.role === \"user\") {\n return (\n <div\n key={index}\n data-message-role=\"user\"\n className=\"copilotKitMessage copilotKitUserMessage\"\n >\n {message.content}\n </div>\n );\n } else if (message.role == \"assistant\") {\n return (\n <div\n key={index}\n data-message-role=\"assistant\"\n className={`copilotKitMessage copilotKitAssistantMessage`}\n >\n {isCurrentMessage && inProgress && !message.content ? (\n icons.spinnerIcon\n ) : (\n <Markdown content={message.content} />\n )}\n </div>\n );\n }\n }\n}\n"],"mappings":";;;;;;;;AAWQ;AAND,SAAS,kBAAkB,OAA2B;AAC3D,QAAM,EAAE,SAAS,YAAY,OAAO,iBAAiB,IAAI;AACzD,QAAM,EAAE,MAAM,IAAI,eAAe;AACjC,MAAI,QAAQ,cAAc,GAAG;AAC3B,QAAI,QAAQ,SAAS,QAAQ;AAC3B,aACE;AAAA,QAAC;AAAA;AAAA,UAEC,qBAAkB;AAAA,UAClB,WAAU;AAAA,UAET,kBAAQ;AAAA;AAAA,QAJJ;AAAA,MAKP;AAAA,IAEJ,WAAW,QAAQ,QAAQ,aAAa;AACtC,aACE;AAAA,QAAC;AAAA;AAAA,UAEC,qBAAkB;AAAA,UAClB,WAAW;AAAA,UAEV,8BAAoB,cAAc,CAAC,QAAQ,UAC1C,MAAM,cAEN,oBAAC,YAAS,SAAS,QAAQ,SAAS;AAAA;AAAA,QAPjC;AAAA,MASP;AAAA,IAEJ;AAAA,EACF;AACF;","names":[]}
|
|
@@ -718,7 +718,16 @@ var Input = ({ inProgress, onSend, isVisible = false }) => {
|
|
|
718
718
|
children: context.icons.pushToTalkIcon
|
|
719
719
|
}
|
|
720
720
|
),
|
|
721
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
721
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
722
|
+
"button",
|
|
723
|
+
{
|
|
724
|
+
disabled: sendDisabled,
|
|
725
|
+
onClick: send,
|
|
726
|
+
"data-copilotkit-in-progress": !!inProgress,
|
|
727
|
+
"data-testid": inProgress ? "copilot-chat-request-in-progress" : void 0,
|
|
728
|
+
children: sendIcon
|
|
729
|
+
}
|
|
730
|
+
)
|
|
722
731
|
] })
|
|
723
732
|
] });
|
|
724
733
|
};
|
|
@@ -1208,9 +1217,25 @@ function RenderTextMessage(props) {
|
|
|
1208
1217
|
const { icons } = useChatContext();
|
|
1209
1218
|
if (message.isTextMessage()) {
|
|
1210
1219
|
if (message.role === "user") {
|
|
1211
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1221
|
+
"div",
|
|
1222
|
+
{
|
|
1223
|
+
"data-message-role": "user",
|
|
1224
|
+
className: "copilotKitMessage copilotKitUserMessage",
|
|
1225
|
+
children: message.content
|
|
1226
|
+
},
|
|
1227
|
+
index
|
|
1228
|
+
);
|
|
1212
1229
|
} else if (message.role == "assistant") {
|
|
1213
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1231
|
+
"div",
|
|
1232
|
+
{
|
|
1233
|
+
"data-message-role": "assistant",
|
|
1234
|
+
className: `copilotKitMessage copilotKitAssistantMessage`,
|
|
1235
|
+
children: isCurrentMessage && inProgress && !message.content ? icons.spinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Markdown, { content: message.content })
|
|
1236
|
+
},
|
|
1237
|
+
index
|
|
1238
|
+
);
|
|
1214
1239
|
}
|
|
1215
1240
|
}
|
|
1216
1241
|
}
|
|
@@ -1260,7 +1285,15 @@ function RenderActionExecutionMessage(props) {
|
|
|
1260
1285
|
toRender
|
|
1261
1286
|
] }, index);
|
|
1262
1287
|
} else {
|
|
1263
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1289
|
+
"div",
|
|
1290
|
+
{
|
|
1291
|
+
"data-message-type": "action-render",
|
|
1292
|
+
className: "copilotKitCustomAssistantMessage",
|
|
1293
|
+
children: toRender
|
|
1294
|
+
},
|
|
1295
|
+
index
|
|
1296
|
+
);
|
|
1264
1297
|
}
|
|
1265
1298
|
} catch (e) {
|
|
1266
1299
|
console.error(`Error executing render function for action ${message.name}: ${e}`);
|
|
@@ -1387,8 +1420,8 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
1387
1420
|
const numOfSuggestionsInstructions = config.minSuggestions === 0 ? `Produce up to ${config.maxSuggestions} suggestions. If there are no highly relevant suggestions you can think of, provide an empty array.` : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
|
|
1388
1421
|
const result = yield (0, import_react_core5.extract)({
|
|
1389
1422
|
context,
|
|
1390
|
-
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. "
|
|
1391
|
-
data: "
|
|
1423
|
+
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
|
|
1424
|
+
data: config.instructions + "\n\n" + numOfSuggestionsInstructions + "\n\nAvailable tools: " + tools + "\n\n",
|
|
1392
1425
|
requestType: import_runtime_client_gql3.CopilotRequestType.Task,
|
|
1393
1426
|
parameters: [
|
|
1394
1427
|
{
|