@copilotkit/react-core 0.25.0 → 0.36.0-mme-push-to-talk.0
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/.turbo/turbo-build.log +108 -189
- package/CHANGELOG.md +11 -0
- package/dist/{chunk-ZIR7KCEA.mjs → chunk-4GYWZE2P.mjs} +1 -2
- package/dist/{chunk-OWBDHSLH.mjs → chunk-5L4TYK4W.mjs} +8 -4
- package/dist/{chunk-MZ5UN3BY.mjs → chunk-6WFEP6DR.mjs} +1 -2
- package/dist/chunk-BJZMR7WC.mjs +0 -0
- package/dist/chunk-CROTHJUA.mjs +0 -0
- package/dist/chunk-CWK7RV25.mjs +0 -0
- package/dist/chunk-FT5DESSI.mjs +0 -0
- package/dist/{chunk-PC6FY3LD.mjs → chunk-FT5S7PNE.mjs} +1 -2
- package/dist/{chunk-O35YOIHC.mjs → chunk-GBUK745N.mjs} +1 -2
- package/dist/{chunk-MRXNTQOX.mjs → chunk-HIDP27A7.mjs} +0 -1
- package/dist/chunk-HNKVKTPX.mjs +0 -0
- package/dist/{chunk-YULKJPY3.mjs → chunk-K4KJZOIZ.mjs} +0 -1
- package/dist/chunk-KQTWUIAM.mjs +0 -0
- package/dist/{chunk-4NNFSZOY.mjs → chunk-LD2JLHT2.mjs} +2 -3
- package/dist/chunk-LOLJLZCX.mjs +0 -0
- package/dist/chunk-M4IVLZIH.mjs +0 -0
- package/dist/{chunk-VUY2K2DI.mjs → chunk-NWOJ4DVV.mjs} +1 -2
- package/dist/{chunk-CGT3AVYT.mjs → chunk-QBL56RUZ.mjs} +5 -4
- package/dist/{chunk-M6WULIFO.mjs → chunk-SIFJW3HD.mjs} +4 -5
- package/dist/{chunk-72BJ3A3S.mjs → chunk-UNX3EO3E.mjs} +1 -2
- package/dist/{chunk-6ARSX7BW.mjs → chunk-V5SRTWPE.mjs} +1 -2
- package/dist/chunk-VK5H6Y6B.mjs +121 -0
- package/dist/{chunk-6VF626RG.mjs → chunk-WNH25WIR.mjs} +4 -5
- package/dist/chunk-YGKURLXD.mjs +0 -0
- package/dist/chunk-YQ6KMLKO.mjs +0 -0
- package/dist/{chunk-KTUNGBJF.mjs → chunk-YQUWTA3R.mjs} +1 -2
- package/dist/{chunk-7LVVZQRG.mjs → chunk-ZYDU7WF7.mjs} +7 -6
- package/dist/components/copilot-provider/copilotkit-props.d.ts +18 -12
- package/dist/components/copilot-provider/copilotkit-props.js +0 -1
- package/dist/components/copilot-provider/copilotkit-props.mjs +0 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +0 -20
- package/dist/components/copilot-provider/copilotkit.js +3 -2
- package/dist/components/copilot-provider/copilotkit.mjs +5 -6
- package/dist/components/copilot-provider/index.js +3 -2
- package/dist/components/copilot-provider/index.mjs +6 -7
- package/dist/components/index.js +3 -2
- package/dist/components/index.mjs +7 -8
- package/dist/context/copilot-context.d.ts +8 -0
- package/dist/context/copilot-context.js +0 -1
- package/dist/context/copilot-context.mjs +2 -3
- package/dist/context/index.js +0 -1
- package/dist/context/index.mjs +3 -4
- package/dist/hooks/index.js +4 -3
- package/dist/hooks/index.mjs +16 -17
- package/dist/hooks/use-chat.js +4 -3
- package/dist/hooks/use-chat.mjs +3 -4
- package/dist/hooks/use-copilot-action.js +0 -1
- package/dist/hooks/use-copilot-action.mjs +3 -4
- package/dist/hooks/use-copilot-chat.js +4 -3
- package/dist/hooks/use-copilot-chat.mjs +10 -11
- package/dist/hooks/use-copilot-readable.js +0 -1
- package/dist/hooks/use-copilot-readable.mjs +3 -4
- package/dist/hooks/use-flat-category-store.js +0 -1
- package/dist/hooks/use-flat-category-store.mjs +2 -3
- package/dist/hooks/use-make-copilot-actionable.js +0 -1
- package/dist/hooks/use-make-copilot-actionable.mjs +3 -4
- package/dist/hooks/use-make-copilot-document-readable.js +0 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +3 -4
- package/dist/hooks/use-make-copilot-readable.js +0 -1
- package/dist/hooks/use-make-copilot-readable.mjs +3 -4
- package/dist/hooks/use-tree.js +0 -1
- package/dist/hooks/use-tree.mjs +2 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +122 -7
- package/dist/index.mjs +30 -26
- package/dist/lib/copilot-task.d.ts +97 -1
- package/dist/lib/copilot-task.js +9 -3
- package/dist/lib/copilot-task.mjs +9 -10
- package/dist/lib/index.js +9 -3
- package/dist/lib/index.mjs +10 -11
- package/dist/openai-assistants/hooks/index.js +0 -1
- package/dist/openai-assistants/hooks/index.mjs +12 -13
- package/dist/openai-assistants/hooks/use-assistants.js +0 -1
- package/dist/openai-assistants/hooks/use-assistants.mjs +3 -4
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.js +0 -1
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs +11 -12
- package/dist/openai-assistants/index.js +0 -1
- package/dist/openai-assistants/index.mjs +13 -14
- package/dist/openai-assistants/utils/index.js +0 -1
- package/dist/openai-assistants/utils/index.mjs +3 -4
- package/dist/openai-assistants/utils/process-message-stream.js +0 -1
- package/dist/openai-assistants/utils/process-message-stream.mjs +2 -3
- package/dist/types/document-pointer.js +0 -1
- package/dist/types/document-pointer.mjs +0 -1
- package/dist/types/frontend-action.js +0 -1
- package/dist/types/frontend-action.mjs +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.mjs +1 -2
- package/dist/types/system-message.js +0 -1
- package/dist/types/system-message.mjs +0 -1
- package/dist/utils/extract.d.ts +36 -0
- package/dist/utils/extract.js +244 -0
- package/dist/utils/extract.mjs +14 -0
- package/dist/utils/fetch-chat-completion.d.ts +7 -1
- package/dist/utils/fetch-chat-completion.js +4 -3
- package/dist/utils/fetch-chat-completion.mjs +2 -3
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +266 -0
- package/dist/utils/index.mjs +22 -0
- package/dist/utils/utils.js +0 -1
- package/dist/utils/utils.mjs +0 -1
- package/dist/utils/utils.test.js +0 -1
- package/dist/utils/utils.test.mjs +0 -1
- package/package.json +4 -4
- package/src/components/copilot-provider/copilotkit-props.tsx +20 -12
- package/src/components/copilot-provider/copilotkit.tsx +40 -20
- package/src/context/copilot-context.tsx +11 -1
- package/src/hooks/use-chat.ts +2 -2
- package/src/hooks/use-copilot-readable.ts +94 -0
- package/src/index.tsx +1 -6
- package/src/lib/copilot-task.ts +97 -1
- package/src/utils/extract.ts +164 -0
- package/src/utils/fetch-chat-completion.ts +5 -1
- package/src/utils/index.ts +8 -0
- package/tsup.config.ts +1 -1
- package/typedoc.json +4 -0
- package/dist/chunk-4NNFSZOY.mjs.map +0 -1
- package/dist/chunk-6ARSX7BW.mjs.map +0 -1
- package/dist/chunk-6VF626RG.mjs.map +0 -1
- package/dist/chunk-72BJ3A3S.mjs.map +0 -1
- package/dist/chunk-7GFKOIO7.mjs +0 -1
- package/dist/chunk-7GFKOIO7.mjs.map +0 -1
- package/dist/chunk-7LVVZQRG.mjs.map +0 -1
- package/dist/chunk-BABVSMJR.mjs +0 -1
- package/dist/chunk-BABVSMJR.mjs.map +0 -1
- package/dist/chunk-CGT3AVYT.mjs.map +0 -1
- package/dist/chunk-EFZPSZWO.mjs +0 -1
- package/dist/chunk-EFZPSZWO.mjs.map +0 -1
- package/dist/chunk-EYKDJBDE.mjs +0 -1
- package/dist/chunk-EYKDJBDE.mjs.map +0 -1
- package/dist/chunk-FRAKUJWH.mjs +0 -1
- package/dist/chunk-FRAKUJWH.mjs.map +0 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -1
- package/dist/chunk-JD7BAH7U.mjs.map +0 -1
- package/dist/chunk-KTUNGBJF.mjs.map +0 -1
- package/dist/chunk-LUGEI4YQ.mjs +0 -1
- package/dist/chunk-LUGEI4YQ.mjs.map +0 -1
- package/dist/chunk-M6WULIFO.mjs.map +0 -1
- package/dist/chunk-MRXNTQOX.mjs.map +0 -1
- package/dist/chunk-MZ5UN3BY.mjs.map +0 -1
- package/dist/chunk-O35YOIHC.mjs.map +0 -1
- package/dist/chunk-OWBDHSLH.mjs.map +0 -1
- package/dist/chunk-PC6FY3LD.mjs.map +0 -1
- package/dist/chunk-SPCZTZCY.mjs +0 -1
- package/dist/chunk-SPCZTZCY.mjs.map +0 -1
- package/dist/chunk-VNRDQJXW.mjs +0 -1
- package/dist/chunk-VNRDQJXW.mjs.map +0 -1
- package/dist/chunk-VUY2K2DI.mjs.map +0 -1
- package/dist/chunk-YULKJPY3.mjs.map +0 -1
- package/dist/chunk-ZIR7KCEA.mjs.map +0 -1
- package/dist/components/copilot-provider/copilotkit-props.js.map +0 -1
- package/dist/components/copilot-provider/copilotkit-props.mjs.map +0 -1
- package/dist/components/copilot-provider/copilotkit.js.map +0 -1
- package/dist/components/copilot-provider/copilotkit.mjs.map +0 -1
- package/dist/components/copilot-provider/index.js.map +0 -1
- package/dist/components/copilot-provider/index.mjs.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/index.mjs.map +0 -1
- package/dist/context/copilot-context.js.map +0 -1
- package/dist/context/copilot-context.mjs.map +0 -1
- package/dist/context/index.js.map +0 -1
- package/dist/context/index.mjs.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/hooks/use-chat.js.map +0 -1
- package/dist/hooks/use-chat.mjs.map +0 -1
- package/dist/hooks/use-copilot-action.js.map +0 -1
- package/dist/hooks/use-copilot-action.mjs.map +0 -1
- package/dist/hooks/use-copilot-chat.js.map +0 -1
- package/dist/hooks/use-copilot-chat.mjs.map +0 -1
- package/dist/hooks/use-copilot-readable.js.map +0 -1
- package/dist/hooks/use-copilot-readable.mjs.map +0 -1
- package/dist/hooks/use-flat-category-store.js.map +0 -1
- package/dist/hooks/use-flat-category-store.mjs.map +0 -1
- package/dist/hooks/use-make-copilot-actionable.js.map +0 -1
- package/dist/hooks/use-make-copilot-actionable.mjs.map +0 -1
- package/dist/hooks/use-make-copilot-document-readable.js.map +0 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs.map +0 -1
- package/dist/hooks/use-make-copilot-readable.js.map +0 -1
- package/dist/hooks/use-make-copilot-readable.mjs.map +0 -1
- package/dist/hooks/use-tree.js.map +0 -1
- package/dist/hooks/use-tree.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/lib/copilot-task.js.map +0 -1
- package/dist/lib/copilot-task.mjs.map +0 -1
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/index.mjs.map +0 -1
- package/dist/openai-assistants/hooks/index.js.map +0 -1
- package/dist/openai-assistants/hooks/index.mjs.map +0 -1
- package/dist/openai-assistants/hooks/use-assistants.js.map +0 -1
- package/dist/openai-assistants/hooks/use-assistants.mjs.map +0 -1
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.js.map +0 -1
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map +0 -1
- package/dist/openai-assistants/index.js.map +0 -1
- package/dist/openai-assistants/index.mjs.map +0 -1
- package/dist/openai-assistants/utils/index.js.map +0 -1
- package/dist/openai-assistants/utils/index.mjs.map +0 -1
- package/dist/openai-assistants/utils/process-message-stream.js.map +0 -1
- package/dist/openai-assistants/utils/process-message-stream.mjs.map +0 -1
- package/dist/types/document-pointer.js.map +0 -1
- package/dist/types/document-pointer.mjs.map +0 -1
- package/dist/types/frontend-action.js.map +0 -1
- package/dist/types/frontend-action.mjs.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/system-message.js.map +0 -1
- package/dist/types/system-message.mjs.map +0 -1
- package/dist/utils/fetch-chat-completion.js.map +0 -1
- package/dist/utils/fetch-chat-completion.mjs.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/dist/utils/utils.mjs.map +0 -1
- package/dist/utils/utils.test.js.map +0 -1
- package/dist/utils/utils.test.mjs.map +0 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotTask
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-5L4TYK4W.mjs";
|
|
4
|
+
import "../chunk-BJZMR7WC.mjs";
|
|
5
|
+
import "../chunk-FT5DESSI.mjs";
|
|
6
|
+
import "../chunk-ZYDU7WF7.mjs";
|
|
7
|
+
import "../chunk-K4KJZOIZ.mjs";
|
|
8
|
+
import "../chunk-NWOJ4DVV.mjs";
|
|
9
|
+
import "../chunk-QBL56RUZ.mjs";
|
|
10
|
+
import "../chunk-GBUK745N.mjs";
|
|
11
|
+
import "../chunk-HIDP27A7.mjs";
|
|
12
12
|
export {
|
|
13
13
|
CopilotTask
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=copilot-task.mjs.map
|
package/dist/lib/index.js
CHANGED
|
@@ -75,7 +75,8 @@ function fetchChatCompletion(_0) {
|
|
|
75
75
|
temperature,
|
|
76
76
|
headers,
|
|
77
77
|
body,
|
|
78
|
-
signal
|
|
78
|
+
signal,
|
|
79
|
+
toolChoice
|
|
79
80
|
}) {
|
|
80
81
|
temperature || (temperature = 0.5);
|
|
81
82
|
tools || (tools = []);
|
|
@@ -83,6 +84,7 @@ function fetchChatCompletion(_0) {
|
|
|
83
84
|
const { content, role, name, function_call } = message;
|
|
84
85
|
return { content, role, name, function_call };
|
|
85
86
|
});
|
|
87
|
+
toolChoice || (toolChoice = "auto");
|
|
86
88
|
const response = yield fetch(copilotConfig.chatApiEndpoint, {
|
|
87
89
|
method: "POST",
|
|
88
90
|
headers: __spreadValues(__spreadValues({
|
|
@@ -92,7 +94,7 @@ function fetchChatCompletion(_0) {
|
|
|
92
94
|
model,
|
|
93
95
|
messages: cleanedMessages,
|
|
94
96
|
stream: true
|
|
95
|
-
}, tools.length ? { tools } : {}), temperature ? { temperature } : {}), tools.length != 0 ? { tool_choice:
|
|
97
|
+
}, tools.length ? { tools } : {}), temperature ? { temperature } : {}), tools.length != 0 ? { tool_choice: toolChoice } : {}), copilotConfig.body), copilotConfig.backendOnlyProps), excludeBackendOnlyProps(copilotConfig)), body ? __spreadValues({}, body) : {}), copilotConfig.cloud ? { cloud: copilotConfig.cloud } : {})),
|
|
96
98
|
signal
|
|
97
99
|
});
|
|
98
100
|
return response;
|
|
@@ -130,6 +132,11 @@ var CopilotTask = class {
|
|
|
130
132
|
this.includeCopilotReadable = config.includeCopilotReadable !== false;
|
|
131
133
|
this.includeCopilotActions = config.includeCopilotActions !== false && config.includeCopilotActionable !== false;
|
|
132
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Run the task.
|
|
137
|
+
* @param context The CopilotContext to use for the task. Use `useCopilotContext` to obtain the current context.
|
|
138
|
+
* @param data The data to use for the task.
|
|
139
|
+
*/
|
|
133
140
|
run(context, data) {
|
|
134
141
|
return __async(this, null, function* () {
|
|
135
142
|
const entryPoints = this.includeCopilotActions ? Object.assign({}, context.entryPoints) : {};
|
|
@@ -213,4 +220,3 @@ ${instructions}
|
|
|
213
220
|
0 && (module.exports = {
|
|
214
221
|
CopilotTask
|
|
215
222
|
});
|
|
216
|
-
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.mjs
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-KQTWUIAM.mjs";
|
|
2
2
|
import {
|
|
3
3
|
CopilotTask
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-5L4TYK4W.mjs";
|
|
5
|
+
import "../chunk-BJZMR7WC.mjs";
|
|
6
|
+
import "../chunk-FT5DESSI.mjs";
|
|
7
|
+
import "../chunk-ZYDU7WF7.mjs";
|
|
8
|
+
import "../chunk-K4KJZOIZ.mjs";
|
|
9
|
+
import "../chunk-NWOJ4DVV.mjs";
|
|
10
|
+
import "../chunk-QBL56RUZ.mjs";
|
|
11
|
+
import "../chunk-GBUK745N.mjs";
|
|
12
|
+
import "../chunk-HIDP27A7.mjs";
|
|
13
13
|
export {
|
|
14
14
|
CopilotTask
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import "../../chunk-
|
|
1
|
+
import "../../chunk-YQ6KMLKO.mjs";
|
|
2
2
|
import {
|
|
3
3
|
useCopilotChatV2
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-SIFJW3HD.mjs";
|
|
5
|
+
import "../../chunk-YGKURLXD.mjs";
|
|
6
|
+
import "../../chunk-6WFEP6DR.mjs";
|
|
7
|
+
import "../../chunk-CWK7RV25.mjs";
|
|
8
|
+
import "../../chunk-BJZMR7WC.mjs";
|
|
9
|
+
import "../../chunk-FT5DESSI.mjs";
|
|
10
|
+
import "../../chunk-ZYDU7WF7.mjs";
|
|
11
|
+
import "../../chunk-K4KJZOIZ.mjs";
|
|
12
|
+
import "../../chunk-NWOJ4DVV.mjs";
|
|
13
|
+
import "../../chunk-GBUK745N.mjs";
|
|
14
|
+
import "../../chunk-HIDP27A7.mjs";
|
|
15
15
|
export {
|
|
16
16
|
useCopilotChatV2
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../../chunk-
|
|
1
|
+
import "../../chunk-YGKURLXD.mjs";
|
|
2
2
|
import {
|
|
3
3
|
processMessageStream
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-6WFEP6DR.mjs";
|
|
5
5
|
import {
|
|
6
6
|
__async
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-HIDP27A7.mjs";
|
|
8
8
|
|
|
9
9
|
// src/openai-assistants/hooks/use-assistants.ts
|
|
10
10
|
import { useState } from "react";
|
|
@@ -89,4 +89,3 @@ function experimental_useAssistant({
|
|
|
89
89
|
export {
|
|
90
90
|
experimental_useAssistant
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=use-assistants.mjs.map
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultSystemMessage,
|
|
3
3
|
useCopilotChatV2
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-SIFJW3HD.mjs";
|
|
5
|
+
import "../../chunk-YGKURLXD.mjs";
|
|
6
|
+
import "../../chunk-6WFEP6DR.mjs";
|
|
7
|
+
import "../../chunk-CWK7RV25.mjs";
|
|
8
|
+
import "../../chunk-BJZMR7WC.mjs";
|
|
9
|
+
import "../../chunk-FT5DESSI.mjs";
|
|
10
|
+
import "../../chunk-ZYDU7WF7.mjs";
|
|
11
|
+
import "../../chunk-K4KJZOIZ.mjs";
|
|
12
|
+
import "../../chunk-NWOJ4DVV.mjs";
|
|
13
|
+
import "../../chunk-GBUK745N.mjs";
|
|
14
|
+
import "../../chunk-HIDP27A7.mjs";
|
|
15
15
|
export {
|
|
16
16
|
defaultSystemMessage,
|
|
17
17
|
useCopilotChatV2
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=use-copilot-chat-v2.mjs.map
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import "../chunk-
|
|
2
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-HNKVKTPX.mjs";
|
|
2
|
+
import "../chunk-YQ6KMLKO.mjs";
|
|
3
3
|
import {
|
|
4
4
|
useCopilotChatV2
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-SIFJW3HD.mjs";
|
|
6
|
+
import "../chunk-YGKURLXD.mjs";
|
|
7
7
|
import {
|
|
8
8
|
processMessageStream
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-6WFEP6DR.mjs";
|
|
10
|
+
import "../chunk-CWK7RV25.mjs";
|
|
11
|
+
import "../chunk-BJZMR7WC.mjs";
|
|
12
|
+
import "../chunk-FT5DESSI.mjs";
|
|
13
|
+
import "../chunk-ZYDU7WF7.mjs";
|
|
14
|
+
import "../chunk-K4KJZOIZ.mjs";
|
|
15
|
+
import "../chunk-NWOJ4DVV.mjs";
|
|
16
|
+
import "../chunk-GBUK745N.mjs";
|
|
17
|
+
import "../chunk-HIDP27A7.mjs";
|
|
18
18
|
export {
|
|
19
19
|
processMessageStream,
|
|
20
20
|
useCopilotChatV2
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import "../../chunk-
|
|
1
|
+
import "../../chunk-YGKURLXD.mjs";
|
|
2
2
|
import {
|
|
3
3
|
processMessageStream
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-6WFEP6DR.mjs";
|
|
5
|
+
import "../../chunk-HIDP27A7.mjs";
|
|
6
6
|
export {
|
|
7
7
|
processMessageStream
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
processMessageStream
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-6WFEP6DR.mjs";
|
|
4
|
+
import "../../chunk-HIDP27A7.mjs";
|
|
5
5
|
export {
|
|
6
6
|
processMessageStream
|
|
7
7
|
};
|
|
8
|
-
//# sourceMappingURL=process-message-stream.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=document-pointer.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=frontend-action.mjs.map
|
package/dist/types/index.js
CHANGED
package/dist/types/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import "../chunk-
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import "../chunk-LOLJLZCX.mjs";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=system-message.mjs.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Parameter, MappedParameterTypes } from '@copilotkit/shared';
|
|
2
|
+
import { CopilotContextParams } from '../context/copilot-context.js';
|
|
3
|
+
import '../types/frontend-action.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '../hooks/use-tree.js';
|
|
6
|
+
import '../types/document-pointer.js';
|
|
7
|
+
|
|
8
|
+
interface InitialState<T extends Parameter[] | [] = []> {
|
|
9
|
+
status: "initial";
|
|
10
|
+
args: Partial<MappedParameterTypes<T>>;
|
|
11
|
+
}
|
|
12
|
+
interface InProgressState<T extends Parameter[] | [] = []> {
|
|
13
|
+
status: "inProgress";
|
|
14
|
+
args: Partial<MappedParameterTypes<T>>;
|
|
15
|
+
}
|
|
16
|
+
interface CompleteState<T extends Parameter[] | [] = []> {
|
|
17
|
+
status: "complete";
|
|
18
|
+
args: MappedParameterTypes<T>;
|
|
19
|
+
}
|
|
20
|
+
type StreamHandlerArgs<T extends Parameter[] | [] = []> = InitialState<T> | InProgressState<T> | CompleteState<T>;
|
|
21
|
+
interface ExtractOptions<T extends Parameter[]> {
|
|
22
|
+
context: CopilotContextParams;
|
|
23
|
+
instructions: string;
|
|
24
|
+
parameters: T;
|
|
25
|
+
include?: IncludeOptions;
|
|
26
|
+
data?: any;
|
|
27
|
+
abortSignal?: AbortSignal;
|
|
28
|
+
stream?: (args: StreamHandlerArgs<T>) => void;
|
|
29
|
+
}
|
|
30
|
+
interface IncludeOptions {
|
|
31
|
+
readable?: boolean;
|
|
32
|
+
messages?: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare function extract<const T extends Parameter[]>({ context, instructions, parameters, include, data, abortSignal, stream, }: ExtractOptions<T>): Promise<MappedParameterTypes<T>>;
|
|
35
|
+
|
|
36
|
+
export { extract };
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
+
mod
|
|
41
|
+
));
|
|
42
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
|
+
var __async = (__this, __arguments, generator) => {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
var fulfilled = (value) => {
|
|
46
|
+
try {
|
|
47
|
+
step(generator.next(value));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var rejected = (value) => {
|
|
53
|
+
try {
|
|
54
|
+
step(generator.throw(value));
|
|
55
|
+
} catch (e) {
|
|
56
|
+
reject(e);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
60
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/utils/extract.ts
|
|
65
|
+
var extract_exports = {};
|
|
66
|
+
__export(extract_exports, {
|
|
67
|
+
extract: () => extract
|
|
68
|
+
});
|
|
69
|
+
module.exports = __toCommonJS(extract_exports);
|
|
70
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
71
|
+
|
|
72
|
+
// src/components/copilot-provider/copilotkit.tsx
|
|
73
|
+
var import_react = require("react");
|
|
74
|
+
var import_shared = require("@copilotkit/shared");
|
|
75
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
76
|
+
var defaultCopilotContextCategories = ["global"];
|
|
77
|
+
|
|
78
|
+
// src/utils/fetch-chat-completion.ts
|
|
79
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
80
|
+
function fetchChatCompletion(_0) {
|
|
81
|
+
return __async(this, arguments, function* ({
|
|
82
|
+
copilotConfig,
|
|
83
|
+
model,
|
|
84
|
+
messages,
|
|
85
|
+
tools,
|
|
86
|
+
temperature,
|
|
87
|
+
headers,
|
|
88
|
+
body,
|
|
89
|
+
signal,
|
|
90
|
+
toolChoice
|
|
91
|
+
}) {
|
|
92
|
+
temperature || (temperature = 0.5);
|
|
93
|
+
tools || (tools = []);
|
|
94
|
+
const cleanedMessages = messages.map((message) => {
|
|
95
|
+
const { content, role, name, function_call } = message;
|
|
96
|
+
return { content, role, name, function_call };
|
|
97
|
+
});
|
|
98
|
+
toolChoice || (toolChoice = "auto");
|
|
99
|
+
const response = yield fetch(copilotConfig.chatApiEndpoint, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
headers: __spreadValues(__spreadValues({
|
|
102
|
+
"Content-Type": "application/json"
|
|
103
|
+
}, copilotConfig.headers), headers ? __spreadValues({}, headers) : {}),
|
|
104
|
+
body: JSON.stringify(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
105
|
+
model,
|
|
106
|
+
messages: cleanedMessages,
|
|
107
|
+
stream: true
|
|
108
|
+
}, tools.length ? { tools } : {}), temperature ? { temperature } : {}), tools.length != 0 ? { tool_choice: toolChoice } : {}), copilotConfig.body), copilotConfig.backendOnlyProps), excludeBackendOnlyProps(copilotConfig)), body ? __spreadValues({}, body) : {}), copilotConfig.cloud ? { cloud: copilotConfig.cloud } : {})),
|
|
109
|
+
signal
|
|
110
|
+
});
|
|
111
|
+
return response;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function excludeBackendOnlyProps(copilotConfig) {
|
|
115
|
+
var _a;
|
|
116
|
+
const backendOnlyProps = (_a = copilotConfig.backendOnlyProps) != null ? _a : {};
|
|
117
|
+
if (Object.keys(backendOnlyProps).length > 0) {
|
|
118
|
+
return {
|
|
119
|
+
[import_shared2.EXCLUDE_FROM_FORWARD_PROPS_KEYS]: Object.keys(backendOnlyProps)
|
|
120
|
+
};
|
|
121
|
+
} else {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function fetchAndDecodeChatCompletion(params) {
|
|
126
|
+
return __async(this, null, function* () {
|
|
127
|
+
const response = yield fetchChatCompletion(params);
|
|
128
|
+
if (!response.ok || !response.body) {
|
|
129
|
+
response.events = null;
|
|
130
|
+
} else {
|
|
131
|
+
const events = yield (0, import_shared2.decodeChatCompletion)((0, import_shared2.parseChatCompletion)(response.body));
|
|
132
|
+
response.events = events;
|
|
133
|
+
}
|
|
134
|
+
return response;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/utils/extract.ts
|
|
139
|
+
var import_untruncate_json = __toESM(require("untruncate-json"));
|
|
140
|
+
function extract(_0) {
|
|
141
|
+
return __async(this, arguments, function* ({
|
|
142
|
+
context,
|
|
143
|
+
instructions,
|
|
144
|
+
parameters,
|
|
145
|
+
include,
|
|
146
|
+
data,
|
|
147
|
+
abortSignal,
|
|
148
|
+
stream
|
|
149
|
+
}) {
|
|
150
|
+
var _a, _b;
|
|
151
|
+
const { messages } = context;
|
|
152
|
+
const action = {
|
|
153
|
+
name: "extract",
|
|
154
|
+
parameters,
|
|
155
|
+
handler: (args) => {
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const includeReadable = (_a = include == null ? void 0 : include.readable) != null ? _a : false;
|
|
159
|
+
const includeMessages = (_b = include == null ? void 0 : include.messages) != null ? _b : false;
|
|
160
|
+
let contextString = "";
|
|
161
|
+
if (data) {
|
|
162
|
+
contextString = (typeof data === "string" ? data : JSON.stringify(data)) + "\n\n";
|
|
163
|
+
}
|
|
164
|
+
if (includeReadable) {
|
|
165
|
+
contextString += context.getContextString([], defaultCopilotContextCategories);
|
|
166
|
+
}
|
|
167
|
+
const systemMessage = {
|
|
168
|
+
id: "system",
|
|
169
|
+
content: makeSystemMessage(contextString, instructions),
|
|
170
|
+
role: "system"
|
|
171
|
+
};
|
|
172
|
+
const headers = __spreadValues(__spreadValues({}, context.copilotApiConfig.headers || {}), context.copilotApiConfig.publicApiKey ? { [import_shared3.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: context.copilotApiConfig.publicApiKey } : {});
|
|
173
|
+
const response = yield fetchAndDecodeChatCompletion({
|
|
174
|
+
copilotConfig: context.copilotApiConfig,
|
|
175
|
+
messages: includeMessages ? [systemMessage, ...messages] : [systemMessage],
|
|
176
|
+
tools: context.getChatCompletionFunctionDescriptions({ extract: action }),
|
|
177
|
+
headers,
|
|
178
|
+
body: context.copilotApiConfig.body,
|
|
179
|
+
toolChoice: { type: "function", function: { name: "extract" } },
|
|
180
|
+
signal: abortSignal
|
|
181
|
+
});
|
|
182
|
+
if (!response.events) {
|
|
183
|
+
throw new Error("extract() failed: Could not fetch chat completion");
|
|
184
|
+
}
|
|
185
|
+
const reader = response.events.getReader();
|
|
186
|
+
let isInitial = true;
|
|
187
|
+
while (true) {
|
|
188
|
+
const { done, value } = yield reader.read();
|
|
189
|
+
if (done) {
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
if (value.type === "partial") {
|
|
193
|
+
try {
|
|
194
|
+
let partialArguments = JSON.parse((0, import_untruncate_json.default)(value.arguments));
|
|
195
|
+
stream == null ? void 0 : stream({
|
|
196
|
+
status: isInitial ? "initial" : "inProgress",
|
|
197
|
+
args: partialArguments
|
|
198
|
+
});
|
|
199
|
+
isInitial = false;
|
|
200
|
+
} catch (e) {
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (value.type === "function") {
|
|
204
|
+
stream == null ? void 0 : stream({
|
|
205
|
+
status: "complete",
|
|
206
|
+
args: value.arguments
|
|
207
|
+
});
|
|
208
|
+
return value.arguments;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
throw new Error("extract() failed: No function call occurred");
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function makeSystemMessage(contextString, instructions) {
|
|
215
|
+
return `
|
|
216
|
+
Please act as an efficient, competent, conscientious, and industrious professional assistant.
|
|
217
|
+
|
|
218
|
+
Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
|
|
219
|
+
Always be polite and respectful, and prefer brevity over verbosity.
|
|
220
|
+
|
|
221
|
+
The user has provided you with the following context:
|
|
222
|
+
\`\`\`
|
|
223
|
+
${contextString}
|
|
224
|
+
\`\`\`
|
|
225
|
+
|
|
226
|
+
They have also provided you with a function you MUST call to initiate actions on their behalf.
|
|
227
|
+
|
|
228
|
+
Please assist them as best you can.
|
|
229
|
+
|
|
230
|
+
This is not a conversation, so please do not ask questions. Just call the function without saying anything else.
|
|
231
|
+
|
|
232
|
+
The user has given you the following task to complete:
|
|
233
|
+
|
|
234
|
+
\`\`\`
|
|
235
|
+
${instructions}
|
|
236
|
+
\`\`\`
|
|
237
|
+
|
|
238
|
+
Any additional messages provided are for providing context only and should not be used to ask questions or engage in conversation.
|
|
239
|
+
`;
|
|
240
|
+
}
|
|
241
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
242
|
+
0 && (module.exports = {
|
|
243
|
+
extract
|
|
244
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extract
|
|
3
|
+
} from "../chunk-VK5H6Y6B.mjs";
|
|
4
|
+
import "../chunk-BJZMR7WC.mjs";
|
|
5
|
+
import "../chunk-FT5DESSI.mjs";
|
|
6
|
+
import "../chunk-ZYDU7WF7.mjs";
|
|
7
|
+
import "../chunk-K4KJZOIZ.mjs";
|
|
8
|
+
import "../chunk-NWOJ4DVV.mjs";
|
|
9
|
+
import "../chunk-QBL56RUZ.mjs";
|
|
10
|
+
import "../chunk-GBUK745N.mjs";
|
|
11
|
+
import "../chunk-HIDP27A7.mjs";
|
|
12
|
+
export {
|
|
13
|
+
extract
|
|
14
|
+
};
|
|
@@ -15,8 +15,14 @@ interface FetchChatCompletionParams {
|
|
|
15
15
|
headers?: Record<string, string> | Headers;
|
|
16
16
|
body?: object;
|
|
17
17
|
signal?: AbortSignal;
|
|
18
|
+
toolChoice?: string | {
|
|
19
|
+
type: "function";
|
|
20
|
+
function: {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
18
24
|
}
|
|
19
|
-
declare function fetchChatCompletion({ copilotConfig, model, messages, tools, temperature, headers, body, signal, }: FetchChatCompletionParams): Promise<Response>;
|
|
25
|
+
declare function fetchChatCompletion({ copilotConfig, model, messages, tools, temperature, headers, body, signal, toolChoice, }: FetchChatCompletionParams): Promise<Response>;
|
|
20
26
|
interface DecodedChatCompletionResponse extends Response {
|
|
21
27
|
events: ReadableStream<ChatCompletionEvent> | null;
|
|
22
28
|
}
|