@copilotkit/react-core 0.16.0 → 0.17.0-alpha.1
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 +168 -134
- package/CHANGELOG.md +12 -0
- package/dist/chunk-5UGLWBZJ.mjs +3 -0
- package/dist/{chunk-YGJFU4ZP.mjs → chunk-6A4PCNMZ.mjs} +2 -12
- package/dist/chunk-6A4PCNMZ.mjs.map +1 -0
- package/dist/chunk-6SOQYBNX.mjs +44 -0
- package/dist/chunk-6SOQYBNX.mjs.map +1 -0
- package/dist/{chunk-RFZQHCNS.mjs → chunk-7P4OYNP3.mjs} +2 -2
- package/dist/{chunk-WL2MC3E2.mjs → chunk-FP4EXCGS.mjs} +2 -2
- package/dist/{chunk-PF7LXYPO.mjs → chunk-HW5IH6PV.mjs} +2 -2
- package/dist/chunk-PUFR5OAI.mjs +3 -0
- package/dist/{chunk-EV26IMLL.mjs → chunk-QTET3FBV.mjs} +5 -5
- package/dist/chunk-QTET3FBV.mjs.map +1 -0
- package/dist/{chunk-DE37LEZJ.mjs → chunk-SM3XH2NJ.mjs} +10 -12
- package/dist/chunk-SM3XH2NJ.mjs.map +1 -0
- package/dist/chunk-TDH7XE4X.mjs +104 -0
- package/dist/chunk-TDH7XE4X.mjs.map +1 -0
- package/dist/chunk-TKXPMMND.mjs +177 -0
- package/dist/chunk-TKXPMMND.mjs.map +1 -0
- package/dist/{chunk-IF64NU27.mjs → chunk-TU4DNDO7.mjs} +4 -4
- package/dist/chunk-TU4DNDO7.mjs.map +1 -0
- package/dist/chunk-VK25FIML.mjs +144 -0
- package/dist/chunk-VK25FIML.mjs.map +1 -0
- package/dist/chunk-VNRDQJXW.mjs +3 -0
- package/dist/chunk-VNRDQJXW.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-provider-props.d.ts +3 -3
- package/dist/components/copilot-provider/copilot-provider.d.ts +3 -3
- package/dist/components/copilot-provider/copilot-provider.mjs +2 -2
- package/dist/components/copilot-provider/index.d.ts +3 -3
- package/dist/components/copilot-provider/index.mjs +2 -2
- package/dist/components/copilot-provider/standard-copilot-api-config.d.ts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.mjs +2 -2
- package/dist/context/copilot-context.d.ts +4 -8
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.d.ts +4 -4
- package/dist/context/index.mjs +2 -2
- package/dist/hooks/index.d.ts +6 -1
- package/dist/hooks/index.mjs +10 -7
- package/dist/hooks/use-chat.d.ts +84 -0
- package/dist/hooks/use-chat.mjs +6 -0
- package/dist/hooks/use-chat.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat.d.ts +10 -3
- package/dist/hooks/use-copilot-chat.mjs +6 -3
- package/dist/hooks/use-make-copilot-actionable.mjs +2 -2
- 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 +6 -2
- package/dist/index.mjs +15 -10
- package/dist/openai/chat-completion-client.d.ts +52 -0
- package/dist/openai/chat-completion-client.mjs +5 -0
- package/dist/openai/chat-completion-client.mjs.map +1 -0
- package/dist/openai/chat-completion-stream.d.ts +21 -0
- package/dist/openai/chat-completion-stream.mjs +5 -0
- package/dist/openai/chat-completion-stream.mjs.map +1 -0
- package/dist/openai/chat-completion-transport.d.ts +38 -0
- package/dist/openai/chat-completion-transport.mjs +4 -0
- package/dist/openai/chat-completion-transport.mjs.map +1 -0
- package/dist/openai/index.d.ts +10 -0
- package/dist/openai/index.mjs +6 -0
- package/dist/openai/index.mjs.map +1 -0
- package/dist/openai-assistants/hooks/index.mjs +4 -4
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs +4 -4
- package/dist/openai-assistants/index.mjs +4 -4
- package/dist/types/base.d.ts +56 -0
- package/dist/types/base.mjs +3 -0
- package/dist/types/base.mjs.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/message.d.ts +2 -0
- package/dist/types/message.mjs +3 -0
- package/dist/types/message.mjs.map +1 -0
- package/package.json +2 -2
- package/src/components/copilot-provider/copilot-provider.tsx +4 -5
- package/src/context/copilot-context.tsx +1 -12
- package/src/context/index.ts +0 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-chat.ts +197 -0
- package/src/hooks/use-copilot-chat.ts +10 -22
- package/src/index.tsx +1 -0
- package/src/openai/chat-completion-client.ts +229 -0
- package/src/openai/chat-completion-stream.ts +54 -0
- package/src/openai/chat-completion-transport.ts +186 -0
- package/src/openai/index.tsx +5 -0
- package/src/openai-assistants/hooks/use-copilot-chat-v2.ts +2 -2
- package/src/types/base.ts +61 -0
- package/src/types/index.ts +1 -0
- package/src/types/message.ts +0 -0
- package/dist/chunk-DE37LEZJ.mjs.map +0 -1
- package/dist/chunk-EV26IMLL.mjs.map +0 -1
- package/dist/chunk-IF64NU27.mjs.map +0 -1
- package/dist/chunk-QACD2U6P.mjs +0 -3
- package/dist/chunk-YGJFU4ZP.mjs.map +0 -1
- package/dist/chunk-YPSGKPDA.mjs +0 -3
- /package/dist/{chunk-QACD2U6P.mjs.map → chunk-5UGLWBZJ.mjs.map} +0 -0
- /package/dist/{chunk-RFZQHCNS.mjs.map → chunk-7P4OYNP3.mjs.map} +0 -0
- /package/dist/{chunk-WL2MC3E2.mjs.map → chunk-FP4EXCGS.mjs.map} +0 -0
- /package/dist/{chunk-PF7LXYPO.mjs.map → chunk-HW5IH6PV.mjs.map} +0 -0
- /package/dist/{chunk-YPSGKPDA.mjs.map → chunk-PUFR5OAI.mjs.map} +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,151 +1,185 @@
|
|
|
1
1
|
|
|
2
|
-
> @copilotkit/react-core@0.
|
|
2
|
+
> @copilotkit/react-core@0.17.0-alpha.0 build /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core
|
|
3
3
|
> tsup --treeshake
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
CLI Building entry: src/index.tsx, src/components/index.ts, src/context/copilot-context.tsx, src/context/index.ts, src/hooks/index.ts, src/hooks/use-chat.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/openai-assistants/index.ts, src/openai/chat-completion-client.ts, src/openai/chat-completion-stream.ts, src/openai/chat-completion-transport.ts, src/openai/index.tsx, src/types/annotated-function.ts, src/types/base.ts, src/types/document-pointer.ts, src/types/index.ts, src/types/message.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/components/copilot-provider/copilot-provider-props.tsx, src/components/copilot-provider/copilot-provider.tsx, src/components/copilot-provider/index.ts, src/components/copilot-provider/standard-copilot-api-config.tsx, src/openai-assistants/hooks/index.ts, src/openai-assistants/hooks/use-assistants.ts, src/openai-assistants/hooks/use-copilot-chat-v2.ts, src/openai-assistants/utils/index.ts, src/openai-assistants/utils/process-message-stream.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v6.7.0
|
|
8
|
+
CLI Using tsup config: /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core/tsup.config.ts
|
|
9
|
+
CLI Target: es6
|
|
10
|
+
CLI Cleaning output folder
|
|
11
|
+
ESM Build start
|
|
12
12
|
Module level directives cause errors when bundled, "use client" in "dist/components/copilot-provider/copilot-provider-props.mjs" was ignored.
|
|
13
13
|
Module level directives cause errors when bundled, "use client" in "dist/components/copilot-provider/copilot-provider.mjs" was ignored.
|
|
14
14
|
Module level directives cause errors when bundled, "use client" in "dist/openai-assistants/hooks/use-assistants.mjs" was ignored.
|
|
15
|
-
Module level directives cause errors when bundled, "use client" in "dist/context/copilot-context.mjs" was ignored.
|
|
16
15
|
Module level directives cause errors when bundled, "use client" in "dist/hooks/use-make-copilot-actionable.mjs" was ignored.
|
|
17
16
|
Module level directives cause errors when bundled, "use client" in "dist/hooks/use-make-copilot-document-readable.mjs" was ignored.
|
|
18
17
|
Module level directives cause errors when bundled, "use client" in "dist/hooks/use-make-copilot-readable.mjs" was ignored.
|
|
19
|
-
|
|
18
|
+
Module level directives cause errors when bundled, "use client" in "dist/context/copilot-context.mjs" was ignored.
|
|
20
19
|
Generated an empty chunk: "copilot-provider-props".
|
|
21
20
|
Generated an empty chunk: "annotated-function".
|
|
21
|
+
Generated an empty chunk: "base".
|
|
22
22
|
Generated an empty chunk: "document-pointer".
|
|
23
|
+
Generated an empty chunk: "message".
|
|
24
|
+
Generated an empty chunk: "utils".
|
|
25
|
+
Generated an empty chunk: "chunk-PUFR5OAI".
|
|
26
|
+
Generated an empty chunk: "chunk-EFZPSZWO".
|
|
23
27
|
Generated an empty chunk: "chunk-7GFKOIO7".
|
|
24
28
|
Generated an empty chunk: "chunk-BABVSMJR".
|
|
25
29
|
Generated an empty chunk: "chunk-FRAKUJWH".
|
|
26
|
-
Generated an empty chunk: "chunk-
|
|
27
|
-
Generated an empty chunk: "chunk-
|
|
28
|
-
Generated an empty chunk: "chunk-QACD2U6P".
|
|
30
|
+
Generated an empty chunk: "chunk-VNRDQJXW".
|
|
31
|
+
Generated an empty chunk: "chunk-5UGLWBZJ".
|
|
29
32
|
Generated an empty chunk: "chunk-JD7BAH7U".
|
|
30
33
|
Generated an empty chunk: "chunk-SPCZTZCY".
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
34
|
+
ESM dist/chunk-EFZPSZWO.mjs 76.00 B
|
|
35
|
+
ESM dist/hooks/use-make-copilot-actionable.mjs 218.00 B
|
|
36
|
+
ESM dist/types/index.mjs 98.00 B
|
|
37
|
+
ESM dist/openai/index.mjs 224.00 B
|
|
38
|
+
ESM dist/chunk-PUFR5OAI.mjs 76.00 B
|
|
39
|
+
ESM dist/openai-assistants/index.mjs 570.00 B
|
|
40
|
+
ESM dist/chunk-BABVSMJR.mjs 76.00 B
|
|
41
|
+
ESM dist/chunk-JD7BAH7U.mjs 76.00 B
|
|
42
|
+
ESM dist/chunk-F2JIAPZQ.mjs 435.00 B
|
|
43
|
+
ESM dist/chunk-7GFKOIO7.mjs 76.00 B
|
|
44
|
+
ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
|
|
45
|
+
ESM dist/chunk-SPCZTZCY.mjs 76.00 B
|
|
46
|
+
ESM dist/chunk-5UGLWBZJ.mjs 76.00 B
|
|
47
|
+
ESM dist/chunk-VNRDQJXW.mjs 76.00 B
|
|
48
|
+
ESM dist/hooks/use-tree.mjs 170.00 B
|
|
49
|
+
ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
|
|
50
|
+
ESM dist/openai/chat-completion-client.mjs 209.00 B
|
|
51
|
+
ESM dist/openai/chat-completion-transport.mjs 183.00 B
|
|
52
|
+
ESM dist/openai/chat-completion-stream.mjs 209.00 B
|
|
53
|
+
ESM dist/index.mjs 1.11 KB
|
|
54
|
+
ESM dist/chunk-MZ5UN3BY.mjs 830.00 B
|
|
55
|
+
ESM dist/chunk-6SOQYBNX.mjs 1.24 KB
|
|
56
|
+
ESM dist/components/index.mjs 380.00 B
|
|
57
|
+
ESM dist/chunk-TU4DNDO7.mjs 4.33 KB
|
|
58
|
+
ESM dist/chunk-FP4EXCGS.mjs 954.00 B
|
|
59
|
+
ESM dist/hooks/index.mjs 708.00 B
|
|
60
|
+
ESM dist/chunk-7P4OYNP3.mjs 677.00 B
|
|
61
|
+
ESM dist/hooks/use-chat.mjs 214.00 B
|
|
62
|
+
ESM dist/chunk-SM3XH2NJ.mjs 2.71 KB
|
|
63
|
+
ESM dist/hooks/use-copilot-chat.mjs 507.00 B
|
|
64
|
+
ESM dist/chunk-HW5IH6PV.mjs 626.00 B
|
|
65
|
+
ESM dist/chunk-6A4PCNMZ.mjs 1.30 KB
|
|
66
|
+
ESM dist/chunk-FRAKUJWH.mjs 76.00 B
|
|
67
|
+
ESM dist/chunk-VUY2K2DI.mjs 3.89 KB
|
|
68
|
+
ESM dist/chunk-TKXPMMND.mjs 5.33 KB
|
|
69
|
+
ESM dist/chunk-VK25FIML.mjs 4.48 KB
|
|
70
|
+
ESM dist/chunk-TDH7XE4X.mjs 3.28 KB
|
|
71
|
+
ESM dist/chunk-QTET3FBV.mjs 5.18 KB
|
|
72
|
+
ESM dist/hooks/use-flat-category-store.mjs 200.00 B
|
|
73
|
+
ESM dist/context/copilot-context.mjs 164.00 B
|
|
74
|
+
ESM dist/hooks/use-make-copilot-document-readable.mjs 231.00 B
|
|
75
|
+
ESM dist/chunk-YULKJPY3.mjs 1.87 KB
|
|
76
|
+
ESM dist/context/index.mjs 186.00 B
|
|
77
|
+
ESM dist/components/copilot-provider/copilot-provider-props.mjs 84.00 B
|
|
78
|
+
ESM dist/openai-assistants/utils/process-message-stream.mjs 183.00 B
|
|
79
|
+
ESM dist/utils/utils.test.mjs 202.00 B
|
|
80
|
+
ESM dist/openai-assistants/hooks/index.mjs 547.00 B
|
|
81
|
+
ESM dist/types/message.mjs 69.00 B
|
|
82
|
+
ESM dist/utils/utils.mjs 67.00 B
|
|
83
|
+
ESM dist/types/base.mjs 66.00 B
|
|
84
|
+
ESM dist/types/annotated-function.mjs 80.00 B
|
|
85
|
+
ESM dist/types/document-pointer.mjs 78.00 B
|
|
86
|
+
ESM dist/components/copilot-provider/index.mjs 369.00 B
|
|
87
|
+
ESM dist/openai-assistants/utils/index.mjs 201.00 B
|
|
88
|
+
ESM dist/components/copilot-provider/copilot-provider.mjs 345.00 B
|
|
89
|
+
ESM dist/openai-assistants/hooks/use-assistants.mjs 2.55 KB
|
|
90
|
+
ESM dist/components/copilot-provider/standard-copilot-api-config.mjs 192.00 B
|
|
91
|
+
ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs 548.00 B
|
|
92
|
+
ESM dist/chunk-EFZPSZWO.mjs.map 51.00 B
|
|
93
|
+
ESM dist/hooks/use-make-copilot-actionable.mjs.map 51.00 B
|
|
94
|
+
ESM dist/types/index.mjs.map 51.00 B
|
|
95
|
+
ESM dist/openai/index.mjs.map 51.00 B
|
|
96
|
+
ESM dist/chunk-PUFR5OAI.mjs.map 51.00 B
|
|
97
|
+
ESM dist/chunk-BABVSMJR.mjs.map 51.00 B
|
|
98
|
+
ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
|
|
99
|
+
ESM dist/chunk-F2JIAPZQ.mjs.map 1.12 KB
|
|
100
|
+
ESM dist/openai-assistants/index.mjs.map 51.00 B
|
|
101
|
+
ESM dist/chunk-JD7BAH7U.mjs.map 51.00 B
|
|
102
|
+
ESM dist/chunk-5UGLWBZJ.mjs.map 51.00 B
|
|
103
|
+
ESM dist/chunk-SPCZTZCY.mjs.map 51.00 B
|
|
104
|
+
ESM dist/openai/chat-completion-client.mjs.map 51.00 B
|
|
105
|
+
ESM dist/openai/chat-completion-transport.mjs.map 51.00 B
|
|
106
|
+
ESM dist/openai/chat-completion-stream.mjs.map 51.00 B
|
|
107
|
+
ESM dist/hooks/use-make-copilot-readable.mjs.map 51.00 B
|
|
108
|
+
ESM dist/chunk-VNRDQJXW.mjs.map 51.00 B
|
|
109
|
+
ESM dist/hooks/use-tree.mjs.map 51.00 B
|
|
110
|
+
ESM dist/chunk-6SOQYBNX.mjs.map 2.07 KB
|
|
111
|
+
ESM dist/index.mjs.map 51.00 B
|
|
112
|
+
ESM dist/chunk-MZ5UN3BY.mjs.map 1.26 KB
|
|
113
|
+
ESM dist/chunk-7GFKOIO7.mjs.map 51.00 B
|
|
114
|
+
ESM dist/chunk-7P4OYNP3.mjs.map 1.42 KB
|
|
115
|
+
ESM dist/hooks/index.mjs.map 51.00 B
|
|
116
|
+
ESM dist/hooks/use-chat.mjs.map 51.00 B
|
|
117
|
+
ESM dist/chunk-TU4DNDO7.mjs.map 7.90 KB
|
|
118
|
+
ESM dist/chunk-HW5IH6PV.mjs.map 1.47 KB
|
|
119
|
+
ESM dist/chunk-FP4EXCGS.mjs.map 1.67 KB
|
|
120
|
+
ESM dist/chunk-SM3XH2NJ.mjs.map 4.37 KB
|
|
121
|
+
ESM dist/chunk-6A4PCNMZ.mjs.map 4.26 KB
|
|
122
|
+
ESM dist/hooks/use-copilot-chat.mjs.map 51.00 B
|
|
123
|
+
ESM dist/chunk-FRAKUJWH.mjs.map 51.00 B
|
|
124
|
+
ESM dist/components/index.mjs.map 51.00 B
|
|
125
|
+
ESM dist/chunk-TKXPMMND.mjs.map 9.93 KB
|
|
126
|
+
ESM dist/chunk-VUY2K2DI.mjs.map 8.27 KB
|
|
127
|
+
ESM dist/chunk-VK25FIML.mjs.map 7.84 KB
|
|
128
|
+
ESM dist/chunk-TDH7XE4X.mjs.map 7.85 KB
|
|
129
|
+
ESM dist/chunk-QTET3FBV.mjs.map 11.03 KB
|
|
130
|
+
ESM dist/context/copilot-context.mjs.map 51.00 B
|
|
131
|
+
ESM dist/chunk-YULKJPY3.mjs.map 4.21 KB
|
|
132
|
+
ESM dist/hooks/use-flat-category-store.mjs.map 51.00 B
|
|
133
|
+
ESM dist/hooks/use-make-copilot-document-readable.mjs.map 51.00 B
|
|
134
|
+
ESM dist/context/index.mjs.map 51.00 B
|
|
135
|
+
ESM dist/components/copilot-provider/copilot-provider-props.mjs.map 51.00 B
|
|
136
|
+
ESM dist/openai-assistants/utils/process-message-stream.mjs.map 51.00 B
|
|
137
|
+
ESM dist/utils/utils.test.mjs.map 351.00 B
|
|
138
|
+
ESM dist/openai-assistants/hooks/index.mjs.map 51.00 B
|
|
139
|
+
ESM dist/types/message.mjs.map 51.00 B
|
|
140
|
+
ESM dist/utils/utils.mjs.map 51.00 B
|
|
141
|
+
ESM dist/types/annotated-function.mjs.map 51.00 B
|
|
142
|
+
ESM dist/types/base.mjs.map 51.00 B
|
|
143
|
+
ESM dist/openai-assistants/utils/index.mjs.map 51.00 B
|
|
144
|
+
ESM dist/components/copilot-provider/index.mjs.map 51.00 B
|
|
145
|
+
ESM dist/types/document-pointer.mjs.map 51.00 B
|
|
146
|
+
ESM dist/openai-assistants/hooks/use-assistants.mjs.map 4.67 KB
|
|
147
|
+
ESM dist/components/copilot-provider/copilot-provider.mjs.map 51.00 B
|
|
148
|
+
ESM dist/components/copilot-provider/standard-copilot-api-config.mjs.map 51.00 B
|
|
149
|
+
ESM dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map 51.00 B
|
|
150
|
+
ESM ⚡️ Build success in 137ms
|
|
151
|
+
DTS Build start
|
|
152
|
+
DTS ⚡️ Build success in 2803ms
|
|
153
|
+
DTS dist/index.d.ts 1.61 KB
|
|
154
|
+
DTS dist/components/copilot-provider/copilot-provider.d.ts 1.55 KB
|
|
155
|
+
DTS dist/components/copilot-provider/copilot-provider-props.d.ts 1.52 KB
|
|
156
|
+
DTS dist/context/copilot-context.d.ts 1.98 KB
|
|
157
|
+
DTS dist/hooks/use-copilot-chat.d.ts 955.00 B
|
|
158
|
+
DTS dist/hooks/use-make-copilot-actionable.d.ts 255.00 B
|
|
159
|
+
DTS dist/hooks/use-make-copilot-readable.d.ts 598.00 B
|
|
160
|
+
DTS dist/hooks/use-make-copilot-document-readable.d.ts 516.00 B
|
|
161
|
+
DTS dist/hooks/use-chat.d.ts 2.75 KB
|
|
162
|
+
DTS dist/types/annotated-function.d.ts 767.00 B
|
|
163
|
+
DTS dist/types/document-pointer.d.ts 181.00 B
|
|
164
|
+
DTS dist/types/base.d.ts 1.96 KB
|
|
165
|
+
DTS dist/openai-assistants/hooks/use-copilot-chat-v2.d.ts 1.41 KB
|
|
166
|
+
DTS dist/openai-assistants/utils/process-message-stream.d.ts 196.00 B
|
|
167
|
+
DTS dist/openai/chat-completion-stream.d.ts 694.00 B
|
|
168
|
+
DTS dist/openai/chat-completion-transport.d.ts 1.26 KB
|
|
169
|
+
DTS dist/hooks/use-tree.d.ts 543.00 B
|
|
170
|
+
DTS dist/components/index.d.ts 482.00 B
|
|
171
|
+
DTS dist/context/index.d.ts 281.00 B
|
|
172
|
+
DTS dist/hooks/index.d.ts 608.00 B
|
|
173
|
+
DTS dist/hooks/use-flat-category-store.d.ts 424.00 B
|
|
174
|
+
DTS dist/openai-assistants/index.d.ts 262.00 B
|
|
175
|
+
DTS dist/openai/chat-completion-client.d.ts 1.44 KB
|
|
176
|
+
DTS dist/openai/index.d.ts 438.00 B
|
|
177
|
+
DTS dist/types/index.d.ts 233.00 B
|
|
178
|
+
DTS dist/types/message.d.ts 12.00 B
|
|
179
|
+
DTS dist/utils/utils.test.d.ts 12.00 B
|
|
180
|
+
DTS dist/utils/utils.d.ts 12.00 B
|
|
181
|
+
DTS dist/components/copilot-provider/index.d.ts 463.00 B
|
|
182
|
+
DTS dist/components/copilot-provider/standard-copilot-api-config.d.ts 911.00 B
|
|
183
|
+
DTS dist/openai-assistants/hooks/index.d.ts 182.00 B
|
|
184
|
+
DTS dist/openai-assistants/hooks/use-assistants.d.ts 551.00 B
|
|
185
|
+
DTS dist/openai-assistants/utils/index.d.ts 68.00 B
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 0.17.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- strictly propagate copilot api params through the fetch arguments - not through any constructors
|
|
8
|
+
|
|
9
|
+
## 0.17.0-alpha.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- remove vercel ai
|
|
14
|
+
|
|
3
15
|
## 0.16.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import './chunk-MRXNTQOX.mjs';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
-
function copilotApiConfigExtrapolator(config) {
|
|
5
|
-
return {
|
|
6
|
-
get chatApiEndpoint() {
|
|
7
|
-
return `${config.chatApiEndpoint}`;
|
|
8
|
-
},
|
|
9
|
-
get chatApiEndpointV2() {
|
|
10
|
-
return `${config.chatApiEndpointV2}`;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
4
|
var emptyCopilotContext = {
|
|
15
5
|
entryPoints: {},
|
|
16
6
|
setEntryPoint: () => {
|
|
@@ -53,6 +43,6 @@ function returnAndThrowInDebug(value) {
|
|
|
53
43
|
);
|
|
54
44
|
}
|
|
55
45
|
|
|
56
|
-
export { CopilotContext
|
|
46
|
+
export { CopilotContext };
|
|
57
47
|
//# sourceMappingURL=out.js.map
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-6A4PCNMZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context/copilot-context.tsx"],"names":[],"mappings":";;;;;AAGA,OAAO,WAAW;AAmElB,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,oBAA4B;AAC9B,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,iBAAiB,MAAM,cAAoC,mBAAmB;AAE3F,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT","sourcesContent":["\"use client\";\n\nimport { FunctionCallHandler } from \"../types\";\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 * The endpoint for the chat API v2.\n */\n chatApiEndpointV2: 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 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 addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\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 chatApiEndpointV2(): 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 = 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"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ChatCompletionTransport } from './chunk-VK25FIML.mjs';
|
|
2
|
+
import { __async, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
3
|
+
|
|
4
|
+
// src/openai/chat-completion-stream.ts
|
|
5
|
+
var ChatCompletionStream = class {
|
|
6
|
+
constructor(params) {
|
|
7
|
+
this.url = params.url;
|
|
8
|
+
}
|
|
9
|
+
fetch(params) {
|
|
10
|
+
return __async(this, null, function* () {
|
|
11
|
+
params = __spreadValues({}, params);
|
|
12
|
+
params.functions = void 0;
|
|
13
|
+
const transport = new ChatCompletionTransport({});
|
|
14
|
+
const cleanup = () => {
|
|
15
|
+
transport.off("data");
|
|
16
|
+
transport.off("end");
|
|
17
|
+
transport.off("error");
|
|
18
|
+
};
|
|
19
|
+
const stream = new ReadableStream({
|
|
20
|
+
start: (controller) => {
|
|
21
|
+
transport.on("data", (data) => {
|
|
22
|
+
if (data.choices[0].delta.content) {
|
|
23
|
+
controller.enqueue(data.choices[0].delta.content);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
transport.on("error", (error) => {
|
|
27
|
+
controller.error(error);
|
|
28
|
+
cleanup();
|
|
29
|
+
});
|
|
30
|
+
transport.on("end", () => {
|
|
31
|
+
controller.close();
|
|
32
|
+
cleanup();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
transport.fetch(params);
|
|
37
|
+
return stream;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { ChatCompletionStream };
|
|
43
|
+
//# sourceMappingURL=out.js.map
|
|
44
|
+
//# sourceMappingURL=chunk-6SOQYBNX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/openai/chat-completion-stream.ts"],"names":[],"mappings":";;;;;;;;;AAUO,IAAM,uBAAN,MAA2B;AAAA,EAGhC,YAAY,QAA2C;AACrD,SAAK,MAAM,OAAO;AAAA,EACpB;AAAA,EAEa,MAAM,QAA6E;AAAA;AAC9F,eAAS,mBAAK;AACd,aAAO,YAAY;AAEnB,YAAM,YAAY,IAAI,wBAAwB,CAAC,CAAC;AAEhD,YAAM,UAAU,MAAM;AACpB,kBAAU,IAAI,MAAM;AACpB,kBAAU,IAAI,KAAK;AACnB,kBAAU,IAAI,OAAO;AAAA,MACvB;AAEA,YAAM,SAAS,IAAI,eAAuB;AAAA,QACxC,OAAO,CAAC,eAAe;AACrB,oBAAU,GAAG,QAAQ,CAAC,SAAS;AAC7B,gBAAI,KAAK,QAAQ,CAAC,EAAE,MAAM,SAAS;AACjC,yBAAW,QAAQ,KAAK,QAAQ,CAAC,EAAE,MAAM,OAAO;AAAA,YAClD;AAAA,UACF,CAAC;AAED,oBAAU,GAAG,SAAS,CAAC,UAAU;AAC/B,uBAAW,MAAM,KAAK;AACtB,oBAAQ;AAAA,UACV,CAAC;AAED,oBAAU,GAAG,OAAO,MAAM;AACxB,uBAAW,MAAM;AACjB,oBAAQ;AAAA,UACV,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAED,gBAAU,MAAM,MAAM;AAEtB,aAAO;AAAA,IACT;AAAA;AACF","sourcesContent":["import {\n ChatCompletionTransport,\n ChatCompletionTransportFetchParams,\n} from \"./chat-completion-transport\";\n\nexport interface ChatCompletionStreamConfiguration {\n url: string;\n model?: string;\n}\n\nexport class ChatCompletionStream {\n private url: string;\n\n constructor(params: ChatCompletionStreamConfiguration) {\n this.url = params.url;\n }\n\n public async fetch(params: ChatCompletionTransportFetchParams): Promise<ReadableStream<string>> {\n params = { ...params };\n params.functions = undefined;\n\n const transport = new ChatCompletionTransport({});\n\n const cleanup = () => {\n transport.off(\"data\");\n transport.off(\"end\");\n transport.off(\"error\");\n };\n\n const stream = new ReadableStream<string>({\n start: (controller) => {\n transport.on(\"data\", (data) => {\n if (data.choices[0].delta.content) {\n controller.enqueue(data.choices[0].delta.content);\n }\n });\n\n transport.on(\"error\", (error) => {\n controller.error(error);\n cleanup();\n });\n\n transport.on(\"end\", () => {\n controller.close();\n cleanup();\n });\n },\n });\n\n transport.fetch(params);\n\n return stream;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopilotContext } from './chunk-
|
|
1
|
+
import { CopilotContext } from './chunk-6A4PCNMZ.mjs';
|
|
2
2
|
import { useContext, useRef, useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
|
|
@@ -16,4 +16,4 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
|
|
|
16
16
|
|
|
17
17
|
export { useMakeCopilotDocumentReadable };
|
|
18
18
|
//# sourceMappingURL=out.js.map
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-7P4OYNP3.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopilotContext } from './chunk-
|
|
1
|
+
import { CopilotContext } from './chunk-6A4PCNMZ.mjs';
|
|
2
2
|
import { useRef, useContext, useMemo, useEffect } from 'react';
|
|
3
3
|
import { nanoid } from 'nanoid';
|
|
4
4
|
|
|
@@ -24,4 +24,4 @@ function useMakeCopilotActionable(annotatedFunction, dependencies) {
|
|
|
24
24
|
|
|
25
25
|
export { useMakeCopilotActionable };
|
|
26
26
|
//# sourceMappingURL=out.js.map
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-FP4EXCGS.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopilotContext } from './chunk-
|
|
1
|
+
import { CopilotContext } from './chunk-6A4PCNMZ.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-HW5IH6PV.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StandardCopilotApiConfig } from './chunk-F2JIAPZQ.mjs';
|
|
2
2
|
import { use_tree_default } from './chunk-VUY2K2DI.mjs';
|
|
3
|
+
import { CopilotContext } from './chunk-6A4PCNMZ.mjs';
|
|
3
4
|
import { use_flat_category_store_default } from './chunk-YULKJPY3.mjs';
|
|
4
|
-
import { CopilotContext } from './chunk-YGJFU4ZP.mjs';
|
|
5
5
|
import { __objRest, __spreadProps, __spreadValues, __async } from './chunk-MRXNTQOX.mjs';
|
|
6
6
|
import { useState, useCallback } from 'react';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -119,14 +119,14 @@ function entryPointsToFunctionCallHandler(entryPoints) {
|
|
|
119
119
|
}
|
|
120
120
|
const entryPointFunction = entrypointsByFunctionName[functionCall.name || ""];
|
|
121
121
|
if (entryPointFunction) {
|
|
122
|
-
let
|
|
122
|
+
let functionCallArguments = [];
|
|
123
123
|
if (functionCall.arguments) {
|
|
124
|
-
|
|
124
|
+
functionCallArguments = JSON.parse(functionCall.arguments);
|
|
125
125
|
}
|
|
126
126
|
const paramsInCorrectOrder = [];
|
|
127
127
|
for (let arg of entryPointFunction.argumentAnnotations) {
|
|
128
128
|
paramsInCorrectOrder.push(
|
|
129
|
-
|
|
129
|
+
functionCallArguments[arg.name]
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
yield entryPointFunction.implementation(...paramsInCorrectOrder);
|
|
@@ -162,4 +162,4 @@ function annotatedFunctionToChatCompletionFunction(annotatedFunction) {
|
|
|
162
162
|
|
|
163
163
|
export { CopilotProvider, defaultCopilotContextCategories };
|
|
164
164
|
//# sourceMappingURL=out.js.map
|
|
165
|
-
//# sourceMappingURL=chunk-
|
|
165
|
+
//# sourceMappingURL=chunk-QTET3FBV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/copilot-provider/copilot-provider.tsx"],"names":[],"mappings":"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","sourcesContent":["\"use client\";\n\nimport { 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, FunctionCallHandler } from \"../../types\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { StandardCopilotApiConfig } from \"./standard-copilot-api-config\";\nimport { CopilotProviderProps } from \"./copilot-provider-props\";\n\n/**\n * The CopilotProvider component.\n * This component provides the Copilot context to its children.\n * It can be configured either with a chat API endpoint or a CopilotApiConfig.\n *\n * NOTE: The backend can use OpenAI, or you can bring your own LLM.\n * For examples of the backend api implementation, see `examples/next-openai` usage (under `src/api/copilotkit`),\n * or read the documentation at https://docs.copilotkit.ai\n * In particular, Getting-Started > Quickstart-Backend: https://docs.copilotkit.ai/getting-started/quickstart-backend\n *\n * Example usage:\n * ```\n * <CopilotProvider chatApiEndpoint=\"https://your.copilotkit.api\">\n * <App />\n * </CopilotProvider>\n * ```\n *\n * or\n *\n * ```\n * const copilotApiConfig = new StandardCopilotApiConfig(\n * \"https://your.copilotkit.api/v1\",\n * \"https://your.copilotkit.api/v2\",\n * {},\n * {}\n * );\n *\n * // ...\n *\n * <CopilotProvider chatApiConfig={copilotApiConfig}>\n * <App />\n * </CopilotProvider>\n * ```\n *\n * @param props - The props for the component.\n * @returns The CopilotProvider component.\n */\nexport function CopilotProvider({ children, ...props }: CopilotProviderProps): JSX.Element {\n // Compute all the functions and properties that we need to pass\n // to the CopilotContext.\n\n const [entryPoints, setEntryPoints] = useState<Record<string, AnnotatedFunction<any[]>>>({});\n\n const { addElement, removeElement, printTree } = useTree();\n\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n const setEntryPoint = useCallback((id: string, entryPoint: AnnotatedFunction<any[]>) => {\n setEntryPoints((prevPoints) => {\n return {\n ...prevPoints,\n [id]: entryPoint,\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} (${document.sourceApplication}):\\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 (documentPointer: DocumentPointer, categories: string[] = defaultCopilotContextCategories) => {\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 // get the appropriate CopilotApiConfig from the props\n let copilotApiConfig: CopilotApiConfig;\n if (\"chatApiEndpoint\" in props) {\n copilotApiConfig = new StandardCopilotApiConfig(\n props.chatApiEndpoint,\n props.chatApiEndpointV2 || `${props.chatApiEndpoint}/v2`,\n {},\n {},\n );\n } else {\n copilotApiConfig = props.chatApiConfig;\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: copilotApiConfig,\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<string, AnnotatedFunction<any[]>> = {};\n for (let entryPoint of entryPoints) {\n entrypointsByFunctionName[entryPoint.name] = entryPoint;\n }\n\n const entryPointFunction = entrypointsByFunctionName[functionCall.name || \"\"];\n if (entryPointFunction) {\n let functionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n functionCallArguments = JSON.parse(functionCall.arguments);\n }\n\n const paramsInCorrectOrder: any[] = [];\n for (let arg of entryPointFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(\n functionCallArguments[arg.name as keyof typeof functionCallArguments],\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"]}
|