@copilotkit/react-core 0.8.0-alpha.4 → 0.8.0-alpha.5
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 +42 -38
- package/CHANGELOG.md +6 -0
- package/dist/components/copilot-provider.mjs +340 -5
- package/dist/components/copilot-provider.mjs.map +1 -1
- package/dist/components/index.mjs +340 -6
- package/dist/components/index.mjs.map +1 -1
- package/dist/context/copilot-context.mjs +63 -3
- package/dist/context/copilot-context.mjs.map +1 -1
- package/dist/context/index.mjs +63 -4
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/index.mjs +199 -7
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +155 -4
- package/dist/hooks/use-copilot-chat.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-actionable.mjs +84 -4
- package/dist/hooks/use-make-copilot-actionable.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-readable.mjs +73 -4
- package/dist/hooks/use-make-copilot-readable.mjs.map +1 -1
- package/dist/hooks/use-tree.mjs +159 -3
- package/dist/hooks/use-tree.mjs.map +1 -1
- package/dist/index.mjs +470 -12
- package/dist/index.mjs.map +1 -1
- package/dist/types/annotated-function.mjs +0 -2
- package/dist/types/annotated-function.mjs.map +1 -1
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/utils.mjs +0 -2
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/utils.test.mjs +0 -1
- package/dist/utils/utils.test.mjs.map +1 -1
- package/package.json +2 -2
- package/src/hooks/use-copilot-chat.ts +0 -3
- package/dist/chunk-3BOHSSKR.mjs +0 -141
- package/dist/chunk-3BOHSSKR.mjs.map +0 -1
- package/dist/chunk-6VD2ABXH.mjs +0 -82
- package/dist/chunk-6VD2ABXH.mjs.map +0 -1
- package/dist/chunk-BVQRDAR7.mjs +0 -3
- package/dist/chunk-BVQRDAR7.mjs.map +0 -1
- package/dist/chunk-DFQJR3H5.mjs +0 -120
- package/dist/chunk-DFQJR3H5.mjs.map +0 -1
- package/dist/chunk-EFZPSZWO.mjs +0 -3
- package/dist/chunk-EFZPSZWO.mjs.map +0 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -3
- package/dist/chunk-JD7BAH7U.mjs.map +0 -1
- package/dist/chunk-JLQULZT4.mjs +0 -19
- package/dist/chunk-JLQULZT4.mjs.map +0 -1
- package/dist/chunk-MRXNTQOX.mjs +0 -55
- package/dist/chunk-MRXNTQOX.mjs.map +0 -1
- package/dist/chunk-W6NBODX5.mjs +0 -30
- package/dist/chunk-W6NBODX5.mjs.map +0 -1
- package/dist/chunk-YPSGKPDA.mjs +0 -3
- package/dist/chunk-YPSGKPDA.mjs.map +0 -1
- package/dist/chunk-ZKO7HCZS.mjs +0 -40
- package/dist/chunk-ZKO7HCZS.mjs.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,73 +1,75 @@
|
|
|
1
|
+
Debugger attached.
|
|
1
2
|
|
|
2
|
-
> @copilotkit/react-core@0.8.0-alpha.
|
|
3
|
+
> @copilotkit/react-core@0.8.0-alpha.4 build /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core
|
|
3
4
|
> tsup --treeshake
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Debugger attached.
|
|
7
|
+
CLI Building entry: src/index.tsx, src/components/copilot-provider.tsx, src/components/index.ts, src/context/copilot-context.tsx, src/context/index.ts, src/hooks/index.ts, src/hooks/use-copilot-chat.ts, src/hooks/use-make-copilot-actionable.ts, src/hooks/use-make-copilot-readable.ts, src/hooks/use-tree.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/types/annotated-function.ts, src/types/index.ts
|
|
6
8
|
CLI Using tsconfig: tsconfig.json
|
|
7
9
|
CLI tsup v6.5.0
|
|
8
10
|
CLI Using tsup config: /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core/tsup.config.ts
|
|
9
11
|
CLI Target: es6
|
|
10
12
|
CLI Cleaning output folder
|
|
11
13
|
ESM Build start
|
|
12
|
-
Generated an empty chunk: "annotated-function".
|
|
13
14
|
Generated an empty chunk: "utils".
|
|
14
|
-
Generated an empty chunk: "
|
|
15
|
+
Generated an empty chunk: "annotated-function".
|
|
15
16
|
Generated an empty chunk: "chunk-EFZPSZWO".
|
|
16
17
|
Generated an empty chunk: "chunk-JD7BAH7U".
|
|
18
|
+
Generated an empty chunk: "chunk-YPSGKPDA".
|
|
17
19
|
Generated an empty chunk: "chunk-BVQRDAR7".
|
|
18
|
-
ESM dist/types/annotated-function.mjs 80.00 B
|
|
19
|
-
ESM dist/utils/utils.mjs 67.00 B
|
|
20
|
-
ESM dist/chunk-YPSGKPDA.mjs 76.00 B
|
|
21
20
|
ESM dist/utils/utils.test.mjs 202.00 B
|
|
21
|
+
ESM dist/types/annotated-function.mjs 80.00 B
|
|
22
|
+
ESM dist/chunk-EFZPSZWO.mjs 76.00 B
|
|
22
23
|
ESM dist/chunk-JD7BAH7U.mjs 76.00 B
|
|
24
|
+
ESM dist/chunk-YPSGKPDA.mjs 76.00 B
|
|
23
25
|
ESM dist/chunk-BVQRDAR7.mjs 76.00 B
|
|
24
|
-
ESM dist/chunk-EFZPSZWO.mjs 76.00 B
|
|
25
26
|
ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
|
|
27
|
+
ESM dist/utils/utils.mjs 67.00 B
|
|
28
|
+
ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
|
|
26
29
|
ESM dist/index.mjs 576.00 B
|
|
30
|
+
ESM dist/hooks/use-tree.mjs 170.00 B
|
|
31
|
+
ESM dist/chunk-NI4P4OEH.mjs 3.69 KB
|
|
32
|
+
ESM dist/types/index.mjs 98.00 B
|
|
27
33
|
ESM dist/components/copilot-provider.mjs 230.00 B
|
|
28
34
|
ESM dist/components/index.mjs 251.00 B
|
|
29
|
-
ESM dist/
|
|
30
|
-
ESM dist/chunk-W6NBODX5.mjs 972.00 B
|
|
31
|
-
ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
|
|
32
|
-
ESM dist/chunk-JLQULZT4.mjs 626.00 B
|
|
33
|
-
ESM dist/chunk-6VD2ABXH.mjs 2.67 KB
|
|
35
|
+
ESM dist/context/copilot-context.mjs 194.00 B
|
|
34
36
|
ESM dist/chunk-3BOHSSKR.mjs 3.95 KB
|
|
35
|
-
ESM dist/hooks/use-tree.mjs 170.00 B
|
|
36
37
|
ESM dist/context/index.mjs 216.00 B
|
|
37
|
-
ESM dist/
|
|
38
|
-
ESM dist/chunk-DFQJR3H5.mjs 3.69 KB
|
|
39
|
-
ESM dist/types/index.mjs 98.00 B
|
|
40
|
-
ESM dist/chunk-ZKO7HCZS.mjs 1.06 KB
|
|
41
|
-
ESM dist/hooks/use-copilot-chat.mjs 219.00 B
|
|
38
|
+
ESM dist/chunk-JLQULZT4.mjs 626.00 B
|
|
42
39
|
ESM dist/hooks/index.mjs 348.00 B
|
|
43
|
-
ESM dist/chunk-
|
|
40
|
+
ESM dist/chunk-W6NBODX5.mjs 972.00 B
|
|
41
|
+
ESM dist/hooks/use-make-copilot-actionable.mjs 218.00 B
|
|
42
|
+
ESM dist/chunk-6VXNL5FO.mjs 2.62 KB
|
|
43
|
+
ESM dist/hooks/use-copilot-chat.mjs 219.00 B
|
|
44
|
+
ESM dist/chunk-ZKO7HCZS.mjs 1.06 KB
|
|
45
|
+
ESM dist/utils/utils.test.mjs.map 351.00 B
|
|
44
46
|
ESM dist/chunk-JD7BAH7U.mjs.map 51.00 B
|
|
45
47
|
ESM dist/chunk-EFZPSZWO.mjs.map 51.00 B
|
|
46
|
-
ESM dist/
|
|
48
|
+
ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
|
|
47
49
|
ESM dist/chunk-BVQRDAR7.mjs.map 51.00 B
|
|
48
|
-
ESM dist/utils/utils.mjs.map 51.00 B
|
|
49
|
-
ESM dist/index.mjs.map 51.00 B
|
|
50
|
-
ESM dist/utils/utils.test.mjs.map 351.00 B
|
|
51
|
-
ESM dist/hooks/use-make-copilot-actionable.mjs.map 51.00 B
|
|
52
50
|
ESM dist/hooks/use-make-copilot-readable.mjs.map 51.00 B
|
|
53
|
-
ESM dist/
|
|
54
|
-
ESM dist/
|
|
51
|
+
ESM dist/index.mjs.map 51.00 B
|
|
52
|
+
ESM dist/types/annotated-function.mjs.map 51.00 B
|
|
53
|
+
ESM dist/chunk-YPSGKPDA.mjs.map 51.00 B
|
|
54
|
+
ESM dist/utils/utils.mjs.map 51.00 B
|
|
55
|
+
ESM dist/chunk-NI4P4OEH.mjs.map 7.37 KB
|
|
56
|
+
ESM dist/types/index.mjs.map 51.00 B
|
|
55
57
|
ESM dist/components/copilot-provider.mjs.map 51.00 B
|
|
56
|
-
ESM dist/hooks/use-tree.mjs.map 51.00 B
|
|
57
|
-
ESM dist/chunk-JLQULZT4.mjs.map 1.47 KB
|
|
58
58
|
ESM dist/components/index.mjs.map 51.00 B
|
|
59
59
|
ESM dist/context/copilot-context.mjs.map 51.00 B
|
|
60
|
-
ESM dist/chunk-
|
|
60
|
+
ESM dist/chunk-3BOHSSKR.mjs.map 8.39 KB
|
|
61
|
+
ESM dist/chunk-JLQULZT4.mjs.map 1.47 KB
|
|
61
62
|
ESM dist/context/index.mjs.map 51.00 B
|
|
63
|
+
ESM dist/hooks/use-tree.mjs.map 51.00 B
|
|
62
64
|
ESM dist/chunk-W6NBODX5.mjs.map 1.70 KB
|
|
63
|
-
ESM dist/chunk-ZKO7HCZS.mjs.map 2.82 KB
|
|
64
|
-
ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
|
|
65
|
-
ESM dist/types/index.mjs.map 51.00 B
|
|
66
|
-
ESM dist/hooks/use-copilot-chat.mjs.map 51.00 B
|
|
67
65
|
ESM dist/hooks/index.mjs.map 51.00 B
|
|
68
|
-
ESM
|
|
66
|
+
ESM dist/chunk-6VXNL5FO.mjs.map 4.48 KB
|
|
67
|
+
ESM dist/hooks/use-make-copilot-actionable.mjs.map 51.00 B
|
|
68
|
+
ESM dist/hooks/use-copilot-chat.mjs.map 51.00 B
|
|
69
|
+
ESM dist/chunk-ZKO7HCZS.mjs.map 2.82 KB
|
|
70
|
+
ESM ⚡️ Build success in 150ms
|
|
69
71
|
DTS Build start
|
|
70
|
-
DTS ⚡️ Build success in
|
|
72
|
+
DTS ⚡️ Build success in 786ms
|
|
71
73
|
DTS dist/index.d.ts 655.00 B
|
|
72
74
|
DTS dist/components/copilot-provider.d.ts 398.00 B
|
|
73
75
|
DTS dist/context/copilot-context.d.ts 1.16 KB
|
|
@@ -77,8 +79,10 @@ DTS dist/hooks/use-make-copilot-readable.d.ts 598.00 B
|
|
|
77
79
|
DTS dist/types/annotated-function.d.ts 767.00 B
|
|
78
80
|
DTS dist/hooks/use-tree.d.ts 543.00 B
|
|
79
81
|
DTS dist/components/index.d.ts 230.00 B
|
|
80
|
-
DTS dist/hooks/index.d.ts 305.00 B
|
|
81
82
|
DTS dist/context/index.d.ts 258.00 B
|
|
82
|
-
DTS dist/
|
|
83
|
+
DTS dist/hooks/index.d.ts 305.00 B
|
|
83
84
|
DTS dist/utils/utils.test.d.ts 1.00 B
|
|
84
85
|
DTS dist/utils/utils.d.ts 1.00 B
|
|
86
|
+
DTS dist/types/index.d.ts 88.00 B
|
|
87
|
+
Waiting for the debugger to disconnect...
|
|
88
|
+
Waiting for the debugger to disconnect...
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,341 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/components/copilot-provider.tsx
|
|
54
|
+
import { useCallback as useCallback2, useState } from "react";
|
|
55
|
+
|
|
56
|
+
// src/context/copilot-context.tsx
|
|
57
|
+
import React from "react";
|
|
58
|
+
"use client";
|
|
59
|
+
var emptyCopilotContext = {
|
|
60
|
+
entryPoints: {},
|
|
61
|
+
setEntryPoint: () => {
|
|
62
|
+
},
|
|
63
|
+
removeEntryPoint: () => {
|
|
64
|
+
},
|
|
65
|
+
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
|
|
66
|
+
getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
|
|
67
|
+
})),
|
|
68
|
+
getContextString: () => returnAndThrowInDebug(""),
|
|
69
|
+
addContext: () => "",
|
|
70
|
+
removeContext: () => {
|
|
71
|
+
},
|
|
72
|
+
copilotApiConfig: new class {
|
|
73
|
+
get chatApiEndpoint() {
|
|
74
|
+
throw new Error(
|
|
75
|
+
"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}()
|
|
79
|
+
};
|
|
80
|
+
var CopilotContext = React.createContext(emptyCopilotContext);
|
|
81
|
+
function returnAndThrowInDebug(value) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!"
|
|
84
|
+
);
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/hooks/use-tree.ts
|
|
89
|
+
import { nanoid } from "nanoid";
|
|
90
|
+
import { useCallback, useReducer } from "react";
|
|
91
|
+
var removeNode = (nodes, id) => {
|
|
92
|
+
return nodes.reduce((result, node) => {
|
|
93
|
+
if (node.id !== id) {
|
|
94
|
+
const newNode = __spreadProps(__spreadValues({}, node), { children: removeNode(node.children, id) });
|
|
95
|
+
result.push(newNode);
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}, []);
|
|
99
|
+
};
|
|
100
|
+
var addNode = (nodes, newNode, parentId) => {
|
|
101
|
+
if (!parentId) {
|
|
102
|
+
return [...nodes, newNode];
|
|
103
|
+
}
|
|
104
|
+
return nodes.map((node) => {
|
|
105
|
+
if (node.id === parentId) {
|
|
106
|
+
return __spreadProps(__spreadValues({}, node), { children: [...node.children, newNode] });
|
|
107
|
+
} else if (node.children.length) {
|
|
108
|
+
return __spreadProps(__spreadValues({}, node), { children: addNode(node.children, newNode, parentId) });
|
|
109
|
+
}
|
|
110
|
+
return node;
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
var treeIndentationRepresentation = (index, indentLevel) => {
|
|
114
|
+
if (indentLevel === 0) {
|
|
115
|
+
return (index + 1).toString();
|
|
116
|
+
} else if (indentLevel === 1) {
|
|
117
|
+
return String.fromCharCode(65 + index);
|
|
118
|
+
} else if (indentLevel === 2) {
|
|
119
|
+
return String.fromCharCode(97 + index);
|
|
120
|
+
} else {
|
|
121
|
+
return "-";
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
var printNode = (node, prefix = "", indentLevel = 0) => {
|
|
125
|
+
const indent = " ".repeat(3).repeat(indentLevel);
|
|
126
|
+
const prefixPlusIndentLength = prefix.length + indent.length;
|
|
127
|
+
const subsequentLinesPrefix = " ".repeat(prefixPlusIndentLength);
|
|
128
|
+
const valueLines = node.value.split("\n");
|
|
129
|
+
const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;
|
|
130
|
+
const outputSubsequentLines = valueLines.slice(1).map((line) => `${subsequentLinesPrefix}${line}`).join("\n");
|
|
131
|
+
let output = `${outputFirstLine}
|
|
132
|
+
`;
|
|
133
|
+
if (outputSubsequentLines) {
|
|
134
|
+
output += `${outputSubsequentLines}
|
|
135
|
+
`;
|
|
136
|
+
}
|
|
137
|
+
const childPrePrefix = " ".repeat(prefix.length);
|
|
138
|
+
node.children.forEach(
|
|
139
|
+
(child, index) => output += printNode(
|
|
140
|
+
child,
|
|
141
|
+
`${childPrePrefix}${treeIndentationRepresentation(
|
|
142
|
+
index,
|
|
143
|
+
indentLevel + 1
|
|
144
|
+
)}. `,
|
|
145
|
+
indentLevel + 1
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
return output;
|
|
149
|
+
};
|
|
150
|
+
function treeReducer(state, action) {
|
|
151
|
+
switch (action.type) {
|
|
152
|
+
case "ADD_NODE": {
|
|
153
|
+
const { value, parentId, id: newNodeId } = action;
|
|
154
|
+
const newNode = {
|
|
155
|
+
id: newNodeId,
|
|
156
|
+
value,
|
|
157
|
+
children: [],
|
|
158
|
+
categories: new Set(action.categories)
|
|
159
|
+
};
|
|
160
|
+
try {
|
|
161
|
+
return addNode(state, newNode, parentId);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error(`Error while adding node with id ${newNodeId}: ${error}`);
|
|
164
|
+
return state;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
case "REMOVE_NODE":
|
|
168
|
+
return removeNode(state, action.id);
|
|
169
|
+
default:
|
|
170
|
+
return state;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
var useTree = () => {
|
|
174
|
+
const [tree, dispatch] = useReducer(treeReducer, []);
|
|
175
|
+
const addElement = useCallback(
|
|
176
|
+
(value, categories, parentId) => {
|
|
177
|
+
const newNodeId = nanoid();
|
|
178
|
+
dispatch({
|
|
179
|
+
type: "ADD_NODE",
|
|
180
|
+
value,
|
|
181
|
+
parentId,
|
|
182
|
+
id: newNodeId,
|
|
183
|
+
categories
|
|
184
|
+
});
|
|
185
|
+
return newNodeId;
|
|
186
|
+
},
|
|
187
|
+
[]
|
|
188
|
+
);
|
|
189
|
+
const removeElement = useCallback((id) => {
|
|
190
|
+
dispatch({ type: "REMOVE_NODE", id });
|
|
191
|
+
}, []);
|
|
192
|
+
const printTree = useCallback(
|
|
193
|
+
(categories) => {
|
|
194
|
+
const categoriesSet = new Set(categories);
|
|
195
|
+
let output = "";
|
|
196
|
+
tree.forEach((node, index) => {
|
|
197
|
+
if (!setsHaveIntersection(categoriesSet, node.categories)) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (index !== 0) {
|
|
201
|
+
output += "\n";
|
|
202
|
+
}
|
|
203
|
+
output += printNode(
|
|
204
|
+
node,
|
|
205
|
+
`${treeIndentationRepresentation(index, 0)}. `
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
return output;
|
|
209
|
+
},
|
|
210
|
+
[tree]
|
|
211
|
+
);
|
|
212
|
+
return { tree, addElement, printTree, removeElement };
|
|
213
|
+
};
|
|
214
|
+
var use_tree_default = useTree;
|
|
215
|
+
function setsHaveIntersection(setA, setB) {
|
|
216
|
+
const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
|
|
217
|
+
for (let item of smallerSet) {
|
|
218
|
+
if (largerSet.has(item)) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/components/copilot-provider.tsx
|
|
226
|
+
import { jsx } from "react/jsx-runtime";
|
|
227
|
+
"use client";
|
|
228
|
+
function CopilotProvider({
|
|
229
|
+
copilotApiConfig,
|
|
230
|
+
children
|
|
231
|
+
}) {
|
|
232
|
+
const [entryPoints, setEntryPoints] = useState({});
|
|
233
|
+
const { addElement, removeElement, printTree } = use_tree_default();
|
|
234
|
+
const setEntryPoint = useCallback2(
|
|
235
|
+
(id, entryPoint) => {
|
|
236
|
+
setEntryPoints((prevPoints) => {
|
|
237
|
+
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
238
|
+
[id]: entryPoint
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
[]
|
|
243
|
+
);
|
|
244
|
+
const removeEntryPoint = useCallback2((id) => {
|
|
245
|
+
setEntryPoints((prevPoints) => {
|
|
246
|
+
const newPoints = __spreadValues({}, prevPoints);
|
|
247
|
+
delete newPoints[id];
|
|
248
|
+
return newPoints;
|
|
249
|
+
});
|
|
250
|
+
}, []);
|
|
251
|
+
const getContextString = useCallback2(
|
|
252
|
+
(categories = ["global"]) => {
|
|
253
|
+
return printTree(categories);
|
|
254
|
+
},
|
|
255
|
+
[printTree]
|
|
256
|
+
);
|
|
257
|
+
const addContext = useCallback2(
|
|
258
|
+
(context, parentId, categories = ["global"]) => {
|
|
259
|
+
return addElement(context, categories, parentId);
|
|
260
|
+
},
|
|
261
|
+
[addElement]
|
|
262
|
+
);
|
|
263
|
+
const removeContext = useCallback2(
|
|
264
|
+
(id) => {
|
|
265
|
+
removeElement(id);
|
|
266
|
+
},
|
|
267
|
+
[removeElement]
|
|
268
|
+
);
|
|
269
|
+
const getChatCompletionFunctionDescriptions = useCallback2(() => {
|
|
270
|
+
return entryPointsToChatCompletionFunctions(Object.values(entryPoints));
|
|
271
|
+
}, [entryPoints]);
|
|
272
|
+
const getFunctionCallHandler = useCallback2(() => {
|
|
273
|
+
return entryPointsToFunctionCallHandler(Object.values(entryPoints));
|
|
274
|
+
}, [entryPoints]);
|
|
275
|
+
return /* @__PURE__ */ jsx(CopilotContext.Provider, {
|
|
276
|
+
value: {
|
|
277
|
+
entryPoints,
|
|
278
|
+
getChatCompletionFunctionDescriptions,
|
|
279
|
+
getFunctionCallHandler,
|
|
280
|
+
setEntryPoint,
|
|
281
|
+
removeEntryPoint,
|
|
282
|
+
getContextString,
|
|
283
|
+
addContext,
|
|
284
|
+
removeContext,
|
|
285
|
+
copilotApiConfig
|
|
286
|
+
},
|
|
287
|
+
children
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function entryPointsToFunctionCallHandler(entryPoints) {
|
|
291
|
+
return (chatMessages, functionCall) => __async(this, null, function* () {
|
|
292
|
+
let entrypointsByFunctionName = {};
|
|
293
|
+
for (let entryPoint of entryPoints) {
|
|
294
|
+
entrypointsByFunctionName[entryPoint.name] = entryPoint;
|
|
295
|
+
}
|
|
296
|
+
const entryPointFunction = entrypointsByFunctionName[functionCall.name || ""];
|
|
297
|
+
if (entryPointFunction) {
|
|
298
|
+
let parsedFunctionCallArguments = [];
|
|
299
|
+
if (functionCall.arguments) {
|
|
300
|
+
parsedFunctionCallArguments = JSON.parse(functionCall.arguments);
|
|
301
|
+
}
|
|
302
|
+
const paramsInCorrectOrder = [];
|
|
303
|
+
for (let arg of entryPointFunction.argumentAnnotations) {
|
|
304
|
+
paramsInCorrectOrder.push(
|
|
305
|
+
parsedFunctionCallArguments[arg.name]
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
yield entryPointFunction.implementation(...paramsInCorrectOrder);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function entryPointsToChatCompletionFunctions(entryPoints) {
|
|
313
|
+
return entryPoints.map(annotatedFunctionToChatCompletionFunction);
|
|
314
|
+
}
|
|
315
|
+
function annotatedFunctionToChatCompletionFunction(annotatedFunction) {
|
|
316
|
+
let parameters = {};
|
|
317
|
+
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
318
|
+
let _a = arg, { name, required } = _a, forwardedArgs = __objRest(_a, ["name", "required"]);
|
|
319
|
+
parameters[arg.name] = forwardedArgs;
|
|
320
|
+
}
|
|
321
|
+
let requiredParameterNames = [];
|
|
322
|
+
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
323
|
+
if (arg.required) {
|
|
324
|
+
requiredParameterNames.push(arg.name);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
let chatCompletionFunction = {
|
|
328
|
+
name: annotatedFunction.name,
|
|
329
|
+
description: annotatedFunction.description,
|
|
330
|
+
parameters: {
|
|
331
|
+
type: "object",
|
|
332
|
+
properties: parameters,
|
|
333
|
+
required: requiredParameterNames
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
return chatCompletionFunction;
|
|
337
|
+
}
|
|
338
|
+
export {
|
|
339
|
+
CopilotProvider
|
|
340
|
+
};
|
|
6
341
|
//# sourceMappingURL=copilot-provider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"sources":["../../src/components/copilot-provider.tsx","../../src/context/copilot-context.tsx","../../src/hooks/use-tree.ts"],"sourcesContent":["\"use client\";\nimport { FunctionCallHandler } from \"ai\";\nimport { ReactNode, useCallback, useState } from \"react\";\nimport { CopilotContext, CopilotApiConfig } from \"../context/copilot-context\";\nimport useTree from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\n\nexport function CopilotProvider({\n copilotApiConfig,\n children,\n}: {\n copilotApiConfig: CopilotApiConfig;\n children: ReactNode;\n}): JSX.Element {\n const [entryPoints, setEntryPoints] = useState<\n Record<string, AnnotatedFunction<any[]>>\n >({});\n\n const { addElement, removeElement, printTree } = useTree();\n\n const setEntryPoint = useCallback(\n (id: string, entryPoint: AnnotatedFunction<any[]>) => {\n setEntryPoints((prevPoints) => {\n return {\n ...prevPoints,\n [id]: entryPoint,\n };\n });\n },\n []\n );\n\n const removeEntryPoint = useCallback((id: string) => {\n setEntryPoints((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (categories: string[] = [\"global\"]) => {\n return printTree(categories);\n },\n [printTree]\n );\n\n const addContext = useCallback(\n (context: string, parentId?: string, categories: string[] = [\"global\"]) => {\n return addElement(context, categories, parentId);\n },\n [addElement]\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement]\n );\n\n const getChatCompletionFunctionDescriptions = useCallback(() => {\n return entryPointsToChatCompletionFunctions(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getFunctionCallHandler = useCallback(() => {\n return entryPointsToFunctionCallHandler(Object.values(entryPoints));\n }, [entryPoints]);\n\n return (\n <CopilotContext.Provider\n value={{\n entryPoints,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n setEntryPoint,\n removeEntryPoint,\n getContextString,\n addContext,\n removeContext,\n\n copilotApiConfig,\n }}\n >\n {children}\n </CopilotContext.Provider>\n );\n}\n\nfunction entryPointsToFunctionCallHandler(\n entryPoints: AnnotatedFunction<any[]>[]\n): FunctionCallHandler {\n return async (chatMessages, functionCall) => {\n let entrypointsByFunctionName: Record<\n string,\n AnnotatedFunction<any[]>\n > = {};\n for (let entryPoint of entryPoints) {\n entrypointsByFunctionName[entryPoint.name] = entryPoint;\n }\n\n const entryPointFunction =\n entrypointsByFunctionName[functionCall.name || \"\"];\n if (entryPointFunction) {\n let parsedFunctionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n parsedFunctionCallArguments = JSON.parse(functionCall.arguments);\n }\n\n const paramsInCorrectOrder: any[] = [];\n for (let arg of entryPointFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(\n parsedFunctionCallArguments[\n arg.name as keyof typeof parsedFunctionCallArguments\n ]\n );\n }\n\n await entryPointFunction.implementation(...paramsInCorrectOrder);\n\n // commented out becasue for now we don't want to return anything\n // const result = await entryPointFunction.implementation(\n // ...parsedFunctionCallArguments\n // );\n // const functionResponse: ChatRequest = {\n // messages: [\n // ...chatMessages,\n // {\n // id: nanoid(),\n // name: functionCall.name,\n // role: 'function' as const,\n // content: JSON.stringify(result),\n // },\n // ],\n // };\n\n // return functionResponse;\n }\n };\n}\n\nfunction entryPointsToChatCompletionFunctions(\n entryPoints: AnnotatedFunction<any[]>[]\n): ChatCompletionCreateParams.Function[] {\n return entryPoints.map(annotatedFunctionToChatCompletionFunction);\n}\n\nfunction annotatedFunctionToChatCompletionFunction(\n annotatedFunction: AnnotatedFunction<any[]>\n): ChatCompletionCreateParams.Function {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let arg of annotatedFunction.argumentAnnotations) {\n // isolate the args we should forward inline\n let { name, required, ...forwardedArgs } = arg;\n parameters[arg.name] = forwardedArgs;\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of annotatedFunction.argumentAnnotations) {\n if (arg.required) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n let chatCompletionFunction: ChatCompletionCreateParams.Function = {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n };\n\n return chatCompletionFunction;\n}\n","\"use client\";\n\nimport { FunctionCallHandler } from \"ai\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\n\nexport interface CopilotApiConfig {\n chatApiEndpoint: string;\n}\n\nexport function copilotApiConfigExtrapolator(config: CopilotApiConfig) {\n return {\n get chatApiEndpoint(): string {\n return `${config.chatApiEndpoint}`;\n },\n };\n}\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, AnnotatedFunction<any[]>>;\n setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;\n removeEntryPoint: (id: string) => void;\n getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n getContextString: (categories?: string[]) => string;\n addContext: (\n context: string,\n parentId?: string,\n categories?: string[]\n ) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: () => returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n }\n })(),\n};\n\nexport const CopilotContext =\n React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n return value;\n}\n","import { nanoid } from \"nanoid\";\nimport { useCallback, useReducer } from \"react\";\n\nexport type TreeNodeId = string;\n\nexport interface TreeNode {\n id: TreeNodeId;\n value: string;\n children: TreeNode[];\n parentId?: TreeNodeId;\n categories: Set<string>;\n}\n\nexport type Tree = TreeNode[];\n\nexport interface UseTreeReturn {\n tree: Tree;\n addElement: (\n value: string,\n categories: string[],\n parentId?: TreeNodeId\n ) => TreeNodeId;\n printTree: (categories: string[]) => string;\n removeElement: (id: TreeNodeId) => void;\n}\n\nconst findNode = (nodes: Tree, id: TreeNodeId): TreeNode | undefined => {\n for (const node of nodes) {\n if (node.id === id) {\n return node;\n }\n const result = findNode(node.children, id);\n if (result) {\n return result;\n }\n }\n return undefined;\n};\n\nconst removeNode = (nodes: Tree, id: TreeNodeId): Tree => {\n return nodes.reduce((result: Tree, node) => {\n if (node.id !== id) {\n const newNode = { ...node, children: removeNode(node.children, id) };\n result.push(newNode);\n }\n return result;\n }, []);\n};\n\nconst addNode = (\n nodes: Tree,\n newNode: TreeNode,\n parentId?: TreeNodeId\n): Tree => {\n if (!parentId) {\n return [...nodes, newNode];\n }\n return nodes.map((node) => {\n if (node.id === parentId) {\n return { ...node, children: [...node.children, newNode] };\n } else if (node.children.length) {\n return { ...node, children: addNode(node.children, newNode, parentId) };\n }\n return node;\n });\n};\n\nconst treeIndentationRepresentation = (\n index: number,\n indentLevel: number\n): string => {\n if (indentLevel === 0) {\n return (index + 1).toString();\n } else if (indentLevel === 1) {\n return String.fromCharCode(65 + index); // 65 is the ASCII value for 'A'\n } else if (indentLevel === 2) {\n return String.fromCharCode(97 + index); // 97 is the ASCII value for 'a'\n } else {\n return \"-\";\n }\n};\n\nconst printNode = (node: TreeNode, prefix = \"\", indentLevel = 0): string => {\n const indent = \" \".repeat(3).repeat(indentLevel);\n\n const prefixPlusIndentLength = prefix.length + indent.length;\n const subsequentLinesPrefix = \" \".repeat(prefixPlusIndentLength);\n\n const valueLines = node.value.split(\"\\n\");\n\n const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;\n const outputSubsequentLines = valueLines\n .slice(1)\n .map((line) => `${subsequentLinesPrefix}${line}`)\n .join(\"\\n\");\n\n let output = `${outputFirstLine}\\n`;\n if (outputSubsequentLines) {\n output += `${outputSubsequentLines}\\n`;\n }\n\n const childPrePrefix = \" \".repeat(prefix.length);\n\n node.children.forEach(\n (child, index) =>\n (output += printNode(\n child,\n `${childPrePrefix}${treeIndentationRepresentation(\n index,\n indentLevel + 1\n )}. `,\n indentLevel + 1\n ))\n );\n return output;\n};\n\n// Action types\ntype Action =\n | {\n type: \"ADD_NODE\";\n value: string;\n parentId?: string;\n id: string;\n categories: string[];\n }\n | { type: \"REMOVE_NODE\"; id: string };\n\n// Reducer function\nfunction treeReducer(state: Tree, action: Action): Tree {\n switch (action.type) {\n case \"ADD_NODE\": {\n const { value, parentId, id: newNodeId } = action;\n const newNode: TreeNode = {\n id: newNodeId,\n value,\n children: [],\n categories: new Set(action.categories),\n };\n\n try {\n return addNode(state, newNode, parentId);\n } catch (error) {\n console.error(`Error while adding node with id ${newNodeId}: ${error}`);\n return state;\n }\n }\n case \"REMOVE_NODE\":\n return removeNode(state, action.id);\n default:\n return state;\n }\n}\n\n// useTree hook\nconst useTree = (): UseTreeReturn => {\n const [tree, dispatch] = useReducer(treeReducer, []);\n\n const addElement = useCallback(\n (value: string, categories: string[], parentId?: string): TreeNodeId => {\n const newNodeId = nanoid(); // Generate new ID outside of dispatch\n dispatch({\n type: \"ADD_NODE\",\n value,\n parentId,\n id: newNodeId,\n categories: categories,\n });\n return newNodeId; // Return the new ID\n },\n []\n );\n\n const removeElement = useCallback((id: TreeNodeId): void => {\n dispatch({ type: \"REMOVE_NODE\", id });\n }, []);\n\n const printTree = useCallback(\n (categories: string[]): string => {\n const categoriesSet = new Set(categories);\n\n let output = \"\";\n tree.forEach((node, index) => {\n // if the node does not have any of the desired categories, continue to the next node\n if (!setsHaveIntersection(categoriesSet, node.categories)) {\n return;\n }\n\n // add a new line before each node except the first one\n if (index !== 0) {\n output += \"\\n\";\n }\n\n output += printNode(\n node,\n `${treeIndentationRepresentation(index, 0)}. `\n );\n });\n return output;\n },\n [tree]\n );\n\n return { tree, addElement, printTree, removeElement };\n};\n\nexport default useTree;\n\nfunction setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {\n const [smallerSet, largerSet] =\n setA.size <= setB.size ? [setA, setB] : [setB, setA];\n\n for (let item of smallerSet) {\n if (largerSet.has(item)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAoB,eAAAA,cAAa,gBAAgB;;;ACCjD,OAAO,WAAW;AAHlB;AAyCA,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,MAAM,sBAAsB,EAAE;AAAA,EAChD,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBACX,MAA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