@copilotkit/react-ui 0.36.0-mme-push-to-talk.0 → 0.36.0-mme-pre.1

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.
Files changed (159) hide show
  1. package/.turbo/turbo-build.log +174 -167
  2. package/CHANGELOG.md +12 -0
  3. package/dist/{chunk-DMAQBCTX.mjs → chunk-4MKP23AD.mjs} +6 -4
  4. package/dist/chunk-4MKP23AD.mjs.map +1 -0
  5. package/dist/{chunk-UVMROYDT.mjs → chunk-6XLZXLM5.mjs} +5 -5
  6. package/dist/{chunk-UVMROYDT.mjs.map → chunk-6XLZXLM5.mjs.map} +1 -1
  7. package/dist/{chunk-XYM43AHP.mjs → chunk-7FES2IQA.mjs} +3 -3
  8. package/dist/chunk-ANO23V2M.mjs +135 -0
  9. package/dist/chunk-ANO23V2M.mjs.map +1 -0
  10. package/dist/{chunk-DRNCOXZO.mjs → chunk-BL65ZC6L.mjs} +28 -7
  11. package/dist/chunk-BL65ZC6L.mjs.map +1 -0
  12. package/dist/{chunk-PGZDQT74.mjs → chunk-CE7PJAAO.mjs} +2 -2
  13. package/dist/{chunk-FWTPMPSN.mjs → chunk-FZC7X5PK.mjs} +23 -3
  14. package/dist/{chunk-FWTPMPSN.mjs.map → chunk-FZC7X5PK.mjs.map} +1 -1
  15. package/dist/{chunk-Z45ZEXJW.mjs → chunk-LTCJCXCP.mjs} +5 -8
  16. package/dist/chunk-LTCJCXCP.mjs.map +1 -0
  17. package/dist/chunk-MRFF7GSQ.mjs +1 -0
  18. package/dist/{chunk-SKC7AJIV.mjs → chunk-MRXNTQOX.mjs} +1 -3
  19. package/dist/{chunk-MWFHYCQB.mjs → chunk-PAQWLSA4.mjs} +2 -2
  20. package/dist/chunk-RT2XG2T7.mjs +25 -0
  21. package/dist/chunk-RT2XG2T7.mjs.map +1 -0
  22. package/dist/chunk-T3JTSIHT.mjs +93 -0
  23. package/dist/chunk-T3JTSIHT.mjs.map +1 -0
  24. package/dist/{chunk-A7J4KGLP.mjs → chunk-UPTB2MVO.mjs} +2 -2
  25. package/dist/{chunk-KZME7C5S.mjs → chunk-VUZA5AFH.mjs} +8 -11
  26. package/dist/chunk-VUZA5AFH.mjs.map +1 -0
  27. package/dist/{chunk-XWWMYJJF.mjs → chunk-XRODMID5.mjs} +5 -5
  28. package/dist/{chunk-XWWMYJJF.mjs.map → chunk-XRODMID5.mjs.map} +1 -1
  29. package/dist/{chunk-ZKLK3M77.mjs → chunk-YQ3D5IQV.mjs} +3 -3
  30. package/dist/{chunk-WM6BS77F.mjs → chunk-YQFVRDNC.mjs} +2 -2
  31. package/dist/{chunk-WM6BS77F.mjs.map → chunk-YQFVRDNC.mjs.map} +1 -1
  32. package/dist/chunk-ZO3GLN23.mjs +137 -0
  33. package/dist/chunk-ZO3GLN23.mjs.map +1 -0
  34. package/dist/components/chat/Button.d.ts +1 -1
  35. package/dist/components/chat/Button.js +2 -30
  36. package/dist/components/chat/Button.js.map +1 -1
  37. package/dist/components/chat/Button.mjs +4 -4
  38. package/dist/components/chat/Chat.d.ts +66 -47
  39. package/dist/components/chat/Chat.js +274 -430
  40. package/dist/components/chat/Chat.js.map +1 -1
  41. package/dist/components/chat/Chat.mjs +16 -17
  42. package/dist/components/chat/ChatContext.d.ts +17 -22
  43. package/dist/components/chat/ChatContext.js +23 -8
  44. package/dist/components/chat/ChatContext.js.map +1 -1
  45. package/dist/components/chat/ChatContext.mjs +3 -3
  46. package/dist/components/chat/CodeBlock.js.map +1 -1
  47. package/dist/components/chat/CodeBlock.mjs +3 -3
  48. package/dist/components/chat/Header.js.map +1 -1
  49. package/dist/components/chat/Header.mjs +4 -4
  50. package/dist/components/chat/Icons.d.ts +6 -5
  51. package/dist/components/chat/Icons.js +21 -0
  52. package/dist/components/chat/Icons.js.map +1 -1
  53. package/dist/components/chat/Icons.mjs +4 -2
  54. package/dist/components/chat/Input.js +147 -9
  55. package/dist/components/chat/Input.js.map +1 -1
  56. package/dist/components/chat/Input.mjs +6 -5
  57. package/dist/components/chat/Markdown.js.map +1 -1
  58. package/dist/components/chat/Markdown.mjs +4 -4
  59. package/dist/components/chat/Messages.js.map +1 -1
  60. package/dist/components/chat/Messages.mjs +6 -6
  61. package/dist/components/chat/Modal.d.ts +50 -0
  62. package/dist/components/chat/Modal.js +1584 -0
  63. package/dist/components/chat/Modal.js.map +1 -0
  64. package/dist/components/chat/Modal.mjs +23 -0
  65. package/dist/components/chat/Popup.d.ts +6 -5
  66. package/dist/components/chat/Popup.js +288 -249
  67. package/dist/components/chat/Popup.js.map +1 -1
  68. package/dist/components/chat/Popup.mjs +16 -15
  69. package/dist/components/chat/Response.js.map +1 -1
  70. package/dist/components/chat/Response.mjs +4 -4
  71. package/dist/components/chat/Sidebar.d.ts +6 -5
  72. package/dist/components/chat/Sidebar.js +290 -251
  73. package/dist/components/chat/Sidebar.js.map +1 -1
  74. package/dist/components/chat/Sidebar.mjs +16 -15
  75. package/dist/components/chat/Suggestion.d.ts +1 -2
  76. package/dist/components/chat/Suggestion.js.map +1 -1
  77. package/dist/components/chat/Suggestion.mjs +3 -3
  78. package/dist/components/chat/Textarea.d.ts +4 -4
  79. package/dist/components/chat/Textarea.js +1 -1
  80. package/dist/components/chat/Textarea.js.map +1 -1
  81. package/dist/components/chat/Textarea.mjs +2 -2
  82. package/dist/components/chat/Window.mjs +1 -1
  83. package/dist/components/chat/index.d.ts +2 -1
  84. package/dist/components/chat/index.js +294 -253
  85. package/dist/components/chat/index.js.map +1 -1
  86. package/dist/components/chat/index.mjs +23 -19
  87. package/dist/components/chat/props.d.ts +1 -3
  88. package/dist/components/chat/props.js.map +1 -1
  89. package/dist/components/index.d.ts +2 -1
  90. package/dist/components/index.js +294 -253
  91. package/dist/components/index.js.map +1 -1
  92. package/dist/components/index.mjs +23 -19
  93. package/dist/hooks/index.d.ts +0 -1
  94. package/dist/hooks/index.js +6 -31
  95. package/dist/hooks/index.js.map +1 -1
  96. package/dist/hooks/index.mjs +2 -22
  97. package/dist/hooks/use-copilot-chat-suggestions.d.ts +26 -4
  98. package/dist/hooks/use-copilot-chat-suggestions.js +6 -31
  99. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
  100. package/dist/hooks/use-copilot-chat-suggestions.mjs +2 -22
  101. package/dist/hooks/use-copy-to-clipboard.mjs +1 -1
  102. package/dist/hooks/use-push-to-talk.d.ts +19 -0
  103. package/dist/hooks/use-push-to-talk.js +177 -0
  104. package/dist/hooks/use-push-to-talk.js.map +1 -0
  105. package/dist/hooks/use-push-to-talk.mjs +12 -0
  106. package/dist/hooks/use-push-to-talk.mjs.map +1 -0
  107. package/dist/index.css +60 -8
  108. package/dist/index.css.map +1 -1
  109. package/dist/index.d.ts +2 -1
  110. package/dist/index.js +300 -258
  111. package/dist/index.js.map +1 -1
  112. package/dist/index.mjs +28 -24
  113. package/dist/lib/utils.mjs +1 -1
  114. package/dist/types/suggestions.d.ts +1 -21
  115. package/dist/types/suggestions.js.map +1 -1
  116. package/package.json +6 -6
  117. package/src/components/chat/Button.tsx +2 -35
  118. package/src/components/chat/Chat.tsx +126 -255
  119. package/src/components/chat/ChatContext.tsx +8 -22
  120. package/src/components/chat/Icons.tsx +17 -0
  121. package/src/components/chat/Input.tsx +37 -5
  122. package/src/components/chat/Modal.tsx +115 -0
  123. package/src/components/chat/Popup.tsx +3 -3
  124. package/src/components/chat/Sidebar.tsx +4 -4
  125. package/src/components/chat/Suggestion.tsx +6 -2
  126. package/src/components/chat/Textarea.tsx +1 -1
  127. package/src/components/chat/index.tsx +1 -0
  128. package/src/components/chat/props.ts +1 -3
  129. package/src/css/input.css +18 -8
  130. package/src/css/panel.css +38 -0
  131. package/src/css/window.css +3 -1
  132. package/src/hooks/use-copilot-chat-suggestions.tsx +31 -5
  133. package/src/hooks/use-push-to-talk.tsx +162 -0
  134. package/src/styles.css +1 -0
  135. package/src/types/suggestions.ts +0 -24
  136. package/dist/chunk-5ASYNEHX.mjs +0 -53
  137. package/dist/chunk-5ASYNEHX.mjs.map +0 -1
  138. package/dist/chunk-DMAQBCTX.mjs.map +0 -1
  139. package/dist/chunk-DRNCOXZO.mjs.map +0 -1
  140. package/dist/chunk-JPX5ODUX.mjs +0 -266
  141. package/dist/chunk-JPX5ODUX.mjs.map +0 -1
  142. package/dist/chunk-KZME7C5S.mjs.map +0 -1
  143. package/dist/chunk-PEDSZYHE.mjs +0 -36
  144. package/dist/chunk-PEDSZYHE.mjs.map +0 -1
  145. package/dist/chunk-UGQQ4WEQ.mjs +0 -1
  146. package/dist/chunk-Z45ZEXJW.mjs.map +0 -1
  147. package/dist/components/chat/audio.d.ts +0 -7
  148. package/dist/components/chat/audio.js +0 -77
  149. package/dist/components/chat/audio.js.map +0 -1
  150. package/dist/components/chat/audio.mjs +0 -10
  151. package/src/components/chat/audio.ts +0 -26
  152. /package/dist/{chunk-XYM43AHP.mjs.map → chunk-7FES2IQA.mjs.map} +0 -0
  153. /package/dist/{chunk-PGZDQT74.mjs.map → chunk-CE7PJAAO.mjs.map} +0 -0
  154. /package/dist/{chunk-SKC7AJIV.mjs.map → chunk-MRFF7GSQ.mjs.map} +0 -0
  155. /package/dist/{chunk-UGQQ4WEQ.mjs.map → chunk-MRXNTQOX.mjs.map} +0 -0
  156. /package/dist/{chunk-MWFHYCQB.mjs.map → chunk-PAQWLSA4.mjs.map} +0 -0
  157. /package/dist/{chunk-A7J4KGLP.mjs.map → chunk-UPTB2MVO.mjs.map} +0 -0
  158. /package/dist/{chunk-ZKLK3M77.mjs.map → chunk-YQ3D5IQV.mjs.map} +0 -0
  159. /package/dist/components/chat/{audio.mjs.map → Modal.mjs.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/ChatContext.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const context = {\n labels: {\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n },\n ...labels,\n },\n\n icons: {\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.PushToTalkIcon,\n },\n icons,\n },\n open,\n setOpen,\n };\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAO,WAAkC;AA6KhC;AA/DF,IAAM,cAAc,MAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,MAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAaO,IAAM,sBAAsB,CAAC;AAAA;AAAA;AAAA;AAAA,EAIlC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwB;AACtB,QAAM,UAAU;AAAA,IACd,QAAQ,kCACH;AAAA,MACD,SAAS;AAAA,MACT,OAAO;AAAA,MACP,aAAa;AAAA,MACb,OAAO;AAAA,MACP,gBAAgB;AAAA,MAChB,oBAAoB;AAAA,IACtB,IACG;AAAA,IAGL,OAAO,iCACF;AAAA,MACD,UAAuB;AAAA,MACvB,WAAwB;AAAA,MACxB,iBAA8B;AAAA,MAC9B,UAAuB;AAAA,MACvB,cAA2B;AAAA,MAC3B,aAA0B;AAAA,MAC1B,UAAuB;AAAA,MACvB,gBAA6B;AAAA,MAC7B,gBAA6B;AAAA,IAC/B,IAXK;AAAA,MAYL;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAO,SAAU,UAAS;AACzD;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import {
2
- CopilotChat
3
- } from "./chunk-JPX5ODUX.mjs";
2
+ CopilotModal
3
+ } from "./chunk-T3JTSIHT.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
7
- } from "./chunk-SKC7AJIV.mjs";
7
+ } from "./chunk-MRXNTQOX.mjs";
8
8
 
9
9
  // src/components/chat/Popup.tsx
10
10
  import { jsx } from "react/jsx-runtime";
@@ -12,10 +12,10 @@ function CopilotPopup(props) {
12
12
  props = __spreadProps(__spreadValues({}, props), {
13
13
  className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
14
14
  });
15
- return /* @__PURE__ */ jsx(CopilotChat, __spreadProps(__spreadValues({}, props), { children: props.children }));
15
+ return /* @__PURE__ */ jsx(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
16
16
  }
17
17
 
18
18
  export {
19
19
  CopilotPopup
20
20
  };
21
- //# sourceMappingURL=chunk-XWWMYJJF.mjs.map
21
+ //# sourceMappingURL=chunk-XRODMID5.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/chat/Popup.tsx"],"sourcesContent":["/**\n * A chatbot popup component for CopilotKit.\n *\n * <img src=\"/images/CopilotPopup/CopilotPopup.gif\" width=\"500\" />\n *\n * <img referrerPolicy=\"no-referrer-when-downgrade\" src=\"https://static.scarf.sh/a.png?x-pxid=a9b290bb-38f9-4518-ac3b-8f54fdbf43be\" />\n *\n * A chatbot popup component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\n *\n * See [CopilotSidebar](./CopilotSidebar) for a sidebar version of this component.\n *\n * <RequestExample>\n * ```jsx CopilotPopup Example\n * import { CopilotPopup } from \"@copilotkit/react-ui\";\n *\n * <CopilotPopup\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n * </RequestExample>\n *\n * ## Custom CSS\n *\n * You can customize the colors of the chat window by overriding the CSS variables\n * defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).\n *\n * For example, to set the primary color to purple:\n *\n * ```jsx\n * <div style={{ \"--copilot-kit-primary-color\": \"#7D5BA6\" }}>\n * <CopilotPopup />\n * </div>\n * ```\n *\n * To further customize the chat window, you can override the CSS classes defined\n * [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).\n *\n * For example:\n *\n * ```css\n * .copilotKitButton {\n * border-radius: 0;\n * }\n * ```\n */\n\nimport { CopilotChat, CopilotChatProps } from \"./Chat\";\n\nexport function CopilotPopup(props: CopilotChatProps) {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitPopup\" : \"copilotKitPopup\",\n };\n return <CopilotChat {...props}>{props.children}</CopilotChat>;\n}\n"],"mappings":";;;;;;;;;AAyDS;AALF,SAAS,aAAa,OAAyB;AACpD,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,qBAAqB;AAAA,EACtE;AACA,SAAO,oBAAC,8CAAgB,QAAhB,EAAwB,gBAAM,WAAS;AACjD;","names":[]}
1
+ {"version":3,"sources":["../src/components/chat/Popup.tsx"],"sourcesContent":["/**\n * A chatbot popup component for CopilotKit.\n *\n * <img src=\"/images/CopilotPopup/CopilotPopup.gif\" width=\"500\" />\n *\n * <img referrerPolicy=\"no-referrer-when-downgrade\" src=\"https://static.scarf.sh/a.png?x-pxid=a9b290bb-38f9-4518-ac3b-8f54fdbf43be\" />\n *\n * A chatbot popup component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\n *\n * See [CopilotSidebar](./CopilotSidebar) for a sidebar version of this component.\n *\n * <RequestExample>\n * ```jsx CopilotPopup Example\n * import { CopilotPopup } from \"@copilotkit/react-ui\";\n *\n * <CopilotPopup\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n * </RequestExample>\n *\n * ## Custom CSS\n *\n * You can customize the colors of the chat window by overriding the CSS variables\n * defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).\n *\n * For example, to set the primary color to purple:\n *\n * ```jsx\n * <div style={{ \"--copilot-kit-primary-color\": \"#7D5BA6\" }}>\n * <CopilotPopup />\n * </div>\n * ```\n *\n * To further customize the chat window, you can override the CSS classes defined\n * [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).\n *\n * For example:\n *\n * ```css\n * .copilotKitButton {\n * border-radius: 0;\n * }\n * ```\n */\n\nimport { CopilotModal, CopilotModalProps } from \"./Modal\";\n\nexport function CopilotPopup(props: CopilotModalProps) {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitPopup\" : \"copilotKitPopup\",\n };\n return <CopilotModal {...props}>{props.children}</CopilotModal>;\n}\n"],"mappings":";;;;;;;;;AAyDS;AALF,SAAS,aAAa,OAA0B;AACrD,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,qBAAqB;AAAA,EACtE;AACA,SAAO,oBAAC,+CAAiB,QAAjB,EAAyB,gBAAM,WAAS;AAClD;","names":[]}
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  CodeBlock
3
- } from "./chunk-A7J4KGLP.mjs";
3
+ } from "./chunk-UPTB2MVO.mjs";
4
4
  import {
5
5
  __objRest,
6
6
  __spreadProps,
7
7
  __spreadValues
8
- } from "./chunk-SKC7AJIV.mjs";
8
+ } from "./chunk-MRXNTQOX.mjs";
9
9
 
10
10
  // src/components/chat/Markdown.tsx
11
11
  import { memo } from "react";
@@ -72,4 +72,4 @@ var components = {
72
72
  export {
73
73
  Markdown
74
74
  };
75
- //# sourceMappingURL=chunk-ZKLK3M77.mjs.map
75
+ //# sourceMappingURL=chunk-YQ3D5IQV.mjs.map
@@ -36,7 +36,7 @@ var AutoResizingTextarea = forwardRef(
36
36
  onKeyDown,
37
37
  placeholder,
38
38
  style: {
39
- overflow: "hidden",
39
+ overflow: "auto",
40
40
  resize: "none",
41
41
  maxHeight: `${maxHeight}px`
42
42
  },
@@ -50,4 +50,4 @@ var Textarea_default = AutoResizingTextarea;
50
50
  export {
51
51
  Textarea_default
52
52
  };
53
- //# sourceMappingURL=chunk-WM6BS77F.mjs.map
53
+ //# sourceMappingURL=chunk-YQFVRDNC.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/chat/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from \"react\";\n\ninterface AutoResizingTextareaProps {\n maxRows?: number;\n placeholder?: string;\n value: string;\n onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n autoFocus?: boolean;\n}\n\nconst AutoResizingTextarea = forwardRef<HTMLTextAreaElement, AutoResizingTextareaProps>(\n ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {\n const internalTextareaRef = useRef<HTMLTextAreaElement>(null);\n const [maxHeight, setMaxHeight] = useState<number>(0);\n\n useImperativeHandle(ref, () => internalTextareaRef.current as HTMLTextAreaElement);\n\n useEffect(() => {\n const calculateMaxHeight = () => {\n const textarea = internalTextareaRef.current;\n if (textarea) {\n textarea.style.height = \"auto\";\n const singleRowHeight = textarea.scrollHeight;\n setMaxHeight(singleRowHeight * maxRows);\n if (autoFocus) {\n textarea.focus();\n }\n }\n };\n\n calculateMaxHeight();\n }, [maxRows]);\n\n useEffect(() => {\n const textarea = internalTextareaRef.current;\n if (textarea) {\n textarea.style.height = \"auto\";\n textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;\n }\n }, [value, maxHeight]);\n\n return (\n <textarea\n ref={internalTextareaRef}\n value={value}\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n style={{\n overflow: \"hidden\",\n resize: \"none\",\n maxHeight: `${maxHeight}px`,\n }}\n rows={1}\n />\n );\n },\n);\n\nexport default AutoResizingTextarea;\n"],"mappings":";AAAA,SAAgB,UAAU,QAAQ,WAAW,YAAY,2BAA2B;AA2C9E;AAhCN,IAAM,uBAAuB;AAAA,EAC3B,CAAC,EAAE,UAAU,GAAG,aAAa,OAAO,UAAU,WAAW,UAAU,GAAG,QAAQ;AAC5E,UAAM,sBAAsB,OAA4B,IAAI;AAC5D,UAAM,CAAC,WAAW,YAAY,IAAI,SAAiB,CAAC;AAEpD,wBAAoB,KAAK,MAAM,oBAAoB,OAA8B;AAEjF,cAAU,MAAM;AACd,YAAM,qBAAqB,MAAM;AAC/B,cAAM,WAAW,oBAAoB;AACrC,YAAI,UAAU;AACZ,mBAAS,MAAM,SAAS;AACxB,gBAAM,kBAAkB,SAAS;AACjC,uBAAa,kBAAkB,OAAO;AACtC,cAAI,WAAW;AACb,qBAAS,MAAM;AAAA,UACjB;AAAA,QACF;AAAA,MACF;AAEA,yBAAmB;AAAA,IACrB,GAAG,CAAC,OAAO,CAAC;AAEZ,cAAU,MAAM;AACd,YAAM,WAAW,oBAAoB;AACrC,UAAI,UAAU;AACZ,iBAAS,MAAM,SAAS;AACxB,iBAAS,MAAM,SAAS,GAAG,KAAK,IAAI,SAAS,cAAc,SAAS;AAAA,MACtE;AAAA,IACF,GAAG,CAAC,OAAO,SAAS,CAAC;AAErB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,WAAW,GAAG;AAAA,QAChB;AAAA,QACA,MAAM;AAAA;AAAA,IACR;AAAA,EAEJ;AACF;AAEA,IAAO,mBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/components/chat/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from \"react\";\n\ninterface AutoResizingTextareaProps {\n maxRows?: number;\n placeholder?: string;\n value: string;\n onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n autoFocus?: boolean;\n}\n\nconst AutoResizingTextarea = forwardRef<HTMLTextAreaElement, AutoResizingTextareaProps>(\n ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {\n const internalTextareaRef = useRef<HTMLTextAreaElement>(null);\n const [maxHeight, setMaxHeight] = useState<number>(0);\n\n useImperativeHandle(ref, () => internalTextareaRef.current as HTMLTextAreaElement);\n\n useEffect(() => {\n const calculateMaxHeight = () => {\n const textarea = internalTextareaRef.current;\n if (textarea) {\n textarea.style.height = \"auto\";\n const singleRowHeight = textarea.scrollHeight;\n setMaxHeight(singleRowHeight * maxRows);\n if (autoFocus) {\n textarea.focus();\n }\n }\n };\n\n calculateMaxHeight();\n }, [maxRows]);\n\n useEffect(() => {\n const textarea = internalTextareaRef.current;\n if (textarea) {\n textarea.style.height = \"auto\";\n textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;\n }\n }, [value, maxHeight]);\n\n return (\n <textarea\n ref={internalTextareaRef}\n value={value}\n onChange={onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n style={{\n overflow: \"auto\",\n resize: \"none\",\n maxHeight: `${maxHeight}px`,\n }}\n rows={1}\n />\n );\n },\n);\n\nexport default AutoResizingTextarea;\n"],"mappings":";AAAA,SAAgB,UAAU,QAAQ,WAAW,YAAY,2BAA2B;AA2C9E;AAhCN,IAAM,uBAAuB;AAAA,EAC3B,CAAC,EAAE,UAAU,GAAG,aAAa,OAAO,UAAU,WAAW,UAAU,GAAG,QAAQ;AAC5E,UAAM,sBAAsB,OAA4B,IAAI;AAC5D,UAAM,CAAC,WAAW,YAAY,IAAI,SAAiB,CAAC;AAEpD,wBAAoB,KAAK,MAAM,oBAAoB,OAA8B;AAEjF,cAAU,MAAM;AACd,YAAM,qBAAqB,MAAM;AAC/B,cAAM,WAAW,oBAAoB;AACrC,YAAI,UAAU;AACZ,mBAAS,MAAM,SAAS;AACxB,gBAAM,kBAAkB,SAAS;AACjC,uBAAa,kBAAkB,OAAO;AACtC,cAAI,WAAW;AACb,qBAAS,MAAM;AAAA,UACjB;AAAA,QACF;AAAA,MACF;AAEA,yBAAmB;AAAA,IACrB,GAAG,CAAC,OAAO,CAAC;AAEZ,cAAU,MAAM;AACd,YAAM,WAAW,oBAAoB;AACrC,UAAI,UAAU;AACZ,iBAAS,MAAM,SAAS;AACxB,iBAAS,MAAM,SAAS,GAAG,KAAK,IAAI,SAAS,cAAc,SAAS;AAAA,MACtE;AAAA,IACF,GAAG,CAAC,OAAO,SAAS,CAAC;AAErB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,WAAW,GAAG;AAAA,QAChB;AAAA,QACA,MAAM;AAAA;AAAA,IACR;AAAA,EAEJ;AACF;AAEA,IAAO,mBAAQ;","names":[]}
@@ -0,0 +1,137 @@
1
+ import {
2
+ Suggestion,
3
+ reloadSuggestions
4
+ } from "./chunk-4MKP23AD.mjs";
5
+ import {
6
+ Input
7
+ } from "./chunk-BL65ZC6L.mjs";
8
+ import {
9
+ Messages
10
+ } from "./chunk-7FES2IQA.mjs";
11
+ import {
12
+ ResponseButton
13
+ } from "./chunk-CE7PJAAO.mjs";
14
+ import {
15
+ ChatContext,
16
+ ChatContextProvider
17
+ } from "./chunk-VUZA5AFH.mjs";
18
+ import {
19
+ __async
20
+ } from "./chunk-MRXNTQOX.mjs";
21
+
22
+ // src/components/chat/Chat.tsx
23
+ import React, { useEffect, useRef, useState } from "react";
24
+ import { useCopilotChat, useCopilotContext } from "@copilotkit/react-core";
25
+ import { nanoid } from "nanoid";
26
+ import { jsx, jsxs } from "react/jsx-runtime";
27
+ function CopilotChat({
28
+ instructions,
29
+ onSubmitMessage,
30
+ icons,
31
+ labels,
32
+ makeSystemMessage,
33
+ showResponseButton = true,
34
+ onInProgress,
35
+ Messages: Messages2 = Messages,
36
+ Input: Input2 = Input,
37
+ ResponseButton: ResponseButton2 = ResponseButton,
38
+ className
39
+ }) {
40
+ const { visibleMessages, isLoading, currentSuggestions, sendMessage, stop, reload } = useCopilotChatLogic(instructions, makeSystemMessage, onInProgress, onSubmitMessage);
41
+ const context = React.useContext(ChatContext);
42
+ let open = true;
43
+ let setOpen = () => {
44
+ };
45
+ if (context) {
46
+ icons = context.icons;
47
+ labels = context.labels;
48
+ open = context.open;
49
+ setOpen = context.setOpen;
50
+ }
51
+ return /* @__PURE__ */ jsx(ChatContextProvider, { icons, labels, open, setOpen, children: /* @__PURE__ */ jsxs("div", { className: `copilotKitPanel ${className}`, children: [
52
+ /* @__PURE__ */ jsxs(Messages2, { messages: visibleMessages, inProgress: isLoading, children: [
53
+ currentSuggestions.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
54
+ /* @__PURE__ */ jsx("h6", { children: "Suggested:" }),
55
+ /* @__PURE__ */ jsx("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ jsx(
56
+ Suggestion,
57
+ {
58
+ title: suggestion.title,
59
+ message: suggestion.message,
60
+ partial: suggestion.partial,
61
+ className: suggestion.className,
62
+ onClick: (message) => sendMessage(message)
63
+ },
64
+ index
65
+ )) })
66
+ ] }),
67
+ showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ jsx(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading })
68
+ ] }),
69
+ /* @__PURE__ */ jsx(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible: true })
70
+ ] }) });
71
+ }
72
+ var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
73
+ var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubmitMessage) => {
74
+ const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({
75
+ id: nanoid(),
76
+ makeSystemMessage,
77
+ additionalInstructions: instructions
78
+ });
79
+ const [currentSuggestions, setCurrentSuggestions] = useState([]);
80
+ const suggestionsAbortControllerRef = useRef(null);
81
+ const debounceTimerRef = useRef();
82
+ const abortSuggestions = () => {
83
+ var _a;
84
+ (_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
85
+ suggestionsAbortControllerRef.current = null;
86
+ };
87
+ const context = useCopilotContext();
88
+ useEffect(() => {
89
+ onInProgress == null ? void 0 : onInProgress(isLoading);
90
+ abortSuggestions();
91
+ debounceTimerRef.current = setTimeout(
92
+ () => {
93
+ if (!isLoading && Object.keys(context.chatSuggestionConfiguration).length !== 0) {
94
+ suggestionsAbortControllerRef.current = new AbortController();
95
+ reloadSuggestions(
96
+ context,
97
+ context.chatSuggestionConfiguration,
98
+ setCurrentSuggestions,
99
+ suggestionsAbortControllerRef
100
+ );
101
+ }
102
+ },
103
+ currentSuggestions.length == 0 ? 0 : SUGGESTIONS_DEBOUNCE_TIMEOUT
104
+ );
105
+ return () => {
106
+ clearTimeout(debounceTimerRef.current);
107
+ };
108
+ }, [isLoading, context.chatSuggestionConfiguration]);
109
+ const sendMessage = (messageContent) => __async(void 0, null, function* () {
110
+ abortSuggestions();
111
+ setCurrentSuggestions([]);
112
+ onSubmitMessage == null ? void 0 : onSubmitMessage(messageContent);
113
+ const message = {
114
+ id: nanoid(),
115
+ content: messageContent,
116
+ role: "user"
117
+ };
118
+ append(message);
119
+ return message;
120
+ });
121
+ return {
122
+ visibleMessages,
123
+ isLoading,
124
+ currentSuggestions,
125
+ sendMessage,
126
+ stop,
127
+ reload,
128
+ input,
129
+ setInput
130
+ };
131
+ };
132
+
133
+ export {
134
+ CopilotChat,
135
+ useCopilotChatLogic
136
+ };
137
+ //# sourceMappingURL=chunk-ZO3GLN23.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Chat.tsx"],"sourcesContent":["/**\n * An embeddable chat panel for CopilotKit.\n *\n * <img src=\"/images/CopilotChat/CopilotChat.gif\" width=\"500\" />\n *\n * A chatbot panel component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\n *\n * <RequestExample>\n * ```jsx CopilotChat Example\n * import { CopilotChat } from \"@copilotkit/react-ui\";\n *\n * <CopilotChat\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n * </RequestExample>\n *\n * ## Custom CSS\n *\n * You can customize the colors of the panel by overriding the CSS variables\n * defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).\n *\n * For example, to set the primary color to purple:\n *\n * ```jsx\n * <div style={{ \"--copilot-kit-primary-color\": \"#7D5BA6\" }}>\n * <CopilotPopup />\n * </div>\n * ```\n *\n * To further customize the panel, you can override the CSS classes defined\n * [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).\n *\n * For example:\n *\n * ```css\n * .copilotKitButton {\n * border-radius: 0;\n * }\n * ```\n */\n\nimport {\n ChatContext,\n ChatContextProvider,\n CopilotChatIcons,\n CopilotChatLabels,\n} from \"./ChatContext\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { ResponseButton as DefaultResponseButton } from \"./Response\";\nimport { Suggestion } from \"./Suggestion\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { SystemMessageFunction, useCopilotChat, useCopilotContext } from \"@copilotkit/react-core\";\nimport { nanoid } from \"nanoid\";\nimport { reloadSuggestions } from \"./Suggestion\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { Message } from \"@copilotkit/shared\";\nimport { InputProps, MessagesProps, ResponseButtonProps } from \"./props\";\n\n/**\n * Props for CopilotChat component.\n */\nexport interface CopilotChatProps {\n /**\n * Custom instructions to be added to the system message. Use this property to\n * provide additional context or guidance to the language model, influencing\n * its responses. These instructions can include specific directions,\n * preferences, or criteria that the model should consider when generating\n * its output, thereby tailoring the conversation more precisely to the\n * user's needs or the application's requirements.\n */\n instructions?: string;\n\n /**\n * A callback that gets called when the in progress state changes.\n */\n onInProgress?: (inProgress: boolean) => void;\n\n /**\n * A callback that gets called when a new message it submitted.\n */\n onSubmitMessage?: (message: string) => void;\n\n /**\n * Icons can be used to set custom icons for the chat window.\n */\n icons?: CopilotChatIcons;\n\n /**\n * Labels can be used to set custom labels for the chat window.\n */\n labels?: CopilotChatLabels;\n\n /**\n * A function that takes in context string and instructions and returns\n * the system message to include in the chat request.\n * Use this to completely override the system message, when providing\n * instructions is not enough.\n */\n makeSystemMessage?: SystemMessageFunction;\n\n /**\n * Whether to show the response button.\n * @default true\n */\n showResponseButton?: boolean;\n\n /**\n * A custom Messages component to use instead of the default.\n */\n Messages?: React.ComponentType<MessagesProps>;\n\n /**\n * A custom Input component to use instead of the default.\n */\n Input?: React.ComponentType<InputProps>;\n\n /**\n * A custom ResponseButton component to use instead of the default.\n */\n ResponseButton?: React.ComponentType<ResponseButtonProps>;\n\n /**\n * A class name to apply to the root element.\n */\n className?: string;\n\n /**\n * Children to render.\n */\n children?: React.ReactNode;\n}\n\nexport function CopilotChat({\n instructions,\n onSubmitMessage,\n icons,\n labels,\n makeSystemMessage,\n showResponseButton = true,\n onInProgress,\n Messages = DefaultMessages,\n Input = DefaultInput,\n ResponseButton = DefaultResponseButton,\n className,\n}: CopilotChatProps) {\n const { visibleMessages, isLoading, currentSuggestions, sendMessage, stop, reload } =\n useCopilotChatLogic(instructions, makeSystemMessage, onInProgress, onSubmitMessage);\n\n const context = React.useContext(ChatContext);\n let open = true;\n let setOpen: (open: boolean) => void = () => {};\n if (context) {\n icons = context.icons;\n labels = context.labels;\n open = context.open;\n setOpen = context.setOpen;\n }\n\n return (\n <ChatContextProvider icons={icons} labels={labels} open={open} setOpen={setOpen}>\n <div className={`copilotKitPanel ${className}`}>\n <Messages messages={visibleMessages} inProgress={isLoading}>\n {currentSuggestions.length > 0 && (\n <div>\n <h6>Suggested:</h6>\n <div className=\"suggestions\">\n {currentSuggestions.map((suggestion, index) => (\n <Suggestion\n key={index}\n title={suggestion.title}\n message={suggestion.message}\n partial={suggestion.partial}\n className={suggestion.className}\n onClick={(message) => sendMessage(message)}\n />\n ))}\n </div>\n </div>\n )}\n {showResponseButton && visibleMessages.length > 0 && (\n <ResponseButton onClick={isLoading ? stop : reload} inProgress={isLoading} />\n )}\n </Messages>\n <Input inProgress={isLoading} onSend={sendMessage} isVisible={true} />\n </div>\n </ChatContextProvider>\n );\n}\n\nconst SUGGESTIONS_DEBOUNCE_TIMEOUT = 1000;\n\nexport const useCopilotChatLogic = (\n instructions?: string,\n makeSystemMessage?: SystemMessageFunction,\n onInProgress?: (isLoading: boolean) => void,\n onSubmitMessage?: (messageContent: string) => void,\n) => {\n const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({\n id: nanoid(),\n makeSystemMessage,\n additionalInstructions: instructions,\n });\n\n const [currentSuggestions, setCurrentSuggestions] = useState<CopilotChatSuggestion[]>([]);\n const suggestionsAbortControllerRef = useRef<AbortController | null>(null);\n const debounceTimerRef = useRef<any>();\n\n const abortSuggestions = () => {\n suggestionsAbortControllerRef.current?.abort();\n suggestionsAbortControllerRef.current = null;\n };\n\n const context = useCopilotContext();\n\n useEffect(() => {\n onInProgress?.(isLoading);\n\n abortSuggestions();\n\n debounceTimerRef.current = setTimeout(\n () => {\n if (!isLoading && Object.keys(context.chatSuggestionConfiguration).length !== 0) {\n suggestionsAbortControllerRef.current = new AbortController();\n reloadSuggestions(\n context,\n context.chatSuggestionConfiguration,\n setCurrentSuggestions,\n suggestionsAbortControllerRef,\n );\n }\n },\n currentSuggestions.length == 0 ? 0 : SUGGESTIONS_DEBOUNCE_TIMEOUT,\n );\n\n return () => {\n clearTimeout(debounceTimerRef.current);\n };\n }, [isLoading, context.chatSuggestionConfiguration]);\n\n const sendMessage = async (messageContent: string) => {\n abortSuggestions();\n setCurrentSuggestions([]);\n onSubmitMessage?.(messageContent);\n const message: Message = {\n id: nanoid(),\n content: messageContent,\n role: \"user\",\n };\n append(message);\n return message;\n };\n\n return {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stop,\n reload,\n input,\n setInput,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwDA,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD,SAAgC,gBAAgB,yBAAyB;AACzE,SAAS,cAAc;AA+GX,SACE,KADF;AA/BL,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB;AAAA,EACrB;AAAA,EACA,UAAAA,YAAW;AAAA,EACX,OAAAC,SAAQ;AAAA,EACR,gBAAAC,kBAAiB;AAAA,EACjB;AACF,GAAqB;AACnB,QAAM,EAAE,iBAAiB,WAAW,oBAAoB,aAAa,MAAM,OAAO,IAChF,oBAAoB,cAAc,mBAAmB,cAAc,eAAe;AAEpF,QAAM,UAAU,MAAM,WAAW,WAAW;AAC5C,MAAI,OAAO;AACX,MAAI,UAAmC,MAAM;AAAA,EAAC;AAC9C,MAAI,SAAS;AACX,YAAQ,QAAQ;AAChB,aAAS,QAAQ;AACjB,WAAO,QAAQ;AACf,cAAU,QAAQ;AAAA,EACpB;AAEA,SACE,oBAAC,uBAAoB,OAAc,QAAgB,MAAY,SAC7D,+BAAC,SAAI,WAAW,mBAAmB,aACjC;AAAA,yBAACF,WAAA,EAAS,UAAU,iBAAiB,YAAY,WAC9C;AAAA,yBAAmB,SAAS,KAC3B,qBAAC,SACC;AAAA,4BAAC,QAAG,wBAAU;AAAA,QACd,oBAAC,SAAI,WAAU,eACZ,6BAAmB,IAAI,CAAC,YAAY,UACnC;AAAA,UAAC;AAAA;AAAA,YAEC,OAAO,WAAW;AAAA,YAClB,SAAS,WAAW;AAAA,YACpB,SAAS,WAAW;AAAA,YACpB,WAAW,WAAW;AAAA,YACtB,SAAS,CAAC,YAAY,YAAY,OAAO;AAAA;AAAA,UALpC;AAAA,QAMP,CACD,GACH;AAAA,SACF;AAAA,MAED,sBAAsB,gBAAgB,SAAS,KAC9C,oBAACE,iBAAA,EAAe,SAAS,YAAY,OAAO,QAAQ,YAAY,WAAW;AAAA,OAE/E;AAAA,IACA,oBAACD,QAAA,EAAM,YAAY,WAAW,QAAQ,aAAa,WAAW,MAAM;AAAA,KACtE,GACF;AAEJ;AAEA,IAAM,+BAA+B;AAE9B,IAAM,sBAAsB,CACjC,cACA,mBACA,cACA,oBACG;AACH,QAAM,EAAE,iBAAiB,QAAQ,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,eAAe;AAAA,IAC3F,IAAI,OAAO;AAAA,IACX;AAAA,IACA,wBAAwB;AAAA,EAC1B,CAAC;AAED,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAkC,CAAC,CAAC;AACxF,QAAM,gCAAgC,OAA+B,IAAI;AACzE,QAAM,mBAAmB,OAAY;AAErC,QAAM,mBAAmB,MAAM;AArNjC;AAsNI,wCAA8B,YAA9B,mBAAuC;AACvC,kCAA8B,UAAU;AAAA,EAC1C;AAEA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,iDAAe;AAEf,qBAAiB;AAEjB,qBAAiB,UAAU;AAAA,MACzB,MAAM;AACJ,YAAI,CAAC,aAAa,OAAO,KAAK,QAAQ,2BAA2B,EAAE,WAAW,GAAG;AAC/E,wCAA8B,UAAU,IAAI,gBAAgB;AAC5D;AAAA,YACE;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MACA,mBAAmB,UAAU,IAAI,IAAI;AAAA,IACvC;AAEA,WAAO,MAAM;AACX,mBAAa,iBAAiB,OAAO;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,2BAA2B,CAAC;AAEnD,QAAM,cAAc,CAAO,mBAA2B;AACpD,qBAAiB;AACjB,0BAAsB,CAAC,CAAC;AACxB,uDAAkB;AAClB,UAAM,UAAmB;AAAA,MACvB,IAAI,OAAO;AAAA,MACX,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AACA,WAAO,OAAO;AACd,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["Messages","Input","ResponseButton"]}
@@ -1,6 +1,6 @@
1
1
  import { ButtonProps } from './props.js';
2
2
  import '@copilotkit/shared';
3
3
 
4
- declare const Button: ({ open, setOpen, pushToTalk, setPushToTalk }: ButtonProps) => JSX.Element;
4
+ declare const Button: ({ open, setOpen }: ButtonProps) => JSX.Element;
5
5
 
6
6
  export { Button };
@@ -33,7 +33,6 @@ __export(Button_exports, {
33
33
  Button: () => Button
34
34
  });
35
35
  module.exports = __toCommonJS(Button_exports);
36
- var import_react2 = require("react");
37
36
 
38
37
  // src/components/chat/ChatContext.tsx
39
38
  var import_react = __toESM(require("react"));
@@ -51,36 +50,9 @@ function useChatContext() {
51
50
 
52
51
  // src/components/chat/Button.tsx
53
52
  var import_jsx_runtime2 = require("react/jsx-runtime");
54
- var Button = ({ open, setOpen, pushToTalk, setPushToTalk }) => {
53
+ var Button = ({ open, setOpen }) => {
55
54
  const context = useChatContext();
56
- const timerRef = (0, import_react2.useRef)(null);
57
- const [isLongPress, setIsLongPress] = (0, import_react2.useState)(false);
58
- const handleMouseDown = () => {
59
- timerRef.current = setTimeout(() => {
60
- setPushToTalk(true);
61
- setIsLongPress(true);
62
- }, 500);
63
- };
64
- const handleMouseUp = () => {
65
- if (timerRef.current) {
66
- clearTimeout(timerRef.current);
67
- setPushToTalk(false);
68
- }
69
- };
70
- const handleClick = () => {
71
- if (!isLongPress) {
72
- setOpen(!open);
73
- } else {
74
- setIsLongPress(false);
75
- }
76
- };
77
- (0, import_react2.useEffect)(() => {
78
- document.addEventListener("mouseup", handleMouseUp);
79
- return () => {
80
- document.removeEventListener("mouseup", handleMouseUp);
81
- };
82
- }, []);
83
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { onClick: handleClick, onMouseDown: handleMouseDown, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
55
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
84
56
  "button",
85
57
  {
86
58
  className: `copilotKitButton ${open ? "open" : ""}`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/chat/Button.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { ButtonProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Button = ({ open, setOpen, pushToTalk, setPushToTalk }: ButtonProps) => {\n const context = useChatContext();\n const timerRef = useRef<NodeJS.Timeout | null>(null);\n const [isLongPress, setIsLongPress] = useState(false);\n\n const handleMouseDown = () => {\n timerRef.current = setTimeout(() => {\n setPushToTalk(true);\n setIsLongPress(true);\n }, 500); // 500ms for long press\n };\n\n const handleMouseUp = () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n setPushToTalk(false);\n }\n };\n\n const handleClick = () => {\n if (!isLongPress) {\n setOpen(!open);\n } else {\n setIsLongPress(false);\n }\n };\n\n // we want to handle the mouse up event event outside of the button component\n useEffect(() => {\n document.addEventListener(\"mouseup\", handleMouseUp);\n return () => {\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, []);\n\n return (\n <div onClick={handleClick} onMouseDown={handleMouseDown}>\n <button\n className={`copilotKitButton ${open ? \"open\" : \"\"}`}\n aria-label={open ? \"Close Chat\" : \"Open Chat\"}\n >\n <div className=\"copilotKitButtonIcon copilotKitButtonIconOpen\">\n {context.icons.openIcon}\n </div>\n <div className=\"copilotKitButtonIcon copilotKitButtonIconClose\">\n {context.icons.closeIcon}\n </div>\n </button>\n </div>\n );\n};\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\nimport { CopilotChatSuggestion, CopilotChatSuggestionConfiguration } from \"../../types/suggestions\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display while the chat GPT is \"thinking\".\n * @default \"Thinking...\"\n */\n thinking?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n addChatSuggestionConfiguration,\n removeChatSuggestionConfiguration,\n}: ChatContextProps) => {\n const context = {\n labels: {\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n thinking: \"Thinking...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n },\n ...labels,\n },\n\n icons: {\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n },\n icons,\n },\n open,\n setOpen,\n addChatSuggestionConfiguration,\n removeChatSuggestionConfiguration,\n };\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA4C;;;ACA5C,mBAAyC;AA2LhC;AAxEF,IAAM,cAAc,aAAAC,QAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,aAAAA,QAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ADpFM,IAAAC,sBAAA;AArCC,IAAM,SAAS,CAAC,EAAE,MAAM,SAAS,YAAY,cAAc,MAAmB;AACnF,QAAM,UAAU,eAAe;AAC/B,QAAM,eAAW,sBAA8B,IAAI;AACnD,QAAM,CAAC,aAAa,cAAc,QAAI,wBAAS,KAAK;AAEpD,QAAM,kBAAkB,MAAM;AAC5B,aAAS,UAAU,WAAW,MAAM;AAClC,oBAAc,IAAI;AAClB,qBAAe,IAAI;AAAA,IACrB,GAAG,GAAG;AAAA,EACR;AAEA,QAAM,gBAAgB,MAAM;AAC1B,QAAI,SAAS,SAAS;AACpB,mBAAa,SAAS,OAAO;AAC7B,oBAAc,KAAK;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,cAAc,MAAM;AACxB,QAAI,CAAC,aAAa;AAChB,cAAQ,CAAC,IAAI;AAAA,IACf,OAAO;AACL,qBAAe,KAAK;AAAA,IACtB;AAAA,EACF;AAGA,+BAAU,MAAM;AACd,aAAS,iBAAiB,WAAW,aAAa;AAClD,WAAO,MAAM;AACX,eAAS,oBAAoB,WAAW,aAAa;AAAA,IACvD;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SACE,6CAAC,SAAI,SAAS,aAAa,aAAa,iBACtC;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,oBAAoB,OAAO,SAAS;AAAA,MAC/C,cAAY,OAAO,eAAe;AAAA,MAElC;AAAA,qDAAC,SAAI,WAAU,iDACZ,kBAAQ,MAAM,UACjB;AAAA,QACA,6CAAC,SAAI,WAAU,kDACZ,kBAAQ,MAAM,WACjB;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":["import_react","React","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../src/components/chat/Button.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import { ButtonProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Button = ({ open, setOpen }: ButtonProps) => {\n const context = useChatContext();\n\n return (\n <div onClick={() => setOpen(!open)}>\n <button\n className={`copilotKitButton ${open ? \"open\" : \"\"}`}\n aria-label={open ? \"Close Chat\" : \"Open Chat\"}\n >\n <div className=\"copilotKitButtonIcon copilotKitButtonIconOpen\">\n {context.icons.openIcon}\n </div>\n <div className=\"copilotKitButtonIcon copilotKitButtonIconClose\">\n {context.icons.closeIcon}\n </div>\n </button>\n </div>\n );\n};\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const context = {\n labels: {\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n },\n ...labels,\n },\n\n icons: {\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.PushToTalkIcon,\n },\n icons,\n },\n open,\n setOpen,\n };\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AA6KhC;AA/DF,IAAM,cAAc,aAAAA,QAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,aAAAA,QAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ADhHM,IAAAC,sBAAA;AALC,IAAM,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAmB;AACxD,QAAM,UAAU,eAAe;AAE/B,SACE,6CAAC,SAAI,SAAS,MAAM,QAAQ,CAAC,IAAI,GAC/B;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,oBAAoB,OAAO,SAAS;AAAA,MAC/C,cAAY,OAAO,eAAe;AAAA,MAElC;AAAA,qDAAC,SAAI,WAAU,iDACZ,kBAAQ,MAAM,UACjB;AAAA,QACA,6CAAC,SAAI,WAAU,kDACZ,kBAAQ,MAAM,WACjB;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;","names":["React","import_jsx_runtime"]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Button
3
- } from "../../chunk-5ASYNEHX.mjs";
4
- import "../../chunk-KZME7C5S.mjs";
5
- import "../../chunk-FWTPMPSN.mjs";
6
- import "../../chunk-SKC7AJIV.mjs";
3
+ } from "../../chunk-RT2XG2T7.mjs";
4
+ import "../../chunk-VUZA5AFH.mjs";
5
+ import "../../chunk-FZC7X5PK.mjs";
6
+ import "../../chunk-MRXNTQOX.mjs";
7
7
  export {
8
8
  Button
9
9
  };
@@ -1,9 +1,55 @@
1
- import React from 'react';
2
1
  import { CopilotChatIcons, CopilotChatLabels } from './ChatContext.js';
2
+ import React__default from 'react';
3
3
  import { SystemMessageFunction } from '@copilotkit/react-core';
4
- import { WindowProps, ButtonProps, HeaderProps, MessagesProps, InputProps, ResponseButtonProps } from './props.js';
5
- import '../../types/suggestions.js';
6
- import '@copilotkit/shared';
4
+ import { CopilotChatSuggestion } from '../../types/suggestions.js';
5
+ import { Message } from '@copilotkit/shared';
6
+ import { MessagesProps, InputProps, ResponseButtonProps } from './props.js';
7
+
8
+ /**
9
+ * An embeddable chat panel for CopilotKit.
10
+ *
11
+ * <img src="/images/CopilotChat/CopilotChat.gif" width="500" />
12
+ *
13
+ * A chatbot panel component for the CopilotKit framework. The component allows for a high degree
14
+ * of customization through various props and custom CSS.
15
+ *
16
+ * <RequestExample>
17
+ * ```jsx CopilotChat Example
18
+ * import { CopilotChat } from "@copilotkit/react-ui";
19
+ *
20
+ * <CopilotChat
21
+ * labels={{
22
+ * title: "Your Assistant",
23
+ * initial: "Hi! 👋 How can I assist you today?",
24
+ * }}
25
+ * />
26
+ * ```
27
+ * </RequestExample>
28
+ *
29
+ * ## Custom CSS
30
+ *
31
+ * You can customize the colors of the panel by overriding the CSS variables
32
+ * defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).
33
+ *
34
+ * For example, to set the primary color to purple:
35
+ *
36
+ * ```jsx
37
+ * <div style={{ "--copilot-kit-primary-color": "#7D5BA6" }}>
38
+ * <CopilotPopup />
39
+ * </div>
40
+ * ```
41
+ *
42
+ * To further customize the panel, you can override the CSS classes defined
43
+ * [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).
44
+ *
45
+ * For example:
46
+ *
47
+ * ```css
48
+ * .copilotKitButton {
49
+ * border-radius: 0;
50
+ * }
51
+ * ```
52
+ */
7
53
 
8
54
  /**
9
55
  * Props for CopilotChat component.
@@ -18,25 +64,6 @@ interface CopilotChatProps {
18
64
  * user's needs or the application's requirements.
19
65
  */
20
66
  instructions?: string;
21
- /**
22
- * Whether the chat window should be open by default.
23
- * @default false
24
- */
25
- defaultOpen?: boolean;
26
- /**
27
- * If the chat window should close when the user clicks outside of it.
28
- * @default true
29
- */
30
- clickOutsideToClose?: boolean;
31
- /**
32
- * If the chat window should close when the user hits the Escape key.
33
- * @default true
34
- */
35
- hitEscapeToClose?: boolean;
36
- /**
37
- * A callback that gets called when the chat window opens or closes.
38
- */
39
- onSetOpen?: (open: boolean) => void;
40
67
  /**
41
68
  * A callback that gets called when the in progress state changes.
42
69
  */
@@ -45,12 +72,6 @@ interface CopilotChatProps {
45
72
  * A callback that gets called when a new message it submitted.
46
73
  */
47
74
  onSubmitMessage?: (message: string) => void;
48
- /**
49
- * The shortcut key to open the chat window.
50
- * Uses Command-[shortcut] on a Mac and Ctrl-[shortcut] on Windows.
51
- * @default "/"
52
- */
53
- shortcut?: string;
54
75
  /**
55
76
  * Icons can be used to set custom icons for the chat window.
56
77
  */
@@ -71,30 +92,18 @@ interface CopilotChatProps {
71
92
  * @default true
72
93
  */
73
94
  showResponseButton?: boolean;
74
- /**
75
- * A custom Window component to use instead of the default.
76
- */
77
- Window?: React.ComponentType<WindowProps>;
78
- /**
79
- * A custom Button component to use instead of the default.
80
- */
81
- Button?: React.ComponentType<ButtonProps>;
82
- /**
83
- * A custom Header component to use instead of the default.
84
- */
85
- Header?: React.ComponentType<HeaderProps>;
86
95
  /**
87
96
  * A custom Messages component to use instead of the default.
88
97
  */
89
- Messages?: React.ComponentType<MessagesProps>;
98
+ Messages?: React__default.ComponentType<MessagesProps>;
90
99
  /**
91
100
  * A custom Input component to use instead of the default.
92
101
  */
93
- Input?: React.ComponentType<InputProps>;
102
+ Input?: React__default.ComponentType<InputProps>;
94
103
  /**
95
104
  * A custom ResponseButton component to use instead of the default.
96
105
  */
97
- ResponseButton?: React.ComponentType<ResponseButtonProps>;
106
+ ResponseButton?: React__default.ComponentType<ResponseButtonProps>;
98
107
  /**
99
108
  * A class name to apply to the root element.
100
109
  */
@@ -102,8 +111,18 @@ interface CopilotChatProps {
102
111
  /**
103
112
  * Children to render.
104
113
  */
105
- children?: React.ReactNode;
114
+ children?: React__default.ReactNode;
106
115
  }
107
- declare const CopilotChat: ({ instructions, defaultOpen, clickOutsideToClose, hitEscapeToClose, onSetOpen, onSubmitMessage, shortcut, icons, labels, makeSystemMessage, showResponseButton, onInProgress, Window, Button, Header, Messages, Input, ResponseButton, className, children, }: CopilotChatProps) => JSX.Element;
116
+ declare function CopilotChat({ instructions, onSubmitMessage, icons, labels, makeSystemMessage, showResponseButton, onInProgress, Messages, Input, ResponseButton, className, }: CopilotChatProps): JSX.Element;
117
+ declare const useCopilotChatLogic: (instructions?: string, makeSystemMessage?: SystemMessageFunction, onInProgress?: ((isLoading: boolean) => void) | undefined, onSubmitMessage?: ((messageContent: string) => void) | undefined) => {
118
+ visibleMessages: Message[];
119
+ isLoading: boolean;
120
+ currentSuggestions: CopilotChatSuggestion[];
121
+ sendMessage: (messageContent: string) => Promise<Message>;
122
+ stop: () => void;
123
+ reload: () => Promise<void>;
124
+ input: string;
125
+ setInput: React__default.Dispatch<React__default.SetStateAction<string>>;
126
+ };
108
127
 
109
- export { CopilotChat, CopilotChatProps };
128
+ export { CopilotChat, CopilotChatProps, useCopilotChatLogic };