@copilotkit/react-core 1.9.2-next.10 → 1.9.2-next.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 +16 -0
- package/dist/{chunk-EXU7GWLC.mjs → chunk-ENLPADPJ.mjs} +2 -2
- package/dist/{chunk-OF4SZTLL.mjs → chunk-GPCFFQHF.mjs} +2 -2
- package/dist/{chunk-G7LYGERN.mjs → chunk-IF2M6XIO.mjs} +24 -10
- package/dist/{chunk-G7LYGERN.mjs.map → chunk-IF2M6XIO.mjs.map} +1 -1
- package/dist/{chunk-ADIITPD2.mjs → chunk-UHEKBL6C.mjs} +2 -2
- package/dist/hooks/index.js +23 -9
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +4 -4
- package/dist/hooks/use-chat.js +23 -9
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +1 -1
- package/dist/hooks/use-coagent.js +23 -9
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +3 -3
- package/dist/hooks/use-copilot-chat.js +23 -9
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +2 -2
- package/dist/hooks/use-langgraph-interrupt.js +23 -9
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +3 -3
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +3 -3
- package/src/hooks/use-chat.ts +31 -9
- /package/dist/{chunk-EXU7GWLC.mjs.map → chunk-ENLPADPJ.mjs.map} +0 -0
- /package/dist/{chunk-OF4SZTLL.mjs.map → chunk-GPCFFQHF.mjs.map} +0 -0
- /package/dist/{chunk-ADIITPD2.mjs.map → chunk-UHEKBL6C.mjs.map} +0 -0
|
@@ -982,21 +982,35 @@ function useChat(options) {
|
|
|
982
982
|
[isLoading, messages, setMessages, runChatCompletionAndHandleFunctionCall]
|
|
983
983
|
);
|
|
984
984
|
const reload = useAsyncCallback(
|
|
985
|
-
(
|
|
985
|
+
(reloadMessageId) => __async(this, null, function* () {
|
|
986
986
|
if (isLoading || messages.length === 0) {
|
|
987
987
|
return;
|
|
988
988
|
}
|
|
989
|
-
const
|
|
990
|
-
if (
|
|
991
|
-
console.warn(`Message with id ${
|
|
989
|
+
const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);
|
|
990
|
+
if (reloadMessageIndex === -1) {
|
|
991
|
+
console.warn(`Message with id ${reloadMessageId} not found`);
|
|
992
992
|
return;
|
|
993
993
|
}
|
|
994
|
-
|
|
995
|
-
if (
|
|
996
|
-
|
|
994
|
+
const reloadMessageRole = messages[reloadMessageIndex].role;
|
|
995
|
+
if (reloadMessageRole !== import_runtime_client_gql3.MessageRole.Assistant) {
|
|
996
|
+
console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);
|
|
997
|
+
return;
|
|
997
998
|
}
|
|
998
|
-
|
|
999
|
-
|
|
999
|
+
let historyCutoff = [];
|
|
1000
|
+
if (messages.length > 2) {
|
|
1001
|
+
const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).reverse().find(
|
|
1002
|
+
(msg) => (
|
|
1003
|
+
// @ts-expect-error -- message has role
|
|
1004
|
+
msg.role === import_runtime_client_gql3.MessageRole.User
|
|
1005
|
+
)
|
|
1006
|
+
);
|
|
1007
|
+
const indexOfLastUserMessageBeforeRegenerate = messages.findIndex(
|
|
1008
|
+
(msg) => msg.id === lastUserMessageBeforeRegenerate.id
|
|
1009
|
+
);
|
|
1010
|
+
historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);
|
|
1011
|
+
}
|
|
1012
|
+
setMessages(historyCutoff);
|
|
1013
|
+
return runChatCompletionAndHandleFunctionCall(historyCutoff);
|
|
1000
1014
|
}),
|
|
1001
1015
|
[isLoading, messages, setMessages, runChatCompletionAndHandleFunctionCall]
|
|
1002
1016
|
);
|