@copilotkit/react-ui 1.3.6 → 1.3.7
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 +10 -0
- package/dist/{chunk-H7TM5JE6.mjs → chunk-4FIGRRFS.mjs} +8 -8
- package/dist/chunk-4FIGRRFS.mjs.map +1 -0
- package/dist/{chunk-SPZEI5EN.mjs → chunk-6VYMULPK.mjs} +4 -4
- package/dist/{chunk-HIX4HRWU.mjs → chunk-7YQICPBC.mjs} +19 -12
- package/dist/chunk-7YQICPBC.mjs.map +1 -0
- package/dist/{chunk-RF3KLUPD.mjs → chunk-AAY3WWWC.mjs} +2 -3
- package/dist/chunk-AAY3WWWC.mjs.map +1 -0
- package/dist/{chunk-U6J5DGOE.mjs → chunk-BNCTYKEP.mjs} +2 -2
- package/dist/{chunk-GOTHQ665.mjs → chunk-DP5YVGNX.mjs} +2 -3
- package/dist/chunk-DP5YVGNX.mjs.map +1 -0
- package/dist/{chunk-TSQVQAAC.mjs → chunk-JQOSF44H.mjs} +2 -2
- package/dist/{chunk-WCPLXRZX.mjs → chunk-KFQYJ5R5.mjs} +1 -1
- package/dist/chunk-KFQYJ5R5.mjs.map +1 -0
- package/dist/{chunk-LT5YTQ4F.mjs → chunk-RS6UPR5N.mjs} +12 -4
- package/dist/chunk-RS6UPR5N.mjs.map +1 -0
- package/dist/{chunk-YH2STM73.mjs → chunk-RWT7WRG2.mjs} +3 -3
- package/dist/chunk-RWT7WRG2.mjs.map +1 -0
- package/dist/{chunk-VOBX4JOA.mjs → chunk-S5MBUNGN.mjs} +8 -6
- package/dist/chunk-S5MBUNGN.mjs.map +1 -0
- package/dist/{chunk-GDNJRSD4.mjs → chunk-SHTMRY45.mjs} +8 -10
- package/dist/chunk-SHTMRY45.mjs.map +1 -0
- package/dist/{chunk-P47XGGRX.mjs → chunk-TYYJR3LE.mjs} +2 -2
- package/dist/{chunk-MA5B5ELM.mjs → chunk-WHSD7DBC.mjs} +2 -3
- package/dist/chunk-WHSD7DBC.mjs.map +1 -0
- package/dist/components/chat/Chat.js +37 -33
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +11 -11
- package/dist/components/chat/Input.js +18 -3
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +2 -2
- package/dist/components/chat/Messages.js +6 -6
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.js +37 -33
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +12 -12
- package/dist/components/chat/Popup.js +37 -33
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +13 -13
- package/dist/components/chat/Sidebar.js +37 -33
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +13 -13
- package/dist/components/chat/Suggestion.d.ts +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 +37 -33
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +14 -14
- package/dist/components/chat/messages/RenderActionExecutionMessage.js +1 -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/RenderAgentStateMessage.js +1 -2
- package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderResultMessage.js +1 -2
- package/dist/components/chat/messages/RenderResultMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderResultMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderTextMessage.js +1 -2
- package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderTextMessage.mjs +1 -1
- package/dist/components/dev-console/console.js +13 -7
- 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.js +13 -7
- 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 +4 -6
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/index.js +37 -33
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +14 -14
- package/dist/hooks/use-push-to-talk.js +18 -3
- package/dist/hooks/use-push-to-talk.js.map +1 -1
- package/dist/hooks/use-push-to-talk.mjs +1 -1
- package/dist/index.js +37 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -14
- package/package.json +8 -8
- package/src/components/chat/Chat.tsx +9 -2
- package/src/components/chat/Messages.tsx +6 -6
- package/src/components/chat/Suggestion.tsx +2 -2
- package/src/components/chat/messages/RenderActionExecutionMessage.tsx +1 -1
- package/src/components/chat/messages/RenderAgentStateMessage.tsx +1 -1
- package/src/components/chat/messages/RenderResultMessage.tsx +1 -1
- package/src/components/chat/messages/RenderTextMessage.tsx +1 -1
- package/src/components/dev-console/console.tsx +6 -2
- package/src/components/dev-console/utils.ts +10 -6
- package/src/hooks/use-push-to-talk.tsx +5 -3
- package/dist/chunk-GDNJRSD4.mjs.map +0 -1
- package/dist/chunk-GOTHQ665.mjs.map +0 -1
- package/dist/chunk-H7TM5JE6.mjs.map +0 -1
- package/dist/chunk-HIX4HRWU.mjs.map +0 -1
- package/dist/chunk-LT5YTQ4F.mjs.map +0 -1
- package/dist/chunk-MA5B5ELM.mjs.map +0 -1
- package/dist/chunk-RF3KLUPD.mjs.map +0 -1
- package/dist/chunk-VOBX4JOA.mjs.map +0 -1
- package/dist/chunk-WCPLXRZX.mjs.map +0 -1
- package/dist/chunk-YH2STM73.mjs.map +0 -1
- /package/dist/{chunk-SPZEI5EN.mjs.map → chunk-6VYMULPK.mjs.map} +0 -0
- /package/dist/{chunk-U6J5DGOE.mjs.map → chunk-BNCTYKEP.mjs.map} +0 -0
- /package/dist/{chunk-TSQVQAAC.mjs.map → chunk-JQOSF44H.mjs.map} +0 -0
- /package/dist/{chunk-P47XGGRX.mjs.map → chunk-TYYJR3LE.mjs.map} +0 -0
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotSidebar
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-TYYJR3LE.mjs";
|
|
4
|
+
import "../../chunk-6VYMULPK.mjs";
|
|
5
5
|
import "../../chunk-FO7Z5LAL.mjs";
|
|
6
6
|
import "../../chunk-FLV3J3VX.mjs";
|
|
7
7
|
import "../../chunk-YOH25I6N.mjs";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-7YQICPBC.mjs";
|
|
9
9
|
import "../../chunk-V7W6IM2V.mjs";
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
15
|
-
import "../../chunk-
|
|
16
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-RWT7WRG2.mjs";
|
|
11
|
+
import "../../chunk-AAY3WWWC.mjs";
|
|
12
|
+
import "../../chunk-DP5YVGNX.mjs";
|
|
13
|
+
import "../../chunk-WHSD7DBC.mjs";
|
|
14
|
+
import "../../chunk-KFQYJ5R5.mjs";
|
|
15
|
+
import "../../chunk-RS6UPR5N.mjs";
|
|
16
|
+
import "../../chunk-4FIGRRFS.mjs";
|
|
17
17
|
import "../../chunk-OTPAZXVR.mjs";
|
|
18
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-BNCTYKEP.mjs";
|
|
19
19
|
import "../../chunk-YQFVRDNC.mjs";
|
|
20
20
|
import "../../chunk-YQ3D5IQV.mjs";
|
|
21
|
-
import "../../chunk-
|
|
21
|
+
import "../../chunk-SHTMRY45.mjs";
|
|
22
22
|
import "../../chunk-XSUSSWDS.mjs";
|
|
23
23
|
import "../../chunk-BJPGMY3I.mjs";
|
|
24
24
|
import "../../chunk-UPTB2MVO.mjs";
|
|
25
25
|
import "../../chunk-FZC7X5PK.mjs";
|
|
26
26
|
import "../../chunk-54JAUBUJ.mjs";
|
|
27
|
-
import "../../chunk-
|
|
27
|
+
import "../../chunk-S5MBUNGN.mjs";
|
|
28
28
|
import "../../chunk-MRXNTQOX.mjs";
|
|
29
29
|
export {
|
|
30
30
|
CopilotSidebar
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { CopilotContextParams, CopilotChatSuggestionConfiguration } from '@copilotkit/react-core';
|
|
2
|
+
import { CopilotContextParams, CopilotMessagesContextParams, CopilotChatSuggestionConfiguration } from '@copilotkit/react-core';
|
|
3
3
|
import { SuggestionsProps } from './props.js';
|
|
4
4
|
import '@copilotkit/runtime-client-gql';
|
|
5
5
|
|
|
6
6
|
declare function Suggestion({ title, message, onClick, partial, className }: SuggestionsProps): react_jsx_runtime.JSX.Element;
|
|
7
|
-
declare const reloadSuggestions: (context: CopilotContextParams, chatSuggestionConfiguration: {
|
|
7
|
+
declare const reloadSuggestions: (context: CopilotContextParams & CopilotMessagesContextParams, chatSuggestionConfiguration: {
|
|
8
8
|
[key: string]: CopilotChatSuggestionConfiguration;
|
|
9
9
|
}, setCurrentSuggestions: (suggestions: {
|
|
10
10
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/chat/Suggestion.tsx","../../../src/components/chat/Icons.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n useCopilotContext,\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,\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 config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions,\n data: \"Available tools: \" + tools + \"\\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","import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth={1.5}\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5\"\n />\n </svg>\n);\n\nexport const SpinnerIcon = (\n <svg\n style={{\n animation: \"copilotKitSpinAnimation 1s linear infinite\",\n color: \"rgb(107 114 128)\",\n }}\n width=\"24\"\n height=\"24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle\n style={{ opacity: 0.25 }}\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n ></circle>\n <path\n style={{ opacity: 0.75 }}\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>\n);\n\nexport const SmallSpinnerIcon = (\n <svg\n style={{\n animation: \"copilotKitSpinAnimation 1s linear infinite\",\n }}\n width=\"13\"\n height=\"13\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle\n style={{ opacity: 0.25 }}\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n ></circle>\n <path\n style={{ opacity: 0.75 }}\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>\n);\n\nexport const ActivityIcon = (\n <svg\n style={{\n display: \"inline-block\",\n marginLeft: \"0.25rem\",\n marginRight: \"0.25rem\",\n }}\n height=\"24\"\n width=\"24\"\n viewBox=\"0 0 27 27\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\"\n >\n <circle className=\"copilotKitActivityDot1\" cx=\"4\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot2\" cx=\"12\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot3\" cx=\"20\" cy=\"12\" r=\"3\" />\n </svg>\n);\n\nexport function CheckIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z\" />\n </svg>\n );\n}\n\nexport function DownloadIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z\" />\n </svg>\n );\n}\n\nexport function CopyIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z\" />\n </svg>\n );\n}\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path d=\"M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z\" />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path d=\"M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z\" />\n </svg>\n);\n\nexport const PushToTalkIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth={1.5}\n stroke=\"currentColor\"\n className=\"w-6 h-6\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 0 1-3-3V4.5a3 3 0 1 1 6 0v8.25a3 3 0 0 1-3 3Z\"\n />\n </svg>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKO;;;ACMD;AAmFC,IAAM,mBACX;AAAA,EAAC;AAAA;AAAA,IACC,OAAO;AAAA,MACL,WAAW;AAAA,IACb;AAAA,IACA,OAAM;AAAA,IACN,QAAO;AAAA,IACP,OAAM;AAAA,IACN,MAAK;AAAA,IACL,SAAQ;AAAA,IAER;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,EAAE,SAAS,KAAK;AAAA,UACvB,IAAG;AAAA,UACH,IAAG;AAAA,UACH,GAAE;AAAA,UACF,QAAO;AAAA,UACP,aAAY;AAAA;AAAA,MACb;AAAA,MACD;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,EAAE,SAAS,KAAK;AAAA,UACvB,MAAK;AAAA,UACL,GAAE;AAAA;AAAA,MACH;AAAA;AAAA;AACH;;;AD7GF,oBAA6C;AAC7C,gCAAmC;AAI/B,IAAAA,sBAAA;AAFG,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,SAAS,UAAU,GAAqB;AAC5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ,OAAO;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AG,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":["import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chat/Suggestion.tsx","../../../src/components/chat/Icons.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 config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions,\n data: \"Available tools: \" + tools + \"\\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","import React from \"react\";\n\nexport const OpenIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <g transform=\"translate(24, 0) scale(-1, 1)\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z\"\n clipRule=\"evenodd\"\n />\n </g>\n </svg>\n);\n\nexport const CloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M19.5 8.25l-7.5 7.5-7.5-7.5\" />\n </svg>\n);\n\nexport const HeaderCloseIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth=\"1.5\"\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n);\n\nexport const SendIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth={1.5}\n stroke=\"currentColor\"\n width=\"24\"\n height=\"24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5\"\n />\n </svg>\n);\n\nexport const SpinnerIcon = (\n <svg\n style={{\n animation: \"copilotKitSpinAnimation 1s linear infinite\",\n color: \"rgb(107 114 128)\",\n }}\n width=\"24\"\n height=\"24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle\n style={{ opacity: 0.25 }}\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n ></circle>\n <path\n style={{ opacity: 0.75 }}\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>\n);\n\nexport const SmallSpinnerIcon = (\n <svg\n style={{\n animation: \"copilotKitSpinAnimation 1s linear infinite\",\n }}\n width=\"13\"\n height=\"13\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <circle\n style={{ opacity: 0.25 }}\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n ></circle>\n <path\n style={{ opacity: 0.75 }}\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>\n);\n\nexport const ActivityIcon = (\n <svg\n style={{\n display: \"inline-block\",\n marginLeft: \"0.25rem\",\n marginRight: \"0.25rem\",\n }}\n height=\"24\"\n width=\"24\"\n viewBox=\"0 0 27 27\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\"\n >\n <circle className=\"copilotKitActivityDot1\" cx=\"4\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot2\" cx=\"12\" cy=\"12\" r=\"3\" />\n <circle className=\"copilotKitActivityDot1 copilotKitActivityDot3\" cx=\"20\" cy=\"12\" r=\"3\" />\n </svg>\n);\n\nexport function CheckIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z\" />\n </svg>\n );\n}\n\nexport function DownloadIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z\" />\n </svg>\n );\n}\n\nexport function CopyIcon({ className, ...props }: React.ComponentProps<\"svg\">) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n className={className}\n {...props}\n >\n <path d=\"M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z\" />\n </svg>\n );\n}\n\nexport const StopIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path d=\"M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z\" />\n </svg>\n);\n\nexport const RegenerateIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n style={{ height: \"1rem\", width: \"1rem\" }}\n >\n <path d=\"M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z\" />\n </svg>\n);\n\nexport const PushToTalkIcon = (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n strokeWidth={1.5}\n stroke=\"currentColor\"\n className=\"w-6 h-6\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 0 1-3-3V4.5a3 3 0 1 1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9D;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":["import_jsx_runtime"]}
|
|
@@ -538,10 +538,10 @@ var Messages = ({
|
|
|
538
538
|
messages = [...initialMessages, ...messages];
|
|
539
539
|
const actionResults = {};
|
|
540
540
|
for (let i = 0; i < messages.length; i++) {
|
|
541
|
-
if (messages[i]
|
|
541
|
+
if (messages[i].isActionExecutionMessage()) {
|
|
542
542
|
const id = messages[i].id;
|
|
543
543
|
const resultMessage = messages.find(
|
|
544
|
-
(message) => message
|
|
544
|
+
(message) => message.isResultMessage() && message.actionExecutionId === id
|
|
545
545
|
);
|
|
546
546
|
if (resultMessage) {
|
|
547
547
|
actionResults[id] = import_runtime_client_gql.ResultMessage.decodeResult(resultMessage.result || "");
|
|
@@ -562,7 +562,7 @@ var Messages = ({
|
|
|
562
562
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
563
563
|
messages.map((message, index) => {
|
|
564
564
|
const isCurrentMessage = index === messages.length - 1;
|
|
565
|
-
if (message
|
|
565
|
+
if (message.isTextMessage()) {
|
|
566
566
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
567
567
|
RenderTextMessage2,
|
|
568
568
|
{
|
|
@@ -573,7 +573,7 @@ var Messages = ({
|
|
|
573
573
|
},
|
|
574
574
|
index
|
|
575
575
|
);
|
|
576
|
-
} else if (message
|
|
576
|
+
} else if (message.isActionExecutionMessage()) {
|
|
577
577
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
578
578
|
RenderActionExecutionMessage2,
|
|
579
579
|
{
|
|
@@ -585,7 +585,7 @@ var Messages = ({
|
|
|
585
585
|
},
|
|
586
586
|
index
|
|
587
587
|
);
|
|
588
|
-
} else if (message
|
|
588
|
+
} else if (message.isAgentStateMessage()) {
|
|
589
589
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
590
590
|
RenderAgentStateMessage2,
|
|
591
591
|
{
|
|
@@ -596,7 +596,7 @@ var Messages = ({
|
|
|
596
596
|
},
|
|
597
597
|
index
|
|
598
598
|
);
|
|
599
|
-
} else if (message
|
|
599
|
+
} else if (message.isResultMessage()) {
|
|
600
600
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
601
601
|
RenderResultMessage2,
|
|
602
602
|
{
|
|
@@ -683,7 +683,6 @@ var Textarea_default = AutoResizingTextarea;
|
|
|
683
683
|
|
|
684
684
|
// src/hooks/use-push-to-talk.tsx
|
|
685
685
|
var import_react_core = require("@copilotkit/react-core");
|
|
686
|
-
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
687
686
|
var import_react5 = require("react");
|
|
688
687
|
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
689
688
|
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
@@ -738,7 +737,9 @@ var usePushToTalk = ({
|
|
|
738
737
|
const audioContextRef = (0, import_react5.useRef)(null);
|
|
739
738
|
const mediaRecorderRef = (0, import_react5.useRef)(null);
|
|
740
739
|
const recordedChunks = (0, import_react5.useRef)([]);
|
|
741
|
-
const
|
|
740
|
+
const generalContext = (0, import_react_core.useCopilotContext)();
|
|
741
|
+
const messagesContext = (0, import_react_core.useCopilotMessagesContext)();
|
|
742
|
+
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
742
743
|
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react5.useState)(null);
|
|
743
744
|
(0, import_react5.useEffect)(() => {
|
|
744
745
|
if (pushToTalkState === "recording") {
|
|
@@ -774,7 +775,7 @@ var usePushToTalk = ({
|
|
|
774
775
|
(message) => message.id === startReadingFromMessageId
|
|
775
776
|
);
|
|
776
777
|
const messagesAfterLast = context.messages.slice(lastMessageIndex + 1).filter(
|
|
777
|
-
(message) => message
|
|
778
|
+
(message) => message.isTextMessage() && message.role === "assistant"
|
|
778
779
|
);
|
|
779
780
|
const text = messagesAfterLast.map((message) => message.content).join("\n");
|
|
780
781
|
playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl, audioContextRef.current);
|
|
@@ -862,9 +863,6 @@ var ResponseButton = ({ onClick, inProgress }) => {
|
|
|
862
863
|
] });
|
|
863
864
|
};
|
|
864
865
|
|
|
865
|
-
// src/components/chat/messages/RenderTextMessage.tsx
|
|
866
|
-
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
867
|
-
|
|
868
866
|
// src/components/chat/Markdown.tsx
|
|
869
867
|
var import_react8 = require("react");
|
|
870
868
|
var import_react_markdown = __toESM(require("react-markdown"));
|
|
@@ -1338,7 +1336,7 @@ var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
|
1338
1336
|
function RenderTextMessage(props) {
|
|
1339
1337
|
const { message, inProgress, index, isCurrentMessage } = props;
|
|
1340
1338
|
const { icons } = useChatContext();
|
|
1341
|
-
if (message
|
|
1339
|
+
if (message.isTextMessage()) {
|
|
1342
1340
|
if (message.role === "user") {
|
|
1343
1341
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
|
|
1344
1342
|
} else if (message.role == "assistant") {
|
|
@@ -1348,14 +1346,14 @@ function RenderTextMessage(props) {
|
|
|
1348
1346
|
}
|
|
1349
1347
|
|
|
1350
1348
|
// src/components/chat/messages/RenderActionExecutionMessage.tsx
|
|
1351
|
-
var
|
|
1349
|
+
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
1352
1350
|
var import_react_core3 = require("@copilotkit/react-core");
|
|
1353
1351
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1354
1352
|
function RenderActionExecutionMessage(props) {
|
|
1355
1353
|
const { message, inProgress, index, isCurrentMessage, actionResult } = props;
|
|
1356
1354
|
const { chatComponentsCache } = (0, import_react_core3.useCopilotContext)();
|
|
1357
1355
|
const { icons } = useChatContext();
|
|
1358
|
-
if (message
|
|
1356
|
+
if (message.isActionExecutionMessage()) {
|
|
1359
1357
|
if (chatComponentsCache.current !== null && chatComponentsCache.current.actions[message.name]) {
|
|
1360
1358
|
const render = chatComponentsCache.current.actions[message.name];
|
|
1361
1359
|
if (typeof render === "string") {
|
|
@@ -1373,7 +1371,7 @@ function RenderActionExecutionMessage(props) {
|
|
|
1373
1371
|
let status = "inProgress";
|
|
1374
1372
|
if (actionResult !== void 0) {
|
|
1375
1373
|
status = "complete";
|
|
1376
|
-
} else if (message.status.code !==
|
|
1374
|
+
} else if (message.status.code !== import_runtime_client_gql2.MessageStatusCode.Pending) {
|
|
1377
1375
|
status = "executing";
|
|
1378
1376
|
}
|
|
1379
1377
|
try {
|
|
@@ -1416,25 +1414,23 @@ function RenderActionExecutionMessage(props) {
|
|
|
1416
1414
|
}
|
|
1417
1415
|
|
|
1418
1416
|
// src/components/chat/messages/RenderResultMessage.tsx
|
|
1419
|
-
var import_runtime_client_gql5 = require("@copilotkit/runtime-client-gql");
|
|
1420
1417
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1421
1418
|
function RenderResultMessage(props) {
|
|
1422
1419
|
const { message, inProgress, index, isCurrentMessage } = props;
|
|
1423
1420
|
const { icons } = useChatContext();
|
|
1424
|
-
if (message
|
|
1421
|
+
if (message.isResultMessage() && inProgress && isCurrentMessage) {
|
|
1425
1422
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: icons.spinnerIcon }, index);
|
|
1426
1423
|
}
|
|
1427
1424
|
}
|
|
1428
1425
|
|
|
1429
1426
|
// src/components/chat/messages/RenderAgentStateMessage.tsx
|
|
1430
|
-
var import_runtime_client_gql6 = require("@copilotkit/runtime-client-gql");
|
|
1431
1427
|
var import_react_core4 = require("@copilotkit/react-core");
|
|
1432
1428
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1433
1429
|
function RenderAgentStateMessage(props) {
|
|
1434
1430
|
const { message, inProgress, index, isCurrentMessage } = props;
|
|
1435
1431
|
const { chatComponentsCache } = (0, import_react_core4.useCopilotContext)();
|
|
1436
1432
|
const { icons } = useChatContext();
|
|
1437
|
-
if (message
|
|
1433
|
+
if (message.isAgentStateMessage()) {
|
|
1438
1434
|
let render;
|
|
1439
1435
|
if (chatComponentsCache.current !== null) {
|
|
1440
1436
|
render = chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-${message.nodeName}`] || chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-global`];
|
|
@@ -1487,7 +1483,7 @@ function RenderAgentStateMessage(props) {
|
|
|
1487
1483
|
// src/components/chat/Suggestion.tsx
|
|
1488
1484
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
1489
1485
|
var import_shared = require("@copilotkit/shared");
|
|
1490
|
-
var
|
|
1486
|
+
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
1491
1487
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1492
1488
|
function Suggestion({ title, message, onClick, partial, className }) {
|
|
1493
1489
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
@@ -1523,7 +1519,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
1523
1519
|
context,
|
|
1524
1520
|
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. " + config.instructions + "\n\n" + numOfSuggestionsInstructions,
|
|
1525
1521
|
data: "Available tools: " + tools + "\n\n",
|
|
1526
|
-
requestType:
|
|
1522
|
+
requestType: import_runtime_client_gql3.CopilotRequestType.Task,
|
|
1527
1523
|
parameters: [
|
|
1528
1524
|
{
|
|
1529
1525
|
name: "suggestions",
|
|
@@ -1579,13 +1575,11 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
1579
1575
|
// src/components/chat/Chat.tsx
|
|
1580
1576
|
var import_react11 = __toESM(require("react"));
|
|
1581
1577
|
var import_react_core8 = require("@copilotkit/react-core");
|
|
1582
|
-
var
|
|
1578
|
+
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
1583
1579
|
var import_shared3 = require("@copilotkit/shared");
|
|
1584
1580
|
|
|
1585
1581
|
// src/components/dev-console/utils.ts
|
|
1586
1582
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
1587
|
-
var import_runtime_client_gql8 = require("@copilotkit/runtime-client-gql");
|
|
1588
|
-
var import_runtime_client_gql9 = require("@copilotkit/runtime-client-gql");
|
|
1589
1583
|
function shouldShowDevConsole(showDevConsole) {
|
|
1590
1584
|
if (typeof showDevConsole === "boolean") {
|
|
1591
1585
|
return showDevConsole;
|
|
@@ -1675,7 +1669,7 @@ function logMessages(context) {
|
|
|
1675
1669
|
return;
|
|
1676
1670
|
}
|
|
1677
1671
|
const tableData = context.messages.map((message) => {
|
|
1678
|
-
if (message
|
|
1672
|
+
if (message.isTextMessage()) {
|
|
1679
1673
|
return {
|
|
1680
1674
|
id: message.id,
|
|
1681
1675
|
type: "TextMessage",
|
|
@@ -1684,7 +1678,7 @@ function logMessages(context) {
|
|
|
1684
1678
|
scope: void 0,
|
|
1685
1679
|
content: message.content
|
|
1686
1680
|
};
|
|
1687
|
-
} else if (message
|
|
1681
|
+
} else if (message.isActionExecutionMessage()) {
|
|
1688
1682
|
return {
|
|
1689
1683
|
id: message.id,
|
|
1690
1684
|
type: "ActionExecutionMessage",
|
|
@@ -1693,7 +1687,7 @@ function logMessages(context) {
|
|
|
1693
1687
|
scope: message.scope,
|
|
1694
1688
|
content: message.arguments
|
|
1695
1689
|
};
|
|
1696
|
-
} else if (message
|
|
1690
|
+
} else if (message.isResultMessage()) {
|
|
1697
1691
|
return {
|
|
1698
1692
|
id: message.id,
|
|
1699
1693
|
type: "ResultMessage",
|
|
@@ -1702,7 +1696,7 @@ function logMessages(context) {
|
|
|
1702
1696
|
scope: message.actionExecutionId,
|
|
1703
1697
|
content: message.result
|
|
1704
1698
|
};
|
|
1705
|
-
} else if (message
|
|
1699
|
+
} else if (message.isAgentStateMessage()) {
|
|
1706
1700
|
return {
|
|
1707
1701
|
id: message.id,
|
|
1708
1702
|
type: `AgentStateMessage (running: ${message.running})`,
|
|
@@ -1974,6 +1968,7 @@ function DebugMenuButton({
|
|
|
1974
1968
|
mode
|
|
1975
1969
|
}) {
|
|
1976
1970
|
const context = (0, import_react_core7.useCopilotContext)();
|
|
1971
|
+
const messagesContext = (0, import_react_core7.useCopilotMessagesContext)();
|
|
1977
1972
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "bg-black top-24 w-52 text-right", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react10.Menu, { children: [
|
|
1978
1973
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuButton, { className: `copilotKitDebugMenuButton ${mode === "compact" ? "compact" : ""}`, children: mode == "compact" ? "Debug" : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
1979
1974
|
"Debug ",
|
|
@@ -1989,7 +1984,14 @@ function DebugMenuButton({
|
|
|
1989
1984
|
children: [
|
|
1990
1985
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
|
|
1991
1986
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
|
|
1992
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1987
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1988
|
+
"button",
|
|
1989
|
+
{
|
|
1990
|
+
className: "copilotKitDebugMenuItem",
|
|
1991
|
+
onClick: () => logMessages(messagesContext),
|
|
1992
|
+
children: "Log Messages"
|
|
1993
|
+
}
|
|
1994
|
+
) }),
|
|
1993
1995
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
|
|
1994
1996
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("hr", {}),
|
|
1995
1997
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
|
|
@@ -2098,7 +2100,9 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2098
2100
|
(_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
|
|
2099
2101
|
suggestionsAbortControllerRef.current = null;
|
|
2100
2102
|
};
|
|
2101
|
-
const
|
|
2103
|
+
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
2104
|
+
const messagesContext = (0, import_react_core8.useCopilotMessagesContext)();
|
|
2105
|
+
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
2102
2106
|
(0, import_react11.useEffect)(() => {
|
|
2103
2107
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2104
2108
|
abortSuggestions();
|
|
@@ -2123,9 +2127,9 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2123
2127
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2124
2128
|
abortSuggestions();
|
|
2125
2129
|
setCurrentSuggestions([]);
|
|
2126
|
-
const message = new
|
|
2130
|
+
const message = new import_runtime_client_gql4.TextMessage({
|
|
2127
2131
|
content: messageContent,
|
|
2128
|
-
role:
|
|
2132
|
+
role: import_runtime_client_gql4.Role.User
|
|
2129
2133
|
});
|
|
2130
2134
|
if (onSubmitMessage) {
|
|
2131
2135
|
try {
|