@copilotkit/react-ui 1.5.14-next.0 → 1.5.15-next.0
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 +18 -0
- package/dist/{chunk-PNQVKBPN.mjs → chunk-6TCUJ3B7.mjs} +2 -2
- package/dist/chunk-6TCUJ3B7.mjs.map +1 -0
- package/dist/{chunk-E5SIPE2R.mjs → chunk-6ZBXFJHS.mjs} +2 -2
- package/dist/{chunk-YGWWZL4N.mjs → chunk-HBUJWEWY.mjs} +2 -2
- package/dist/{chunk-GDOB4BYD.mjs → chunk-I37TTM3T.mjs} +2 -2
- package/dist/{chunk-DGGCSR5M.mjs → chunk-R5ZETDHL.mjs} +2 -2
- package/dist/{chunk-F2W5FD7L.mjs → chunk-VY62BA22.mjs} +2 -2
- package/dist/{chunk-Z2UZSN3K.mjs → chunk-Z4XPPVZT.mjs} +5 -2
- package/dist/{chunk-Z2UZSN3K.mjs.map → chunk-Z4XPPVZT.mjs.map} +1 -1
- package/dist/components/chat/Chat.js +1 -1
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +3 -3
- package/dist/components/chat/Modal.js +1 -1
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +4 -4
- package/dist/components/chat/Popup.js +1 -1
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +5 -5
- package/dist/components/chat/Sidebar.js +1 -1
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +5 -5
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +6 -6
- package/dist/components/dev-console/console.js +1 -1
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +2 -2
- package/dist/components/dev-console/index.js +1 -1
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +2 -2
- package/dist/components/dev-console/utils.js +1 -1
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -6
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +6 -1
- package/dist/hooks/use-copilot-chat-suggestions.js +4 -1
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/package.json +4 -4
- package/src/components/dev-console/utils.ts +1 -1
- package/src/hooks/use-copilot-chat-suggestions.tsx +11 -1
- package/dist/chunk-PNQVKBPN.mjs.map +0 -1
- /package/dist/{chunk-E5SIPE2R.mjs.map → chunk-6ZBXFJHS.mjs.map} +0 -0
- /package/dist/{chunk-YGWWZL4N.mjs.map → chunk-HBUJWEWY.mjs.map} +0 -0
- /package/dist/{chunk-GDOB4BYD.mjs.map → chunk-I37TTM3T.mjs.map} +0 -0
- /package/dist/{chunk-DGGCSR5M.mjs.map → chunk-R5ZETDHL.mjs.map} +0 -0
- /package/dist/{chunk-F2W5FD7L.mjs.map → chunk-VY62BA22.mjs.map} +0 -0
|
@@ -2,18 +2,18 @@ import "../chunk-MMVDU6DF.mjs";
|
|
|
2
2
|
import "../chunk-SQMEPWVT.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CopilotSidebar
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-R5ZETDHL.mjs";
|
|
6
6
|
import "../chunk-WB3YULQ4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotPopup
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-I37TTM3T.mjs";
|
|
10
|
+
import "../chunk-6ZBXFJHS.mjs";
|
|
11
11
|
import "../chunk-YAGE7RCE.mjs";
|
|
12
12
|
import "../chunk-VEC45H6Q.mjs";
|
|
13
13
|
import "../chunk-RQNJNK2W.mjs";
|
|
14
14
|
import {
|
|
15
15
|
CopilotChat
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-HBUJWEWY.mjs";
|
|
17
17
|
import "../chunk-UWWMAJ7R.mjs";
|
|
18
18
|
import "../chunk-F7VWGY77.mjs";
|
|
19
19
|
import "../chunk-OFYI4UU4.mjs";
|
|
@@ -28,10 +28,10 @@ import "../chunk-XB6QCUPB.mjs";
|
|
|
28
28
|
import "../chunk-WGAZXTUA.mjs";
|
|
29
29
|
import {
|
|
30
30
|
CopilotDevConsole
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-VY62BA22.mjs";
|
|
32
32
|
import {
|
|
33
33
|
shouldShowDevConsole
|
|
34
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-6TCUJ3B7.mjs";
|
|
35
35
|
import "../chunk-KXE2JCUH.mjs";
|
|
36
36
|
import "../chunk-TI7SY2RI.mjs";
|
|
37
37
|
import "../chunk-BH6PCAAL.mjs";
|
package/dist/hooks/index.js
CHANGED
|
@@ -29,6 +29,7 @@ var import_react = require("react");
|
|
|
29
29
|
var import_react_core = require("@copilotkit/react-core");
|
|
30
30
|
var import_shared = require("@copilotkit/shared");
|
|
31
31
|
function useCopilotChatSuggestions({
|
|
32
|
+
available = "enabled",
|
|
32
33
|
instructions,
|
|
33
34
|
className,
|
|
34
35
|
minSuggestions = 1,
|
|
@@ -36,6 +37,8 @@ function useCopilotChatSuggestions({
|
|
|
36
37
|
}, dependencies = []) {
|
|
37
38
|
const context = (0, import_react_core.useCopilotContext)();
|
|
38
39
|
(0, import_react.useEffect)(() => {
|
|
40
|
+
if (available === "disabled")
|
|
41
|
+
return;
|
|
39
42
|
const id = (0, import_shared.randomId)();
|
|
40
43
|
context.addChatSuggestionConfiguration(id, {
|
|
41
44
|
instructions,
|
|
@@ -46,7 +49,7 @@ function useCopilotChatSuggestions({
|
|
|
46
49
|
return () => {
|
|
47
50
|
context.removeChatSuggestionConfiguration(id);
|
|
48
51
|
};
|
|
49
|
-
}, [...dependencies, instructions, minSuggestions, maxSuggestions, className]);
|
|
52
|
+
}, [...dependencies, instructions, minSuggestions, maxSuggestions, className, available]);
|
|
50
53
|
}
|
|
51
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
55
|
0 && (module.exports = {
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/index.ts","../../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["export * from \"./use-copilot-chat-suggestions\";\n","/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\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 { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\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 = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, [...dependencies, instructions, minSuggestions, maxSuggestions, className]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6DA,mBAA0B;AAC1B,wBAAkC;AAClC,oBAAyB;
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/index.ts","../../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["export * from \"./use-copilot-chat-suggestions\";\n","/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\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 { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\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 /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n available = \"enabled\",\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\n const id = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, [...dependencies, instructions, minSuggestions, maxSuggestions, className, available]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6DA,mBAA0B;AAC1B,wBAAkC;AAClC,oBAAyB;AA8BlB,SAAS,0BACd;AAAA,EACE,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,cAAU,qCAAkB;AAElC,8BAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,UAAM,SAAK,wBAAS;AAEpB,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,CAAC,GAAG,cAAc,cAAc,gBAAgB,gBAAgB,WAAW,SAAS,CAAC;AAC1F;","names":[]}
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -73,11 +73,16 @@ interface UseCopilotChatSuggestionsConfiguration {
|
|
|
73
73
|
* @default 1
|
|
74
74
|
*/
|
|
75
75
|
maxSuggestions?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the suggestions are available. Defaults to `enabled`.
|
|
78
|
+
* @default enabled
|
|
79
|
+
*/
|
|
80
|
+
available?: "enabled" | "disabled";
|
|
76
81
|
/**
|
|
77
82
|
* An optional class name to apply to the suggestions.
|
|
78
83
|
*/
|
|
79
84
|
className?: string;
|
|
80
85
|
}
|
|
81
|
-
declare function useCopilotChatSuggestions({ instructions, className, minSuggestions, maxSuggestions, }: UseCopilotChatSuggestionsConfiguration, dependencies?: any[]): void;
|
|
86
|
+
declare function useCopilotChatSuggestions({ available, instructions, className, minSuggestions, maxSuggestions, }: UseCopilotChatSuggestionsConfiguration, dependencies?: any[]): void;
|
|
82
87
|
|
|
83
88
|
export { useCopilotChatSuggestions };
|
|
@@ -27,6 +27,7 @@ var import_react = require("react");
|
|
|
27
27
|
var import_react_core = require("@copilotkit/react-core");
|
|
28
28
|
var import_shared = require("@copilotkit/shared");
|
|
29
29
|
function useCopilotChatSuggestions({
|
|
30
|
+
available = "enabled",
|
|
30
31
|
instructions,
|
|
31
32
|
className,
|
|
32
33
|
minSuggestions = 1,
|
|
@@ -34,6 +35,8 @@ function useCopilotChatSuggestions({
|
|
|
34
35
|
}, dependencies = []) {
|
|
35
36
|
const context = (0, import_react_core.useCopilotContext)();
|
|
36
37
|
(0, import_react.useEffect)(() => {
|
|
38
|
+
if (available === "disabled")
|
|
39
|
+
return;
|
|
37
40
|
const id = (0, import_shared.randomId)();
|
|
38
41
|
context.addChatSuggestionConfiguration(id, {
|
|
39
42
|
instructions,
|
|
@@ -44,7 +47,7 @@ function useCopilotChatSuggestions({
|
|
|
44
47
|
return () => {
|
|
45
48
|
context.removeChatSuggestionConfiguration(id);
|
|
46
49
|
};
|
|
47
|
-
}, [...dependencies, instructions, minSuggestions, maxSuggestions, className]);
|
|
50
|
+
}, [...dependencies, instructions, minSuggestions, maxSuggestions, className, available]);
|
|
48
51
|
}
|
|
49
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
53
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\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 { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\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 = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, [...dependencies, instructions, minSuggestions, maxSuggestions, className]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6DA,mBAA0B;AAC1B,wBAAkC;AAClC,oBAAyB;
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\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 { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\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 /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n available = \"enabled\",\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\n const id = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, [...dependencies, instructions, minSuggestions, maxSuggestions, className, available]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6DA,mBAA0B;AAC1B,wBAAkC;AAClC,oBAAyB;AA8BlB,SAAS,0BACd;AAAA,EACE,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,cAAU,qCAAkB;AAElC,8BAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,UAAM,SAAK,wBAAS;AAEpB,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,CAAC,GAAG,cAAc,cAAc,gBAAgB,gBAAgB,WAAW,SAAS,CAAC;AAC1F;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1825,7 +1825,7 @@ function getPublishedCopilotKitVersion(current, forceCheck = false) {
|
|
|
1825
1825
|
}
|
|
1826
1826
|
}
|
|
1827
1827
|
try {
|
|
1828
|
-
const response = yield fetch("https://api.cloud.
|
|
1828
|
+
const response = yield fetch("https://api.cloud.copilotkit.ai/check-for-updates", {
|
|
1829
1829
|
method: "POST",
|
|
1830
1830
|
headers: {
|
|
1831
1831
|
"Content-Type": "application/json"
|
|
@@ -2782,6 +2782,7 @@ var import_react15 = require("react");
|
|
|
2782
2782
|
var import_react_core10 = require("@copilotkit/react-core");
|
|
2783
2783
|
var import_shared4 = require("@copilotkit/shared");
|
|
2784
2784
|
function useCopilotChatSuggestions({
|
|
2785
|
+
available = "enabled",
|
|
2785
2786
|
instructions,
|
|
2786
2787
|
className,
|
|
2787
2788
|
minSuggestions = 1,
|
|
@@ -2789,6 +2790,8 @@ function useCopilotChatSuggestions({
|
|
|
2789
2790
|
}, dependencies = []) {
|
|
2790
2791
|
const context = (0, import_react_core10.useCopilotContext)();
|
|
2791
2792
|
(0, import_react15.useEffect)(() => {
|
|
2793
|
+
if (available === "disabled")
|
|
2794
|
+
return;
|
|
2792
2795
|
const id = (0, import_shared4.randomId)();
|
|
2793
2796
|
context.addChatSuggestionConfiguration(id, {
|
|
2794
2797
|
instructions,
|
|
@@ -2799,7 +2802,7 @@ function useCopilotChatSuggestions({
|
|
|
2799
2802
|
return () => {
|
|
2800
2803
|
context.removeChatSuggestionConfiguration(id);
|
|
2801
2804
|
};
|
|
2802
|
-
}, [...dependencies, instructions, minSuggestions, maxSuggestions, className]);
|
|
2805
|
+
}, [...dependencies, instructions, minSuggestions, maxSuggestions, className, available]);
|
|
2803
2806
|
}
|
|
2804
2807
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2805
2808
|
0 && (module.exports = {
|