@copilotkit/react-ui 1.3.16-mme-lgc-langgraph-package.11 → 1.3.16-mme-reset-chat.10
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 +55 -95
- package/dist/{chunk-C5KOJ3IH.mjs → chunk-3QOICFXX.mjs} +103 -7
- package/dist/chunk-3QOICFXX.mjs.map +1 -0
- package/dist/{chunk-QK6XA3PL.mjs → chunk-H7LLXN6X.mjs} +6 -2
- package/dist/chunk-H7LLXN6X.mjs.map +1 -0
- package/dist/{chunk-TEZWY2BL.mjs → chunk-P54DK2TL.mjs} +2 -2
- package/dist/{chunk-OJ5NVSTU.mjs → chunk-SEY3XSCD.mjs} +2 -2
- 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-C5KOJ3IH.mjs.map +0 -1
- package/dist/chunk-QK6XA3PL.mjs.map +0 -1
- /package/dist/{chunk-TEZWY2BL.mjs.map → chunk-P54DK2TL.mjs.map} +0 -0
- /package/dist/{chunk-OJ5NVSTU.mjs.map → chunk-SEY3XSCD.mjs.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotPopup
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-SEY3XSCD.mjs";
|
|
4
|
+
import "../../chunk-H7LLXN6X.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-3QOICFXX.mjs";
|
|
9
9
|
import "../../chunk-V7W6IM2V.mjs";
|
|
10
10
|
import "../../chunk-OMTPWC7T.mjs";
|
|
11
11
|
import "../../chunk-ZABXREBH.mjs";
|
|
@@ -2044,6 +2044,7 @@ function DebugMenuButton({
|
|
|
2044
2044
|
}
|
|
2045
2045
|
|
|
2046
2046
|
// src/components/chat/Chat.tsx
|
|
2047
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2047
2048
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2048
2049
|
function CopilotChat({
|
|
2049
2050
|
instructions,
|
|
@@ -2051,6 +2052,8 @@ function CopilotChat({
|
|
|
2051
2052
|
makeSystemMessage,
|
|
2052
2053
|
showResponseButton = true,
|
|
2053
2054
|
onInProgress,
|
|
2055
|
+
onStopGeneration,
|
|
2056
|
+
onReloadMessages,
|
|
2054
2057
|
Messages: Messages2 = Messages,
|
|
2055
2058
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2056
2059
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2073,7 +2076,13 @@ function CopilotChat({
|
|
|
2073
2076
|
sendMessage,
|
|
2074
2077
|
stopGeneration,
|
|
2075
2078
|
reloadMessages
|
|
2076
|
-
} = useCopilotChatLogic(
|
|
2079
|
+
} = useCopilotChatLogic(
|
|
2080
|
+
makeSystemMessage,
|
|
2081
|
+
onInProgress,
|
|
2082
|
+
onSubmitMessage,
|
|
2083
|
+
onStopGeneration,
|
|
2084
|
+
onReloadMessages
|
|
2085
|
+
);
|
|
2077
2086
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2078
2087
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2079
2088
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2129,8 +2138,15 @@ function WrappedCopilotChat({
|
|
|
2129
2138
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2130
2139
|
}
|
|
2131
2140
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2132
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2133
|
-
|
|
2141
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2142
|
+
var _a;
|
|
2143
|
+
const {
|
|
2144
|
+
visibleMessages,
|
|
2145
|
+
appendMessage,
|
|
2146
|
+
reloadMessages: defaultReloadMessages,
|
|
2147
|
+
stopGeneration: defaultStopGeneration,
|
|
2148
|
+
isLoading
|
|
2149
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2134
2150
|
id: (0, import_shared3.randomId)(),
|
|
2135
2151
|
makeSystemMessage
|
|
2136
2152
|
});
|
|
@@ -2138,8 +2154,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2138
2154
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2139
2155
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2140
2156
|
const abortSuggestions = () => {
|
|
2141
|
-
var
|
|
2142
|
-
(
|
|
2157
|
+
var _a2;
|
|
2158
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2143
2159
|
suggestionsAbortControllerRef.current = null;
|
|
2144
2160
|
};
|
|
2145
2161
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2165,7 +2181,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2165
2181
|
return () => {
|
|
2166
2182
|
clearTimeout(debounceTimerRef.current);
|
|
2167
2183
|
};
|
|
2168
|
-
}, [
|
|
2184
|
+
}, [
|
|
2185
|
+
isLoading,
|
|
2186
|
+
context.chatSuggestionConfiguration,
|
|
2187
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2188
|
+
// global context
|
|
2189
|
+
visibleMessages.length == 0
|
|
2190
|
+
]);
|
|
2169
2191
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2170
2192
|
abortSuggestions();
|
|
2171
2193
|
setCurrentSuggestions([]);
|
|
@@ -2183,6 +2205,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2183
2205
|
appendMessage(message);
|
|
2184
2206
|
return message;
|
|
2185
2207
|
});
|
|
2208
|
+
const messages = visibleMessages;
|
|
2209
|
+
const { setMessages } = messagesContext;
|
|
2210
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2211
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2212
|
+
if (generalContext.agentSession) {
|
|
2213
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2214
|
+
nodeName: void 0,
|
|
2215
|
+
threadId: void 0
|
|
2216
|
+
}));
|
|
2217
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2218
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2219
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2220
|
+
threadId: void 0,
|
|
2221
|
+
nodeName: void 0,
|
|
2222
|
+
runId: void 0
|
|
2223
|
+
})
|
|
2224
|
+
});
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
});
|
|
2228
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2229
|
+
if (generalContext.agentSession) {
|
|
2230
|
+
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2231
|
+
}
|
|
2232
|
+
});
|
|
2233
|
+
const stopCurrentAgent = () => {
|
|
2234
|
+
if (generalContext.agentSession) {
|
|
2235
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
const setCurrentAgentState = (state) => {
|
|
2239
|
+
if (generalContext.agentSession) {
|
|
2240
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2241
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2242
|
+
[generalContext.agentSession.agentName]: {
|
|
2243
|
+
state
|
|
2244
|
+
}
|
|
2245
|
+
});
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
};
|
|
2249
|
+
function stopGeneration() {
|
|
2250
|
+
if (onStopGeneration) {
|
|
2251
|
+
onStopGeneration({
|
|
2252
|
+
messages,
|
|
2253
|
+
setMessages,
|
|
2254
|
+
stopGeneration: defaultStopGeneration,
|
|
2255
|
+
currentAgentName,
|
|
2256
|
+
restartCurrentAgent,
|
|
2257
|
+
stopCurrentAgent,
|
|
2258
|
+
runCurrentAgent,
|
|
2259
|
+
setCurrentAgentState
|
|
2260
|
+
});
|
|
2261
|
+
} else {
|
|
2262
|
+
defaultStopGeneration();
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
function reloadMessages() {
|
|
2266
|
+
if (onReloadMessages) {
|
|
2267
|
+
onReloadMessages({
|
|
2268
|
+
messages,
|
|
2269
|
+
setMessages,
|
|
2270
|
+
stopGeneration: defaultStopGeneration,
|
|
2271
|
+
currentAgentName,
|
|
2272
|
+
restartCurrentAgent,
|
|
2273
|
+
stopCurrentAgent,
|
|
2274
|
+
runCurrentAgent,
|
|
2275
|
+
setCurrentAgentState
|
|
2276
|
+
});
|
|
2277
|
+
} else {
|
|
2278
|
+
defaultReloadMessages();
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2186
2281
|
return {
|
|
2187
2282
|
visibleMessages,
|
|
2188
2283
|
isLoading,
|
|
@@ -2202,6 +2297,8 @@ var CopilotModal = ({
|
|
|
2202
2297
|
hitEscapeToClose = true,
|
|
2203
2298
|
onSetOpen,
|
|
2204
2299
|
onSubmitMessage,
|
|
2300
|
+
onStopGeneration,
|
|
2301
|
+
onReloadMessages,
|
|
2205
2302
|
shortcut = "/",
|
|
2206
2303
|
icons,
|
|
2207
2304
|
labels,
|
|
@@ -2239,6 +2336,8 @@ var CopilotModal = ({
|
|
|
2239
2336
|
{
|
|
2240
2337
|
instructions,
|
|
2241
2338
|
onSubmitMessage,
|
|
2339
|
+
onStopGeneration,
|
|
2340
|
+
onReloadMessages,
|
|
2242
2341
|
makeSystemMessage,
|
|
2243
2342
|
showResponseButton,
|
|
2244
2343
|
onInProgress,
|