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