@copilotkit/react-core 0.18.0-alpha.8 → 0.18.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 +198 -245
- package/CHANGELOG.md +43 -0
- package/dist/chunk-4CFJ6A6A.mjs +15 -9
- package/dist/chunk-4CFJ6A6A.mjs.map +1 -1
- package/dist/chunk-5GS7FQPW.mjs +20 -7
- package/dist/chunk-5GS7FQPW.mjs.map +1 -1
- package/dist/chunk-5UGLWBZJ.mjs +0 -2
- package/dist/chunk-5UGLWBZJ.mjs.map +1 -1
- package/dist/chunk-7GFKOIO7.mjs +0 -2
- package/dist/chunk-7GFKOIO7.mjs.map +1 -1
- package/dist/chunk-BABVSMJR.mjs +0 -2
- package/dist/chunk-BABVSMJR.mjs.map +1 -1
- package/dist/chunk-DGUVNY3V.mjs +9 -5
- package/dist/chunk-DGUVNY3V.mjs.map +1 -1
- package/dist/chunk-EFZPSZWO.mjs +0 -2
- package/dist/chunk-EFZPSZWO.mjs.map +1 -1
- package/dist/chunk-F2JIAPZQ.mjs +3 -2
- package/dist/chunk-F2JIAPZQ.mjs.map +1 -1
- package/dist/chunk-FRAKUJWH.mjs +0 -2
- package/dist/chunk-FRAKUJWH.mjs.map +1 -1
- package/dist/chunk-GBZZPQ5X.mjs +28 -10
- package/dist/chunk-GBZZPQ5X.mjs.map +1 -1
- package/dist/chunk-IQEWY7P4.mjs +13 -6
- package/dist/chunk-IQEWY7P4.mjs.map +1 -1
- package/dist/chunk-IQH5AQQC.mjs +8 -4
- package/dist/chunk-IQH5AQQC.mjs.map +1 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -2
- package/dist/chunk-JD7BAH7U.mjs.map +1 -1
- package/dist/chunk-MRXNTQOX.mjs +6 -2
- package/dist/chunk-MRXNTQOX.mjs.map +1 -1
- package/dist/chunk-MZ5UN3BY.mjs +6 -3
- package/dist/chunk-MZ5UN3BY.mjs.map +1 -1
- package/dist/chunk-SPCZTZCY.mjs +0 -2
- package/dist/chunk-SPCZTZCY.mjs.map +1 -1
- package/dist/chunk-UAKLDQMP.mjs +16 -4
- package/dist/chunk-UAKLDQMP.mjs.map +1 -1
- package/dist/chunk-VNRDQJXW.mjs +0 -2
- package/dist/chunk-VNRDQJXW.mjs.map +1 -1
- package/dist/chunk-VP2EU4US.mjs +21 -9
- package/dist/chunk-VP2EU4US.mjs.map +1 -1
- package/dist/chunk-VUY2K2DI.mjs +10 -5
- package/dist/chunk-VUY2K2DI.mjs.map +1 -1
- package/dist/chunk-YOXWT7I6.mjs +8 -4
- package/dist/chunk-YOXWT7I6.mjs.map +1 -1
- package/dist/chunk-YULKJPY3.mjs +5 -5
- package/dist/chunk-YULKJPY3.mjs.map +1 -1
- package/dist/components/copilot-provider/copilotkit-props.js +18 -2
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit-props.mjs +1 -2
- package/dist/components/copilot-provider/copilotkit-props.mjs.map +1 -1
- package/dist/components/copilot-provider/copilotkit.js +89 -44
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +14 -7
- package/dist/components/copilot-provider/copilotkit.mjs.map +1 -1
- package/dist/components/copilot-provider/index.js +90 -44
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +14 -8
- package/dist/components/copilot-provider/index.mjs.map +1 -1
- package/dist/components/copilot-provider/standard-copilot-api-config.js +27 -4
- package/dist/components/copilot-provider/standard-copilot-api-config.js.map +1 -1
- package/dist/components/copilot-provider/standard-copilot-api-config.mjs +7 -3
- package/dist/components/copilot-provider/standard-copilot-api-config.mjs.map +1 -1
- package/dist/components/index.js +90 -44
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +15 -9
- package/dist/components/index.mjs.map +1 -1
- package/dist/context/copilot-context.js +68 -16
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +8 -3
- package/dist/context/copilot-context.mjs.map +1 -1
- package/dist/context/index.js +68 -15
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +8 -4
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/index.js +98 -42
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +29 -16
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/use-chat.js +38 -15
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +8 -4
- package/dist/hooks/use-chat.mjs.map +1 -1
- package/dist/hooks/use-copilot-chat.js +72 -30
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +18 -12
- package/dist/hooks/use-copilot-chat.mjs.map +1 -1
- package/dist/hooks/use-flat-category-store.js +30 -12
- package/dist/hooks/use-flat-category-store.js.map +1 -1
- package/dist/hooks/use-flat-category-store.mjs +7 -3
- package/dist/hooks/use-flat-category-store.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-actionable.js +77 -20
- package/dist/hooks/use-make-copilot-actionable.js.map +1 -1
- package/dist/hooks/use-make-copilot-actionable.mjs +9 -4
- package/dist/hooks/use-make-copilot-actionable.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.js +73 -18
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +9 -4
- package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -1
- package/dist/hooks/use-make-copilot-readable.js +73 -18
- package/dist/hooks/use-make-copilot-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-readable.mjs +9 -4
- package/dist/hooks/use-make-copilot-readable.mjs.map +1 -1
- package/dist/hooks/use-tree.js +30 -13
- package/dist/hooks/use-tree.js.map +1 -1
- package/dist/hooks/use-tree.mjs +7 -3
- package/dist/hooks/use-tree.mjs.map +1 -1
- package/dist/index.js +165 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -23
- package/dist/index.mjs.map +1 -1
- package/dist/openai-assistants/hooks/index.js +67 -27
- package/dist/openai-assistants/hooks/index.js.map +1 -1
- package/dist/openai-assistants/hooks/index.mjs +18 -14
- package/dist/openai-assistants/hooks/index.mjs.map +1 -1
- package/dist/openai-assistants/hooks/use-assistants.js +40 -14
- package/dist/openai-assistants/hooks/use-assistants.js.map +1 -1
- package/dist/openai-assistants/hooks/use-assistants.mjs +14 -8
- package/dist/openai-assistants/hooks/use-assistants.mjs.map +1 -1
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.js +67 -28
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.js.map +1 -1
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs +19 -13
- package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map +1 -1
- package/dist/openai-assistants/index.js +69 -28
- package/dist/openai-assistants/index.js.map +1 -1
- package/dist/openai-assistants/index.mjs +22 -15
- package/dist/openai-assistants/index.mjs.map +1 -1
- package/dist/openai-assistants/utils/index.js +29 -5
- package/dist/openai-assistants/utils/index.js.map +1 -1
- package/dist/openai-assistants/utils/index.mjs +8 -4
- package/dist/openai-assistants/utils/index.mjs.map +1 -1
- package/dist/openai-assistants/utils/process-message-stream.js +27 -5
- package/dist/openai-assistants/utils/process-message-stream.js.map +1 -1
- package/dist/openai-assistants/utils/process-message-stream.mjs +7 -3
- package/dist/openai-assistants/utils/process-message-stream.mjs.map +1 -1
- package/dist/types/document-pointer.js +17 -2
- package/dist/types/document-pointer.js.map +1 -1
- package/dist/types/document-pointer.mjs +0 -2
- package/dist/types/document-pointer.mjs.map +1 -1
- package/dist/types/index.js +17 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/system-message.js +17 -2
- package/dist/types/system-message.js.map +1 -1
- package/dist/types/system-message.mjs +0 -2
- package/dist/types/system-message.mjs.map +1 -1
- package/dist/utils/fetch-chat-completion.js +35 -12
- package/dist/utils/fetch-chat-completion.js.map +1 -1
- package/dist/utils/fetch-chat-completion.mjs +11 -3
- package/dist/utils/fetch-chat-completion.mjs.map +1 -1
- package/dist/utils/utils.js +17 -2
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/utils.mjs +0 -2
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/utils.test.js +1 -2
- package/dist/utils/utils.test.js.map +1 -1
- package/dist/utils/utils.test.mjs +0 -1
- package/dist/utils/utils.test.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,26 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __async = (__this, __arguments, generator) => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
var fulfilled = (value) => {
|
|
33
|
+
try {
|
|
34
|
+
step(generator.next(value));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
reject(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var rejected = (value) => {
|
|
40
|
+
try {
|
|
41
|
+
step(generator.throw(value));
|
|
42
|
+
} catch (e) {
|
|
43
|
+
reject(e);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
47
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
48
|
+
});
|
|
49
|
+
};
|
|
7
50
|
|
|
8
|
-
|
|
51
|
+
// src/hooks/use-make-copilot-actionable.ts
|
|
52
|
+
var use_make_copilot_actionable_exports = {};
|
|
53
|
+
__export(use_make_copilot_actionable_exports, {
|
|
54
|
+
useMakeCopilotActionable: () => useMakeCopilotActionable
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(use_make_copilot_actionable_exports);
|
|
57
|
+
var import_react2 = require("react");
|
|
9
58
|
|
|
59
|
+
// src/context/copilot-context.tsx
|
|
60
|
+
var import_react = __toESM(require("react"));
|
|
10
61
|
var emptyCopilotContext = {
|
|
11
62
|
entryPoints: {},
|
|
12
63
|
setEntryPoint: () => {
|
|
13
64
|
},
|
|
14
65
|
removeEntryPoint: () => {
|
|
15
66
|
},
|
|
16
|
-
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug(),
|
|
17
|
-
getFunctionCallHandler: () => returnAndThrowInDebug(),
|
|
18
|
-
|
|
67
|
+
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
|
|
68
|
+
getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
|
|
69
|
+
})),
|
|
70
|
+
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
19
71
|
addContext: () => "",
|
|
20
72
|
removeContext: () => {
|
|
21
73
|
},
|
|
22
|
-
getDocumentsContext: (categories) => returnAndThrowInDebug(),
|
|
23
|
-
addDocumentContext: () => returnAndThrowInDebug(),
|
|
74
|
+
getDocumentsContext: (categories) => returnAndThrowInDebug([]),
|
|
75
|
+
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
24
76
|
removeDocumentContext: () => {
|
|
25
77
|
},
|
|
26
78
|
copilotApiConfig: new class {
|
|
@@ -38,14 +90,18 @@ var emptyCopilotContext = {
|
|
|
38
90
|
}
|
|
39
91
|
}()
|
|
40
92
|
};
|
|
41
|
-
var CopilotContext =
|
|
93
|
+
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
42
94
|
function returnAndThrowInDebug(value) {
|
|
43
95
|
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
96
|
+
return value;
|
|
44
97
|
}
|
|
98
|
+
|
|
99
|
+
// src/hooks/use-make-copilot-actionable.ts
|
|
100
|
+
var import_nanoid = require("nanoid");
|
|
45
101
|
function useMakeCopilotActionable(annotatedFunction, dependencies) {
|
|
46
|
-
const idRef =
|
|
47
|
-
const { setEntryPoint, removeEntryPoint } =
|
|
48
|
-
const memoizedAnnotatedFunction =
|
|
102
|
+
const idRef = (0, import_react2.useRef)((0, import_nanoid.nanoid)());
|
|
103
|
+
const { setEntryPoint, removeEntryPoint } = (0, import_react2.useContext)(CopilotContext);
|
|
104
|
+
const memoizedAnnotatedFunction = (0, import_react2.useMemo)(
|
|
49
105
|
() => ({
|
|
50
106
|
name: annotatedFunction.name,
|
|
51
107
|
description: annotatedFunction.description,
|
|
@@ -54,14 +110,15 @@ function useMakeCopilotActionable(annotatedFunction, dependencies) {
|
|
|
54
110
|
}),
|
|
55
111
|
dependencies
|
|
56
112
|
);
|
|
57
|
-
|
|
113
|
+
(0, import_react2.useEffect)(() => {
|
|
58
114
|
setEntryPoint(idRef.current, memoizedAnnotatedFunction);
|
|
59
115
|
return () => {
|
|
60
116
|
removeEntryPoint(idRef.current);
|
|
61
117
|
};
|
|
62
118
|
}, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);
|
|
63
119
|
}
|
|
64
|
-
|
|
65
|
-
exports
|
|
66
|
-
|
|
120
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
+
0 && (module.exports = {
|
|
122
|
+
useMakeCopilotActionable
|
|
123
|
+
});
|
|
67
124
|
//# sourceMappingURL=use-make-copilot-actionable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-make-copilot-actionable.ts","../../src/context/copilot-context.tsx"],"
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-make-copilot-actionable.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef, useContext, useEffect, useMemo } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { AnnotatedFunction } from \"@copilotkit/shared\";\nimport { nanoid } from \"nanoid\";\n\nexport function useMakeCopilotActionable<ActionInput extends any[]>(\n annotatedFunction: AnnotatedFunction<ActionInput>,\n dependencies: any[],\n) {\n const idRef = useRef(nanoid()); // generate a unique id\n const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);\n\n const memoizedAnnotatedFunction: AnnotatedFunction<ActionInput> = useMemo(\n () => ({\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n argumentAnnotations: annotatedFunction.argumentAnnotations,\n implementation: annotatedFunction.implementation,\n }),\n dependencies,\n );\n\n useEffect(() => {\n setEntryPoint(idRef.current, memoizedAnnotatedFunction as AnnotatedFunction<any[]>);\n\n return () => {\n removeEntryPoint(idRef.current);\n };\n }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);\n}\n","\"use client\";\n\nimport { FunctionCallHandler, AnnotatedFunction, Function } from \"@copilotkit/shared\";\nimport React 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\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: () => 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(\"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\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAAuD;;;ACCvD,mBAAkB;AAiElB,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,MAAM,uEAAuE;AAAA,IACzF;AAAA,IACA,IAAI,oBAA4B;AAC9B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;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,aAAAC,QAAM,cAAoC,mBAAmB;AAE3F,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;;;ADpGA,oBAAuB;AAEhB,SAAS,yBACd,mBACA,cACA;AACA,QAAM,YAAQ,0BAAO,sBAAO,CAAC;AAC7B,QAAM,EAAE,eAAe,iBAAiB,QAAI,0BAAW,cAAc;AAErE,QAAM,gCAA4D;AAAA,IAChE,OAAO;AAAA,MACL,MAAM,kBAAkB;AAAA,MACxB,aAAa,kBAAkB;AAAA,MAC/B,qBAAqB,kBAAkB;AAAA,MACvC,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AAEA,+BAAU,MAAM;AACd,kBAAc,MAAM,SAAS,yBAAqD;AAElF,WAAO,MAAM;AACX,uBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,2BAA2B,eAAe,gBAAgB,CAAC;AACjE;","names":["import_react","React"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useMakeCopilotActionable
|
|
4
|
+
} from "../chunk-DGUVNY3V.mjs";
|
|
5
|
+
import "../chunk-4CFJ6A6A.mjs";
|
|
6
|
+
import "../chunk-MRXNTQOX.mjs";
|
|
7
|
+
export {
|
|
8
|
+
useMakeCopilotActionable
|
|
9
|
+
};
|
|
5
10
|
//# sourceMappingURL=use-make-copilot-actionable.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,25 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __async = (__this, __arguments, generator) => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
var fulfilled = (value) => {
|
|
33
|
+
try {
|
|
34
|
+
step(generator.next(value));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
reject(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var rejected = (value) => {
|
|
40
|
+
try {
|
|
41
|
+
step(generator.throw(value));
|
|
42
|
+
} catch (e) {
|
|
43
|
+
reject(e);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
47
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
48
|
+
});
|
|
49
|
+
};
|
|
6
50
|
|
|
7
|
-
|
|
51
|
+
// src/hooks/use-make-copilot-document-readable.ts
|
|
52
|
+
var use_make_copilot_document_readable_exports = {};
|
|
53
|
+
__export(use_make_copilot_document_readable_exports, {
|
|
54
|
+
useMakeCopilotDocumentReadable: () => useMakeCopilotDocumentReadable
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(use_make_copilot_document_readable_exports);
|
|
57
|
+
var import_react2 = require("react");
|
|
8
58
|
|
|
59
|
+
// src/context/copilot-context.tsx
|
|
60
|
+
var import_react = __toESM(require("react"));
|
|
9
61
|
var emptyCopilotContext = {
|
|
10
62
|
entryPoints: {},
|
|
11
63
|
setEntryPoint: () => {
|
|
12
64
|
},
|
|
13
65
|
removeEntryPoint: () => {
|
|
14
66
|
},
|
|
15
|
-
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug(),
|
|
16
|
-
getFunctionCallHandler: () => returnAndThrowInDebug(),
|
|
17
|
-
|
|
67
|
+
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
|
|
68
|
+
getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
|
|
69
|
+
})),
|
|
70
|
+
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
18
71
|
addContext: () => "",
|
|
19
72
|
removeContext: () => {
|
|
20
73
|
},
|
|
21
|
-
getDocumentsContext: (categories) => returnAndThrowInDebug(),
|
|
22
|
-
addDocumentContext: () => returnAndThrowInDebug(),
|
|
74
|
+
getDocumentsContext: (categories) => returnAndThrowInDebug([]),
|
|
75
|
+
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
23
76
|
removeDocumentContext: () => {
|
|
24
77
|
},
|
|
25
78
|
copilotApiConfig: new class {
|
|
@@ -37,16 +90,17 @@ var emptyCopilotContext = {
|
|
|
37
90
|
}
|
|
38
91
|
}()
|
|
39
92
|
};
|
|
40
|
-
var CopilotContext =
|
|
93
|
+
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
41
94
|
function returnAndThrowInDebug(value) {
|
|
42
95
|
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
96
|
+
return value;
|
|
43
97
|
}
|
|
44
98
|
|
|
45
99
|
// src/hooks/use-make-copilot-document-readable.ts
|
|
46
100
|
function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
|
|
47
|
-
const { addDocumentContext, removeDocumentContext } =
|
|
48
|
-
const idRef =
|
|
49
|
-
|
|
101
|
+
const { addDocumentContext, removeDocumentContext } = (0, import_react2.useContext)(CopilotContext);
|
|
102
|
+
const idRef = (0, import_react2.useRef)();
|
|
103
|
+
(0, import_react2.useEffect)(() => {
|
|
50
104
|
const id = addDocumentContext(document, categories);
|
|
51
105
|
idRef.current = id;
|
|
52
106
|
return () => {
|
|
@@ -55,7 +109,8 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
|
|
|
55
109
|
}, [addDocumentContext, removeDocumentContext, ...dependencies]);
|
|
56
110
|
return idRef.current;
|
|
57
111
|
}
|
|
58
|
-
|
|
59
|
-
exports
|
|
60
|
-
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
useMakeCopilotDocumentReadable
|
|
115
|
+
});
|
|
61
116
|
//# sourceMappingURL=use-make-copilot-document-readable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-make-copilot-document-readable.ts","../../src/context/copilot-context.tsx"],"
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-make-copilot-document-readable.ts","../../src/context/copilot-context.tsx"],"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 } = 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","\"use client\";\n\nimport { FunctionCallHandler, AnnotatedFunction, Function } from \"@copilotkit/shared\";\nimport React 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\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: () => 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(\"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\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAA8C;;;ACC9C,mBAAkB;AAiElB,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,MAAM,uEAAuE;AAAA,IACzF;AAAA,IACA,IAAI,oBAA4B;AAC9B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;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,aAAAC,QAAM,cAAoC,mBAAmB;AAE3F,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;;;AD5FO,SAAS,+BACd,UACA,YACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,QAAI,0BAAW,cAAc;AAC/E,QAAM,YAAQ,sBAAe;AAE7B,+BAAU,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;","names":["import_react","React"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useMakeCopilotDocumentReadable
|
|
4
|
+
} from "../chunk-IQH5AQQC.mjs";
|
|
5
|
+
import "../chunk-4CFJ6A6A.mjs";
|
|
6
|
+
import "../chunk-MRXNTQOX.mjs";
|
|
7
|
+
export {
|
|
8
|
+
useMakeCopilotDocumentReadable
|
|
9
|
+
};
|
|
5
10
|
//# sourceMappingURL=use-make-copilot-document-readable.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,25 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __async = (__this, __arguments, generator) => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
var fulfilled = (value) => {
|
|
33
|
+
try {
|
|
34
|
+
step(generator.next(value));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
reject(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var rejected = (value) => {
|
|
40
|
+
try {
|
|
41
|
+
step(generator.throw(value));
|
|
42
|
+
} catch (e) {
|
|
43
|
+
reject(e);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
47
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
48
|
+
});
|
|
49
|
+
};
|
|
6
50
|
|
|
7
|
-
|
|
51
|
+
// src/hooks/use-make-copilot-readable.ts
|
|
52
|
+
var use_make_copilot_readable_exports = {};
|
|
53
|
+
__export(use_make_copilot_readable_exports, {
|
|
54
|
+
useMakeCopilotReadable: () => useMakeCopilotReadable
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(use_make_copilot_readable_exports);
|
|
57
|
+
var import_react2 = require("react");
|
|
8
58
|
|
|
59
|
+
// src/context/copilot-context.tsx
|
|
60
|
+
var import_react = __toESM(require("react"));
|
|
9
61
|
var emptyCopilotContext = {
|
|
10
62
|
entryPoints: {},
|
|
11
63
|
setEntryPoint: () => {
|
|
12
64
|
},
|
|
13
65
|
removeEntryPoint: () => {
|
|
14
66
|
},
|
|
15
|
-
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug(),
|
|
16
|
-
getFunctionCallHandler: () => returnAndThrowInDebug(),
|
|
17
|
-
|
|
67
|
+
getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
|
|
68
|
+
getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
|
|
69
|
+
})),
|
|
70
|
+
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
18
71
|
addContext: () => "",
|
|
19
72
|
removeContext: () => {
|
|
20
73
|
},
|
|
21
|
-
getDocumentsContext: (categories) => returnAndThrowInDebug(),
|
|
22
|
-
addDocumentContext: () => returnAndThrowInDebug(),
|
|
74
|
+
getDocumentsContext: (categories) => returnAndThrowInDebug([]),
|
|
75
|
+
addDocumentContext: () => returnAndThrowInDebug(""),
|
|
23
76
|
removeDocumentContext: () => {
|
|
24
77
|
},
|
|
25
78
|
copilotApiConfig: new class {
|
|
@@ -37,16 +90,17 @@ var emptyCopilotContext = {
|
|
|
37
90
|
}
|
|
38
91
|
}()
|
|
39
92
|
};
|
|
40
|
-
var CopilotContext =
|
|
93
|
+
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
41
94
|
function returnAndThrowInDebug(value) {
|
|
42
95
|
throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
|
|
96
|
+
return value;
|
|
43
97
|
}
|
|
44
98
|
|
|
45
99
|
// src/hooks/use-make-copilot-readable.ts
|
|
46
100
|
function useMakeCopilotReadable(information, parentId, categories) {
|
|
47
|
-
const { addContext, removeContext } =
|
|
48
|
-
const idRef =
|
|
49
|
-
|
|
101
|
+
const { addContext, removeContext } = (0, import_react2.useContext)(CopilotContext);
|
|
102
|
+
const idRef = (0, import_react2.useRef)();
|
|
103
|
+
(0, import_react2.useEffect)(() => {
|
|
50
104
|
const id = addContext(information, parentId, categories);
|
|
51
105
|
idRef.current = id;
|
|
52
106
|
return () => {
|
|
@@ -55,7 +109,8 @@ function useMakeCopilotReadable(information, parentId, categories) {
|
|
|
55
109
|
}, [information, parentId, addContext, removeContext]);
|
|
56
110
|
return idRef.current;
|
|
57
111
|
}
|
|
58
|
-
|
|
59
|
-
exports
|
|
60
|
-
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
useMakeCopilotReadable
|
|
115
|
+
});
|
|
61
116
|
//# sourceMappingURL=use-make-copilot-readable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/use-make-copilot-readable.ts","../../src/context/copilot-context.tsx"],"
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-make-copilot-readable.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\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 useMakeCopilotReadable(\n information: string,\n parentId?: string,\n categories?: string[],\n): string | undefined {\n const { addContext, removeContext } = useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addContext(information, parentId, categories);\n idRef.current = id;\n\n return () => {\n removeContext(id);\n };\n }, [information, parentId, addContext, removeContext]);\n\n return idRef.current;\n}\n","\"use client\";\n\nimport { FunctionCallHandler, AnnotatedFunction, Function } from \"@copilotkit/shared\";\nimport React 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\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: () => 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(\"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\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAA8C;;;ACC9C,mBAAkB;AAiElB,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,MAAM,uEAAuE;AAAA,IACzF;AAAA,IACA,IAAI,oBAA4B;AAC9B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;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,aAAAC,QAAM,cAAoC,mBAAmB;AAE3F,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;;;AD7FO,SAAS,uBACd,aACA,UACA,YACoB;AACpB,QAAM,EAAE,YAAY,cAAc,QAAI,0BAAW,cAAc;AAC/D,QAAM,YAAQ,sBAAe;AAE7B,+BAAU,MAAM;AACd,UAAM,KAAK,WAAW,aAAa,UAAU,UAAU;AACvD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,oBAAc,EAAE;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,aAAa,UAAU,YAAY,aAAa,CAAC;AAErD,SAAO,MAAM;AACf;","names":["import_react","React"]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useMakeCopilotReadable
|
|
4
|
+
} from "../chunk-YOXWT7I6.mjs";
|
|
5
|
+
import "../chunk-4CFJ6A6A.mjs";
|
|
6
|
+
import "../chunk-MRXNTQOX.mjs";
|
|
7
|
+
export {
|
|
8
|
+
useMakeCopilotReadable
|
|
9
|
+
};
|
|
5
10
|
//# sourceMappingURL=use-make-copilot-readable.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/hooks/use-tree.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var nanoid = require('nanoid');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
6
2
|
var __defProp = Object.defineProperty;
|
|
7
3
|
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
5
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
9
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -22,6 +20,28 @@ var __spreadValues = (a, b) => {
|
|
|
22
20
|
return a;
|
|
23
21
|
};
|
|
24
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
|
|
37
|
+
// src/hooks/use-tree.ts
|
|
38
|
+
var use_tree_exports = {};
|
|
39
|
+
__export(use_tree_exports, {
|
|
40
|
+
default: () => use_tree_default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(use_tree_exports);
|
|
43
|
+
var import_nanoid = require("nanoid");
|
|
44
|
+
var import_react = require("react");
|
|
25
45
|
var removeNode = (nodes, id) => {
|
|
26
46
|
return nodes.reduce((result, node) => {
|
|
27
47
|
if (node.id !== id) {
|
|
@@ -102,10 +122,10 @@ function treeReducer(state, action) {
|
|
|
102
122
|
}
|
|
103
123
|
}
|
|
104
124
|
var useTree = () => {
|
|
105
|
-
const [tree, dispatch] =
|
|
106
|
-
const addElement =
|
|
125
|
+
const [tree, dispatch] = (0, import_react.useReducer)(treeReducer, []);
|
|
126
|
+
const addElement = (0, import_react.useCallback)(
|
|
107
127
|
(value, categories, parentId) => {
|
|
108
|
-
const newNodeId =
|
|
128
|
+
const newNodeId = (0, import_nanoid.nanoid)();
|
|
109
129
|
dispatch({
|
|
110
130
|
type: "ADD_NODE",
|
|
111
131
|
value,
|
|
@@ -117,10 +137,10 @@ var useTree = () => {
|
|
|
117
137
|
},
|
|
118
138
|
[]
|
|
119
139
|
);
|
|
120
|
-
const removeElement =
|
|
140
|
+
const removeElement = (0, import_react.useCallback)((id) => {
|
|
121
141
|
dispatch({ type: "REMOVE_NODE", id });
|
|
122
142
|
}, []);
|
|
123
|
-
const printTree =
|
|
143
|
+
const printTree = (0, import_react.useCallback)(
|
|
124
144
|
(categories) => {
|
|
125
145
|
const categoriesSet = new Set(categories);
|
|
126
146
|
let output = "";
|
|
@@ -149,7 +169,4 @@ function setsHaveIntersection(setA, setB) {
|
|
|
149
169
|
}
|
|
150
170
|
return false;
|
|
151
171
|
}
|
|
152
|
-
|
|
153
|
-
module.exports = use_tree_default;
|
|
154
|
-
//# sourceMappingURL=out.js.map
|
|
155
172
|
//# sourceMappingURL=use-tree.js.map
|