@copilotkit/react-core 1.3.16-mme-improve-langsmith.1 → 1.3.16-mme-reset-chat.3
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 +18 -0
- package/dist/{chunk-QL23NJ57.mjs → chunk-3LGVOOTH.mjs} +3 -3
- package/dist/{chunk-6YEMNWKE.mjs → chunk-7PBUNYGJ.mjs} +10 -3
- package/dist/{chunk-6YEMNWKE.mjs.map → chunk-7PBUNYGJ.mjs.map} +1 -1
- package/dist/{chunk-TRXKPXDE.mjs → chunk-AB6GYTGE.mjs} +2 -2
- package/dist/{chunk-7DFHFZJT.mjs → chunk-DA2PE4TI.mjs} +2 -2
- package/dist/{chunk-CQ23Q555.mjs → chunk-IQ32YPV5.mjs} +2 -2
- package/dist/{chunk-ZM6HV22S.mjs → chunk-KEUH7BJV.mjs} +2 -2
- package/dist/{chunk-G2K6T2QU.mjs → chunk-NTADUCPY.mjs} +12 -4
- package/dist/chunk-NTADUCPY.mjs.map +1 -0
- package/dist/{chunk-ANOG3W5S.mjs → chunk-NV6FEDPI.mjs} +2 -2
- package/dist/{chunk-MX2OYLRS.mjs → chunk-P4BUM2FG.mjs} +33 -6
- package/dist/chunk-P4BUM2FG.mjs.map +1 -0
- package/dist/{chunk-2MPUQRAY.mjs → chunk-UO527OAF.mjs} +8 -1
- package/dist/{chunk-2MPUQRAY.mjs.map → chunk-UO527OAF.mjs.map} +1 -1
- package/dist/{chunk-RYDEG77L.mjs → chunk-YEBQV2YJ.mjs} +2 -2
- package/dist/components/copilot-provider/copilotkit.js +15 -1
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +2 -2
- package/dist/components/copilot-provider/index.js +15 -1
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +2 -2
- package/dist/components/index.js +15 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/context/copilot-context.d.ts +5 -0
- package/dist/context/copilot-context.js +7 -0
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.js +7 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.js +47 -5
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +16 -16
- package/dist/hooks/use-chat.d.ts +16 -0
- package/dist/hooks/use-chat.js +11 -3
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +1 -1
- package/dist/hooks/use-coagent-state-render.js +7 -0
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +2 -2
- package/dist/hooks/use-coagent.js +47 -5
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +6 -6
- package/dist/hooks/use-copilot-action.js +7 -0
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +2 -2
- package/dist/hooks/use-copilot-chat.d.ts +1 -0
- package/dist/hooks/use-copilot-chat.js +47 -5
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +5 -5
- package/dist/hooks/use-copilot-readable.js +7 -0
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-make-copilot-document-readable.js +7 -0
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/index.js +55 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -18
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +3 -3
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +3 -3
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +3 -3
- package/package.json +5 -5
- package/src/components/copilot-provider/copilotkit.tsx +7 -0
- package/src/context/copilot-context.tsx +15 -0
- package/src/hooks/use-chat.ts +31 -2
- package/src/hooks/use-copilot-chat.ts +32 -3
- package/dist/chunk-G2K6T2QU.mjs.map +0 -1
- package/dist/chunk-MX2OYLRS.mjs.map +0 -1
- /package/dist/{chunk-QL23NJ57.mjs.map → chunk-3LGVOOTH.mjs.map} +0 -0
- /package/dist/{chunk-TRXKPXDE.mjs.map → chunk-AB6GYTGE.mjs.map} +0 -0
- /package/dist/{chunk-7DFHFZJT.mjs.map → chunk-DA2PE4TI.mjs.map} +0 -0
- /package/dist/{chunk-CQ23Q555.mjs.map → chunk-IQ32YPV5.mjs.map} +0 -0
- /package/dist/{chunk-ZM6HV22S.mjs.map → chunk-KEUH7BJV.mjs.map} +0 -0
- /package/dist/{chunk-ANOG3W5S.mjs.map → chunk-NV6FEDPI.mjs.map} +0 -0
- /package/dist/{chunk-RYDEG77L.mjs.map → chunk-YEBQV2YJ.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -151,6 +151,13 @@ var emptyCopilotContext = {
|
|
|
151
151
|
},
|
|
152
152
|
agentSession: null,
|
|
153
153
|
setAgentSession: () => {
|
|
154
|
+
},
|
|
155
|
+
agentLock: null,
|
|
156
|
+
threadId: null,
|
|
157
|
+
setThreadId: () => {
|
|
158
|
+
},
|
|
159
|
+
runId: null,
|
|
160
|
+
setRunId: () => {
|
|
154
161
|
}
|
|
155
162
|
};
|
|
156
163
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
@@ -565,6 +572,8 @@ ${nonDocumentStrings}`;
|
|
|
565
572
|
};
|
|
566
573
|
}
|
|
567
574
|
const [agentSession, setAgentSession] = (0, import_react6.useState)(initialAgentSession);
|
|
575
|
+
const [threadId, setThreadId] = (0, import_react6.useState)(null);
|
|
576
|
+
const [runId, setRunId] = (0, import_react6.useState)(null);
|
|
568
577
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
569
578
|
CopilotContext.Provider,
|
|
570
579
|
{
|
|
@@ -595,7 +604,12 @@ ${nonDocumentStrings}`;
|
|
|
595
604
|
coagentStates,
|
|
596
605
|
setCoagentStates,
|
|
597
606
|
agentSession,
|
|
598
|
-
setAgentSession
|
|
607
|
+
setAgentSession,
|
|
608
|
+
agentLock: props.agent || null,
|
|
609
|
+
threadId,
|
|
610
|
+
setThreadId,
|
|
611
|
+
runId,
|
|
612
|
+
setRunId
|
|
599
613
|
},
|
|
600
614
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CopilotMessages, { children })
|
|
601
615
|
}
|
|
@@ -651,16 +665,22 @@ function useChat(options) {
|
|
|
651
665
|
setCoagentStates,
|
|
652
666
|
coagentStates,
|
|
653
667
|
agentSession,
|
|
654
|
-
setAgentSession
|
|
668
|
+
setAgentSession,
|
|
669
|
+
threadId,
|
|
670
|
+
setThreadId,
|
|
671
|
+
runId,
|
|
672
|
+
setRunId
|
|
655
673
|
} = options;
|
|
656
674
|
const abortControllerRef = (0, import_react7.useRef)();
|
|
657
|
-
const threadIdRef = (0, import_react7.useRef)(null);
|
|
658
|
-
const runIdRef = (0, import_react7.useRef)(null);
|
|
659
675
|
const runChatCompletionRef = (0, import_react7.useRef)();
|
|
660
676
|
const coagentStatesRef = (0, import_react7.useRef)(coagentStates);
|
|
661
677
|
coagentStatesRef.current = coagentStates;
|
|
662
678
|
const agentSessionRef = (0, import_react7.useRef)(agentSession);
|
|
663
679
|
agentSessionRef.current = agentSession;
|
|
680
|
+
const threadIdRef = (0, import_react7.useRef)(threadId);
|
|
681
|
+
threadIdRef.current = threadId;
|
|
682
|
+
const runIdRef = (0, import_react7.useRef)(runId);
|
|
683
|
+
runIdRef.current = runId;
|
|
664
684
|
const publicApiKey = copilotConfig.publicApiKey;
|
|
665
685
|
const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared4.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
666
686
|
const runtimeClient = new import_runtime_client_gql.CopilotRuntimeClient({
|
|
@@ -738,6 +758,8 @@ function useChat(options) {
|
|
|
738
758
|
}
|
|
739
759
|
threadIdRef.current = value.generateCopilotResponse.threadId || null;
|
|
740
760
|
runIdRef.current = value.generateCopilotResponse.runId || null;
|
|
761
|
+
setThreadId(threadIdRef.current);
|
|
762
|
+
setRunId(runIdRef.current);
|
|
741
763
|
const messages2 = (0, import_runtime_client_gql.convertGqlOutputToMessages)(
|
|
742
764
|
(0, import_runtime_client_gql.filterAdjacentAgentStateMessages)(value.generateCopilotResponse.messages)
|
|
743
765
|
);
|
|
@@ -894,7 +916,12 @@ function useCopilotChat(_a = {}) {
|
|
|
894
916
|
setCoagentStates,
|
|
895
917
|
coAgentStateRenders,
|
|
896
918
|
agentSession,
|
|
897
|
-
setAgentSession
|
|
919
|
+
setAgentSession,
|
|
920
|
+
agentLock,
|
|
921
|
+
threadId,
|
|
922
|
+
setThreadId,
|
|
923
|
+
runId,
|
|
924
|
+
setRunId
|
|
898
925
|
} = useCopilotContext();
|
|
899
926
|
const { messages, setMessages } = useCopilotMessagesContext();
|
|
900
927
|
const latestGetContextString = useUpdatedRef(getContextString);
|
|
@@ -944,7 +971,11 @@ function useCopilotChat(_a = {}) {
|
|
|
944
971
|
coagentStates,
|
|
945
972
|
setCoagentStates,
|
|
946
973
|
agentSession,
|
|
947
|
-
setAgentSession
|
|
974
|
+
setAgentSession,
|
|
975
|
+
threadId,
|
|
976
|
+
setThreadId,
|
|
977
|
+
runId,
|
|
978
|
+
setRunId
|
|
948
979
|
}));
|
|
949
980
|
const latestAppend = useUpdatedRef(append);
|
|
950
981
|
const latestAppendFunc = (0, import_react8.useCallback)(
|
|
@@ -975,6 +1006,23 @@ function useCopilotChat(_a = {}) {
|
|
|
975
1006
|
},
|
|
976
1007
|
[latestSetMessages]
|
|
977
1008
|
);
|
|
1009
|
+
const reset = (0, import_react8.useCallback)(() => {
|
|
1010
|
+
latestStopFunc();
|
|
1011
|
+
setMessages([]);
|
|
1012
|
+
setThreadId(null);
|
|
1013
|
+
setCoagentStates({});
|
|
1014
|
+
let initialAgentSession = null;
|
|
1015
|
+
if (agentLock) {
|
|
1016
|
+
initialAgentSession = {
|
|
1017
|
+
agentName: agentLock
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
setAgentSession(initialAgentSession);
|
|
1021
|
+
}, [latestStopFunc, setMessages, setThreadId, setCoagentStates, setAgentSession, agentLock]);
|
|
1022
|
+
const latestReset = useUpdatedRef(reset);
|
|
1023
|
+
const latestResetFunc = (0, import_react8.useCallback)(() => {
|
|
1024
|
+
return latestReset.current();
|
|
1025
|
+
}, [latestReset]);
|
|
978
1026
|
return {
|
|
979
1027
|
visibleMessages: messages,
|
|
980
1028
|
appendMessage: latestAppendFunc,
|
|
@@ -982,6 +1030,7 @@ function useCopilotChat(_a = {}) {
|
|
|
982
1030
|
reloadMessages: latestReloadFunc,
|
|
983
1031
|
stopGeneration: latestStopFunc,
|
|
984
1032
|
deleteMessage: latestDeleteFunc,
|
|
1033
|
+
reset: latestResetFunc,
|
|
985
1034
|
isLoading
|
|
986
1035
|
};
|
|
987
1036
|
}
|