@copilotkit/react-core 0.11.0 → 0.13.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 +29 -29
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-IMNFO2OZ.mjs → chunk-AMFRKVFT.mjs} +3 -3
- package/dist/chunk-AMFRKVFT.mjs.map +1 -0
- package/dist/{chunk-3EE3HCUI.mjs → chunk-FIYUJVWU.mjs} +8 -7
- package/dist/chunk-FIYUJVWU.mjs.map +1 -0
- package/dist/{chunk-TNU2L6FJ.mjs → chunk-G5LZS72K.mjs} +2 -2
- package/dist/{chunk-PRQLPFIA.mjs → chunk-P3QUZTN7.mjs} +2 -2
- package/dist/{chunk-ATMIAPXE.mjs → chunk-PRPQRCVY.mjs} +4 -3
- package/dist/chunk-PRPQRCVY.mjs.map +1 -0
- package/dist/{chunk-X3CGMLW5.mjs → chunk-X24EEZGG.mjs} +3 -3
- package/dist/chunk-X24EEZGG.mjs.map +1 -0
- package/dist/components/copilot-provider.d.ts +2 -1
- package/dist/components/copilot-provider.mjs +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/context/copilot-context.d.ts +2 -2
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.mjs +9 -5
- package/dist/hooks/use-copilot-chat.mjs +6 -2
- package/dist/hooks/use-make-copilot-actionable.mjs +2 -2
- package/dist/hooks/use-make-copilot-document-readable.d.ts +5 -5
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/hooks/use-make-copilot-readable.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +8 -8
- package/package.json +1 -1
- package/src/components/copilot-provider.tsx +13 -4
- package/src/components/index.ts +4 -1
- package/src/context/copilot-context.tsx +5 -4
- package/src/hooks/use-copilot-chat.ts +2 -1
- package/src/hooks/use-make-copilot-document-readable.ts +6 -6
- package/dist/chunk-3EE3HCUI.mjs.map +0 -1
- package/dist/chunk-ATMIAPXE.mjs.map +0 -1
- package/dist/chunk-IMNFO2OZ.mjs.map +0 -1
- package/dist/chunk-X3CGMLW5.mjs.map +0 -1
- /package/dist/{chunk-TNU2L6FJ.mjs.map → chunk-G5LZS72K.mjs.map} +0 -0
- /package/dist/{chunk-PRQLPFIA.mjs.map → chunk-P3QUZTN7.mjs.map} +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @copilotkit/react-core@0.
|
|
2
|
+
> @copilotkit/react-core@0.13.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-core
|
|
3
3
|
> tsup --treeshake
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m 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-flat-category-store.ts, src/hooks/use-make-copilot-actionable.ts, src/hooks/use-make-copilot-document-readable.ts, src/hooks/use-make-copilot-readable.ts, src/hooks/use-tree.ts, src/types/annotated-function.ts, src/types/document-pointer.ts, src/types/index.ts, src/utils/utils.test.ts, src/utils/utils.ts
|
|
@@ -13,33 +13,33 @@ Generated an empty chunk: "utils".
|
|
|
13
13
|
Generated an empty chunk: "annotated-function".
|
|
14
14
|
Generated an empty chunk: "document-pointer".
|
|
15
15
|
Generated an empty chunk: "chunk-EFZPSZWO".
|
|
16
|
-
Generated an empty chunk: "chunk-JD7BAH7U".
|
|
17
16
|
Generated an empty chunk: "chunk-YPSGKPDA".
|
|
18
17
|
Generated an empty chunk: "chunk-QACD2U6P".
|
|
18
|
+
Generated an empty chunk: "chunk-JD7BAH7U".
|
|
19
19
|
[32mESM[39m [1mdist/chunk-EFZPSZWO.mjs [22m[32m76.00 B[39m
|
|
20
20
|
[32mESM[39m [1mdist/hooks/use-make-copilot-actionable.mjs [22m[32m218.00 B[39m
|
|
21
21
|
[32mESM[39m [1mdist/types/index.mjs [22m[32m98.00 B[39m
|
|
22
|
-
[32mESM[39m [1mdist/components/copilot-provider.mjs [22m[
|
|
22
|
+
[32mESM[39m [1mdist/components/copilot-provider.mjs [22m[32m295.00 B[39m
|
|
23
23
|
[32mESM[39m [1mdist/context/copilot-context.mjs [22m[32m194.00 B[39m
|
|
24
|
-
[32mESM[39m [1mdist/chunk-JD7BAH7U.mjs [22m[32m76.00 B[39m
|
|
25
24
|
[32mESM[39m [1mdist/chunk-YPSGKPDA.mjs [22m[32m76.00 B[39m
|
|
26
25
|
[32mESM[39m [1mdist/chunk-QACD2U6P.mjs [22m[32m76.00 B[39m
|
|
26
|
+
[32mESM[39m [1mdist/chunk-JD7BAH7U.mjs [22m[32m76.00 B[39m
|
|
27
27
|
[32mESM[39m [1mdist/chunk-MRXNTQOX.mjs [22m[32m1.92 KB[39m
|
|
28
28
|
[32mESM[39m [1mdist/hooks/use-make-copilot-document-readable.mjs [22m[32m231.00 B[39m
|
|
29
29
|
[32mESM[39m [1mdist/hooks/use-make-copilot-readable.mjs [22m[32m214.00 B[39m
|
|
30
30
|
[32mESM[39m [1mdist/hooks/use-tree.mjs [22m[32m170.00 B[39m
|
|
31
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
32
|
-
[32mESM[39m [1mdist/components/index.mjs [22m[
|
|
33
|
-
[32mESM[39m [1mdist/chunk-3EE3HCUI.mjs [22m[32m4.80 KB[39m
|
|
34
|
-
[32mESM[39m [1mdist/chunk-3BOHSSKR.mjs [22m[32m3.95 KB[39m
|
|
31
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m711.00 B[39m
|
|
32
|
+
[32mESM[39m [1mdist/components/index.mjs [22m[32m316.00 B[39m
|
|
35
33
|
[32mESM[39m [1mdist/context/index.mjs [22m[32m216.00 B[39m
|
|
36
|
-
[32mESM[39m [1mdist/hooks/index.mjs [22m[
|
|
37
|
-
[32mESM[39m [1mdist/chunk-
|
|
38
|
-
[32mESM[39m [1mdist/chunk-
|
|
39
|
-
[32mESM[39m [1mdist/chunk-
|
|
40
|
-
[32mESM[39m [1mdist/hooks/use-copilot-chat.mjs [22m[
|
|
41
|
-
[32mESM[39m [1mdist/chunk-
|
|
42
|
-
[32mESM[39m [1mdist/chunk-
|
|
34
|
+
[32mESM[39m [1mdist/hooks/index.mjs [22m[32m548.00 B[39m
|
|
35
|
+
[32mESM[39m [1mdist/chunk-P3QUZTN7.mjs [22m[32m972.00 B[39m
|
|
36
|
+
[32mESM[39m [1mdist/chunk-AMFRKVFT.mjs [22m[32m677.00 B[39m
|
|
37
|
+
[32mESM[39m [1mdist/chunk-G5LZS72K.mjs [22m[32m626.00 B[39m
|
|
38
|
+
[32mESM[39m [1mdist/hooks/use-copilot-chat.mjs [22m[32m347.00 B[39m
|
|
39
|
+
[32mESM[39m [1mdist/chunk-PRPQRCVY.mjs [22m[32m2.96 KB[39m
|
|
40
|
+
[32mESM[39m [1mdist/chunk-FIYUJVWU.mjs [22m[32m4.90 KB[39m
|
|
41
|
+
[32mESM[39m [1mdist/chunk-3BOHSSKR.mjs [22m[32m3.95 KB[39m
|
|
42
|
+
[32mESM[39m [1mdist/chunk-X24EEZGG.mjs [22m[32m1.32 KB[39m
|
|
43
43
|
[32mESM[39m [1mdist/hooks/use-flat-category-store.mjs [22m[32m200.00 B[39m
|
|
44
44
|
[32mESM[39m [1mdist/chunk-63ILXW5V.mjs [22m[32m1.92 KB[39m
|
|
45
45
|
[32mESM[39m [1mdist/utils/utils.mjs [22m[32m67.00 B[39m
|
|
@@ -51,45 +51,45 @@ Generated an empty chunk: "chunk-QACD2U6P".
|
|
|
51
51
|
[32mESM[39m [1mdist/types/index.mjs.map [22m[32m51.00 B[39m
|
|
52
52
|
[32mESM[39m [1mdist/components/copilot-provider.mjs.map [22m[32m51.00 B[39m
|
|
53
53
|
[32mESM[39m [1mdist/context/copilot-context.mjs.map [22m[32m51.00 B[39m
|
|
54
|
-
[32mESM[39m [1mdist/chunk-JD7BAH7U.mjs.map [22m[32m51.00 B[39m
|
|
55
54
|
[32mESM[39m [1mdist/chunk-YPSGKPDA.mjs.map [22m[32m51.00 B[39m
|
|
56
55
|
[32mESM[39m [1mdist/chunk-QACD2U6P.mjs.map [22m[32m51.00 B[39m
|
|
56
|
+
[32mESM[39m [1mdist/chunk-JD7BAH7U.mjs.map [22m[32m51.00 B[39m
|
|
57
57
|
[32mESM[39m [1mdist/chunk-MRXNTQOX.mjs.map [22m[32m71.00 B[39m
|
|
58
58
|
[32mESM[39m [1mdist/hooks/use-make-copilot-document-readable.mjs.map [22m[32m51.00 B[39m
|
|
59
59
|
[32mESM[39m [1mdist/hooks/use-make-copilot-readable.mjs.map [22m[32m51.00 B[39m
|
|
60
60
|
[32mESM[39m [1mdist/hooks/use-tree.mjs.map [22m[32m51.00 B[39m
|
|
61
61
|
[32mESM[39m [1mdist/index.mjs.map [22m[32m51.00 B[39m
|
|
62
62
|
[32mESM[39m [1mdist/components/index.mjs.map [22m[32m51.00 B[39m
|
|
63
|
-
[32mESM[39m [1mdist/chunk-3EE3HCUI.mjs.map [22m[32m9.48 KB[39m
|
|
64
|
-
[32mESM[39m [1mdist/chunk-3BOHSSKR.mjs.map [22m[32m8.39 KB[39m
|
|
65
63
|
[32mESM[39m [1mdist/context/index.mjs.map [22m[32m51.00 B[39m
|
|
66
64
|
[32mESM[39m [1mdist/hooks/index.mjs.map [22m[32m51.00 B[39m
|
|
67
|
-
[32mESM[39m [1mdist/chunk-
|
|
68
|
-
[32mESM[39m [1mdist/chunk-
|
|
69
|
-
[32mESM[39m [1mdist/chunk-
|
|
65
|
+
[32mESM[39m [1mdist/chunk-P3QUZTN7.mjs.map [22m[32m1.70 KB[39m
|
|
66
|
+
[32mESM[39m [1mdist/chunk-AMFRKVFT.mjs.map [22m[32m1.43 KB[39m
|
|
67
|
+
[32mESM[39m [1mdist/chunk-G5LZS72K.mjs.map [22m[32m1.47 KB[39m
|
|
70
68
|
[32mESM[39m [1mdist/hooks/use-copilot-chat.mjs.map [22m[32m51.00 B[39m
|
|
71
|
-
[32mESM[39m [1mdist/chunk-
|
|
72
|
-
[32mESM[39m [1mdist/chunk-
|
|
69
|
+
[32mESM[39m [1mdist/chunk-PRPQRCVY.mjs.map [22m[32m4.86 KB[39m
|
|
70
|
+
[32mESM[39m [1mdist/chunk-FIYUJVWU.mjs.map [22m[32m9.57 KB[39m
|
|
71
|
+
[32mESM[39m [1mdist/chunk-3BOHSSKR.mjs.map [22m[32m8.39 KB[39m
|
|
72
|
+
[32mESM[39m [1mdist/chunk-X24EEZGG.mjs.map [22m[32m4.27 KB[39m
|
|
73
73
|
[32mESM[39m [1mdist/hooks/use-flat-category-store.mjs.map [22m[32m51.00 B[39m
|
|
74
74
|
[32mESM[39m [1mdist/chunk-63ILXW5V.mjs.map [22m[32m4.31 KB[39m
|
|
75
75
|
[32mESM[39m [1mdist/utils/utils.mjs.map [22m[32m51.00 B[39m
|
|
76
76
|
[32mESM[39m [1mdist/types/annotated-function.mjs.map [22m[32m51.00 B[39m
|
|
77
77
|
[32mESM[39m [1mdist/types/document-pointer.mjs.map [22m[32m51.00 B[39m
|
|
78
78
|
[32mESM[39m [1mdist/utils/utils.test.mjs.map [22m[32m351.00 B[39m
|
|
79
|
-
[32mESM[39m ⚡️ Build success in
|
|
79
|
+
[32mESM[39m ⚡️ Build success in 304ms
|
|
80
80
|
[34mDTS[39m Build start
|
|
81
|
-
[32mDTS[39m ⚡️ Build success in
|
|
82
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
83
|
-
[32mDTS[39m [1mdist/components/copilot-provider.d.ts [22m[
|
|
81
|
+
[32mDTS[39m ⚡️ Build success in 1546ms
|
|
82
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m847.00 B[39m
|
|
83
|
+
[32mDTS[39m [1mdist/components/copilot-provider.d.ts [22m[32m378.00 B[39m
|
|
84
84
|
[32mDTS[39m [1mdist/context/copilot-context.d.ts [22m[32m2.03 KB[39m
|
|
85
85
|
[32mDTS[39m [1mdist/hooks/use-copilot-chat.d.ts [22m[32m890.00 B[39m
|
|
86
86
|
[32mDTS[39m [1mdist/hooks/use-make-copilot-actionable.d.ts [22m[32m255.00 B[39m
|
|
87
87
|
[32mDTS[39m [1mdist/hooks/use-make-copilot-readable.d.ts [22m[32m598.00 B[39m
|
|
88
|
-
[32mDTS[39m [1mdist/hooks/use-make-copilot-document-readable.d.ts [22m[
|
|
88
|
+
[32mDTS[39m [1mdist/hooks/use-make-copilot-document-readable.d.ts [22m[32m516.00 B[39m
|
|
89
89
|
[32mDTS[39m [1mdist/types/annotated-function.d.ts [22m[32m767.00 B[39m
|
|
90
90
|
[32mDTS[39m [1mdist/types/document-pointer.d.ts [22m[32m181.00 B[39m
|
|
91
91
|
[32mDTS[39m [1mdist/hooks/use-tree.d.ts [22m[32m543.00 B[39m
|
|
92
|
-
[32mDTS[39m [1mdist/components/index.d.ts [22m[
|
|
92
|
+
[32mDTS[39m [1mdist/components/index.d.ts [22m[32m106.00 B[39m
|
|
93
93
|
[32mDTS[39m [1mdist/context/index.d.ts [22m[32m297.00 B[39m
|
|
94
94
|
[32mDTS[39m [1mdist/hooks/index.d.ts [22m[32m434.00 B[39m
|
|
95
95
|
[32mDTS[39m [1mdist/hooks/use-flat-category-store.d.ts [22m[32m424.00 B[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- contextCategories no longer optional for reading context
|
|
8
|
+
|
|
9
|
+
## 0.12.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- fixed bug: useMakeCopilotDocumentReadable category reference
|
|
14
|
+
|
|
3
15
|
## 0.11.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopilotContext } from './chunk-
|
|
1
|
+
import { CopilotContext } from './chunk-X24EEZGG.mjs';
|
|
2
2
|
import { useContext, useRef, useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
|
|
@@ -10,10 +10,10 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
|
|
|
10
10
|
return () => {
|
|
11
11
|
removeDocumentContext(id);
|
|
12
12
|
};
|
|
13
|
-
}, [
|
|
13
|
+
}, [addDocumentContext, removeDocumentContext, ...dependencies]);
|
|
14
14
|
return idRef.current;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export { useMakeCopilotDocumentReadable };
|
|
18
18
|
//# sourceMappingURL=out.js.map
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-AMFRKVFT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-make-copilot-document-readable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,YAAY,WAAW,cAAc;AAF9C;AAaO,SAAS,+BACd,UACA,YACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAChD,WAAW,cAAc;AAC3B,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE/D,SAAO,MAAM;AACf","sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Makes a document readable by Copilot.\n * @param document The document to make readable.\n * @param categories The categories to associate with the document.\n * @param dependencies The dependencies to use for the effect.\n * @returns The id of the document.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = []\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } =\n useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { use_tree_default } from './chunk-3BOHSSKR.mjs';
|
|
2
|
-
import { CopilotContext } from './chunk-
|
|
2
|
+
import { CopilotContext } from './chunk-X24EEZGG.mjs';
|
|
3
3
|
import { use_flat_category_store_default } from './chunk-63ILXW5V.mjs';
|
|
4
4
|
import { __spreadProps, __spreadValues, __async, __objRest } from './chunk-MRXNTQOX.mjs';
|
|
5
5
|
import { useState, useCallback } from 'react';
|
|
@@ -36,7 +36,7 @@ function CopilotProvider({
|
|
|
36
36
|
});
|
|
37
37
|
}, []);
|
|
38
38
|
const getContextString = useCallback(
|
|
39
|
-
(documents, categories
|
|
39
|
+
(documents, categories) => {
|
|
40
40
|
const documentsString = documents.map((document) => {
|
|
41
41
|
return `${document.name} (${document.sourceApplication}):
|
|
42
42
|
${document.getContents()}`;
|
|
@@ -49,7 +49,7 @@ ${nonDocumentStrings}`;
|
|
|
49
49
|
[printTree]
|
|
50
50
|
);
|
|
51
51
|
const addContext = useCallback(
|
|
52
|
-
(context, parentId, categories =
|
|
52
|
+
(context, parentId, categories = defaultCopilotContextCategories) => {
|
|
53
53
|
return addElement(context, categories, parentId);
|
|
54
54
|
},
|
|
55
55
|
[addElement]
|
|
@@ -67,13 +67,13 @@ ${nonDocumentStrings}`;
|
|
|
67
67
|
return entryPointsToFunctionCallHandler(Object.values(entryPoints));
|
|
68
68
|
}, [entryPoints]);
|
|
69
69
|
const getDocumentsContext = useCallback(
|
|
70
|
-
(categories
|
|
70
|
+
(categories) => {
|
|
71
71
|
return allDocuments(categories);
|
|
72
72
|
},
|
|
73
73
|
[allDocuments]
|
|
74
74
|
);
|
|
75
75
|
const addDocumentContext = useCallback(
|
|
76
|
-
(documentPointer, categories =
|
|
76
|
+
(documentPointer, categories = defaultCopilotContextCategories) => {
|
|
77
77
|
return addDocument(documentPointer, categories);
|
|
78
78
|
},
|
|
79
79
|
[addDocument]
|
|
@@ -106,6 +106,7 @@ ${nonDocumentStrings}`;
|
|
|
106
106
|
children
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
+
var defaultCopilotContextCategories = ["global"];
|
|
109
110
|
function entryPointsToFunctionCallHandler(entryPoints) {
|
|
110
111
|
return (chatMessages, functionCall) => __async(this, null, function* () {
|
|
111
112
|
let entrypointsByFunctionName = {};
|
|
@@ -155,6 +156,6 @@ function annotatedFunctionToChatCompletionFunction(annotatedFunction) {
|
|
|
155
156
|
return chatCompletionFunction;
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
export { CopilotProvider };
|
|
159
|
+
export { CopilotProvider, defaultCopilotContextCategories };
|
|
159
160
|
//# sourceMappingURL=out.js.map
|
|
160
|
-
//# sourceMappingURL=chunk-
|
|
161
|
+
//# sourceMappingURL=chunk-FIYUJVWU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/copilot-provider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,SAAoB,aAAa,gBAAgB;AAsH7C;AAxHJ;AAUO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKgB;AACd,QAAM,CAAC,aAAa,cAAc,IAAI,SAEpC,CAAC,CAAC;AAEJ,QAAM,EAAE,YAAY,eAAe,UAAU,IAAI,iBAAQ;AACzD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,aAAa;AAAA,EACf,IAAI,gCAAsC;AAE1C,QAAM,gBAAgB;AAAA,IACpB,CAAC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kB,qBAAqB;AAErD,QAA2C,UAArC,QAAM,SApNhB,IAoN+C,IAAlB,0BAAkB,IAAlB,CAAnB,QAAM;AACZ,eAAW,IAAI,QAAQ;AAAA,EACzB;AAEA,MAAI,yBAAmC,CAAC;AACxC,WAAS,OAAO,kBAAkB,qBAAqB;AACrD,QAAI,IAAI,UAAU;AAChB,6BAAuB,KAAK,IAAI,IAAI;AAAA,IACtC;AAAA,EACF;AAGA,MAAI,yBAA8D;AAAA,IAChE,MAAM,kBAAkB;AAAA,IACxB,aAAa,kBAAkB;AAAA,IAC/B,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,SAAO;AACT","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\";\nimport { DocumentPointer } from \"../types\";\nimport useFlatCategoryStore from \"../hooks/use-flat-category-store\";\n\nexport function CopilotProvider({\n chatApiEndpoint,\n headers,\n body,\n children,\n}: {\n chatApiEndpoint: string;\n headers?: Record<string, string>;\n body?: Record<string, any>;\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 const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\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 (documents: DocumentPointer[], categories: string[]) => {\n const documentsString = documents\n .map((document) => {\n return `${document.name} (${\n document.sourceApplication\n }):\\n${document.getContents()}`;\n })\n .join(\"\\n\\n\");\n\n const nonDocumentStrings = printTree(categories);\n\n return `${documentsString}\\n\\n${nonDocumentStrings}`;\n },\n [printTree]\n );\n\n const addContext = useCallback(\n (\n context: string,\n parentId?: string,\n categories: string[] = defaultCopilotContextCategories\n ) => {\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 const getDocumentsContext = useCallback(\n (categories: string[]) => {\n return allDocuments(categories);\n },\n [allDocuments]\n );\n\n const addDocumentContext = useCallback(\n (\n documentPointer: DocumentPointer,\n categories: string[] = defaultCopilotContextCategories\n ) => {\n return addDocument(documentPointer, categories);\n },\n [addDocument]\n );\n\n const removeDocumentContext = useCallback(\n (documentId: string) => {\n removeDocument(documentId);\n },\n [removeDocument]\n );\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 getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: {\n chatApiEndpoint,\n headers: headers || {},\n body: body || {},\n },\n }}\n >\n {children}\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopilotContext } from './chunk-
|
|
1
|
+
import { CopilotContext } from './chunk-X24EEZGG.mjs';
|
|
2
2
|
import { useContext, useRef, useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
function useMakeCopilotReadable(information, parentId, categories) {
|
|
@@ -16,4 +16,4 @@ function useMakeCopilotReadable(information, parentId, categories) {
|
|
|
16
16
|
|
|
17
17
|
export { useMakeCopilotReadable };
|
|
18
18
|
//# sourceMappingURL=out.js.map
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-G5LZS72K.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopilotContext } from './chunk-
|
|
1
|
+
import { CopilotContext } from './chunk-X24EEZGG.mjs';
|
|
2
2
|
import { useRef, useContext, useMemo, useEffect } from 'react';
|
|
3
3
|
import { nanoid } from 'nanoid';
|
|
4
4
|
|
|
@@ -27,4 +27,4 @@ function useMakeCopilotActionable(annotatedFunction, dependencies) {
|
|
|
27
27
|
|
|
28
28
|
export { useMakeCopilotActionable };
|
|
29
29
|
//# sourceMappingURL=out.js.map
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-P3QUZTN7.mjs.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultCopilotContextCategories } from './chunk-FIYUJVWU.mjs';
|
|
2
|
+
import { CopilotContext, copilotApiConfigExtrapolator } from './chunk-X24EEZGG.mjs';
|
|
2
3
|
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
4
|
import { useContext, useMemo } from 'react';
|
|
4
5
|
import { useChat } from 'ai/react';
|
|
@@ -17,7 +18,7 @@ function useCopilotChat(_a) {
|
|
|
17
18
|
} = useContext(CopilotContext);
|
|
18
19
|
const systemMessage = useMemo(() => {
|
|
19
20
|
const systemMessageMaker = makeSystemMessage || defaultSystemMessage;
|
|
20
|
-
const contextString = getContextString([]);
|
|
21
|
+
const contextString = getContextString([], defaultCopilotContextCategories);
|
|
21
22
|
return {
|
|
22
23
|
id: "system",
|
|
23
24
|
content: systemMessageMaker(contextString),
|
|
@@ -78,4 +79,4 @@ If you would like to call a function, call it without saying anything else.
|
|
|
78
79
|
|
|
79
80
|
export { defaultSystemMessage, useCopilotChat };
|
|
80
81
|
//# sourceMappingURL=out.js.map
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-PRPQRCVY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,SAAS,kBAAkB;AAMpC,SAAS,eAAe;AAwBjB,SAAS,eAAe,IAGiB;AAHjB,eAC7B;AAAA;AAAA,EA/BF,IA8B+B,IAE1B,oBAF0B,IAE1B;AAAA,IADH;AAAA;AAGA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,cAAc;AAE7B,QAAM,gBAAyB,QAAQ,MAAM;AAC3C,UAAM,qBAAqB,qBAAqB;AAChD,UAAM,gBAAgB,iBAAiB,CAAC,GAAG,+BAA+B;AAE1E,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,mBAAmB,aAAa;AAAA,MACzC,MAAM;AAAA,IACR;AAAA,EACF,GAAG,CAAC,kBAAkB,iBAAiB,CAAC;AAExC,QAAM,6BAA6B,CAAC,aAAa,EAAE;AAAA,IACjD,QAAQ,mBAAmB,CAAC;AAAA,EAC9B;AAEA,QAAM,uBAAuB,QAAQ,MAAM;AACzC,WAAO,sCAAsC;AAAA,EAC/C,GAAG,CAAC,qCAAqC,CAAC;AAE1C,QAAM,EAAE,UAAU,QAAQ,QAAQ,MAAM,WAAW,OAAO,SAAS,IACjE,QAAQ,iCACH,UADG;AAAA,IAEN,KAAK,6BAA6B,gBAAgB,EAAE;AAAA,IACpD,IAAI,QAAQ;AAAA,IACZ,iBAAiB;AAAA,IACjB,6BAA6B,uBAAuB;AAAA,IACpD,SAAS,kCAAK,iBAAiB,UAAY,QAAQ;AAAA,IACnD,MAAM;AAAA,MACJ,IAAI,QAAQ;AAAA,MACZ,WAAW;AAAA,OACR,iBAAiB,OACjB,QAAQ;AAAA,EAEf,EAAC;AAEH,QAAM,kBAAkB,SAAS;AAAA,IAC/B,CAAC,YAAY,QAAQ,SAAS,UAAU,QAAQ,SAAS;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,qBAAqB,eAA+B;AAClE,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWF","sourcesContent":["import { useMemo, useContext } from \"react\";\nimport {\n CopilotContext,\n CopilotContextParams,\n copilotApiConfigExtrapolator,\n} from \"../context/copilot-context\";\nimport { useChat } from \"ai/react\";\nimport { ChatRequestOptions, CreateMessage, Message } from \"ai\";\nimport { UseChatOptions } from \"ai\";\nimport { defaultCopilotContextCategories } from \"../components\";\n\nexport interface UseCopilotChatOptions extends UseChatOptions {\n makeSystemMessage?: (contextString: string) => string;\n}\n\nexport interface UseCopilotChatReturn {\n visibleMessages: Message[];\n append: (\n message: Message | CreateMessage,\n chatRequestOptions?: ChatRequestOptions\n ) => Promise<string | null | undefined>;\n reload: (\n chatRequestOptions?: ChatRequestOptions\n ) => Promise<string | null | undefined>;\n stop: () => void;\n isLoading: boolean;\n input: string;\n setInput: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport function useCopilotChat({\n makeSystemMessage,\n ...options\n}: UseCopilotChatOptions): UseCopilotChatReturn {\n const {\n getContextString,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n copilotApiConfig,\n } = useContext(CopilotContext);\n\n const systemMessage: Message = useMemo(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n const contextString = getContextString([], defaultCopilotContextCategories); // TODO: make the context categories configurable\n\n return {\n id: \"system\",\n content: systemMessageMaker(contextString),\n role: \"system\",\n };\n }, [getContextString, makeSystemMessage]);\n\n const initialMessagesWithContext = [systemMessage].concat(\n options.initialMessages || []\n );\n\n const functionDescriptions = useMemo(() => {\n return getChatCompletionFunctionDescriptions();\n }, [getChatCompletionFunctionDescriptions]);\n\n const { messages, append, reload, stop, isLoading, input, setInput } =\n useChat({\n ...options,\n api: copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint,\n id: options.id,\n initialMessages: initialMessagesWithContext,\n experimental_onFunctionCall: getFunctionCallHandler(),\n headers: { ...copilotApiConfig.headers, ...options.headers },\n body: {\n id: options.id,\n functions: functionDescriptions,\n ...copilotApiConfig.body,\n ...options.body,\n },\n });\n\n const visibleMessages = messages.filter(\n (message) => message.role === \"user\" || message.role === \"assistant\"\n );\n\n return {\n visibleMessages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n\nexport function defaultSystemMessage(contextString: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp 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.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\n`;\n}\n"]}
|
|
@@ -16,11 +16,11 @@ var emptyCopilotContext = {
|
|
|
16
16
|
},
|
|
17
17
|
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug(),
|
|
18
18
|
getFunctionCallHandler: () => returnAndThrowInDebug(),
|
|
19
|
-
getContextString: (documents) => returnAndThrowInDebug(),
|
|
19
|
+
getContextString: (documents, categories) => returnAndThrowInDebug(),
|
|
20
20
|
addContext: () => "",
|
|
21
21
|
removeContext: () => {
|
|
22
22
|
},
|
|
23
|
-
getDocumentsContext: () => returnAndThrowInDebug(),
|
|
23
|
+
getDocumentsContext: (categories) => returnAndThrowInDebug(),
|
|
24
24
|
addDocumentContext: () => returnAndThrowInDebug(),
|
|
25
25
|
removeDocumentContext: () => {
|
|
26
26
|
},
|
|
@@ -47,4 +47,4 @@ function returnAndThrowInDebug(value) {
|
|
|
47
47
|
|
|
48
48
|
export { CopilotContext, copilotApiConfigExtrapolator };
|
|
49
49
|
//# sourceMappingURL=out.js.map
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
50
|
+
//# sourceMappingURL=chunk-X24EEZGG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context/copilot-context.tsx"],"names":[],"mappings":";;;;;AAGA,OAAO,WAAW;AAHlB;AA2CO,SAAS,6BAA6B,QAA0B;AACrE,SAAO;AAAA,IACL,IAAI,kBAA0B;AAC5B,aAAO,GAAG,OAAO;AAAA,IACnB;AAAA,EACF;AACF;AAkCA,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,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,qBAAqB,CAAC,eAAyB,sBAAsB,CAAC,CAAC;AAAA,EACvE,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,IACA,IAAI,UAAkC;AACpC,aAAO,CAAC;AAAA,IACV;AAAA,IACA,IAAI,OAA4B;AAC9B,aAAO,CAAC;AAAA,IACV;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBACX,MAAM,cAAoC,mBAAmB;AAE/D,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT","sourcesContent":["\"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\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Additional body params to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'message': 'Hello, world!'\n * }\n * ```\n */\n body: Record<string, any>;\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: (\n documents: DocumentPointer[],\n categories: string[]\n ) => string;\n addContext: (\n context: string,\n parentId?: string,\n categories?: string[]\n ) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n\n // document context\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n addDocumentContext: (\n documentPointer: DocumentPointer,\n categories?: string[]\n ) => TreeNodeId;\n removeDocumentContext: (documentId: string) => 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: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\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 get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\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"]}
|
|
@@ -6,5 +6,6 @@ declare function CopilotProvider({ chatApiEndpoint, headers, body, children, }:
|
|
|
6
6
|
body?: Record<string, any>;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
}): JSX.Element;
|
|
9
|
+
declare const defaultCopilotContextCategories: string[];
|
|
9
10
|
|
|
10
|
-
export { CopilotProvider };
|
|
11
|
+
export { CopilotProvider, defaultCopilotContextCategories };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { CopilotProvider } from '../chunk-
|
|
1
|
+
export { CopilotProvider, defaultCopilotContextCategories } from '../chunk-FIYUJVWU.mjs';
|
|
2
2
|
import '../chunk-3BOHSSKR.mjs';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-X24EEZGG.mjs';
|
|
4
4
|
import '../chunk-63ILXW5V.mjs';
|
|
5
5
|
import '../chunk-MRXNTQOX.mjs';
|
|
6
6
|
//# sourceMappingURL=out.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CopilotProvider } from './copilot-provider.js';
|
|
1
|
+
export { CopilotProvider, defaultCopilotContextCategories } from './copilot-provider.js';
|
|
2
2
|
import 'react';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../chunk-JD7BAH7U.mjs';
|
|
2
|
-
export { CopilotProvider } from '../chunk-
|
|
2
|
+
export { CopilotProvider, defaultCopilotContextCategories } from '../chunk-FIYUJVWU.mjs';
|
|
3
3
|
import '../chunk-3BOHSSKR.mjs';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-X24EEZGG.mjs';
|
|
5
5
|
import '../chunk-63ILXW5V.mjs';
|
|
6
6
|
import '../chunk-MRXNTQOX.mjs';
|
|
7
7
|
//# sourceMappingURL=out.js.map
|
|
@@ -45,10 +45,10 @@ interface CopilotContextParams {
|
|
|
45
45
|
removeEntryPoint: (id: string) => void;
|
|
46
46
|
getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];
|
|
47
47
|
getFunctionCallHandler: () => FunctionCallHandler;
|
|
48
|
-
getContextString: (documents: DocumentPointer[], categories
|
|
48
|
+
getContextString: (documents: DocumentPointer[], categories: string[]) => string;
|
|
49
49
|
addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;
|
|
50
50
|
removeContext: (id: TreeNodeId) => void;
|
|
51
|
-
getDocumentsContext: (categories
|
|
51
|
+
getDocumentsContext: (categories: string[]) => DocumentPointer[];
|
|
52
52
|
addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;
|
|
53
53
|
removeDocumentContext: (documentId: string) => void;
|
|
54
54
|
copilotApiConfig: CopilotApiConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CopilotContext, copilotApiConfigExtrapolator } from '../chunk-
|
|
1
|
+
export { CopilotContext, copilotApiConfigExtrapolator } from '../chunk-X24EEZGG.mjs';
|
|
2
2
|
import '../chunk-MRXNTQOX.mjs';
|
|
3
3
|
//# sourceMappingURL=out.js.map
|
|
4
4
|
//# sourceMappingURL=copilot-context.mjs.map
|
package/dist/context/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../chunk-YPSGKPDA.mjs';
|
|
2
|
-
export { CopilotContext, copilotApiConfigExtrapolator } from '../chunk-
|
|
2
|
+
export { CopilotContext, copilotApiConfigExtrapolator } from '../chunk-X24EEZGG.mjs';
|
|
3
3
|
import '../chunk-MRXNTQOX.mjs';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import '../chunk-QACD2U6P.mjs';
|
|
2
|
-
export { useMakeCopilotActionable } from '../chunk-
|
|
3
|
-
export { useMakeCopilotDocumentReadable } from '../chunk-
|
|
4
|
-
export { useMakeCopilotReadable } from '../chunk-
|
|
5
|
-
export { useCopilotChat } from '../chunk-
|
|
6
|
-
import '../chunk-
|
|
2
|
+
export { useMakeCopilotActionable } from '../chunk-P3QUZTN7.mjs';
|
|
3
|
+
export { useMakeCopilotDocumentReadable } from '../chunk-AMFRKVFT.mjs';
|
|
4
|
+
export { useMakeCopilotReadable } from '../chunk-G5LZS72K.mjs';
|
|
5
|
+
export { useCopilotChat } from '../chunk-PRPQRCVY.mjs';
|
|
6
|
+
import '../chunk-JD7BAH7U.mjs';
|
|
7
|
+
import '../chunk-FIYUJVWU.mjs';
|
|
8
|
+
import '../chunk-3BOHSSKR.mjs';
|
|
9
|
+
import '../chunk-X24EEZGG.mjs';
|
|
10
|
+
import '../chunk-63ILXW5V.mjs';
|
|
7
11
|
import '../chunk-MRXNTQOX.mjs';
|
|
8
12
|
//# sourceMappingURL=out.js.map
|
|
9
13
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export { defaultSystemMessage, useCopilotChat } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { defaultSystemMessage, useCopilotChat } from '../chunk-PRPQRCVY.mjs';
|
|
2
|
+
import '../chunk-JD7BAH7U.mjs';
|
|
3
|
+
import '../chunk-FIYUJVWU.mjs';
|
|
4
|
+
import '../chunk-3BOHSSKR.mjs';
|
|
5
|
+
import '../chunk-X24EEZGG.mjs';
|
|
6
|
+
import '../chunk-63ILXW5V.mjs';
|
|
3
7
|
import '../chunk-MRXNTQOX.mjs';
|
|
4
8
|
//# sourceMappingURL=out.js.map
|
|
5
9
|
//# sourceMappingURL=use-copilot-chat.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { useMakeCopilotActionable } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { useMakeCopilotActionable } from '../chunk-P3QUZTN7.mjs';
|
|
2
|
+
import '../chunk-X24EEZGG.mjs';
|
|
3
3
|
import '../chunk-MRXNTQOX.mjs';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=use-make-copilot-actionable.mjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DocumentPointer } from '../types/document-pointer.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @returns The
|
|
4
|
+
* Makes a document readable by Copilot.
|
|
5
|
+
* @param document The document to make readable.
|
|
6
|
+
* @param categories The categories to associate with the document.
|
|
7
|
+
* @param dependencies The dependencies to use for the effect.
|
|
8
|
+
* @returns The id of the document.
|
|
9
9
|
*/
|
|
10
10
|
declare function useMakeCopilotDocumentReadable(document: DocumentPointer, categories?: string[], dependencies?: any[]): string | undefined;
|
|
11
11
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { useMakeCopilotDocumentReadable } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { useMakeCopilotDocumentReadable } from '../chunk-AMFRKVFT.mjs';
|
|
2
|
+
import '../chunk-X24EEZGG.mjs';
|
|
3
3
|
import '../chunk-MRXNTQOX.mjs';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=use-make-copilot-document-readable.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { useMakeCopilotReadable } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { useMakeCopilotReadable } from '../chunk-G5LZS72K.mjs';
|
|
2
|
+
import '../chunk-X24EEZGG.mjs';
|
|
3
3
|
import '../chunk-MRXNTQOX.mjs';
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=use-make-copilot-readable.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CopilotProvider } from './components/copilot-provider.js';
|
|
1
|
+
export { CopilotProvider, defaultCopilotContextCategories } from './components/copilot-provider.js';
|
|
2
2
|
export { CopilotApiConfig, CopilotContext, CopilotContextParams, copilotApiConfigExtrapolator } from './context/copilot-context.js';
|
|
3
3
|
export { UseCopilotChatOptions, UseCopilotChatReturn, useCopilotChat } from './hooks/use-copilot-chat.js';
|
|
4
4
|
export { useMakeCopilotActionable } from './hooks/use-make-copilot-actionable.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import './chunk-EFZPSZWO.mjs';
|
|
2
|
-
import './chunk-JD7BAH7U.mjs';
|
|
3
|
-
export { CopilotProvider } from './chunk-3EE3HCUI.mjs';
|
|
4
|
-
import './chunk-3BOHSSKR.mjs';
|
|
5
2
|
import './chunk-YPSGKPDA.mjs';
|
|
6
3
|
import './chunk-QACD2U6P.mjs';
|
|
7
|
-
export { useMakeCopilotActionable } from './chunk-
|
|
8
|
-
export { useMakeCopilotDocumentReadable } from './chunk-
|
|
9
|
-
export { useMakeCopilotReadable } from './chunk-
|
|
10
|
-
export { useCopilotChat } from './chunk-
|
|
11
|
-
|
|
4
|
+
export { useMakeCopilotActionable } from './chunk-P3QUZTN7.mjs';
|
|
5
|
+
export { useMakeCopilotDocumentReadable } from './chunk-AMFRKVFT.mjs';
|
|
6
|
+
export { useMakeCopilotReadable } from './chunk-G5LZS72K.mjs';
|
|
7
|
+
export { useCopilotChat } from './chunk-PRPQRCVY.mjs';
|
|
8
|
+
import './chunk-JD7BAH7U.mjs';
|
|
9
|
+
export { CopilotProvider, defaultCopilotContextCategories } from './chunk-FIYUJVWU.mjs';
|
|
10
|
+
import './chunk-3BOHSSKR.mjs';
|
|
11
|
+
export { CopilotContext, copilotApiConfigExtrapolator } from './chunk-X24EEZGG.mjs';
|
|
12
12
|
import './chunk-63ILXW5V.mjs';
|
|
13
13
|
import './chunk-MRXNTQOX.mjs';
|
|
14
14
|
//# sourceMappingURL=out.js.map
|
package/package.json
CHANGED
|
@@ -51,7 +51,7 @@ export function CopilotProvider({
|
|
|
51
51
|
}, []);
|
|
52
52
|
|
|
53
53
|
const getContextString = useCallback(
|
|
54
|
-
(documents: DocumentPointer[], categories: string[]
|
|
54
|
+
(documents: DocumentPointer[], categories: string[]) => {
|
|
55
55
|
const documentsString = documents
|
|
56
56
|
.map((document) => {
|
|
57
57
|
return `${document.name} (${
|
|
@@ -68,7 +68,11 @@ export function CopilotProvider({
|
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
const addContext = useCallback(
|
|
71
|
-
(
|
|
71
|
+
(
|
|
72
|
+
context: string,
|
|
73
|
+
parentId?: string,
|
|
74
|
+
categories: string[] = defaultCopilotContextCategories
|
|
75
|
+
) => {
|
|
72
76
|
return addElement(context, categories, parentId);
|
|
73
77
|
},
|
|
74
78
|
[addElement]
|
|
@@ -90,14 +94,17 @@ export function CopilotProvider({
|
|
|
90
94
|
}, [entryPoints]);
|
|
91
95
|
|
|
92
96
|
const getDocumentsContext = useCallback(
|
|
93
|
-
(categories: string[]
|
|
97
|
+
(categories: string[]) => {
|
|
94
98
|
return allDocuments(categories);
|
|
95
99
|
},
|
|
96
100
|
[allDocuments]
|
|
97
101
|
);
|
|
98
102
|
|
|
99
103
|
const addDocumentContext = useCallback(
|
|
100
|
-
(
|
|
104
|
+
(
|
|
105
|
+
documentPointer: DocumentPointer,
|
|
106
|
+
categories: string[] = defaultCopilotContextCategories
|
|
107
|
+
) => {
|
|
101
108
|
return addDocument(documentPointer, categories);
|
|
102
109
|
},
|
|
103
110
|
[addDocument]
|
|
@@ -136,6 +143,8 @@ export function CopilotProvider({
|
|
|
136
143
|
);
|
|
137
144
|
}
|
|
138
145
|
|
|
146
|
+
export const defaultCopilotContextCategories = ["global"];
|
|
147
|
+
|
|
139
148
|
function entryPointsToFunctionCallHandler(
|
|
140
149
|
entryPoints: AnnotatedFunction<any[]>[]
|
|
141
150
|
): FunctionCallHandler {
|
package/src/components/index.ts
CHANGED
|
@@ -60,7 +60,7 @@ export interface CopilotContextParams {
|
|
|
60
60
|
// text context
|
|
61
61
|
getContextString: (
|
|
62
62
|
documents: DocumentPointer[],
|
|
63
|
-
categories
|
|
63
|
+
categories: string[]
|
|
64
64
|
) => string;
|
|
65
65
|
addContext: (
|
|
66
66
|
context: string,
|
|
@@ -70,7 +70,7 @@ export interface CopilotContextParams {
|
|
|
70
70
|
removeContext: (id: TreeNodeId) => void;
|
|
71
71
|
|
|
72
72
|
// document context
|
|
73
|
-
getDocumentsContext: (categories
|
|
73
|
+
getDocumentsContext: (categories: string[]) => DocumentPointer[];
|
|
74
74
|
addDocumentContext: (
|
|
75
75
|
documentPointer: DocumentPointer,
|
|
76
76
|
categories?: string[]
|
|
@@ -88,11 +88,12 @@ const emptyCopilotContext: CopilotContextParams = {
|
|
|
88
88
|
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
|
|
89
89
|
getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),
|
|
90
90
|
|
|
91
|
-
getContextString: (documents: DocumentPointer[]) =>
|
|
91
|
+
getContextString: (documents: DocumentPointer[], categories: string[]) =>
|
|
92
|
+
returnAndThrowInDebug(""),
|
|
92
93
|
addContext: () => "",
|
|
93
94
|
removeContext: () => {},
|
|
94
95
|
|
|
95
|
-
getDocumentsContext: () => returnAndThrowInDebug([]),
|
|
96
|
+
getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),
|
|
96
97
|
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
97
98
|
removeDocumentContext: () => {},
|
|
98
99
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { useChat } from "ai/react";
|
|
8
8
|
import { ChatRequestOptions, CreateMessage, Message } from "ai";
|
|
9
9
|
import { UseChatOptions } from "ai";
|
|
10
|
+
import { defaultCopilotContextCategories } from "../components";
|
|
10
11
|
|
|
11
12
|
export interface UseCopilotChatOptions extends UseChatOptions {
|
|
12
13
|
makeSystemMessage?: (contextString: string) => string;
|
|
@@ -40,7 +41,7 @@ export function useCopilotChat({
|
|
|
40
41
|
|
|
41
42
|
const systemMessage: Message = useMemo(() => {
|
|
42
43
|
const systemMessageMaker = makeSystemMessage || defaultSystemMessage;
|
|
43
|
-
const contextString = getContextString([]);
|
|
44
|
+
const contextString = getContextString([], defaultCopilotContextCategories); // TODO: make the context categories configurable
|
|
44
45
|
|
|
45
46
|
return {
|
|
46
47
|
id: "system",
|
|
@@ -5,11 +5,11 @@ import { CopilotContext } from "../context/copilot-context";
|
|
|
5
5
|
import { DocumentPointer } from "../types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @returns The
|
|
8
|
+
* Makes a document readable by Copilot.
|
|
9
|
+
* @param document The document to make readable.
|
|
10
|
+
* @param categories The categories to associate with the document.
|
|
11
|
+
* @param dependencies The dependencies to use for the effect.
|
|
12
|
+
* @returns The id of the document.
|
|
13
13
|
*/
|
|
14
14
|
export function useMakeCopilotDocumentReadable(
|
|
15
15
|
document: DocumentPointer,
|
|
@@ -27,7 +27,7 @@ export function useMakeCopilotDocumentReadable(
|
|
|
27
27
|
return () => {
|
|
28
28
|
removeDocumentContext(id);
|
|
29
29
|
};
|
|
30
|
-
}, [
|
|
30
|
+
}, [addDocumentContext, removeDocumentContext, ...dependencies]);
|
|
31
31
|
|
|
32
32
|
return idRef.current;
|
|
33
33
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/copilot-provider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,SAAoB,aAAa,gBAAgB;AA+G7C;AAjHJ;AAUO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKgB;AACd,QAAM,CAAC,aAAa,cAAc,IAAI,SAEpC,CAAC,CAAC;AAEJ,QAAM,EAAE,YAAY,eAAe,UAAU,IAAI,iBAAQ;AACzD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,aAAa;AAAA,EACf,IAAI,gCAAsC;AAE1C,QAAM,gBAAgB;AAAA,IACpB,CAAC,IAAY,eAAyC;AACpD,qBAAe,CAAC,eAAe;AAC7B,eAAO,iCACF,aADE;AAAA,UAEL,CAAC,KAAK;AAAA,QACR;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,mBAAmB,YAAY,CAAC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mC,CAAC;AACxC,WAAS,OAAO,kBAAkB,qBAAqB;AACrD,QAAI,IAAI,UAAU;AAChB,6BAAuB,KAAK,IAAI,IAAI;AAAA,IACtC;AAAA,EACF;AAGA,MAAI,yBAA8D;AAAA,IAChE,MAAM,kBAAkB;AAAA,IACxB,aAAa,kBAAkB;AAAA,IAC/B,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,SAAO;AACT","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\";\nimport { DocumentPointer } from \"../types\";\nimport useFlatCategoryStore from \"../hooks/use-flat-category-store\";\n\nexport function CopilotProvider({\n chatApiEndpoint,\n headers,\n body,\n children,\n}: {\n chatApiEndpoint: string;\n headers?: Record<string, string>;\n body?: Record<string, any>;\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 const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\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 (documents: DocumentPointer[], categories: string[] = [\"global\"]) => {\n const documentsString = documents\n .map((document) => {\n return `${document.name} (${\n document.sourceApplication\n }):\\n${document.getContents()}`;\n })\n .join(\"\\n\\n\");\n\n const nonDocumentStrings = printTree(categories);\n\n return `${documentsString}\\n\\n${nonDocumentStrings}`;\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 const getDocumentsContext = useCallback(\n (categories: string[] = [\"global\"]) => {\n return allDocuments(categories);\n },\n [allDocuments]\n );\n\n const addDocumentContext = useCallback(\n (documentPointer: DocumentPointer, categories: string[] = [\"global\"]) => {\n return addDocument(documentPointer, categories);\n },\n [addDocument]\n );\n\n const removeDocumentContext = useCallback(\n (documentId: string) => {\n removeDocument(documentId);\n },\n [removeDocument]\n );\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 getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: {\n chatApiEndpoint,\n headers: headers || {},\n body: body || {},\n },\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,SAAS,kBAAkB;AAMpC,SAAS,eAAe;AAuBjB,SA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;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWF","sourcesContent":["import { useMemo, useContext } from \"react\";\nimport {\n CopilotContext,\n CopilotContextParams,\n copilotApiConfigExtrapolator,\n} from \"../context/copilot-context\";\nimport { useChat } from \"ai/react\";\nimport { ChatRequestOptions, CreateMessage, Message } from \"ai\";\nimport { UseChatOptions } from \"ai\";\n\nexport interface UseCopilotChatOptions extends UseChatOptions {\n makeSystemMessage?: (contextString: string) => string;\n}\n\nexport interface UseCopilotChatReturn {\n visibleMessages: Message[];\n append: (\n message: Message | CreateMessage,\n chatRequestOptions?: ChatRequestOptions\n ) => Promise<string | null | undefined>;\n reload: (\n chatRequestOptions?: ChatRequestOptions\n ) => Promise<string | null | undefined>;\n stop: () => void;\n isLoading: boolean;\n input: string;\n setInput: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport function useCopilotChat({\n makeSystemMessage,\n ...options\n}: UseCopilotChatOptions): UseCopilotChatReturn {\n const {\n getContextString,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n copilotApiConfig,\n } = useContext(CopilotContext);\n\n const systemMessage: Message = useMemo(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n const contextString = getContextString([]);\n\n return {\n id: \"system\",\n content: systemMessageMaker(contextString),\n role: \"system\",\n };\n }, [getContextString, makeSystemMessage]);\n\n const initialMessagesWithContext = [systemMessage].concat(\n options.initialMessages || []\n );\n\n const functionDescriptions = useMemo(() => {\n return getChatCompletionFunctionDescriptions();\n }, [getChatCompletionFunctionDescriptions]);\n\n const { messages, append, reload, stop, isLoading, input, setInput } =\n useChat({\n ...options,\n api: copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint,\n id: options.id,\n initialMessages: initialMessagesWithContext,\n experimental_onFunctionCall: getFunctionCallHandler(),\n headers: { ...copilotApiConfig.headers, ...options.headers },\n body: {\n id: options.id,\n functions: functionDescriptions,\n ...copilotApiConfig.body,\n ...options.body,\n },\n });\n\n const visibleMessages = messages.filter(\n (message) => message.role === \"user\" || message.role === \"assistant\"\n );\n\n return {\n visibleMessages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n\nexport function defaultSystemMessage(contextString: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp 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.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\n`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-make-copilot-document-readable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,YAAY,WAAW,cAAc;AAF9C;AAaO,SAAS,+BACd,UACA,YACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAChD,WAAW,cAAc;AAC3B,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,YAAY,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE3E,SAAO,MAAM;AACf","sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n * @param information - The information to be added to the Copilot context.\n * @param parentId - The ID of the parent context, if any.\n * @param categories - An array of categories to control which context are visible where. Particularly useful with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n * @returns The ID of the added context.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = []\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } =\n useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [categories, addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context/copilot-context.tsx"],"names":[],"mappings":";;;;;AAGA,OAAO,WAAW;AAHlB;AA2CO,SAAS,6BAA6B,QAA0B;AACrE,SAAO;AAAA,IACL,IAAI,kBAA0B;AAC5B,aAAO,GAAG,OAAO;AAAA,IACnB;AAAA,EACF;AACF;AAkCA,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,CAAC,cAAiC,sBAAsB,EAAE;AAAA,EAC5E,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,qBAAqB,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACnD,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,IACA,IAAI,UAAkC;AACpC,aAAO,CAAC;AAAA,IACV;AAAA,IACA,IAAI,OAA4B;AAC9B,aAAO,CAAC;AAAA,IACV;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBACX,MAAM,cAAoC,mBAAmB;AAE/D,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT","sourcesContent":["\"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\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Additional body params to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'message': 'Hello, world!'\n * }\n * ```\n */\n body: Record<string, any>;\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: (\n documents: DocumentPointer[],\n categories?: string[]\n ) => string;\n addContext: (\n context: string,\n parentId?: string,\n categories?: string[]\n ) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n\n // document context\n getDocumentsContext: (categories?: string[]) => DocumentPointer[];\n addDocumentContext: (\n documentPointer: DocumentPointer,\n categories?: string[]\n ) => TreeNodeId;\n removeDocumentContext: (documentId: string) => 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: (documents: DocumentPointer[]) => returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getDocumentsContext: () => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\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 get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\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"]}
|
|
File without changes
|
|
File without changes
|