@copilotkit/react-ui 1.3.16-pre.11 → 1.3.16-pre.12
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 +21 -5
- package/dist/{chunk-ORHE7FYT.mjs → chunk-2BAND4IT.mjs} +103 -7
- package/dist/chunk-2BAND4IT.mjs.map +1 -0
- package/dist/{chunk-M2NVAJQA.mjs → chunk-5XQEL3WQ.mjs} +2 -2
- package/dist/{chunk-PY7YBFPA.mjs → chunk-DXMPY4SG.mjs} +2 -2
- package/dist/{chunk-H5CXJBR5.mjs → chunk-OG2XHQQM.mjs} +6 -2
- package/dist/chunk-OG2XHQQM.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +50 -5
- package/dist/components/chat/Chat.js +101 -6
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +105 -6
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +2 -2
- package/dist/components/chat/Popup.js +105 -6
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +3 -3
- package/dist/components/chat/Sidebar.js +105 -6
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +3 -3
- package/dist/components/chat/index.js +105 -6
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +4 -4
- package/dist/components/index.js +105 -6
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/index.js +107 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +7 -7
- package/src/components/chat/Chat.tsx +166 -7
- package/src/components/chat/Modal.tsx +4 -0
- package/dist/chunk-H5CXJBR5.mjs.map +0 -1
- package/dist/chunk-ORHE7FYT.mjs.map +0 -1
- /package/dist/{chunk-M2NVAJQA.mjs.map → chunk-5XQEL3WQ.mjs.map} +0 -0
- /package/dist/{chunk-PY7YBFPA.mjs.map → chunk-DXMPY4SG.mjs.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotPopup
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-DXMPY4SG.mjs";
|
|
4
|
+
import "../../chunk-OG2XHQQM.mjs";
|
|
5
5
|
import "../../chunk-YAGE7RCE.mjs";
|
|
6
6
|
import "../../chunk-VEC45H6Q.mjs";
|
|
7
7
|
import "../../chunk-RQNJNK2W.mjs";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-2BAND4IT.mjs";
|
|
9
9
|
import "../../chunk-V7W6IM2V.mjs";
|
|
10
10
|
import "../../chunk-OMTPWC7T.mjs";
|
|
11
11
|
import "../../chunk-ZABXREBH.mjs";
|
|
@@ -2093,6 +2093,7 @@ function DebugMenuButton({
|
|
|
2093
2093
|
}
|
|
2094
2094
|
|
|
2095
2095
|
// src/components/chat/Chat.tsx
|
|
2096
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2096
2097
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2097
2098
|
function CopilotChat({
|
|
2098
2099
|
instructions,
|
|
@@ -2100,6 +2101,8 @@ function CopilotChat({
|
|
|
2100
2101
|
makeSystemMessage,
|
|
2101
2102
|
showResponseButton = true,
|
|
2102
2103
|
onInProgress,
|
|
2104
|
+
onStopGeneration,
|
|
2105
|
+
onReloadMessages,
|
|
2103
2106
|
Messages: Messages2 = Messages,
|
|
2104
2107
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2105
2108
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2122,7 +2125,13 @@ function CopilotChat({
|
|
|
2122
2125
|
sendMessage,
|
|
2123
2126
|
stopGeneration,
|
|
2124
2127
|
reloadMessages
|
|
2125
|
-
} = useCopilotChatLogic(
|
|
2128
|
+
} = useCopilotChatLogic(
|
|
2129
|
+
makeSystemMessage,
|
|
2130
|
+
onInProgress,
|
|
2131
|
+
onSubmitMessage,
|
|
2132
|
+
onStopGeneration,
|
|
2133
|
+
onReloadMessages
|
|
2134
|
+
);
|
|
2126
2135
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2127
2136
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2128
2137
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2178,8 +2187,15 @@ function WrappedCopilotChat({
|
|
|
2178
2187
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2179
2188
|
}
|
|
2180
2189
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2181
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2182
|
-
|
|
2190
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2191
|
+
var _a;
|
|
2192
|
+
const {
|
|
2193
|
+
visibleMessages,
|
|
2194
|
+
appendMessage,
|
|
2195
|
+
reloadMessages: defaultReloadMessages,
|
|
2196
|
+
stopGeneration: defaultStopGeneration,
|
|
2197
|
+
isLoading
|
|
2198
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2183
2199
|
id: (0, import_shared3.randomId)(),
|
|
2184
2200
|
makeSystemMessage
|
|
2185
2201
|
});
|
|
@@ -2187,8 +2203,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2187
2203
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2188
2204
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2189
2205
|
const abortSuggestions = () => {
|
|
2190
|
-
var
|
|
2191
|
-
(
|
|
2206
|
+
var _a2;
|
|
2207
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2192
2208
|
suggestionsAbortControllerRef.current = null;
|
|
2193
2209
|
};
|
|
2194
2210
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2214,7 +2230,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2214
2230
|
return () => {
|
|
2215
2231
|
clearTimeout(debounceTimerRef.current);
|
|
2216
2232
|
};
|
|
2217
|
-
}, [
|
|
2233
|
+
}, [
|
|
2234
|
+
isLoading,
|
|
2235
|
+
context.chatSuggestionConfiguration,
|
|
2236
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2237
|
+
// global context
|
|
2238
|
+
visibleMessages.length == 0
|
|
2239
|
+
]);
|
|
2218
2240
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2219
2241
|
abortSuggestions();
|
|
2220
2242
|
setCurrentSuggestions([]);
|
|
@@ -2232,6 +2254,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2232
2254
|
appendMessage(message);
|
|
2233
2255
|
return message;
|
|
2234
2256
|
});
|
|
2257
|
+
const messages = visibleMessages;
|
|
2258
|
+
const { setMessages } = messagesContext;
|
|
2259
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2260
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2261
|
+
if (generalContext.agentSession) {
|
|
2262
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2263
|
+
nodeName: void 0,
|
|
2264
|
+
threadId: void 0
|
|
2265
|
+
}));
|
|
2266
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2267
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2268
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2269
|
+
threadId: void 0,
|
|
2270
|
+
nodeName: void 0,
|
|
2271
|
+
runId: void 0
|
|
2272
|
+
})
|
|
2273
|
+
});
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2278
|
+
if (generalContext.agentSession) {
|
|
2279
|
+
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2280
|
+
}
|
|
2281
|
+
});
|
|
2282
|
+
const stopCurrentAgent = () => {
|
|
2283
|
+
if (generalContext.agentSession) {
|
|
2284
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
const setCurrentAgentState = (state) => {
|
|
2288
|
+
if (generalContext.agentSession) {
|
|
2289
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2290
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2291
|
+
[generalContext.agentSession.agentName]: {
|
|
2292
|
+
state
|
|
2293
|
+
}
|
|
2294
|
+
});
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
function stopGeneration() {
|
|
2299
|
+
if (onStopGeneration) {
|
|
2300
|
+
onStopGeneration({
|
|
2301
|
+
messages,
|
|
2302
|
+
setMessages,
|
|
2303
|
+
stopGeneration: defaultStopGeneration,
|
|
2304
|
+
currentAgentName,
|
|
2305
|
+
restartCurrentAgent,
|
|
2306
|
+
stopCurrentAgent,
|
|
2307
|
+
runCurrentAgent,
|
|
2308
|
+
setCurrentAgentState
|
|
2309
|
+
});
|
|
2310
|
+
} else {
|
|
2311
|
+
defaultStopGeneration();
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
function reloadMessages() {
|
|
2315
|
+
if (onReloadMessages) {
|
|
2316
|
+
onReloadMessages({
|
|
2317
|
+
messages,
|
|
2318
|
+
setMessages,
|
|
2319
|
+
stopGeneration: defaultStopGeneration,
|
|
2320
|
+
currentAgentName,
|
|
2321
|
+
restartCurrentAgent,
|
|
2322
|
+
stopCurrentAgent,
|
|
2323
|
+
runCurrentAgent,
|
|
2324
|
+
setCurrentAgentState
|
|
2325
|
+
});
|
|
2326
|
+
} else {
|
|
2327
|
+
defaultReloadMessages();
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2235
2330
|
return {
|
|
2236
2331
|
visibleMessages,
|
|
2237
2332
|
isLoading,
|
|
@@ -2251,6 +2346,8 @@ var CopilotModal = ({
|
|
|
2251
2346
|
hitEscapeToClose = true,
|
|
2252
2347
|
onSetOpen,
|
|
2253
2348
|
onSubmitMessage,
|
|
2349
|
+
onStopGeneration,
|
|
2350
|
+
onReloadMessages,
|
|
2254
2351
|
shortcut = "/",
|
|
2255
2352
|
icons,
|
|
2256
2353
|
labels,
|
|
@@ -2288,6 +2385,8 @@ var CopilotModal = ({
|
|
|
2288
2385
|
{
|
|
2289
2386
|
instructions,
|
|
2290
2387
|
onSubmitMessage,
|
|
2388
|
+
onStopGeneration,
|
|
2389
|
+
onReloadMessages,
|
|
2291
2390
|
makeSystemMessage,
|
|
2292
2391
|
showResponseButton,
|
|
2293
2392
|
onInProgress,
|