@copilotkit/react-ui 0.22.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.
- package/.turbo/turbo-build.log +211 -178
- package/CHANGELOG.md +24 -0
- package/dist/chunk-4MKP23AD.mjs +97 -0
- package/dist/chunk-4MKP23AD.mjs.map +1 -0
- package/dist/{chunk-T3WYKWNC.mjs → chunk-6XLZXLM5.mjs} +6 -6
- package/dist/chunk-6XLZXLM5.mjs.map +1 -0
- package/dist/{chunk-73EBDGYK.mjs → chunk-7FES2IQA.mjs} +5 -5
- package/dist/chunk-7FES2IQA.mjs.map +1 -0
- package/dist/chunk-ANO23V2M.mjs +135 -0
- package/dist/chunk-ANO23V2M.mjs.map +1 -0
- package/dist/chunk-BL65ZC6L.mjs +83 -0
- package/dist/chunk-BL65ZC6L.mjs.map +1 -0
- package/dist/{chunk-YEHO5VMA.mjs → chunk-CE7PJAAO.mjs} +2 -2
- package/dist/{chunk-7YXG7D47.mjs → chunk-FZC7X5PK.mjs} +57 -2
- package/dist/chunk-FZC7X5PK.mjs.map +1 -0
- package/dist/chunk-LTCJCXCP.mjs +29 -0
- package/dist/chunk-LTCJCXCP.mjs.map +1 -0
- package/dist/chunk-MRFF7GSQ.mjs +1 -0
- package/dist/{chunk-7JYUCW7H.mjs → chunk-PAQWLSA4.mjs} +2 -2
- package/dist/{chunk-YTIGBBTC.mjs → chunk-RT2XG2T7.mjs} +2 -2
- package/dist/chunk-RT2XG2T7.mjs.map +1 -0
- package/dist/chunk-T26KLXLH.mjs +1 -0
- package/dist/{chunk-6U3O2JZP.mjs → chunk-T3JTSIHT.mjs} +32 -39
- package/dist/chunk-T3JTSIHT.mjs.map +1 -0
- package/dist/{chunk-MBYUBR3F.mjs → chunk-UPTB2MVO.mjs} +2 -2
- package/dist/chunk-VUZA5AFH.mjs +73 -0
- package/dist/chunk-VUZA5AFH.mjs.map +1 -0
- package/dist/{chunk-YAORLSQ3.mjs → chunk-XRODMID5.mjs} +6 -6
- package/dist/chunk-XRODMID5.mjs.map +1 -0
- package/dist/{chunk-WDHLWSSU.mjs → chunk-YQ3D5IQV.mjs} +2 -2
- package/dist/{chunk-WM6BS77F.mjs → chunk-YQFVRDNC.mjs} +2 -2
- package/dist/{chunk-WM6BS77F.mjs.map → chunk-YQFVRDNC.mjs.map} +1 -1
- package/dist/chunk-ZO3GLN23.mjs +137 -0
- package/dist/chunk-ZO3GLN23.mjs.map +1 -0
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +3 -3
- package/dist/components/chat/Chat.d.ts +66 -46
- package/dist/components/chat/Chat.js +433 -278
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +15 -14
- package/dist/components/chat/ChatContext.d.ts +16 -16
- package/dist/components/chat/ChatContext.js +43 -27
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +2 -2
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +2 -2
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +3 -3
- package/dist/components/chat/Icons.d.ts +7 -5
- package/dist/components/chat/Icons.js +57 -0
- package/dist/components/chat/Icons.js.map +1 -1
- package/dist/components/chat/Icons.mjs +5 -1
- package/dist/components/chat/Input.d.ts +1 -1
- package/dist/components/chat/Input.js +148 -11
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +5 -4
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +3 -3
- package/dist/components/chat/Messages.d.ts +1 -1
- package/dist/components/chat/Messages.js +2 -2
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +5 -5
- package/dist/components/chat/Modal.d.ts +50 -0
- package/dist/components/chat/Modal.js +1584 -0
- package/dist/components/chat/Modal.js.map +1 -0
- package/dist/components/chat/Modal.mjs +23 -0
- package/dist/components/chat/Modal.mjs.map +1 -0
- package/dist/components/chat/Popup.d.ts +56 -4
- package/dist/components/chat/Popup.js +428 -78
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +15 -12
- package/dist/components/chat/Response.js.map +1 -1
- package/dist/components/chat/Response.mjs +3 -3
- package/dist/components/chat/Sidebar.d.ts +7 -8
- package/dist/components/chat/Sidebar.js +430 -80
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +15 -12
- package/dist/components/chat/Suggestion.d.ts +13 -0
- package/dist/components/chat/Suggestion.js +172 -0
- package/dist/components/chat/Suggestion.js.map +1 -0
- package/dist/components/chat/Suggestion.mjs +11 -0
- package/dist/components/chat/Suggestion.mjs.map +1 -0
- package/dist/components/chat/Textarea.d.ts +4 -4
- package/dist/components/chat/Textarea.js +1 -1
- package/dist/components/chat/Textarea.js.map +1 -1
- package/dist/components/chat/Textarea.mjs +1 -1
- package/dist/components/chat/index.d.ts +4 -2
- package/dist/components/chat/index.js +436 -84
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +22 -16
- package/dist/components/chat/props.d.ts +10 -3
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/components/index.js +436 -84
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +22 -16
- package/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/index.js +36 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +8 -1
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +87 -0
- package/dist/hooks/use-copilot-chat-suggestions.js +53 -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-push-to-talk.d.ts +19 -0
- package/dist/hooks/use-push-to-talk.js +177 -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 +101 -13
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +465 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -19
- package/dist/types/suggestions.d.ts +8 -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/package.json +6 -6
- package/src/components/chat/Button.tsx +1 -2
- package/src/components/chat/Chat.tsx +163 -104
- package/src/components/chat/ChatContext.tsx +36 -38
- package/src/components/chat/Icons.tsx +44 -0
- package/src/components/chat/Input.tsx +38 -7
- package/src/components/chat/Messages.tsx +3 -3
- package/src/components/chat/Modal.tsx +115 -0
- package/src/components/chat/Popup.tsx +53 -7
- package/src/components/chat/Sidebar.tsx +62 -9
- package/src/components/chat/Suggestion.tsx +109 -0
- package/src/components/chat/Textarea.tsx +1 -1
- package/src/components/chat/index.tsx +1 -0
- package/src/components/chat/props.ts +10 -2
- package/src/css/input.css +18 -8
- package/src/css/messages.css +7 -1
- package/src/css/panel.css +38 -0
- package/src/css/response.css +1 -4
- package/src/css/suggestions.css +35 -0
- package/src/css/window.css +3 -1
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-copilot-chat-suggestions.tsx +117 -0
- package/src/hooks/use-push-to-talk.tsx +162 -0
- package/src/styles.css +2 -0
- package/src/types/suggestions.ts +6 -0
- package/typedoc.json +4 -0
- package/dist/chunk-6U3O2JZP.mjs.map +0 -1
- package/dist/chunk-73EBDGYK.mjs.map +0 -1
- package/dist/chunk-7LMXXGJT.mjs +0 -75
- package/dist/chunk-7LMXXGJT.mjs.map +0 -1
- package/dist/chunk-7YXG7D47.mjs.map +0 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -1
- package/dist/chunk-KE3N45ZY.mjs +0 -63
- package/dist/chunk-KE3N45ZY.mjs.map +0 -1
- package/dist/chunk-T3WYKWNC.mjs.map +0 -1
- package/dist/chunk-UGQQ4WEQ.mjs +0 -1
- package/dist/chunk-YAORLSQ3.mjs.map +0 -1
- package/dist/chunk-YTIGBBTC.mjs.map +0 -1
- /package/dist/{chunk-YEHO5VMA.mjs.map → chunk-CE7PJAAO.mjs.map} +0 -0
- /package/dist/{chunk-H4VKQGVU.mjs.map → chunk-MRFF7GSQ.mjs.map} +0 -0
- /package/dist/{chunk-7JYUCW7H.mjs.map → chunk-PAQWLSA4.mjs.map} +0 -0
- /package/dist/{chunk-UGQQ4WEQ.mjs.map → chunk-T26KLXLH.mjs.map} +0 -0
- /package/dist/{chunk-MBYUBR3F.mjs.map → chunk-UPTB2MVO.mjs.map} +0 -0
- /package/dist/{chunk-WDHLWSSU.mjs.map → chunk-YQ3D5IQV.mjs.map} +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hook for providing suggestions to the user in the Copilot chat.
|
|
3
|
+
*
|
|
4
|
+
* <Warning>
|
|
5
|
+
* useCopilotChatSuggestions is experimental. The interface is not final and
|
|
6
|
+
* can change without further notice.
|
|
7
|
+
* </Warning>
|
|
8
|
+
*
|
|
9
|
+
* <img src="/images/useCopilotChatSuggestions/use-copilot-chat-suggestions.gif" width="500" />
|
|
10
|
+
*
|
|
11
|
+
* <img referrerPolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=a9b290bb-38f9-4518-ac3b-8f54fdbf43be" />
|
|
12
|
+
*
|
|
13
|
+
* `useCopilotChatSuggestions` integrates auto-generated chat suggestions into your application in the context of your
|
|
14
|
+
* app's state. It dynamically manages suggestions based on provided configurations and
|
|
15
|
+
* dependencies.
|
|
16
|
+
*
|
|
17
|
+
* <RequestExample>
|
|
18
|
+
* ```jsx useCopilotChatSuggestions Example
|
|
19
|
+
* import { useCopilotChatSuggestions }
|
|
20
|
+
* from "@copilotkit/react-ui";
|
|
21
|
+
*
|
|
22
|
+
* useCopilotChatSuggestions({
|
|
23
|
+
* instructions: "Your instructions for suggestions.",
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
* </RequestExample>
|
|
27
|
+
*
|
|
28
|
+
* ## Basic Setup
|
|
29
|
+
*
|
|
30
|
+
* To incorporate this hook into your React components, start by importing it:
|
|
31
|
+
*
|
|
32
|
+
* ```tsx
|
|
33
|
+
* import { useCopilotChatSuggestions } from "@copilotkit/react-ui";
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Then, use it in your component to initiate suggestion functionality:
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* useCopilotChatSuggestions({
|
|
40
|
+
* instructions: "Your instructions for suggestions.",
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* ## Dependency Management
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { useCopilotChatSuggestions } from "@copilotkit/react-ui";
|
|
48
|
+
*
|
|
49
|
+
* useCopilotChatSuggestions(
|
|
50
|
+
* {
|
|
51
|
+
* instructions: "Suggest the most relevant next actions.",
|
|
52
|
+
* },
|
|
53
|
+
* [appState],
|
|
54
|
+
* );
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* In the example above, the suggestions are generated based on the given instructions.
|
|
58
|
+
* The hook monitors `appState`, and updates suggestions accordingly whenever it changes.
|
|
59
|
+
*
|
|
60
|
+
* ## Behavior and Lifecycle
|
|
61
|
+
*
|
|
62
|
+
* The hook registers the configuration with the chat context upon component mount and
|
|
63
|
+
* removes it on unmount, ensuring a clean and efficient lifecycle management.
|
|
64
|
+
*/
|
|
65
|
+
interface UseCopilotChatSuggestionsConfiguration {
|
|
66
|
+
/**
|
|
67
|
+
* A prompt or instructions for the GPT to generate suggestions.
|
|
68
|
+
*/
|
|
69
|
+
instructions: string;
|
|
70
|
+
/**
|
|
71
|
+
* The minimum number of suggestions to generate. Defaults to `1`.
|
|
72
|
+
* @default 1
|
|
73
|
+
*/
|
|
74
|
+
minSuggestions?: number;
|
|
75
|
+
/**
|
|
76
|
+
* The maximum number of suggestions to generate. Defaults to `3`.
|
|
77
|
+
* @default 1
|
|
78
|
+
*/
|
|
79
|
+
maxSuggestions?: number;
|
|
80
|
+
/**
|
|
81
|
+
* An optional class name to apply to the suggestions.
|
|
82
|
+
*/
|
|
83
|
+
className?: string;
|
|
84
|
+
}
|
|
85
|
+
declare function useCopilotChatSuggestions({ instructions, className, minSuggestions, maxSuggestions, }: UseCopilotChatSuggestionsConfiguration, dependencies?: any[]): void;
|
|
86
|
+
|
|
87
|
+
export { useCopilotChatSuggestions };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
21
|
+
var use_copilot_chat_suggestions_exports = {};
|
|
22
|
+
__export(use_copilot_chat_suggestions_exports, {
|
|
23
|
+
useCopilotChatSuggestions: () => useCopilotChatSuggestions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(use_copilot_chat_suggestions_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_nanoid = require("nanoid");
|
|
28
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
29
|
+
function useCopilotChatSuggestions({
|
|
30
|
+
instructions,
|
|
31
|
+
className,
|
|
32
|
+
minSuggestions = 1,
|
|
33
|
+
maxSuggestions = 3
|
|
34
|
+
}, dependencies = []) {
|
|
35
|
+
const context = (0, import_react_core.useCopilotContext)();
|
|
36
|
+
(0, import_react.useEffect)(() => {
|
|
37
|
+
const id = (0, import_nanoid.nanoid)();
|
|
38
|
+
context.addChatSuggestionConfiguration(id, {
|
|
39
|
+
instructions,
|
|
40
|
+
minSuggestions,
|
|
41
|
+
maxSuggestions,
|
|
42
|
+
className
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
context.removeChatSuggestionConfiguration(id);
|
|
46
|
+
};
|
|
47
|
+
}, dependencies);
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
useCopilotChatSuggestions
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=use-copilot-chat-suggestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * A hook for providing suggestions to the user in the Copilot chat.\n *\n * <Warning>\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without further notice.\n * </Warning>\n *\n * <img src=\"/images/useCopilotChatSuggestions/use-copilot-chat-suggestions.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 * `useCopilotChatSuggestions` integrates auto-generated chat suggestions into your application in the context of your\n * app's state. It dynamically manages suggestions based on provided configurations and\n * dependencies.\n *\n * <RequestExample>\n * ```jsx useCopilotChatSuggestions Example\n * import { useCopilotChatSuggestions }\n * from \"@copilotkit/react-ui\";\n *\n * useCopilotChatSuggestions({\n * instructions: \"Your instructions for suggestions.\",\n * })\n * ```\n * </RequestExample>\n *\n * ## Basic Setup\n *\n * To incorporate this hook into your React components, start by importing it:\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n * ```\n *\n * Then, use it in your component to initiate suggestion functionality:\n *\n * ```tsx\n * useCopilotChatSuggestions({\n * instructions: \"Your instructions for suggestions.\",\n * });\n * ```\n *\n * ## Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ## Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\n\nimport { useEffect } from \"react\";\nimport { useChatContext } from \"../components\";\nimport { nanoid } from \"nanoid\";\nimport { CopilotChatSuggestionConfiguration, useCopilotContext } from \"@copilotkit/react-core\";\n\ninterface UseCopilotChatSuggestionsConfiguration {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n const id = nanoid();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, dependencies);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiEA,mBAA0B;AAE1B,oBAAuB;AACvB,wBAAsE;AAuB/D,SAAS,0BACd;AAAA,EACE;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,cAAU,qCAAkB;AAElC,8BAAU,MAAM;AACd,UAAM,SAAK,sBAAO;AAElB,YAAQ,+BAA+B,IAAI;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,cAAQ,kCAAkC,EAAE;AAAA,IAC9C;AAAA,EACF,GAAG,YAAY;AACjB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Message } from '@copilotkit/shared';
|
|
3
|
+
|
|
4
|
+
declare const checkMicrophonePermission: () => Promise<boolean | undefined>;
|
|
5
|
+
declare const requestMicAndPlaybackPermission: () => Promise<{
|
|
6
|
+
stream: MediaStream;
|
|
7
|
+
audioContext: AudioContext;
|
|
8
|
+
} | null>;
|
|
9
|
+
type PushToTalkState = "idle" | "recording" | "transcribing";
|
|
10
|
+
type SendFunction = (text: string) => Promise<Message>;
|
|
11
|
+
declare const usePushToTalk: ({ sendFunction, inProgress, }: {
|
|
12
|
+
sendFunction: SendFunction;
|
|
13
|
+
inProgress: boolean;
|
|
14
|
+
}) => {
|
|
15
|
+
pushToTalkState: PushToTalkState;
|
|
16
|
+
setPushToTalkState: React.Dispatch<React.SetStateAction<PushToTalkState>>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { PushToTalkState, SendFunction, checkMicrophonePermission, requestMicAndPlaybackPermission, usePushToTalk };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __async = (__this, __arguments, generator) => {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
var fulfilled = (value) => {
|
|
22
|
+
try {
|
|
23
|
+
step(generator.next(value));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
reject(e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var rejected = (value) => {
|
|
29
|
+
try {
|
|
30
|
+
step(generator.throw(value));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/hooks/use-push-to-talk.tsx
|
|
41
|
+
var use_push_to_talk_exports = {};
|
|
42
|
+
__export(use_push_to_talk_exports, {
|
|
43
|
+
checkMicrophonePermission: () => checkMicrophonePermission,
|
|
44
|
+
requestMicAndPlaybackPermission: () => requestMicAndPlaybackPermission,
|
|
45
|
+
usePushToTalk: () => usePushToTalk
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(use_push_to_talk_exports);
|
|
48
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
49
|
+
var import_react = require("react");
|
|
50
|
+
var checkMicrophonePermission = () => __async(void 0, null, function* () {
|
|
51
|
+
try {
|
|
52
|
+
const permissionStatus = yield navigator.permissions.query({
|
|
53
|
+
name: "microphone"
|
|
54
|
+
});
|
|
55
|
+
if (permissionStatus.state === "granted") {
|
|
56
|
+
return true;
|
|
57
|
+
} else {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.error("Error checking microphone permission", err);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
var requestMicAndPlaybackPermission = () => __async(void 0, null, function* () {
|
|
65
|
+
try {
|
|
66
|
+
const stream = yield navigator.mediaDevices.getUserMedia({ audio: true });
|
|
67
|
+
const audioContext = new window.AudioContext();
|
|
68
|
+
yield audioContext.resume();
|
|
69
|
+
return { stream, audioContext };
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error("Error requesting microphone and playback permissions", err);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
76
|
+
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
77
|
+
mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
|
|
78
|
+
audioContextRef.current = new window.AudioContext();
|
|
79
|
+
yield audioContextRef.current.resume();
|
|
80
|
+
}
|
|
81
|
+
mediaRecorderRef.current = new MediaRecorder(mediaStreamRef.current);
|
|
82
|
+
mediaRecorderRef.current.start(1e3);
|
|
83
|
+
mediaRecorderRef.current.ondataavailable = (event) => {
|
|
84
|
+
recordedChunks.push(event.data);
|
|
85
|
+
};
|
|
86
|
+
mediaRecorderRef.current.onstop = onStop;
|
|
87
|
+
});
|
|
88
|
+
var stopRecording = (mediaRecorderRef) => {
|
|
89
|
+
if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") {
|
|
90
|
+
mediaRecorderRef.current.stop();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var transcribeAudio = (recordedChunks, transcribeAudioUrl) => __async(void 0, null, function* () {
|
|
94
|
+
const completeBlob = new Blob(recordedChunks, { type: "audio/mp4" });
|
|
95
|
+
const formData = new FormData();
|
|
96
|
+
formData.append("file", completeBlob, "recording.mp4");
|
|
97
|
+
const response = yield fetch(transcribeAudioUrl, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
body: formData
|
|
100
|
+
});
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
throw new Error(`Error: ${response.statusText}`);
|
|
103
|
+
}
|
|
104
|
+
const transcription = yield response.json();
|
|
105
|
+
return transcription.text;
|
|
106
|
+
});
|
|
107
|
+
var playAudioResponse = (text, textToSpeechUrl, audioContext) => {
|
|
108
|
+
const encodedText = encodeURIComponent(text);
|
|
109
|
+
const url = `${textToSpeechUrl}?text=${encodedText}`;
|
|
110
|
+
fetch(url).then((response) => response.arrayBuffer()).then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer)).then((audioBuffer) => {
|
|
111
|
+
const source = audioContext.createBufferSource();
|
|
112
|
+
source.buffer = audioBuffer;
|
|
113
|
+
source.connect(audioContext.destination);
|
|
114
|
+
source.start(0);
|
|
115
|
+
}).catch((error) => {
|
|
116
|
+
console.error("Error with decoding audio data", error);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
var usePushToTalk = ({
|
|
120
|
+
sendFunction,
|
|
121
|
+
inProgress
|
|
122
|
+
}) => {
|
|
123
|
+
const [pushToTalkState, setPushToTalkState] = (0, import_react.useState)("idle");
|
|
124
|
+
const mediaStreamRef = (0, import_react.useRef)(null);
|
|
125
|
+
const audioContextRef = (0, import_react.useRef)(null);
|
|
126
|
+
const mediaRecorderRef = (0, import_react.useRef)(null);
|
|
127
|
+
const recordedChunks = (0, import_react.useRef)([]);
|
|
128
|
+
const context = (0, import_react_core.useCopilotContext)();
|
|
129
|
+
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react.useState)(null);
|
|
130
|
+
(0, import_react.useEffect)(() => {
|
|
131
|
+
if (pushToTalkState === "recording") {
|
|
132
|
+
startRecording(
|
|
133
|
+
mediaStreamRef,
|
|
134
|
+
mediaRecorderRef,
|
|
135
|
+
audioContextRef,
|
|
136
|
+
recordedChunks.current,
|
|
137
|
+
() => {
|
|
138
|
+
setPushToTalkState("transcribing");
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
stopRecording(mediaRecorderRef);
|
|
143
|
+
if (pushToTalkState === "transcribing") {
|
|
144
|
+
transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then(
|
|
145
|
+
(transcription) => __async(void 0, null, function* () {
|
|
146
|
+
recordedChunks.current = [];
|
|
147
|
+
setPushToTalkState("idle");
|
|
148
|
+
const message = yield sendFunction(transcription);
|
|
149
|
+
setStartReadingFromMessageId(message.id);
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return () => {
|
|
155
|
+
stopRecording(mediaRecorderRef);
|
|
156
|
+
};
|
|
157
|
+
}, [pushToTalkState]);
|
|
158
|
+
(0, import_react.useEffect)(() => {
|
|
159
|
+
if (inProgress === false && startReadingFromMessageId) {
|
|
160
|
+
const lastMessageIndex = context.messages.findIndex(
|
|
161
|
+
(message) => message.id === startReadingFromMessageId
|
|
162
|
+
);
|
|
163
|
+
const messagesAfterLast = context.messages.slice(lastMessageIndex + 1).filter((message) => message.role === "assistant" && message.content);
|
|
164
|
+
const text = messagesAfterLast.map((message) => message.content).join("\n");
|
|
165
|
+
playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl, audioContextRef.current);
|
|
166
|
+
setStartReadingFromMessageId(null);
|
|
167
|
+
}
|
|
168
|
+
}, [startReadingFromMessageId, inProgress]);
|
|
169
|
+
return { pushToTalkState, setPushToTalkState };
|
|
170
|
+
};
|
|
171
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
+
0 && (module.exports = {
|
|
173
|
+
checkMicrophonePermission,
|
|
174
|
+
requestMicAndPlaybackPermission,
|
|
175
|
+
usePushToTalk
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=use-push-to-talk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-push-to-talk.tsx"],"sourcesContent":["import { CopilotContextParams, useCopilotContext } from \"@copilotkit/react-core\";\nimport { Message } from \"@copilotkit/shared\";\nimport { MutableRefObject, useEffect, useRef, useState } from \"react\";\n\nexport const checkMicrophonePermission = async () => {\n try {\n const permissionStatus = await navigator.permissions.query({\n name: \"microphone\" as PermissionName,\n });\n if (permissionStatus.state === \"granted\") {\n return true;\n } else {\n return false;\n }\n } catch (err) {\n console.error(\"Error checking microphone permission\", err);\n }\n};\n\nexport const requestMicAndPlaybackPermission = async () => {\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n const audioContext = new window.AudioContext();\n await audioContext.resume();\n return { stream, audioContext };\n } catch (err) {\n console.error(\"Error requesting microphone and playback permissions\", err);\n return null;\n }\n};\n\nconst startRecording = async (\n mediaStreamRef: MutableRefObject<MediaStream | null>,\n mediaRecorderRef: MutableRefObject<MediaRecorder | null>,\n audioContextRef: MutableRefObject<AudioContext | null>,\n recordedChunks: Blob[],\n onStop: () => void,\n) => {\n if (!mediaStreamRef.current || !audioContextRef.current) {\n mediaStreamRef.current = await navigator.mediaDevices.getUserMedia({ audio: true });\n audioContextRef.current = new window.AudioContext();\n await audioContextRef.current.resume();\n }\n\n mediaRecorderRef.current = new MediaRecorder(mediaStreamRef.current!);\n mediaRecorderRef.current.start(1000);\n mediaRecorderRef.current.ondataavailable = (event) => {\n recordedChunks.push(event.data);\n };\n mediaRecorderRef.current.onstop = onStop;\n};\n\nconst stopRecording = (mediaRecorderRef: MutableRefObject<MediaRecorder | null>) => {\n if (mediaRecorderRef.current && mediaRecorderRef.current.state !== \"inactive\") {\n mediaRecorderRef.current.stop();\n }\n};\n\nconst transcribeAudio = async (recordedChunks: Blob[], transcribeAudioUrl: string) => {\n const completeBlob = new Blob(recordedChunks, { type: \"audio/mp4\" });\n const formData = new FormData();\n formData.append(\"file\", completeBlob, \"recording.mp4\");\n\n const response = await fetch(transcribeAudioUrl, {\n method: \"POST\",\n body: formData,\n });\n\n if (!response.ok) {\n throw new Error(`Error: ${response.statusText}`);\n }\n\n const transcription = await response.json();\n return transcription.text;\n};\n\nconst playAudioResponse = (text: string, textToSpeechUrl: string, audioContext: AudioContext) => {\n const encodedText = encodeURIComponent(text);\n const url = `${textToSpeechUrl}?text=${encodedText}`;\n\n fetch(url)\n .then((response) => response.arrayBuffer())\n .then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer))\n .then((audioBuffer) => {\n const source = audioContext.createBufferSource();\n source.buffer = audioBuffer;\n source.connect(audioContext.destination);\n source.start(0);\n })\n .catch((error) => {\n console.error(\"Error with decoding audio data\", error);\n });\n};\n\nexport type PushToTalkState = \"idle\" | \"recording\" | \"transcribing\";\n\nexport type SendFunction = (text: string) => Promise<Message>;\n\nexport const usePushToTalk = ({\n sendFunction,\n inProgress,\n}: {\n sendFunction: SendFunction;\n inProgress: boolean;\n}) => {\n const [pushToTalkState, setPushToTalkState] = useState<PushToTalkState>(\"idle\");\n const mediaStreamRef = useRef<MediaStream | null>(null);\n const audioContextRef = useRef<AudioContext | null>(null);\n const mediaRecorderRef = useRef<MediaRecorder | null>(null);\n const recordedChunks = useRef<Blob[]>([]);\n const context = useCopilotContext();\n const [startReadingFromMessageId, setStartReadingFromMessageId] = useState<string | null>(null);\n\n useEffect(() => {\n if (pushToTalkState === \"recording\") {\n startRecording(\n mediaStreamRef,\n mediaRecorderRef,\n audioContextRef,\n recordedChunks.current,\n () => {\n setPushToTalkState(\"transcribing\");\n },\n );\n } else {\n stopRecording(mediaRecorderRef);\n if (pushToTalkState === \"transcribing\") {\n transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl!).then(\n async (transcription) => {\n recordedChunks.current = [];\n setPushToTalkState(\"idle\");\n const message = await sendFunction(transcription);\n setStartReadingFromMessageId(message.id);\n },\n );\n }\n }\n\n return () => {\n stopRecording(mediaRecorderRef);\n };\n }, [pushToTalkState]);\n\n useEffect(() => {\n if (inProgress === false && startReadingFromMessageId) {\n const lastMessageIndex = context.messages.findIndex(\n (message) => message.id === startReadingFromMessageId,\n );\n\n const messagesAfterLast = context.messages\n .slice(lastMessageIndex + 1)\n .filter((message) => message.role === \"assistant\" && message.content);\n\n const text = messagesAfterLast.map((message) => message.content).join(\"\\n\");\n playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl!, audioContextRef.current!);\n\n setStartReadingFromMessageId(null);\n }\n }, [startReadingFromMessageId, inProgress]);\n\n return { pushToTalkState, setPushToTalkState };\n};\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkMicrophonePermission,
|
|
3
|
+
requestMicAndPlaybackPermission,
|
|
4
|
+
usePushToTalk
|
|
5
|
+
} from "../chunk-ANO23V2M.mjs";
|
|
6
|
+
import "../chunk-MRXNTQOX.mjs";
|
|
7
|
+
export {
|
|
8
|
+
checkMicrophonePermission,
|
|
9
|
+
requestMicAndPlaybackPermission,
|
|
10
|
+
usePushToTalk
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=use-push-to-talk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.css
CHANGED
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
.copilotKitInput {
|
|
203
203
|
border-top: 1px solid var(--copilot-kit-input-separator-color);
|
|
204
204
|
padding-left: 2rem;
|
|
205
|
-
padding-right:
|
|
205
|
+
padding-right: 1rem;
|
|
206
206
|
padding-top: 1rem;
|
|
207
207
|
padding-bottom: 1rem;
|
|
208
208
|
display: flex;
|
|
@@ -213,9 +213,7 @@
|
|
|
213
213
|
border-bottom-right-radius: 0.75rem;
|
|
214
214
|
background-color: var(--copilot-kit-input-background-color);
|
|
215
215
|
}
|
|
216
|
-
.copilotKitInput > button {
|
|
217
|
-
position: absolute;
|
|
218
|
-
right: 0.5rem;
|
|
216
|
+
.copilotKitInput > .copilotKitInputControls > button {
|
|
219
217
|
padding: 0.25rem;
|
|
220
218
|
cursor: pointer;
|
|
221
219
|
transition-property: transform;
|
|
@@ -239,18 +237,22 @@
|
|
|
239
237
|
text-shadow: none;
|
|
240
238
|
display: inline-block;
|
|
241
239
|
text-align: center;
|
|
240
|
+
margin-left: 0.5rem;
|
|
242
241
|
}
|
|
243
|
-
.copilotKitInput > button:not([disabled]) {
|
|
242
|
+
.copilotKitInput > .copilotKitInputControls > button:not([disabled]) {
|
|
244
243
|
color: var(--copilot-kit-input-send-button-color);
|
|
245
244
|
}
|
|
246
|
-
.copilotKitInput > button:not([disabled]):hover {
|
|
245
|
+
.copilotKitInput > .copilotKitInputControls > button:not([disabled]):hover {
|
|
247
246
|
transform: scale(1.1);
|
|
248
247
|
}
|
|
249
|
-
.copilotKitInput > button[disabled] {
|
|
248
|
+
.copilotKitInput > .copilotKitInputControls > button[disabled] {
|
|
250
249
|
color: var(--copilot-kit-input-send-button-disabled-color);
|
|
251
250
|
}
|
|
251
|
+
.copilotKitInputControls {
|
|
252
|
+
display: flex;
|
|
253
|
+
}
|
|
252
254
|
.copilotKitInput > textarea {
|
|
253
|
-
|
|
255
|
+
flex: 1;
|
|
254
256
|
outline: 2px solid transparent;
|
|
255
257
|
outline-offset: 2px;
|
|
256
258
|
resize: none;
|
|
@@ -277,13 +279,18 @@
|
|
|
277
279
|
color: var(--copilot-kit-input-placeholder-color);
|
|
278
280
|
opacity: 1;
|
|
279
281
|
}
|
|
282
|
+
.copilotKitInput > .copilotKitInputControls > button.copilotKitPushToTalkRecording {
|
|
283
|
+
background-color: red;
|
|
284
|
+
color: white;
|
|
285
|
+
border-radius: 50%;
|
|
286
|
+
animation: copilotKitPulseAnimation 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
287
|
+
}
|
|
280
288
|
|
|
281
289
|
/* src/css/messages.css */
|
|
282
290
|
.copilotKitMessages {
|
|
283
291
|
overflow-y: scroll;
|
|
284
292
|
flex: 1;
|
|
285
293
|
padding: 1rem 2rem;
|
|
286
|
-
padding-bottom: 3rem;
|
|
287
294
|
display: flex;
|
|
288
295
|
flex-direction: column;
|
|
289
296
|
background-color: var(--copilot-kit-messages-background-color);
|
|
@@ -335,6 +342,12 @@
|
|
|
335
342
|
.copilotKitMessage .inProgressLabel {
|
|
336
343
|
margin-left: 10px;
|
|
337
344
|
}
|
|
345
|
+
.copilotKitMessages footer {
|
|
346
|
+
flex-grow: 1;
|
|
347
|
+
display: flex;
|
|
348
|
+
flex-direction: column;
|
|
349
|
+
justify-content: flex-end;
|
|
350
|
+
}
|
|
338
351
|
|
|
339
352
|
/* src/css/window.css */
|
|
340
353
|
.copilotKitWindow {
|
|
@@ -442,10 +455,7 @@
|
|
|
442
455
|
text-decoration: none;
|
|
443
456
|
text-transform: none;
|
|
444
457
|
white-space: nowrap;
|
|
445
|
-
|
|
446
|
-
left: 50%;
|
|
447
|
-
transform: translateX(-50%);
|
|
448
|
-
top: -44px;
|
|
458
|
+
margin-top: 15px;
|
|
449
459
|
}
|
|
450
460
|
.copilotKitResponseButton:hover {
|
|
451
461
|
filter: brightness(95%);
|
|
@@ -568,6 +578,75 @@
|
|
|
568
578
|
background-color: rgb(55, 55, 58);
|
|
569
579
|
}
|
|
570
580
|
|
|
581
|
+
/* src/css/suggestions.css */
|
|
582
|
+
.copilotKitMessages footer .suggestions {
|
|
583
|
+
display: flex;
|
|
584
|
+
flex-wrap: wrap;
|
|
585
|
+
gap: 8px;
|
|
586
|
+
}
|
|
587
|
+
.copilotKitMessages footer h6 {
|
|
588
|
+
font-weight: 500;
|
|
589
|
+
font-size: 0.7rem;
|
|
590
|
+
margin-bottom: 8px;
|
|
591
|
+
}
|
|
592
|
+
.copilotKitMessages footer .suggestions .suggestion {
|
|
593
|
+
padding: 8px 12px;
|
|
594
|
+
font-size: 0.7rem;
|
|
595
|
+
border-radius: 0.5rem;
|
|
596
|
+
background: var(--copilot-kit-message-user-background-color);
|
|
597
|
+
color: var(--copilot-kit-message-user-color);
|
|
598
|
+
}
|
|
599
|
+
.copilotKitMessages footer .suggestions button {
|
|
600
|
+
transition: transform 0.3s ease;
|
|
601
|
+
}
|
|
602
|
+
.copilotKitMessages footer .suggestions button:not(:disabled):hover {
|
|
603
|
+
transform: scale(1.05);
|
|
604
|
+
}
|
|
605
|
+
.copilotKitMessages footer .suggestions button:disabled {
|
|
606
|
+
cursor: wait;
|
|
607
|
+
}
|
|
608
|
+
.copilotKitMessages footer .suggestions button svg {
|
|
609
|
+
margin-right: 6px;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/* src/css/panel.css */
|
|
613
|
+
.copilotKitPanel {
|
|
614
|
+
z-index: 30;
|
|
615
|
+
line-height: 1.5;
|
|
616
|
+
-webkit-text-size-adjust: 100%;
|
|
617
|
+
-moz-tab-size: 4;
|
|
618
|
+
-o-tab-size: 4;
|
|
619
|
+
tab-size: 4;
|
|
620
|
+
font-family:
|
|
621
|
+
ui-sans-serif,
|
|
622
|
+
system-ui,
|
|
623
|
+
-apple-system,
|
|
624
|
+
BlinkMacSystemFont,
|
|
625
|
+
"Segoe UI",
|
|
626
|
+
Roboto,
|
|
627
|
+
"Helvetica Neue",
|
|
628
|
+
Arial,
|
|
629
|
+
"Noto Sans",
|
|
630
|
+
sans-serif,
|
|
631
|
+
"Apple Color Emoji",
|
|
632
|
+
"Segoe UI Emoji",
|
|
633
|
+
"Segoe UI Symbol",
|
|
634
|
+
"Noto Color Emoji";
|
|
635
|
+
font-feature-settings: normal;
|
|
636
|
+
font-variation-settings: normal;
|
|
637
|
+
touch-action: manipulation;
|
|
638
|
+
display: flex;
|
|
639
|
+
flex-direction: column;
|
|
640
|
+
height: 100%;
|
|
641
|
+
}
|
|
642
|
+
.copilotKitPanel svg {
|
|
643
|
+
display: inline-block;
|
|
644
|
+
vertical-align: middle;
|
|
645
|
+
}
|
|
646
|
+
.copilotKitPanel .copilotKitMessages {
|
|
647
|
+
flex-grow: 1;
|
|
648
|
+
}
|
|
649
|
+
|
|
571
650
|
/* src/styles.css */
|
|
572
651
|
*,
|
|
573
652
|
::before,
|
|
@@ -914,6 +993,12 @@ video {
|
|
|
914
993
|
.hidden {
|
|
915
994
|
display: none;
|
|
916
995
|
}
|
|
996
|
+
.h-6 {
|
|
997
|
+
height: 1.5rem;
|
|
998
|
+
}
|
|
999
|
+
.w-6 {
|
|
1000
|
+
width: 1.5rem;
|
|
1001
|
+
}
|
|
917
1002
|
.transform {
|
|
918
1003
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
919
1004
|
}
|
|
@@ -929,4 +1014,7 @@ video {
|
|
|
929
1014
|
.underline {
|
|
930
1015
|
text-decoration-line: underline;
|
|
931
1016
|
}
|
|
1017
|
+
.filter {
|
|
1018
|
+
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1019
|
+
}
|
|
932
1020
|
/*# sourceMappingURL=index.css.map */
|