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