@copilotkit/react-ui 0.0.0-0.0.0-max-changeset-10101010101010-20260109191632
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 +17415 -0
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/dist/chunk-3W6J75HS.mjs +126 -0
- package/dist/chunk-3W6J75HS.mjs.map +1 -0
- package/dist/chunk-54JAUBUJ.mjs +26 -0
- package/dist/chunk-54JAUBUJ.mjs.map +1 -0
- package/dist/chunk-7OURDQZJ.mjs +133 -0
- package/dist/chunk-7OURDQZJ.mjs.map +1 -0
- package/dist/chunk-7PR2KJDO.mjs +222 -0
- package/dist/chunk-7PR2KJDO.mjs.map +1 -0
- package/dist/chunk-BH6PCAAL.mjs +81 -0
- package/dist/chunk-BH6PCAAL.mjs.map +1 -0
- package/dist/chunk-C3GSYRC3.mjs +118 -0
- package/dist/chunk-C3GSYRC3.mjs.map +1 -0
- package/dist/chunk-DBKRAOH7.mjs +34 -0
- package/dist/chunk-DBKRAOH7.mjs.map +1 -0
- package/dist/chunk-EFZPSZWO.mjs +1 -0
- package/dist/chunk-EFZPSZWO.mjs.map +1 -0
- package/dist/chunk-ELGRNEAO.mjs +32 -0
- package/dist/chunk-ELGRNEAO.mjs.map +1 -0
- package/dist/chunk-ELUJRANC.mjs +21 -0
- package/dist/chunk-ELUJRANC.mjs.map +1 -0
- package/dist/chunk-FFJHOZX6.mjs +202 -0
- package/dist/chunk-FFJHOZX6.mjs.map +1 -0
- package/dist/chunk-GDSZGYCE.mjs +32 -0
- package/dist/chunk-GDSZGYCE.mjs.map +1 -0
- package/dist/chunk-HIW7RXCD.mjs +184 -0
- package/dist/chunk-HIW7RXCD.mjs.map +1 -0
- package/dist/chunk-IEMQ2SQW.mjs +93 -0
- package/dist/chunk-IEMQ2SQW.mjs.map +1 -0
- package/dist/chunk-IHFR6PYG.mjs +116 -0
- package/dist/chunk-IHFR6PYG.mjs.map +1 -0
- package/dist/chunk-IK2BPURM.mjs +400 -0
- package/dist/chunk-IK2BPURM.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +1 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-JGMFJZMG.mjs +11 -0
- package/dist/chunk-JGMFJZMG.mjs.map +1 -0
- package/dist/chunk-JY2CSDKN.mjs +135 -0
- package/dist/chunk-JY2CSDKN.mjs.map +1 -0
- package/dist/chunk-JZ3RFQQ6.mjs +128 -0
- package/dist/chunk-JZ3RFQQ6.mjs.map +1 -0
- package/dist/chunk-KXE2JCUH.mjs +1 -0
- package/dist/chunk-KXE2JCUH.mjs.map +1 -0
- package/dist/chunk-LQEFRHRT.mjs +30 -0
- package/dist/chunk-LQEFRHRT.mjs.map +1 -0
- package/dist/chunk-MMVDU6DF.mjs +1 -0
- package/dist/chunk-MMVDU6DF.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +59 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-NCIAFFQ2.mjs +82 -0
- package/dist/chunk-NCIAFFQ2.mjs.map +1 -0
- package/dist/chunk-NGJ32FAP.mjs +30 -0
- package/dist/chunk-NGJ32FAP.mjs.map +1 -0
- package/dist/chunk-NRA3CFEE.mjs +97 -0
- package/dist/chunk-NRA3CFEE.mjs.map +1 -0
- package/dist/chunk-O72ZB5V3.mjs +140 -0
- package/dist/chunk-O72ZB5V3.mjs.map +1 -0
- package/dist/chunk-PLHTVHUW.mjs +82 -0
- package/dist/chunk-PLHTVHUW.mjs.map +1 -0
- package/dist/chunk-Q5V6S67N.mjs +103 -0
- package/dist/chunk-Q5V6S67N.mjs.map +1 -0
- package/dist/chunk-QB3GUN2N.mjs +31 -0
- package/dist/chunk-QB3GUN2N.mjs.map +1 -0
- package/dist/chunk-QIOJXTIQ.mjs +64 -0
- package/dist/chunk-QIOJXTIQ.mjs.map +1 -0
- package/dist/chunk-QPQRLXN3.mjs +435 -0
- package/dist/chunk-QPQRLXN3.mjs.map +1 -0
- package/dist/chunk-RYUCX3ZK.mjs +32 -0
- package/dist/chunk-RYUCX3ZK.mjs.map +1 -0
- package/dist/chunk-SC6JRFAJ.mjs +1 -0
- package/dist/chunk-SC6JRFAJ.mjs.map +1 -0
- package/dist/chunk-T26KLXLH.mjs +1 -0
- package/dist/chunk-T26KLXLH.mjs.map +1 -0
- package/dist/chunk-UFN2VWSR.mjs +25 -0
- package/dist/chunk-UFN2VWSR.mjs.map +1 -0
- package/dist/chunk-V7W6IM2V.mjs +1 -0
- package/dist/chunk-V7W6IM2V.mjs.map +1 -0
- package/dist/chunk-WB3YULQ4.mjs +1 -0
- package/dist/chunk-WB3YULQ4.mjs.map +1 -0
- package/dist/chunk-XWG3L6QC.mjs +258 -0
- package/dist/chunk-XWG3L6QC.mjs.map +1 -0
- package/dist/chunk-Y4FKRAKJ.mjs +12 -0
- package/dist/chunk-Y4FKRAKJ.mjs.map +1 -0
- package/dist/components/chat/Button.d.ts +9 -0
- package/dist/components/chat/Button.js +71 -0
- package/dist/components/chat/Button.js.map +1 -0
- package/dist/components/chat/Button.mjs +10 -0
- package/dist/components/chat/Button.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +204 -0
- package/dist/components/chat/Chat.js +2270 -0
- package/dist/components/chat/Chat.js.map +1 -0
- package/dist/components/chat/Chat.mjs +29 -0
- package/dist/components/chat/Chat.mjs.map +1 -0
- package/dist/components/chat/ChatContext.d.ts +145 -0
- package/dist/components/chat/ChatContext.js +329 -0
- package/dist/components/chat/ChatContext.js.map +1 -0
- package/dist/components/chat/ChatContext.mjs +13 -0
- package/dist/components/chat/ChatContext.mjs.map +1 -0
- package/dist/components/chat/CodeBlock.d.ts +14 -0
- package/dist/components/chat/CodeBlock.js +510 -0
- package/dist/components/chat/CodeBlock.js.map +1 -0
- package/dist/components/chat/CodeBlock.mjs +14 -0
- package/dist/components/chat/CodeBlock.mjs.map +1 -0
- package/dist/components/chat/Header.d.ts +9 -0
- package/dist/components/chat/Header.js +582 -0
- package/dist/components/chat/Header.js.map +1 -0
- package/dist/components/chat/Header.mjs +17 -0
- package/dist/components/chat/Header.mjs.map +1 -0
- package/dist/components/chat/Icons.d.ts +20 -0
- package/dist/components/chat/Icons.js +297 -0
- package/dist/components/chat/Icons.js.map +1 -0
- package/dist/components/chat/Icons.mjs +38 -0
- package/dist/components/chat/Icons.mjs.map +1 -0
- package/dist/components/chat/ImageUploadQueue.d.ts +13 -0
- package/dist/components/chat/ImageUploadQueue.js +106 -0
- package/dist/components/chat/ImageUploadQueue.js.map +1 -0
- package/dist/components/chat/ImageUploadQueue.mjs +8 -0
- package/dist/components/chat/ImageUploadQueue.mjs.map +1 -0
- package/dist/components/chat/Input.d.ts +9 -0
- package/dist/components/chat/Input.js +396 -0
- package/dist/components/chat/Input.js.map +1 -0
- package/dist/components/chat/Input.mjs +14 -0
- package/dist/components/chat/Input.mjs.map +1 -0
- package/dist/components/chat/Markdown.d.ts +10 -0
- package/dist/components/chat/Markdown.js +652 -0
- package/dist/components/chat/Markdown.js.map +1 -0
- package/dist/components/chat/Markdown.mjs +11 -0
- package/dist/components/chat/Markdown.mjs.map +1 -0
- package/dist/components/chat/Messages.d.ts +13 -0
- package/dist/components/chat/Messages.js +1195 -0
- package/dist/components/chat/Messages.js.map +1 -0
- package/dist/components/chat/Messages.mjs +20 -0
- package/dist/components/chat/Messages.mjs.map +1 -0
- package/dist/components/chat/Modal.d.ts +51 -0
- package/dist/components/chat/Modal.js +3075 -0
- package/dist/components/chat/Modal.js.map +1 -0
- package/dist/components/chat/Modal.mjs +38 -0
- package/dist/components/chat/Modal.mjs.map +1 -0
- package/dist/components/chat/Popup.d.ts +13 -0
- package/dist/components/chat/Popup.js +3086 -0
- package/dist/components/chat/Popup.js.map +1 -0
- package/dist/components/chat/Popup.mjs +39 -0
- package/dist/components/chat/Popup.mjs.map +1 -0
- package/dist/components/chat/PoweredByTag.d.ts +7 -0
- package/dist/components/chat/PoweredByTag.js +61 -0
- package/dist/components/chat/PoweredByTag.js.map +1 -0
- package/dist/components/chat/PoweredByTag.mjs +9 -0
- package/dist/components/chat/PoweredByTag.mjs.map +1 -0
- package/dist/components/chat/Sidebar.d.ts +13 -0
- package/dist/components/chat/Sidebar.js +3095 -0
- package/dist/components/chat/Sidebar.js.map +1 -0
- package/dist/components/chat/Sidebar.mjs +39 -0
- package/dist/components/chat/Sidebar.mjs.map +1 -0
- package/dist/components/chat/Suggestion.d.ts +12 -0
- package/dist/components/chat/Suggestion.js +56 -0
- package/dist/components/chat/Suggestion.js.map +1 -0
- package/dist/components/chat/Suggestion.mjs +9 -0
- package/dist/components/chat/Suggestion.mjs.map +1 -0
- package/dist/components/chat/Suggestions.d.ts +9 -0
- package/dist/components/chat/Suggestions.js +81 -0
- package/dist/components/chat/Suggestions.js.map +1 -0
- package/dist/components/chat/Suggestions.mjs +10 -0
- package/dist/components/chat/Suggestions.mjs.map +1 -0
- package/dist/components/chat/Textarea.d.ts +15 -0
- package/dist/components/chat/Textarea.js +84 -0
- package/dist/components/chat/Textarea.js.map +1 -0
- package/dist/components/chat/Textarea.mjs +8 -0
- package/dist/components/chat/Textarea.mjs.map +1 -0
- package/dist/components/chat/Window.d.ts +9 -0
- package/dist/components/chat/Window.js +164 -0
- package/dist/components/chat/Window.js.map +1 -0
- package/dist/components/chat/Window.mjs +10 -0
- package/dist/components/chat/Window.mjs.map +1 -0
- package/dist/components/chat/index.d.ts +18 -0
- package/dist/components/chat/index.js +3122 -0
- package/dist/components/chat/index.js.map +1 -0
- package/dist/components/chat/index.mjs +69 -0
- package/dist/components/chat/index.mjs.map +1 -0
- package/dist/components/chat/messages/AssistantMessage.d.ts +9 -0
- package/dist/components/chat/messages/AssistantMessage.js +775 -0
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -0
- package/dist/components/chat/messages/AssistantMessage.mjs +13 -0
- package/dist/components/chat/messages/AssistantMessage.mjs.map +1 -0
- package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
- package/dist/components/chat/messages/ErrorMessage.js +722 -0
- package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
- package/dist/components/chat/messages/ErrorMessage.mjs +66 -0
- package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
- package/dist/components/chat/messages/ImageRenderer.d.ts +12 -0
- package/dist/components/chat/messages/ImageRenderer.js +58 -0
- package/dist/components/chat/messages/ImageRenderer.js.map +1 -0
- package/dist/components/chat/messages/ImageRenderer.mjs +8 -0
- package/dist/components/chat/messages/ImageRenderer.mjs.map +1 -0
- package/dist/components/chat/messages/LegacyRenderMessage.d.ts +28 -0
- package/dist/components/chat/messages/LegacyRenderMessage.js +1023 -0
- package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -0
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +17 -0
- package/dist/components/chat/messages/LegacyRenderMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderMessage.d.ts +9 -0
- package/dist/components/chat/messages/RenderMessage.js +898 -0
- package/dist/components/chat/messages/RenderMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderMessage.mjs +16 -0
- package/dist/components/chat/messages/RenderMessage.mjs.map +1 -0
- package/dist/components/chat/messages/UserMessage.d.ts +9 -0
- package/dist/components/chat/messages/UserMessage.js +56 -0
- package/dist/components/chat/messages/UserMessage.js.map +1 -0
- package/dist/components/chat/messages/UserMessage.mjs +8 -0
- package/dist/components/chat/messages/UserMessage.mjs.map +1 -0
- package/dist/components/chat/props.d.ts +298 -0
- package/dist/components/chat/props.js +19 -0
- package/dist/components/chat/props.js.map +1 -0
- package/dist/components/chat/props.mjs +2 -0
- package/dist/components/chat/props.mjs.map +1 -0
- package/dist/components/dev-console/console.d.ts +11 -0
- package/dist/components/dev-console/console.js +537 -0
- package/dist/components/dev-console/console.js.map +1 -0
- package/dist/components/dev-console/console.mjs +17 -0
- package/dist/components/dev-console/console.mjs.map +1 -0
- package/dist/components/dev-console/icons.d.ts +9 -0
- package/dist/components/dev-console/icons.js +131 -0
- package/dist/components/dev-console/icons.js.map +1 -0
- package/dist/components/dev-console/icons.mjs +16 -0
- package/dist/components/dev-console/icons.mjs.map +1 -0
- package/dist/components/dev-console/index.d.ts +3 -0
- package/dist/components/dev-console/index.js +537 -0
- package/dist/components/dev-console/index.js.map +1 -0
- package/dist/components/dev-console/index.mjs +18 -0
- package/dist/components/dev-console/index.mjs.map +1 -0
- package/dist/components/dev-console/types.d.ts +9 -0
- package/dist/components/dev-console/types.js +19 -0
- package/dist/components/dev-console/types.js.map +1 -0
- package/dist/components/dev-console/types.mjs +1 -0
- package/dist/components/dev-console/types.mjs.map +1 -0
- package/dist/components/dev-console/utils.d.ts +10 -0
- package/dist/components/dev-console/utils.js +177 -0
- package/dist/components/dev-console/utils.js.map +1 -0
- package/dist/components/dev-console/utils.mjs +16 -0
- package/dist/components/dev-console/utils.mjs.map +1 -0
- package/dist/components/help-modal/icons.d.ts +9 -0
- package/dist/components/help-modal/icons.js +107 -0
- package/dist/components/help-modal/icons.js.map +1 -0
- package/dist/components/help-modal/icons.mjs +12 -0
- package/dist/components/help-modal/icons.mjs.map +1 -0
- package/dist/components/help-modal/index.d.ts +2 -0
- package/dist/components/help-modal/index.js +137 -0
- package/dist/components/help-modal/index.js.map +1 -0
- package/dist/components/help-modal/index.mjs +10 -0
- package/dist/components/help-modal/index.mjs.map +1 -0
- package/dist/components/help-modal/modal.d.ts +5 -0
- package/dist/components/help-modal/modal.js +135 -0
- package/dist/components/help-modal/modal.js.map +1 -0
- package/dist/components/help-modal/modal.mjs +9 -0
- package/dist/components/help-modal/modal.mjs.map +1 -0
- package/dist/components/index.d.ts +19 -0
- package/dist/components/index.js +3126 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +76 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +19 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/index.mjs +2 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +36 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +9 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +66 -0
- package/dist/hooks/use-copilot-chat-suggestions.js +34 -0
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
- package/dist/hooks/use-copy-to-clipboard.js +60 -0
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.mjs +8 -0
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
- package/dist/hooks/use-dark-mode.d.ts +3 -0
- package/dist/hooks/use-dark-mode.js +35 -0
- package/dist/hooks/use-dark-mode.js.map +1 -0
- package/dist/hooks/use-dark-mode.mjs +8 -0
- package/dist/hooks/use-dark-mode.mjs.map +1 -0
- package/dist/hooks/use-push-to-talk.d.ts +19 -0
- package/dist/hooks/use-push-to-talk.js +195 -0
- package/dist/hooks/use-push-to-talk.js.map +1 -0
- package/dist/hooks/use-push-to-talk.mjs +12 -0
- package/dist/hooks/use-push-to-talk.mjs.map +1 -0
- package/dist/index.css +1258 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +3135 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +84 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.js +76 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +34 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/types/css.d.ts +22 -0
- package/dist/types/css.js +19 -0
- package/dist/types/css.js.map +1 -0
- package/dist/types/css.mjs +1 -0
- package/dist/types/css.mjs.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/suggestions.d.ts +9 -0
- package/dist/types/suggestions.js +19 -0
- package/dist/types/suggestions.js.map +1 -0
- package/dist/types/suggestions.mjs +1 -0
- package/dist/types/suggestions.mjs.map +1 -0
- package/dist/v2/index.css +4 -0
- package/dist/v2/index.css.map +1 -0
- package/dist/v2/index.d.ts +2 -0
- package/dist/v2/index.js +2 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/index.mjs +2 -0
- package/dist/v2/index.mjs.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +83 -0
- package/postcss.config.js +60 -0
- package/src/components/chat/Button.tsx +18 -0
- package/src/components/chat/Chat.tsx +795 -0
- package/src/components/chat/ChatContext.tsx +248 -0
- package/src/components/chat/CodeBlock.tsx +418 -0
- package/src/components/chat/Header.tsx +24 -0
- package/src/components/chat/Icons.tsx +237 -0
- package/src/components/chat/ImageUploadQueue.tsx +77 -0
- package/src/components/chat/Input.tsx +156 -0
- package/src/components/chat/Markdown.tsx +144 -0
- package/src/components/chat/Messages.tsx +206 -0
- package/src/components/chat/Modal.tsx +220 -0
- package/src/components/chat/Popup.tsx +77 -0
- package/src/components/chat/PoweredByTag.tsx +42 -0
- package/src/components/chat/Sidebar.tsx +96 -0
- package/src/components/chat/Suggestion.tsx +29 -0
- package/src/components/chat/Suggestions.tsx +23 -0
- package/src/components/chat/Textarea.tsx +77 -0
- package/src/components/chat/Window.tsx +152 -0
- package/src/components/chat/index.tsx +11 -0
- package/src/components/chat/messages/AssistantMessage.tsx +118 -0
- package/src/components/chat/messages/ErrorMessage.tsx +59 -0
- package/src/components/chat/messages/ImageRenderer.tsx +37 -0
- package/src/components/chat/messages/LegacyRenderMessage.tsx +150 -0
- package/src/components/chat/messages/RenderMessage.tsx +61 -0
- package/src/components/chat/messages/UserMessage.tsx +46 -0
- package/src/components/chat/props.ts +353 -0
- package/src/components/dev-console/console.tsx +242 -0
- package/src/components/dev-console/icons.tsx +99 -0
- package/src/components/dev-console/index.tsx +2 -0
- package/src/components/dev-console/types.ts +7 -0
- package/src/components/dev-console/utils.ts +142 -0
- package/src/components/help-modal/icons.tsx +68 -0
- package/src/components/help-modal/index.tsx +1 -0
- package/src/components/help-modal/modal.tsx +101 -0
- package/src/components/index.ts +2 -0
- package/src/context/index.ts +1 -0
- package/src/css/animations.css +35 -0
- package/src/css/button.css +67 -0
- package/src/css/colors.css +78 -0
- package/src/css/console.css +166 -0
- package/src/css/crew.css +277 -0
- package/src/css/header.css +65 -0
- package/src/css/input.css +152 -0
- package/src/css/markdown.css +150 -0
- package/src/css/messages.css +244 -0
- package/src/css/panel.css +39 -0
- package/src/css/popup.css +22 -0
- package/src/css/sidebar.css +34 -0
- package/src/css/suggestions.css +43 -0
- package/src/css/window.css +60 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-copilot-chat-suggestions.tsx +71 -0
- package/src/hooks/use-copy-to-clipboard.tsx +29 -0
- package/src/hooks/use-dark-mode.ts +10 -0
- package/src/hooks/use-push-to-talk.tsx +167 -0
- package/src/index.tsx +7 -0
- package/src/lib/utils.test.ts +7 -0
- package/src/lib/utils.ts +27 -0
- package/src/styles.css +14 -0
- package/src/types/css.ts +21 -0
- package/src/types/index.ts +2 -0
- package/src/types/suggestions.ts +7 -0
- package/src/v2/index.ts +1 -0
- package/src/v2/styles.css +1 -0
- package/tailwind.config.js +7 -0
- package/tsconfig.json +12 -0
- package/tsup.config.ts +11 -0
- package/typedoc.json +4 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const OpenIcon = (
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
fill="currentColor"
|
|
8
|
+
width="24"
|
|
9
|
+
height="24"
|
|
10
|
+
>
|
|
11
|
+
<g transform="translate(24, 0) scale(-1, 1)">
|
|
12
|
+
<path
|
|
13
|
+
fillRule="evenodd"
|
|
14
|
+
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"
|
|
15
|
+
clipRule="evenodd"
|
|
16
|
+
/>
|
|
17
|
+
</g>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const CloseIcon = (
|
|
22
|
+
<svg
|
|
23
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
24
|
+
fill="none"
|
|
25
|
+
viewBox="0 0 24 24"
|
|
26
|
+
strokeWidth="1.5"
|
|
27
|
+
stroke="currentColor"
|
|
28
|
+
width="24"
|
|
29
|
+
height="24"
|
|
30
|
+
>
|
|
31
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
|
|
32
|
+
</svg>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const HeaderCloseIcon = (
|
|
36
|
+
<svg
|
|
37
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
38
|
+
fill="none"
|
|
39
|
+
viewBox="0 0 24 24"
|
|
40
|
+
strokeWidth="1.5"
|
|
41
|
+
stroke="currentColor"
|
|
42
|
+
width="24"
|
|
43
|
+
height="24"
|
|
44
|
+
>
|
|
45
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
|
|
46
|
+
</svg>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export const SendIcon = (
|
|
50
|
+
<svg
|
|
51
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
52
|
+
fill="none"
|
|
53
|
+
viewBox="0 0 24 24"
|
|
54
|
+
strokeWidth="1.5"
|
|
55
|
+
stroke="currentColor"
|
|
56
|
+
width="24"
|
|
57
|
+
height="24"
|
|
58
|
+
>
|
|
59
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M12 19V5m0 0l-7 7m7-7l7 7" />
|
|
60
|
+
</svg>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export const MicrophoneIcon = (
|
|
64
|
+
<svg
|
|
65
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
66
|
+
fill="none"
|
|
67
|
+
viewBox="0 0 24 24"
|
|
68
|
+
strokeWidth="1.5"
|
|
69
|
+
stroke="currentColor"
|
|
70
|
+
width="24"
|
|
71
|
+
height="24"
|
|
72
|
+
>
|
|
73
|
+
<path
|
|
74
|
+
strokeLinecap="round"
|
|
75
|
+
strokeLinejoin="round"
|
|
76
|
+
d="M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z"
|
|
77
|
+
/>
|
|
78
|
+
</svg>
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
export const StopIcon = (
|
|
82
|
+
<svg
|
|
83
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
84
|
+
fill="none"
|
|
85
|
+
viewBox="0 0 24 24"
|
|
86
|
+
strokeWidth="1.5"
|
|
87
|
+
stroke="currentColor"
|
|
88
|
+
width="24"
|
|
89
|
+
height="24"
|
|
90
|
+
>
|
|
91
|
+
<path
|
|
92
|
+
strokeLinecap="round"
|
|
93
|
+
strokeLinejoin="round"
|
|
94
|
+
d="M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"
|
|
95
|
+
/>
|
|
96
|
+
</svg>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
export const RegenerateIcon = (
|
|
100
|
+
<svg
|
|
101
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
102
|
+
fill="none"
|
|
103
|
+
viewBox="0 0 24 24"
|
|
104
|
+
strokeWidth="2"
|
|
105
|
+
stroke="currentColor"
|
|
106
|
+
width="16"
|
|
107
|
+
height="16"
|
|
108
|
+
style={{ minWidth: "16px", minHeight: "16px" }}
|
|
109
|
+
>
|
|
110
|
+
<path
|
|
111
|
+
strokeLinecap="round"
|
|
112
|
+
strokeLinejoin="round"
|
|
113
|
+
d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"
|
|
114
|
+
/>
|
|
115
|
+
</svg>
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
export const CopyIcon = (
|
|
119
|
+
<svg
|
|
120
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
121
|
+
fill="none"
|
|
122
|
+
viewBox="0 0 24 24"
|
|
123
|
+
strokeWidth="2"
|
|
124
|
+
stroke="currentColor"
|
|
125
|
+
width="16"
|
|
126
|
+
height="16"
|
|
127
|
+
style={{ minWidth: "16px", minHeight: "16px" }}
|
|
128
|
+
>
|
|
129
|
+
<path
|
|
130
|
+
strokeLinecap="round"
|
|
131
|
+
strokeLinejoin="round"
|
|
132
|
+
d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75"
|
|
133
|
+
/>
|
|
134
|
+
</svg>
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
export const SmallSpinnerIcon = (
|
|
138
|
+
<span className="copilotKitSpinner" style={{ width: "13px", height: "13px" }}></span>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
export const SpinnerIcon = (
|
|
142
|
+
<span className="copilotKitSpinner" style={{ width: "24px", height: "24px" }}></span>
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
export const ActivityIcon = (
|
|
146
|
+
<div style={{ display: "flex", alignItems: "center", gap: "4px" }}>
|
|
147
|
+
<span className="copilotKitActivityDot" style={{ animationDelay: "0s" }}></span>
|
|
148
|
+
<span className="copilotKitActivityDot" style={{ animationDelay: "0.2s" }}></span>
|
|
149
|
+
<span className="copilotKitActivityDot" style={{ animationDelay: "0.4s" }}></span>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
export const ThumbsUpIcon = (
|
|
154
|
+
<svg
|
|
155
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
156
|
+
fill="none"
|
|
157
|
+
viewBox="0 0 24 24"
|
|
158
|
+
strokeWidth="2"
|
|
159
|
+
stroke="currentColor"
|
|
160
|
+
width="16"
|
|
161
|
+
height="16"
|
|
162
|
+
style={{ minWidth: "16px", minHeight: "16px" }}
|
|
163
|
+
>
|
|
164
|
+
<path
|
|
165
|
+
strokeLinecap="round"
|
|
166
|
+
strokeLinejoin="round"
|
|
167
|
+
d="M6.633 10.5c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 012.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 00.322-1.672V3a.75.75 0 01.75-.75A2.25 2.25 0 0116.5 4.5c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 01-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 00-1.423-.23H5.904M14.25 9h2.25M5.904 18.75c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 01-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 10.203 4.167 9.75 5 9.75h1.053c.472 0 .745.556.5.96a8.958 8.958 0 00-1.302 4.665c0 1.194.232 2.333.654 3.375z"
|
|
168
|
+
/>
|
|
169
|
+
</svg>
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
export const ThumbsDownIcon = (
|
|
173
|
+
<svg
|
|
174
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
175
|
+
fill="none"
|
|
176
|
+
viewBox="0 0 24 24"
|
|
177
|
+
strokeWidth="2"
|
|
178
|
+
stroke="currentColor"
|
|
179
|
+
width="16"
|
|
180
|
+
height="16"
|
|
181
|
+
style={{ minWidth: "16px", minHeight: "16px" }}
|
|
182
|
+
>
|
|
183
|
+
<path
|
|
184
|
+
strokeLinecap="round"
|
|
185
|
+
strokeLinejoin="round"
|
|
186
|
+
d="M7.5 15h2.25m8.024-9.75c.011.05.028.1.052.148.591 1.2.924 2.55.924 3.977a8.96 8.96 0 01-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398C20.613 14.547 19.833 15 19 15h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 00.303-.54m.023-8.25H16.48a4.5 4.5 0 01-1.423-.23l-3.114-1.04a4.5 4.5 0 00-1.423-.23H6.504c-.618 0-1.217.247-1.605.729A11.95 11.95 0 002.25 12c0 .434.023.863.068 1.285C2.427 14.306 3.346 15 4.372 15h3.126c.618 0 .991.724.725 1.282A7.471 7.471 0 007.5 19.5a2.25 2.25 0 002.25 2.25.75.75 0 00.75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 002.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384"
|
|
187
|
+
/>
|
|
188
|
+
</svg>
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
export const DownloadIcon = (
|
|
192
|
+
<svg
|
|
193
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
194
|
+
fill="none"
|
|
195
|
+
viewBox="0 0 24 24"
|
|
196
|
+
strokeWidth="2"
|
|
197
|
+
stroke="currentColor"
|
|
198
|
+
width="16"
|
|
199
|
+
height="16"
|
|
200
|
+
style={{ minWidth: "16px", minHeight: "16px" }}
|
|
201
|
+
>
|
|
202
|
+
<path
|
|
203
|
+
strokeLinecap="round"
|
|
204
|
+
strokeLinejoin="round"
|
|
205
|
+
d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"
|
|
206
|
+
/>
|
|
207
|
+
</svg>
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
export const UploadIcon = (
|
|
211
|
+
<svg
|
|
212
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
213
|
+
fill="none"
|
|
214
|
+
viewBox="0 0 24 24"
|
|
215
|
+
strokeWidth="1.5"
|
|
216
|
+
stroke="currentColor"
|
|
217
|
+
width="24"
|
|
218
|
+
height="24"
|
|
219
|
+
>
|
|
220
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
|
221
|
+
</svg>
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
export const CheckIcon = (
|
|
225
|
+
<svg
|
|
226
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
227
|
+
fill="none"
|
|
228
|
+
viewBox="0 0 24 24"
|
|
229
|
+
strokeWidth="2"
|
|
230
|
+
stroke="currentColor"
|
|
231
|
+
width="16"
|
|
232
|
+
height="16"
|
|
233
|
+
style={{ minWidth: "16px", minHeight: "16px" }}
|
|
234
|
+
>
|
|
235
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M4.5 12.75l6 6 9-13.5" />
|
|
236
|
+
</svg>
|
|
237
|
+
);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface ImageUploadQueueProps {
|
|
4
|
+
images: Array<{ contentType: string; bytes: string }>;
|
|
5
|
+
onRemoveImage: (index: number) => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const ImageUploadQueue: React.FC<ImageUploadQueueProps> = ({
|
|
10
|
+
images,
|
|
11
|
+
onRemoveImage,
|
|
12
|
+
className = "",
|
|
13
|
+
}) => {
|
|
14
|
+
if (images.length === 0) return null;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
className={`copilotKitImageUploadQueue ${className}`}
|
|
19
|
+
style={{
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexWrap: "wrap",
|
|
22
|
+
gap: "8px",
|
|
23
|
+
margin: "8px",
|
|
24
|
+
padding: "8px",
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
{images.map((image, index) => (
|
|
28
|
+
<div
|
|
29
|
+
key={index}
|
|
30
|
+
className="copilotKitImageUploadQueueItem"
|
|
31
|
+
style={{
|
|
32
|
+
position: "relative",
|
|
33
|
+
display: "inline-block",
|
|
34
|
+
width: "60px",
|
|
35
|
+
height: "60px",
|
|
36
|
+
borderRadius: "4px",
|
|
37
|
+
overflow: "hidden",
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
41
|
+
<img
|
|
42
|
+
src={`data:${image.contentType};base64,${image.bytes}`}
|
|
43
|
+
alt={`Selected image ${index + 1}`}
|
|
44
|
+
style={{
|
|
45
|
+
width: "100%",
|
|
46
|
+
height: "100%",
|
|
47
|
+
objectFit: "cover",
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
50
|
+
<button
|
|
51
|
+
onClick={() => onRemoveImage(index)}
|
|
52
|
+
className="copilotKitImageUploadQueueRemoveButton"
|
|
53
|
+
style={{
|
|
54
|
+
position: "absolute",
|
|
55
|
+
top: "2px",
|
|
56
|
+
right: "2px",
|
|
57
|
+
background: "rgba(0,0,0,0.6)",
|
|
58
|
+
color: "white",
|
|
59
|
+
border: "none",
|
|
60
|
+
borderRadius: "50%",
|
|
61
|
+
width: "18px",
|
|
62
|
+
height: "18px",
|
|
63
|
+
display: "flex",
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
justifyContent: "center",
|
|
66
|
+
cursor: "pointer",
|
|
67
|
+
fontSize: "10px",
|
|
68
|
+
padding: 0,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
✕
|
|
72
|
+
</button>
|
|
73
|
+
</div>
|
|
74
|
+
))}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import React, { useMemo, useRef, useState } from "react";
|
|
2
|
+
import { InputProps } from "./props";
|
|
3
|
+
import { useChatContext } from "./ChatContext";
|
|
4
|
+
import AutoResizingTextarea from "./Textarea";
|
|
5
|
+
import { usePushToTalk } from "../../hooks/use-push-to-talk";
|
|
6
|
+
import { useCopilotContext, useCopilotChatInternal } from "@copilotkit/react-core";
|
|
7
|
+
import { PoweredByTag } from "./PoweredByTag";
|
|
8
|
+
|
|
9
|
+
const MAX_NEWLINES = 6;
|
|
10
|
+
|
|
11
|
+
export const Input = ({
|
|
12
|
+
inProgress,
|
|
13
|
+
onSend,
|
|
14
|
+
chatReady = false,
|
|
15
|
+
onStop,
|
|
16
|
+
onUpload,
|
|
17
|
+
hideStopButton = false,
|
|
18
|
+
}: InputProps) => {
|
|
19
|
+
const context = useChatContext();
|
|
20
|
+
const copilotContext = useCopilotContext();
|
|
21
|
+
|
|
22
|
+
const showPoweredBy = !copilotContext.copilotApiConfig?.publicApiKey;
|
|
23
|
+
|
|
24
|
+
const pushToTalkConfigured =
|
|
25
|
+
copilotContext.copilotApiConfig.textToSpeechUrl !== undefined &&
|
|
26
|
+
copilotContext.copilotApiConfig.transcribeAudioUrl !== undefined;
|
|
27
|
+
|
|
28
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
29
|
+
const [isComposing, setIsComposing] = useState(false);
|
|
30
|
+
|
|
31
|
+
const handleDivClick = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
32
|
+
const target = event.target as HTMLElement;
|
|
33
|
+
|
|
34
|
+
// If the user clicked a button or inside a button, don't focus the textarea
|
|
35
|
+
if (target.closest("button")) return;
|
|
36
|
+
|
|
37
|
+
// If the user clicked the textarea, do nothing (it's already focused)
|
|
38
|
+
if (target.tagName === "TEXTAREA") return;
|
|
39
|
+
|
|
40
|
+
// Otherwise, focus the textarea
|
|
41
|
+
textareaRef.current?.focus();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const [text, setText] = useState("");
|
|
45
|
+
const send = () => {
|
|
46
|
+
if (inProgress) return;
|
|
47
|
+
onSend(text);
|
|
48
|
+
setText("");
|
|
49
|
+
|
|
50
|
+
textareaRef.current?.focus();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// tylerslaton:
|
|
54
|
+
//
|
|
55
|
+
// This scrolls CopilotKit into view always. Reading the commit history, it was likely
|
|
56
|
+
// added to fix a bug but it is causing issues now.
|
|
57
|
+
//
|
|
58
|
+
// For the future, if we want this behavior again, we will need to find a way to do it without
|
|
59
|
+
// forcing CopilotKit to always be in view. This code causes this because focusing an element
|
|
60
|
+
// in most browsers will scroll that element into view.
|
|
61
|
+
//
|
|
62
|
+
// useEffect(() => {
|
|
63
|
+
// if (isVisible) {
|
|
64
|
+
// textareaRef.current?.focus();
|
|
65
|
+
// }
|
|
66
|
+
// }, [isVisible]);
|
|
67
|
+
|
|
68
|
+
const { pushToTalkState, setPushToTalkState } = usePushToTalk({
|
|
69
|
+
sendFunction: onSend,
|
|
70
|
+
inProgress,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
74
|
+
const { buttonIcon, buttonAlt } = useMemo(() => {
|
|
75
|
+
if (!chatReady) return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
|
|
76
|
+
return isInProgress && !hideStopButton && chatReady
|
|
77
|
+
? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" }
|
|
78
|
+
: { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
|
|
79
|
+
}, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
|
|
80
|
+
const showPushToTalk =
|
|
81
|
+
pushToTalkConfigured &&
|
|
82
|
+
(pushToTalkState === "idle" || pushToTalkState === "recording") &&
|
|
83
|
+
!inProgress;
|
|
84
|
+
|
|
85
|
+
const { interrupt } = useCopilotChatInternal();
|
|
86
|
+
|
|
87
|
+
const canSend = useMemo(() => {
|
|
88
|
+
return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
|
|
89
|
+
}, [interrupt, isInProgress, text, pushToTalkState]);
|
|
90
|
+
|
|
91
|
+
const canStop = useMemo(() => {
|
|
92
|
+
return isInProgress && !hideStopButton;
|
|
93
|
+
}, [isInProgress, hideStopButton]);
|
|
94
|
+
|
|
95
|
+
const sendDisabled = !canSend && !canStop;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div className={`copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`}>
|
|
99
|
+
<div className="copilotKitInput" onClick={handleDivClick}>
|
|
100
|
+
<AutoResizingTextarea
|
|
101
|
+
ref={textareaRef}
|
|
102
|
+
placeholder={context.labels.placeholder}
|
|
103
|
+
autoFocus={false}
|
|
104
|
+
maxRows={MAX_NEWLINES}
|
|
105
|
+
value={text}
|
|
106
|
+
onChange={(event) => setText(event.target.value)}
|
|
107
|
+
onCompositionStart={() => setIsComposing(true)}
|
|
108
|
+
onCompositionEnd={() => setIsComposing(false)}
|
|
109
|
+
onKeyDown={(event) => {
|
|
110
|
+
if (event.key === "Enter" && !event.shiftKey && !isComposing) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
if (canSend) {
|
|
113
|
+
send();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
<div className="copilotKitInputControls">
|
|
119
|
+
{onUpload && (
|
|
120
|
+
<button onClick={onUpload} className="copilotKitInputControlButton">
|
|
121
|
+
{context.icons.uploadIcon}
|
|
122
|
+
</button>
|
|
123
|
+
)}
|
|
124
|
+
|
|
125
|
+
<div style={{ flexGrow: 1 }} />
|
|
126
|
+
|
|
127
|
+
{showPushToTalk && (
|
|
128
|
+
<button
|
|
129
|
+
onClick={() =>
|
|
130
|
+
setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing")
|
|
131
|
+
}
|
|
132
|
+
className={
|
|
133
|
+
pushToTalkState === "recording"
|
|
134
|
+
? "copilotKitInputControlButton copilotKitPushToTalkRecording"
|
|
135
|
+
: "copilotKitInputControlButton"
|
|
136
|
+
}
|
|
137
|
+
>
|
|
138
|
+
{context.icons.pushToTalkIcon}
|
|
139
|
+
</button>
|
|
140
|
+
)}
|
|
141
|
+
<button
|
|
142
|
+
disabled={sendDisabled}
|
|
143
|
+
onClick={isInProgress && !hideStopButton ? onStop : send}
|
|
144
|
+
data-copilotkit-in-progress={inProgress}
|
|
145
|
+
data-test-id={inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready"}
|
|
146
|
+
className="copilotKitInputControlButton"
|
|
147
|
+
aria-label={buttonAlt}
|
|
148
|
+
>
|
|
149
|
+
{buttonIcon}
|
|
150
|
+
</button>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
<PoweredByTag showPoweredBy={showPoweredBy} />
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { FC, memo } from "react";
|
|
2
|
+
import ReactMarkdown, { Options, Components } from "react-markdown";
|
|
3
|
+
import { CodeBlock } from "./CodeBlock";
|
|
4
|
+
import remarkGfm from "remark-gfm";
|
|
5
|
+
import remarkMath from "remark-math";
|
|
6
|
+
import rehypeRaw from "rehype-raw";
|
|
7
|
+
|
|
8
|
+
const defaultComponents: Components = {
|
|
9
|
+
a({ children, ...props }) {
|
|
10
|
+
return (
|
|
11
|
+
<a className="copilotKitMarkdownElement" {...props} target="_blank" rel="noopener noreferrer">
|
|
12
|
+
{children}
|
|
13
|
+
</a>
|
|
14
|
+
);
|
|
15
|
+
},
|
|
16
|
+
// @ts-expect-error -- inline
|
|
17
|
+
code({ children, className, inline, ...props }) {
|
|
18
|
+
if (Array.isArray(children) && children.length) {
|
|
19
|
+
if (children[0] == "▍") {
|
|
20
|
+
return (
|
|
21
|
+
<span
|
|
22
|
+
style={{
|
|
23
|
+
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
24
|
+
marginTop: "0.25rem",
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
▍
|
|
28
|
+
</span>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
children[0] = (children?.[0] as string).replace("`▍`", "▍");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
36
|
+
|
|
37
|
+
// Detect inline code: if it has a language class or contains newlines, it's likely a code block
|
|
38
|
+
// Otherwise, treat it as inline code
|
|
39
|
+
const hasLanguage = match && match[1];
|
|
40
|
+
const content = String(children);
|
|
41
|
+
const hasNewlines = content.includes("\n");
|
|
42
|
+
const isInline = !hasLanguage && !hasNewlines;
|
|
43
|
+
|
|
44
|
+
if (isInline) {
|
|
45
|
+
return (
|
|
46
|
+
<code
|
|
47
|
+
className={`copilotKitMarkdownElement copilotKitInlineCode ${className || ""}`}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</code>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<CodeBlock
|
|
57
|
+
key={Math.random()}
|
|
58
|
+
language={(match && match[1]) || ""}
|
|
59
|
+
value={String(children).replace(/\n$/, "")}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
h1: ({ children, ...props }) => (
|
|
65
|
+
<h1 className="copilotKitMarkdownElement" {...props}>
|
|
66
|
+
{children}
|
|
67
|
+
</h1>
|
|
68
|
+
),
|
|
69
|
+
h2: ({ children, ...props }) => (
|
|
70
|
+
<h2 className="copilotKitMarkdownElement" {...props}>
|
|
71
|
+
{children}
|
|
72
|
+
</h2>
|
|
73
|
+
),
|
|
74
|
+
h3: ({ children, ...props }) => (
|
|
75
|
+
<h3 className="copilotKitMarkdownElement" {...props}>
|
|
76
|
+
{children}
|
|
77
|
+
</h3>
|
|
78
|
+
),
|
|
79
|
+
h4: ({ children, ...props }) => (
|
|
80
|
+
<h4 className="copilotKitMarkdownElement" {...props}>
|
|
81
|
+
{children}
|
|
82
|
+
</h4>
|
|
83
|
+
),
|
|
84
|
+
h5: ({ children, ...props }) => (
|
|
85
|
+
<h5 className="copilotKitMarkdownElement" {...props}>
|
|
86
|
+
{children}
|
|
87
|
+
</h5>
|
|
88
|
+
),
|
|
89
|
+
h6: ({ children, ...props }) => (
|
|
90
|
+
<h6 className="copilotKitMarkdownElement" {...props}>
|
|
91
|
+
{children}
|
|
92
|
+
</h6>
|
|
93
|
+
),
|
|
94
|
+
p: ({ children, ...props }) => (
|
|
95
|
+
<p className="copilotKitMarkdownElement" {...props}>
|
|
96
|
+
{children}
|
|
97
|
+
</p>
|
|
98
|
+
),
|
|
99
|
+
pre: ({ children, ...props }) => (
|
|
100
|
+
<pre className="copilotKitMarkdownElement" {...props}>
|
|
101
|
+
{children}
|
|
102
|
+
</pre>
|
|
103
|
+
),
|
|
104
|
+
blockquote: ({ children, ...props }) => (
|
|
105
|
+
<blockquote className="copilotKitMarkdownElement" {...props}>
|
|
106
|
+
{children}
|
|
107
|
+
</blockquote>
|
|
108
|
+
),
|
|
109
|
+
ul: ({ children, ...props }) => (
|
|
110
|
+
<ul className="copilotKitMarkdownElement" {...props}>
|
|
111
|
+
{children}
|
|
112
|
+
</ul>
|
|
113
|
+
),
|
|
114
|
+
li: ({ children, ...props }) => (
|
|
115
|
+
<li className="copilotKitMarkdownElement" {...props}>
|
|
116
|
+
{children}
|
|
117
|
+
</li>
|
|
118
|
+
),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const MemoizedReactMarkdown: FC<Options> = memo(
|
|
122
|
+
ReactMarkdown,
|
|
123
|
+
(prevProps, nextProps) =>
|
|
124
|
+
prevProps.children === nextProps.children && prevProps.components === nextProps.components,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
type MarkdownProps = {
|
|
128
|
+
content: string;
|
|
129
|
+
components?: Components;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const Markdown = ({ content, components }: MarkdownProps) => {
|
|
133
|
+
return (
|
|
134
|
+
<div className="copilotKitMarkdown">
|
|
135
|
+
<MemoizedReactMarkdown
|
|
136
|
+
components={{ ...defaultComponents, ...components }}
|
|
137
|
+
remarkPlugins={[remarkGfm, [remarkMath, { singleDollarTextMath: false }]]}
|
|
138
|
+
rehypePlugins={[rehypeRaw]}
|
|
139
|
+
>
|
|
140
|
+
{content}
|
|
141
|
+
</MemoizedReactMarkdown>
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
};
|