@copilotkit/react-core 0.25.0-multi-release-alpha.0 → 0.25.0-multi-feature-usecopilotreadable.4

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.
Files changed (94) hide show
  1. package/.turbo/turbo-build.log +165 -162
  2. package/CHANGELOG.md +47 -3
  3. package/dist/chunk-5L5PJJNT.mjs +28 -0
  4. package/dist/chunk-5L5PJJNT.mjs.map +1 -0
  5. package/dist/{chunk-GVLCTSXW.mjs → chunk-BCKOSVRB.mjs} +2 -2
  6. package/dist/{chunk-KJQZ2VEU.mjs → chunk-EABGYUTZ.mjs} +1 -1
  7. package/dist/chunk-EABGYUTZ.mjs.map +1 -0
  8. package/dist/chunk-EYKDJBDE.mjs +1 -0
  9. package/dist/{chunk-QGRMN7L3.mjs → chunk-L45P674M.mjs} +4 -4
  10. package/dist/chunk-L45P674M.mjs.map +1 -0
  11. package/dist/{chunk-AEUR5JBT.mjs → chunk-X3FZ6GTK.mjs} +11 -1
  12. package/dist/chunk-X3FZ6GTK.mjs.map +1 -0
  13. package/dist/components/copilot-provider/copilotkit.mjs +9 -435
  14. package/dist/components/copilot-provider/copilotkit.mjs.map +1 -1
  15. package/dist/components/copilot-provider/index.mjs +10 -435
  16. package/dist/components/copilot-provider/index.mjs.map +1 -1
  17. package/dist/components/copilot-provider/standard-copilot-api-config.mjs +4 -9
  18. package/dist/components/copilot-provider/standard-copilot-api-config.mjs.map +1 -1
  19. package/dist/components/index.mjs +11 -435
  20. package/dist/components/index.mjs.map +1 -1
  21. package/dist/context/copilot-context.mjs +5 -64
  22. package/dist/context/copilot-context.mjs.map +1 -1
  23. package/dist/context/index.mjs +6 -64
  24. package/dist/context/index.mjs.map +1 -1
  25. package/dist/hooks/index.d.ts +1 -0
  26. package/dist/hooks/index.js +22 -0
  27. package/dist/hooks/index.js.map +1 -1
  28. package/dist/hooks/index.mjs +29 -528
  29. package/dist/hooks/index.mjs.map +1 -1
  30. package/dist/hooks/use-chat.mjs +4 -295
  31. package/dist/hooks/use-chat.mjs.map +1 -1
  32. package/dist/hooks/use-copilot-action-implementation.mjs +5 -102
  33. package/dist/hooks/use-copilot-action-implementation.mjs.map +1 -1
  34. package/dist/hooks/use-copilot-action.mjs +6 -107
  35. package/dist/hooks/use-copilot-action.mjs.map +1 -1
  36. package/dist/hooks/use-copilot-chat.mjs +13 -430
  37. package/dist/hooks/use-copilot-chat.mjs.map +1 -1
  38. package/dist/hooks/use-copilot-readable.d.ts +33 -0
  39. package/dist/hooks/use-copilot-readable.js +121 -0
  40. package/dist/hooks/use-copilot-readable.js.map +1 -0
  41. package/dist/hooks/use-copilot-readable.mjs +9 -0
  42. package/dist/hooks/use-copilot-readable.mjs.map +1 -0
  43. package/dist/hooks/use-flat-category-store.mjs +4 -65
  44. package/dist/hooks/use-flat-category-store.mjs.map +1 -1
  45. package/dist/hooks/use-make-copilot-actionable.mjs +5 -88
  46. package/dist/hooks/use-make-copilot-actionable.mjs.map +1 -1
  47. package/dist/hooks/use-make-copilot-document-readable.mjs +5 -78
  48. package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -1
  49. package/dist/hooks/use-make-copilot-readable.d.ts +1 -5
  50. package/dist/hooks/use-make-copilot-readable.js.map +1 -1
  51. package/dist/hooks/use-make-copilot-readable.mjs +5 -78
  52. package/dist/hooks/use-make-copilot-readable.mjs.map +1 -1
  53. package/dist/hooks/use-tree.mjs +4 -150
  54. package/dist/hooks/use-tree.mjs.map +1 -1
  55. package/dist/index.d.ts +1 -0
  56. package/dist/index.js +33 -11
  57. package/dist/index.js.map +1 -1
  58. package/dist/index.mjs +54 -1113
  59. package/dist/index.mjs.map +1 -1
  60. package/dist/lib/copilot-task.d.ts +7 -2
  61. package/dist/lib/copilot-task.js +3 -3
  62. package/dist/lib/copilot-task.js.map +1 -1
  63. package/dist/lib/copilot-task.mjs +11 -192
  64. package/dist/lib/copilot-task.mjs.map +1 -1
  65. package/dist/lib/index.js +3 -3
  66. package/dist/lib/index.js.map +1 -1
  67. package/dist/lib/index.mjs +12 -192
  68. package/dist/lib/index.mjs.map +1 -1
  69. package/dist/openai-assistants/hooks/index.mjs +15 -228
  70. package/dist/openai-assistants/hooks/index.mjs.map +1 -1
  71. package/dist/openai-assistants/hooks/use-assistants.mjs +7 -45
  72. package/dist/openai-assistants/hooks/use-assistants.mjs.map +1 -1
  73. package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs +15 -228
  74. package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map +1 -1
  75. package/dist/openai-assistants/index.mjs +18 -228
  76. package/dist/openai-assistants/index.mjs.map +1 -1
  77. package/dist/openai-assistants/utils/index.mjs +5 -43
  78. package/dist/openai-assistants/utils/index.mjs.map +1 -1
  79. package/dist/openai-assistants/utils/process-message-stream.mjs +4 -43
  80. package/dist/openai-assistants/utils/process-message-stream.mjs.map +1 -1
  81. package/dist/types/index.mjs +1 -0
  82. package/dist/utils/fetch-chat-completion.mjs +5 -112
  83. package/dist/utils/fetch-chat-completion.mjs.map +1 -1
  84. package/package.json +4 -4
  85. package/src/hooks/index.ts +1 -0
  86. package/src/hooks/use-copilot-readable.ts +60 -0
  87. package/src/hooks/use-make-copilot-readable.ts +1 -5
  88. package/src/lib/copilot-task.ts +12 -5
  89. package/dist/chunk-AEUR5JBT.mjs.map +0 -1
  90. package/dist/chunk-IOP6JX34.mjs +0 -1
  91. package/dist/chunk-KJQZ2VEU.mjs.map +0 -1
  92. package/dist/chunk-QGRMN7L3.mjs.map +0 -1
  93. /package/dist/{chunk-GVLCTSXW.mjs.map → chunk-BCKOSVRB.mjs.map} +0 -0
  94. /package/dist/{chunk-IOP6JX34.mjs.map → chunk-EYKDJBDE.mjs.map} +0 -0
@@ -1,438 +1,13 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
-
53
- // src/components/copilot-provider/copilotkit.tsx
54
- import { useCallback as useCallback3, useRef, useState } from "react";
55
-
56
- // src/context/copilot-context.tsx
57
- import React from "react";
58
- var emptyCopilotContext = {
59
- entryPoints: {},
60
- setEntryPoint: () => {
61
- },
62
- removeEntryPoint: () => {
63
- },
64
- getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
65
- getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
66
- })),
67
- chatComponentsCache: { current: {} },
68
- getContextString: (documents, categories) => returnAndThrowInDebug(""),
69
- addContext: () => "",
70
- removeContext: () => {
71
- },
72
- getDocumentsContext: (categories) => returnAndThrowInDebug([]),
73
- addDocumentContext: () => returnAndThrowInDebug(""),
74
- removeDocumentContext: () => {
75
- },
76
- copilotApiConfig: new class {
77
- get chatApiEndpoint() {
78
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
79
- }
80
- get chatApiEndpointV2() {
81
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
82
- }
83
- get headers() {
84
- return {};
85
- }
86
- get body() {
87
- return {};
88
- }
89
- }()
90
- };
91
- var CopilotContext = React.createContext(emptyCopilotContext);
92
- function returnAndThrowInDebug(value) {
93
- throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
94
- return value;
95
- }
96
-
97
- // src/hooks/use-tree.ts
98
- import { nanoid } from "nanoid";
99
- import { useCallback, useReducer } from "react";
100
- var removeNode = (nodes, id) => {
101
- return nodes.reduce((result, node) => {
102
- if (node.id !== id) {
103
- const newNode = __spreadProps(__spreadValues({}, node), { children: removeNode(node.children, id) });
104
- result.push(newNode);
105
- }
106
- return result;
107
- }, []);
108
- };
109
- var addNode = (nodes, newNode, parentId) => {
110
- if (!parentId) {
111
- return [...nodes, newNode];
112
- }
113
- return nodes.map((node) => {
114
- if (node.id === parentId) {
115
- return __spreadProps(__spreadValues({}, node), { children: [...node.children, newNode] });
116
- } else if (node.children.length) {
117
- return __spreadProps(__spreadValues({}, node), { children: addNode(node.children, newNode, parentId) });
118
- }
119
- return node;
120
- });
121
- };
122
- var treeIndentationRepresentation = (index, indentLevel) => {
123
- if (indentLevel === 0) {
124
- return (index + 1).toString();
125
- } else if (indentLevel === 1) {
126
- return String.fromCharCode(65 + index);
127
- } else if (indentLevel === 2) {
128
- return String.fromCharCode(97 + index);
129
- } else {
130
- return "-";
131
- }
132
- };
133
- var printNode = (node, prefix = "", indentLevel = 0) => {
134
- const indent = " ".repeat(3).repeat(indentLevel);
135
- const prefixPlusIndentLength = prefix.length + indent.length;
136
- const subsequentLinesPrefix = " ".repeat(prefixPlusIndentLength);
137
- const valueLines = node.value.split("\n");
138
- const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;
139
- const outputSubsequentLines = valueLines.slice(1).map((line) => `${subsequentLinesPrefix}${line}`).join("\n");
140
- let output = `${outputFirstLine}
141
- `;
142
- if (outputSubsequentLines) {
143
- output += `${outputSubsequentLines}
144
- `;
145
- }
146
- const childPrePrefix = " ".repeat(prefix.length);
147
- node.children.forEach(
148
- (child, index) => output += printNode(
149
- child,
150
- `${childPrePrefix}${treeIndentationRepresentation(index, indentLevel + 1)}. `,
151
- indentLevel + 1
152
- )
153
- );
154
- return output;
155
- };
156
- function treeReducer(state, action) {
157
- switch (action.type) {
158
- case "ADD_NODE": {
159
- const { value, parentId, id: newNodeId } = action;
160
- const newNode = {
161
- id: newNodeId,
162
- value,
163
- children: [],
164
- categories: new Set(action.categories)
165
- };
166
- try {
167
- return addNode(state, newNode, parentId);
168
- } catch (error) {
169
- console.error(`Error while adding node with id ${newNodeId}: ${error}`);
170
- return state;
171
- }
172
- }
173
- case "REMOVE_NODE":
174
- return removeNode(state, action.id);
175
- default:
176
- return state;
177
- }
178
- }
179
- var useTree = () => {
180
- const [tree, dispatch] = useReducer(treeReducer, []);
181
- const addElement = useCallback(
182
- (value, categories, parentId) => {
183
- const newNodeId = nanoid();
184
- dispatch({
185
- type: "ADD_NODE",
186
- value,
187
- parentId,
188
- id: newNodeId,
189
- categories
190
- });
191
- return newNodeId;
192
- },
193
- []
194
- );
195
- const removeElement = useCallback((id) => {
196
- dispatch({ type: "REMOVE_NODE", id });
197
- }, []);
198
- const printTree = useCallback(
199
- (categories) => {
200
- const categoriesSet = new Set(categories);
201
- let output = "";
202
- tree.forEach((node, index) => {
203
- if (!setsHaveIntersection(categoriesSet, node.categories)) {
204
- return;
205
- }
206
- if (index !== 0) {
207
- output += "\n";
208
- }
209
- output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);
210
- });
211
- return output;
212
- },
213
- [tree]
214
- );
215
- return { tree, addElement, printTree, removeElement };
216
- };
217
- var use_tree_default = useTree;
218
- function setsHaveIntersection(setA, setB) {
219
- const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
220
- for (let item of smallerSet) {
221
- if (largerSet.has(item)) {
222
- return true;
223
- }
224
- }
225
- return false;
226
- }
227
-
228
- // src/components/copilot-provider/copilotkit.tsx
229
- import { actionToChatCompletionFunction } from "@copilotkit/shared";
230
-
231
- // src/hooks/use-flat-category-store.ts
232
- import { nanoid as nanoid2 } from "nanoid";
233
- import { useCallback as useCallback2, useReducer as useReducer2 } from "react";
234
- var useFlatCategoryStore = () => {
235
- const [elements, dispatch] = useReducer2(flatCategoryStoreReducer, /* @__PURE__ */ new Map());
236
- const addElement = useCallback2((value, categories) => {
237
- const newId = nanoid2();
238
- dispatch({
239
- type: "ADD_ELEMENT",
240
- value,
241
- id: newId,
242
- categories
243
- });
244
- return newId;
245
- }, []);
246
- const removeElement = useCallback2((id) => {
247
- dispatch({ type: "REMOVE_ELEMENT", id });
248
- }, []);
249
- const allElements = useCallback2(
250
- (categories) => {
251
- const categoriesSet = new Set(categories);
252
- const result = [];
253
- elements.forEach((element) => {
254
- if (setsHaveIntersection2(categoriesSet, element.categories)) {
255
- result.push(element.value);
256
- }
257
- });
258
- return result;
259
- },
260
- [elements]
261
- );
262
- return { addElement, removeElement, allElements };
263
- };
264
- var use_flat_category_store_default = useFlatCategoryStore;
265
- function flatCategoryStoreReducer(state, action) {
266
- switch (action.type) {
267
- case "ADD_ELEMENT": {
268
- const { value, id, categories } = action;
269
- const newElement = {
270
- id,
271
- value,
272
- categories: new Set(categories)
273
- };
274
- const newState = new Map(state);
275
- newState.set(id, newElement);
276
- return newState;
277
- }
278
- case "REMOVE_ELEMENT": {
279
- const newState = new Map(state);
280
- newState.delete(action.id);
281
- return newState;
282
- }
283
- default:
284
- return state;
285
- }
286
- }
287
- function setsHaveIntersection2(setA, setB) {
288
- const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
289
- for (let item of smallerSet) {
290
- if (largerSet.has(item)) {
291
- return true;
292
- }
293
- }
294
- return false;
295
- }
296
-
297
- // src/components/copilot-provider/standard-copilot-api-config.tsx
298
- var StandardCopilotApiConfig = class {
299
- constructor(chatApiEndpoint, chatApiEndpointV2, headers, body) {
300
- this.chatApiEndpoint = chatApiEndpoint;
301
- this.chatApiEndpointV2 = chatApiEndpointV2;
302
- this.headers = headers;
303
- this.body = body;
304
- }
305
- };
306
-
307
- // src/components/copilot-provider/copilotkit.tsx
308
- import { jsx } from "react/jsx-runtime";
309
- function CopilotKit(_a) {
310
- var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
311
- const [entryPoints, setEntryPoints] = useState({});
312
- const chatComponentsCache = useRef({});
313
- const { addElement, removeElement, printTree } = use_tree_default();
314
- const {
315
- addElement: addDocument,
316
- removeElement: removeDocument,
317
- allElements: allDocuments
318
- } = use_flat_category_store_default();
319
- const setEntryPoint = useCallback3((id, entryPoint) => {
320
- setEntryPoints((prevPoints) => {
321
- return __spreadProps(__spreadValues({}, prevPoints), {
322
- [id]: entryPoint
323
- });
324
- });
325
- }, []);
326
- const removeEntryPoint = useCallback3((id) => {
327
- setEntryPoints((prevPoints) => {
328
- const newPoints = __spreadValues({}, prevPoints);
329
- delete newPoints[id];
330
- return newPoints;
331
- });
332
- }, []);
333
- const getContextString = useCallback3(
334
- (documents, categories) => {
335
- const documentsString = documents.map((document) => {
336
- return `${document.name} (${document.sourceApplication}):
337
- ${document.getContents()}`;
338
- }).join("\n\n");
339
- const nonDocumentStrings = printTree(categories);
340
- return `${documentsString}
341
-
342
- ${nonDocumentStrings}`;
343
- },
344
- [printTree]
345
- );
346
- const addContext = useCallback3(
347
- (context, parentId, categories = defaultCopilotContextCategories) => {
348
- return addElement(context, categories, parentId);
349
- },
350
- [addElement]
351
- );
352
- const removeContext = useCallback3(
353
- (id) => {
354
- removeElement(id);
355
- },
356
- [removeElement]
357
- );
358
- const getChatCompletionFunctionDescriptions = useCallback3(
359
- (customEntryPoints) => {
360
- return entryPointsToChatCompletionFunctions(Object.values(customEntryPoints || entryPoints));
361
- },
362
- [entryPoints]
363
- );
364
- const getFunctionCallHandler = useCallback3(
365
- (customEntryPoints) => {
366
- return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || entryPoints));
367
- },
368
- [entryPoints]
369
- );
370
- const getDocumentsContext = useCallback3(
371
- (categories) => {
372
- return allDocuments(categories);
373
- },
374
- [allDocuments]
375
- );
376
- const addDocumentContext = useCallback3(
377
- (documentPointer, categories = defaultCopilotContextCategories) => {
378
- return addDocument(documentPointer, categories);
379
- },
380
- [addDocument]
381
- );
382
- const removeDocumentContext = useCallback3(
383
- (documentId) => {
384
- removeDocument(documentId);
385
- },
386
- [removeDocument]
387
- );
388
- const copilotApiConfig = new StandardCopilotApiConfig(
389
- props.url,
390
- `${props.url}/v2`,
391
- props.headers || {},
392
- __spreadValues(__spreadValues({}, props.body), props.backendOnlyProps)
393
- );
394
- return /* @__PURE__ */ jsx(
395
- CopilotContext.Provider,
396
- {
397
- value: {
398
- entryPoints,
399
- chatComponentsCache,
400
- getChatCompletionFunctionDescriptions,
401
- getFunctionCallHandler,
402
- setEntryPoint,
403
- removeEntryPoint,
404
- getContextString,
405
- addContext,
406
- removeContext,
407
- getDocumentsContext,
408
- addDocumentContext,
409
- removeDocumentContext,
410
- copilotApiConfig
411
- },
412
- children
413
- }
414
- );
415
- }
416
- var defaultCopilotContextCategories = ["global"];
417
- function entryPointsToChatCompletionFunctions(actions) {
418
- return actions.map(actionToChatCompletionFunction);
419
- }
420
- function entryPointsToFunctionCallHandler(actions) {
421
- return (chatMessages, functionCall) => __async(this, null, function* () {
422
- let actionsByFunctionName = {};
423
- for (let action2 of actions) {
424
- actionsByFunctionName[action2.name] = action2;
425
- }
426
- const action = actionsByFunctionName[functionCall.name || ""];
427
- if (action) {
428
- let functionCallArguments = [];
429
- if (functionCall.arguments) {
430
- functionCallArguments = JSON.parse(functionCall.arguments);
431
- }
432
- return yield action.handler(functionCallArguments);
433
- }
434
- });
435
- }
1
+ import "../../chunk-SPCZTZCY.mjs";
2
+ import {
3
+ CopilotKit,
4
+ defaultCopilotContextCategories
5
+ } from "../../chunk-H3FQWB4B.mjs";
6
+ import "../../chunk-F2JIAPZQ.mjs";
7
+ import "../../chunk-YULKJPY3.mjs";
8
+ import "../../chunk-VUY2K2DI.mjs";
9
+ import "../../chunk-KIKHLN4X.mjs";
10
+ import "../../chunk-MRXNTQOX.mjs";
436
11
  export {
437
12
  CopilotKit,
438
13
  defaultCopilotContextCategories
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/copilot-provider/copilotkit.tsx","../../../src/context/copilot-context.tsx","../../../src/hooks/use-tree.ts","../../../src/hooks/use-flat-category-store.ts","../../../src/components/copilot-provider/standard-copilot-api-config.tsx"],"sourcesContent":["import { Ref, useCallback, useRef, useState } from \"react\";\nimport {\n CopilotContext,\n CopilotApiConfig,\n InChatRenderFunction,\n} from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { DocumentPointer } from \"../../types\";\nimport { FunctionCallHandler, actionToChatCompletionFunction } from \"@copilotkit/shared\";\nimport { FrontendAction } from \"../../types/frontend-action\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { StandardCopilotApiConfig } from \"./standard-copilot-api-config\";\nimport { CopilotKitProps } from \"./copilotkit-props\";\nimport { ToolDefinition } from \"@copilotkit/shared\";\n\n/**\n * The CopilotKit 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 * <CopilotKit url=\"https://your.copilotkit.api\">\n * <App />\n * </CopilotKit>\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 * <CopilotKit chatApiConfig={copilotApiConfig}>\n * <App />\n * </CopilotKit>\n * ```\n *\n * @param props - The props for the component.\n * @returns The CopilotKit component.\n */\nexport function CopilotKit({ children, ...props }: CopilotKitProps) {\n // Compute all the functions and properties that we need to pass\n // to the CopilotContext.\n\n const [entryPoints, setEntryPoints] = useState<Record<string, FrontendAction<any>>>({});\n const chatComponentsCache = useRef<Record<string, InChatRenderFunction | string>>({});\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: FrontendAction<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 (customEntryPoints?: Record<string, FrontendAction<any>>) => {\n return entryPointsToChatCompletionFunctions(Object.values(customEntryPoints || entryPoints));\n },\n [entryPoints],\n );\n\n const getFunctionCallHandler = useCallback(\n (customEntryPoints?: Record<string, FrontendAction<any>>) => {\n return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || entryPoints));\n },\n [entryPoints],\n );\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 const copilotApiConfig: CopilotApiConfig = new StandardCopilotApiConfig(\n props.url,\n `${props.url}/v2`,\n props.headers || {},\n {\n ...props.body,\n ...props.backendOnlyProps,\n },\n );\n\n return (\n <CopilotContext.Provider\n value={{\n entryPoints,\n chatComponentsCache,\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 entryPointsToChatCompletionFunctions(actions: FrontendAction<any>[]): ToolDefinition[] {\n return actions.map(actionToChatCompletionFunction);\n}\n\nfunction entryPointsToFunctionCallHandler(actions: FrontendAction<any>[]): FunctionCallHandler {\n return async (chatMessages, functionCall) => {\n let actionsByFunctionName: Record<string, FrontendAction<any>> = {};\n for (let action of actions) {\n actionsByFunctionName[action.name] = action;\n }\n\n const action = actionsByFunctionName[functionCall.name || \"\"];\n if (action) {\n let functionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n functionCallArguments = JSON.parse(functionCall.arguments);\n }\n return await action.handler(functionCallArguments);\n }\n };\n}\n","import { FunctionCallHandler, ToolDefinition } from \"@copilotkit/shared\";\nimport { ActionRenderProps, FrontendAction } from \"../types/frontend-action\";\nimport React, { Ref } from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\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 /**\n * Backend only props that will be combined to body params to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n backendOnlyProps?: Record<string, any>;\n}\n\nexport type InChatRenderFunction = (props: ActionRenderProps<any>) => string | JSX.Element;\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, FrontendAction<any>>;\n setEntryPoint: (id: string, entryPoint: FrontendAction<any>) => void;\n removeEntryPoint: (id: string) => void;\n chatComponentsCache: React.RefObject<Record<string, InChatRenderFunction | string>>;\n getChatCompletionFunctionDescriptions: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => ToolDefinition[];\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => 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 chatComponentsCache: { current: {} },\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(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n get chatApiEndpointV2(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\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\nexport function useCopilotContext(): CopilotContextParams {\n return React.useContext(CopilotContext);\n}\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n return value;\n}\n","import { nanoid } from \"nanoid\";\nimport { useCallback, useReducer } from \"react\";\n\nexport type TreeNodeId = string;\n\nexport interface TreeNode {\n id: TreeNodeId;\n value: string;\n children: TreeNode[];\n parentId?: TreeNodeId;\n categories: Set<string>;\n}\n\nexport type Tree = TreeNode[];\n\nexport interface UseTreeReturn {\n tree: Tree;\n addElement: (value: string, categories: string[], parentId?: TreeNodeId) => TreeNodeId;\n printTree: (categories: string[]) => string;\n removeElement: (id: TreeNodeId) => void;\n}\n\nconst findNode = (nodes: Tree, id: TreeNodeId): TreeNode | undefined => {\n for (const node of nodes) {\n if (node.id === id) {\n return node;\n }\n const result = findNode(node.children, id);\n if (result) {\n return result;\n }\n }\n return undefined;\n};\n\nconst removeNode = (nodes: Tree, id: TreeNodeId): Tree => {\n return nodes.reduce((result: Tree, node) => {\n if (node.id !== id) {\n const newNode = { ...node, children: removeNode(node.children, id) };\n result.push(newNode);\n }\n return result;\n }, []);\n};\n\nconst addNode = (nodes: Tree, newNode: TreeNode, parentId?: TreeNodeId): Tree => {\n if (!parentId) {\n return [...nodes, newNode];\n }\n return nodes.map((node) => {\n if (node.id === parentId) {\n return { ...node, children: [...node.children, newNode] };\n } else if (node.children.length) {\n return { ...node, children: addNode(node.children, newNode, parentId) };\n }\n return node;\n });\n};\n\nconst treeIndentationRepresentation = (index: number, indentLevel: number): string => {\n if (indentLevel === 0) {\n return (index + 1).toString();\n } else if (indentLevel === 1) {\n return String.fromCharCode(65 + index); // 65 is the ASCII value for 'A'\n } else if (indentLevel === 2) {\n return String.fromCharCode(97 + index); // 97 is the ASCII value for 'a'\n } else {\n return \"-\";\n }\n};\n\nconst printNode = (node: TreeNode, prefix = \"\", indentLevel = 0): string => {\n const indent = \" \".repeat(3).repeat(indentLevel);\n\n const prefixPlusIndentLength = prefix.length + indent.length;\n const subsequentLinesPrefix = \" \".repeat(prefixPlusIndentLength);\n\n const valueLines = node.value.split(\"\\n\");\n\n const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;\n const outputSubsequentLines = valueLines\n .slice(1)\n .map((line) => `${subsequentLinesPrefix}${line}`)\n .join(\"\\n\");\n\n let output = `${outputFirstLine}\\n`;\n if (outputSubsequentLines) {\n output += `${outputSubsequentLines}\\n`;\n }\n\n const childPrePrefix = \" \".repeat(prefix.length);\n\n node.children.forEach(\n (child, index) =>\n (output += printNode(\n child,\n `${childPrePrefix}${treeIndentationRepresentation(index, indentLevel + 1)}. `,\n indentLevel + 1,\n )),\n );\n return output;\n};\n\n// Action types\ntype Action =\n | {\n type: \"ADD_NODE\";\n value: string;\n parentId?: string;\n id: string;\n categories: string[];\n }\n | { type: \"REMOVE_NODE\"; id: string };\n\n// Reducer function\nfunction treeReducer(state: Tree, action: Action): Tree {\n switch (action.type) {\n case \"ADD_NODE\": {\n const { value, parentId, id: newNodeId } = action;\n const newNode: TreeNode = {\n id: newNodeId,\n value,\n children: [],\n categories: new Set(action.categories),\n };\n\n try {\n return addNode(state, newNode, parentId);\n } catch (error) {\n console.error(`Error while adding node with id ${newNodeId}: ${error}`);\n return state;\n }\n }\n case \"REMOVE_NODE\":\n return removeNode(state, action.id);\n default:\n return state;\n }\n}\n\n// useTree hook\nconst useTree = (): UseTreeReturn => {\n const [tree, dispatch] = useReducer(treeReducer, []);\n\n const addElement = useCallback(\n (value: string, categories: string[], parentId?: string): TreeNodeId => {\n const newNodeId = nanoid(); // Generate new ID outside of dispatch\n dispatch({\n type: \"ADD_NODE\",\n value,\n parentId,\n id: newNodeId,\n categories: categories,\n });\n return newNodeId; // Return the new ID\n },\n [],\n );\n\n const removeElement = useCallback((id: TreeNodeId): void => {\n dispatch({ type: \"REMOVE_NODE\", id });\n }, []);\n\n const printTree = useCallback(\n (categories: string[]): string => {\n const categoriesSet = new Set(categories);\n\n let output = \"\";\n tree.forEach((node, index) => {\n // if the node does not have any of the desired categories, continue to the next node\n if (!setsHaveIntersection(categoriesSet, node.categories)) {\n return;\n }\n\n // add a new line before each node except the first one\n if (index !== 0) {\n output += \"\\n\";\n }\n\n output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);\n });\n return output;\n },\n [tree],\n );\n\n return { tree, addElement, printTree, removeElement };\n};\n\nexport default useTree;\n\nfunction setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {\n const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];\n\n for (let item of smallerSet) {\n if (largerSet.has(item)) {\n return true;\n }\n }\n\n return false;\n}\n","import { nanoid } from \"nanoid\";\nimport { useCallback, useReducer } from \"react\";\n\nexport type FlatCategoryStoreId = string;\n\nexport interface UseFlatCategoryStoreReturn<T> {\n addElement: (value: T, categories: string[]) => FlatCategoryStoreId;\n removeElement: (id: FlatCategoryStoreId) => void;\n allElements: (categories: string[]) => T[];\n}\n\ninterface FlatCategoryStoreElement<T> {\n id: FlatCategoryStoreId;\n value: T;\n categories: Set<string>;\n}\n\nconst useFlatCategoryStore = <T>(): UseFlatCategoryStoreReturn<T> => {\n const [elements, dispatch] = useReducer<\n React.Reducer<Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>, Action<T>>\n >(flatCategoryStoreReducer, new Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>());\n\n const addElement = useCallback((value: T, categories: string[]): FlatCategoryStoreId => {\n const newId = nanoid();\n dispatch({\n type: \"ADD_ELEMENT\",\n value,\n id: newId,\n categories,\n });\n return newId;\n }, []);\n\n const removeElement = useCallback((id: FlatCategoryStoreId): void => {\n dispatch({ type: \"REMOVE_ELEMENT\", id });\n }, []);\n\n const allElements = useCallback(\n (categories: string[]): T[] => {\n const categoriesSet = new Set(categories);\n const result: T[] = [];\n elements.forEach((element) => {\n if (setsHaveIntersection(categoriesSet, element.categories)) {\n result.push(element.value);\n }\n });\n return result;\n },\n [elements],\n );\n\n return { addElement, removeElement, allElements };\n};\n\nexport default useFlatCategoryStore;\n\n// Action types\ntype Action<T> =\n | {\n type: \"ADD_ELEMENT\";\n value: T;\n id: FlatCategoryStoreId;\n categories: string[];\n }\n | { type: \"REMOVE_ELEMENT\"; id: FlatCategoryStoreId };\n\n// Reducer\nfunction flatCategoryStoreReducer<T>(\n state: Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>>,\n action: Action<T>,\n): Map<FlatCategoryStoreId, FlatCategoryStoreElement<T>> {\n switch (action.type) {\n case \"ADD_ELEMENT\": {\n const { value, id, categories } = action;\n const newElement: FlatCategoryStoreElement<T> = {\n id,\n value,\n categories: new Set(categories),\n };\n const newState = new Map(state);\n newState.set(id, newElement);\n return newState;\n }\n case \"REMOVE_ELEMENT\": {\n const newState = new Map(state);\n newState.delete(action.id);\n return newState;\n }\n default:\n return state;\n }\n}\n\nfunction setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {\n const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];\n\n for (let item of smallerSet) {\n if (largerSet.has(item)) {\n return true;\n }\n }\n\n return false;\n}\n","import { CopilotApiConfig } from \"../../context/copilot-context\";\n\n/**\n * A standard implementation of the CopilotApiConfig interface.\n *\n * Pass in the base URL of the chat API, the headers to be sent with each request, and the body to be sent with each request.\n * The rest of the CopilotApiConfig interface is implemented by default.\n *\n */\n\nexport class StandardCopilotApiConfig implements CopilotApiConfig {\n chatApiEndpoint: string;\n chatApiEndpointV2: string;\n headers: Record<string, string>;\n body: Record<string, any>;\n\n constructor(\n chatApiEndpoint: string,\n chatApiEndpointV2: string,\n headers: Record<string, string>,\n body: Record<string, any>,\n ) {\n this.chatApiEndpoint = chatApiEndpoint;\n this.chatApiEndpointV2 = chatApiEndpointV2;\n this.headers = headers;\n this.body = body;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAc,eAAAA,cAAa,QAAQ,gBAAgB;;;ACEnD,OAAO,WAAoB;AAoF3B,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,EAClE,qBAAqB,EAAE,SAAS,CAAC,EAAE;AAAA,EACnC,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC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B,CAAC,iBAAkC,aAAuB,oCAAoC;AAC5F,aAAO,YAAY,iBAAiB,UAAU;AAAA,IAChD;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,QAAM,wBAAwBA;AAAA,IAC5B,CAAC,eAAuB;AACtB,qBAAe,UAAU;AAAA,IAC3B;AAAA,IACA,CAAC,cAAc;AAAA,EACjB;AAGA,QAAM,mBAAqC,IAAI;AAAA,IAC7C,MAAM;AAAA,IACN,GAAG,MAAM;AAAA,IACT,MAAM,WAAW,CAAC;AAAA,IAClB,kCACK,MAAM,OACN,MAAM;AAAA,EAEb;AAEA,SACE;AAAA,IAAC,eAAe;AAAA,IAAf;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,IAAM,kCAAkC,CAAC,QAAQ;AAExD,SAAS,qCAAqC,SAAkD;AAC9F,SAAO,QAAQ,IAAI,8BAA8B;AACnD;AAEA,SAAS,iCAAiC,SAAqD;AAC7F,SAAO,CAAO,cAAc,iBAAiB;AAC3C,QAAI,wBAA6D,CAAC;AAClE,aAASC,WAAU,SAAS;AAC1B,4BAAsBA,QAAO,IAAI,IAAIA;AAAA,IACvC;AAEA,UAAM,SAAS,sBAAsB,aAAa,QAAQ,EAAE;AAC5D,QAAI,QAAQ;AACV,UAAI,wBAA+C,CAAC;AACpD,UAAI,aAAa,WAAW;AAC1B,gCAAwB,KAAK,MAAM,aAAa,SAAS;AAAA,MAC3D;AACA,aAAO,MAAM,OAAO,QAAQ,qBAAqB;AAAA,IACnD;AAAA,EACF;AACF;","names":["useCallback","nanoid","useCallback","useReducer","setsHaveIntersection","useCallback","action"]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,12 +1,7 @@
1
- // src/components/copilot-provider/standard-copilot-api-config.tsx
2
- var StandardCopilotApiConfig = class {
3
- constructor(chatApiEndpoint, chatApiEndpointV2, headers, body) {
4
- this.chatApiEndpoint = chatApiEndpoint;
5
- this.chatApiEndpointV2 = chatApiEndpointV2;
6
- this.headers = headers;
7
- this.body = body;
8
- }
9
- };
1
+ import {
2
+ StandardCopilotApiConfig
3
+ } from "../../chunk-F2JIAPZQ.mjs";
4
+ import "../../chunk-MRXNTQOX.mjs";
10
5
  export {
11
6
  StandardCopilotApiConfig
12
7
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/copilot-provider/standard-copilot-api-config.tsx"],"sourcesContent":["import { CopilotApiConfig } from \"../../context/copilot-context\";\n\n/**\n * A standard implementation of the CopilotApiConfig interface.\n *\n * Pass in the base URL of the chat API, the headers to be sent with each request, and the body to be sent with each request.\n * The rest of the CopilotApiConfig interface is implemented by default.\n *\n */\n\nexport class StandardCopilotApiConfig implements CopilotApiConfig {\n chatApiEndpoint: string;\n chatApiEndpointV2: string;\n headers: Record<string, string>;\n body: Record<string, any>;\n\n constructor(\n chatApiEndpoint: string,\n chatApiEndpointV2: string,\n headers: Record<string, string>,\n body: Record<string, any>,\n ) {\n this.chatApiEndpoint = chatApiEndpoint;\n this.chatApiEndpointV2 = chatApiEndpointV2;\n this.headers = headers;\n this.body = body;\n }\n}\n"],"mappings":";AAUO,IAAM,2BAAN,MAA2D;AAAA,EAMhE,YACE,iBACA,mBACA,SACA,MACA;AACA,SAAK,kBAAkB;AACvB,SAAK,oBAAoB;AACzB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}