@copilotkit/react-core 0.7.0 → 0.8.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.
@@ -1,76 +1,76 @@
1
1
 
2
- > @copilotkit/react-core@0.6.0 build /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core
2
+ > @copilotkit/react-core@0.8.0-alpha.1 build /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core
3
3
  > tsup --treeshake
4
4
 
5
- CLI Building entry: src/index.tsx, src/components/copilot-provider.tsx, src/components/index.ts, src/context/copilot-context.tsx, src/context/index.ts, src/hooks/index.ts, src/hooks/use-copilot-chat.ts, src/hooks/use-make-copilot-actionable.ts, src/hooks/use-make-copilot-readable.ts, src/hooks/use-tree.ts, src/utils/utils.test.ts, src/utils/utils.ts, src/types/annotated-function.ts, src/types/index.ts
5
+ CLI Building entry: src/index.tsx, src/components/copilot-provider.tsx, src/components/index.ts, src/context/copilot-context.tsx, src/context/index.ts, src/hooks/index.ts, src/hooks/use-copilot-chat.ts, src/hooks/use-make-copilot-actionable.ts, src/hooks/use-make-copilot-readable.ts, src/hooks/use-tree.ts, src/types/annotated-function.ts, src/types/index.ts, src/utils/utils.test.ts, src/utils/utils.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v6.5.0
8
8
  CLI Using tsup config: /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core/tsup.config.ts
9
9
  CLI Target: es6
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
- Generated an empty chunk: "utils".
13
12
  Generated an empty chunk: "annotated-function".
13
+ Generated an empty chunk: "utils".
14
14
  Generated an empty chunk: "chunk-EFZPSZWO".
15
15
  Generated an empty chunk: "chunk-JD7BAH7U".
16
16
  Generated an empty chunk: "chunk-VNRDQJXW".
17
17
  Generated an empty chunk: "chunk-BVQRDAR7".
18
+ ESM dist/chunk-JD7BAH7U.mjs 76.00 B
19
+ ESM dist/utils/utils.mjs 67.00 B
18
20
  ESM dist/chunk-EFZPSZWO.mjs 76.00 B
19
- ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
20
21
  ESM dist/chunk-BVQRDAR7.mjs 76.00 B
21
- ESM dist/index.mjs 546.00 B
22
+ ESM dist/chunk-VNRDQJXW.mjs 76.00 B
22
23
  ESM dist/types/index.mjs 98.00 B
23
- ESM dist/hooks/use-tree.mjs 170.00 B
24
+ ESM dist/types/annotated-function.mjs 80.00 B
25
+ ESM dist/chunk-3BOHSSKR.mjs 3.95 KB
24
26
  ESM dist/components/copilot-provider.mjs 230.00 B
25
- ESM dist/chunk-JD7BAH7U.mjs 76.00 B
26
- ESM dist/chunk-HZM7VSAI.mjs 3.65 KB
27
- ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
28
- ESM dist/components/index.mjs 251.00 B
29
- ESM dist/hooks/index.mjs 348.00 B
30
- ESM dist/chunk-MYPA66N5.mjs 626.00 B
31
- ESM dist/hooks/use-copilot-chat.mjs 219.00 B
32
- ESM dist/chunk-FWAPH3V2.mjs 2.59 KB
27
+ ESM dist/chunk-FCFGH4M4.mjs 3.65 KB
33
28
  ESM dist/context/index.mjs 186.00 B
34
29
  ESM dist/context/copilot-context.mjs 164.00 B
30
+ ESM dist/hooks/use-copilot-chat.mjs 219.00 B
31
+ ESM dist/hooks/index.mjs 348.00 B
32
+ ESM dist/chunk-KQACBBGH.mjs 626.00 B
33
+ ESM dist/chunk-547TMALJ.mjs 2.59 KB
34
+ ESM dist/hooks/use-make-copilot-readable.mjs 214.00 B
35
+ ESM dist/chunk-6CBAEPMO.mjs 723.00 B
36
+ ESM dist/index.mjs 546.00 B
37
+ ESM dist/chunk-H23NBUJ7.mjs 972.00 B
35
38
  ESM dist/hooks/use-make-copilot-actionable.mjs 218.00 B
36
- ESM dist/chunk-QC54QNRW.mjs 972.00 B
37
- ESM dist/chunk-3BOHSSKR.mjs 3.95 KB
38
- ESM dist/chunk-VNRDQJXW.mjs 76.00 B
39
- ESM dist/chunk-YOYU25BE.mjs 723.00 B
39
+ ESM dist/components/index.mjs 251.00 B
40
+ ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
41
+ ESM dist/hooks/use-tree.mjs 170.00 B
40
42
  ESM dist/utils/utils.test.mjs 202.00 B
41
- ESM dist/types/annotated-function.mjs 80.00 B
42
- ESM dist/utils/utils.mjs 67.00 B
43
- ESM dist/hooks/use-make-copilot-readable.mjs.map 51.00 B
44
- ESM dist/chunk-EFZPSZWO.mjs.map 51.00 B
45
- ESM dist/hooks/use-tree.mjs.map 51.00 B
46
- ESM dist/index.mjs.map 51.00 B
47
43
  ESM dist/chunk-JD7BAH7U.mjs.map 51.00 B
48
44
  ESM dist/chunk-BVQRDAR7.mjs.map 51.00 B
49
- ESM dist/chunk-HZM7VSAI.mjs.map 7.23 KB
50
- ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
51
- ESM dist/chunk-MYPA66N5.mjs.map 1.47 KB
52
- ESM dist/hooks/use-copilot-chat.mjs.map 51.00 B
45
+ ESM dist/chunk-EFZPSZWO.mjs.map 51.00 B
53
46
  ESM dist/types/index.mjs.map 51.00 B
54
- ESM dist/hooks/index.mjs.map 51.00 B
55
- ESM dist/chunk-FWAPH3V2.mjs.map 4.43 KB
56
- ESM dist/components/copilot-provider.mjs.map 51.00 B
57
- ESM dist/chunk-QC54QNRW.mjs.map 1.70 KB
58
- ESM dist/context/copilot-context.mjs.map 51.00 B
59
47
  ESM dist/chunk-3BOHSSKR.mjs.map 8.39 KB
60
- ESM dist/context/index.mjs.map 51.00 B
61
48
  ESM dist/chunk-VNRDQJXW.mjs.map 51.00 B
62
- ESM dist/components/index.mjs.map 51.00 B
63
- ESM dist/chunk-YOYU25BE.mjs.map 2.06 KB
49
+ ESM dist/hooks/use-copilot-chat.mjs.map 51.00 B
50
+ ESM dist/chunk-FCFGH4M4.mjs.map 7.25 KB
51
+ ESM dist/context/copilot-context.mjs.map 51.00 B
52
+ ESM dist/context/index.mjs.map 51.00 B
53
+ ESM dist/hooks/index.mjs.map 51.00 B
54
+ ESM dist/utils/utils.mjs.map 51.00 B
55
+ ESM dist/index.mjs.map 51.00 B
56
+ ESM dist/chunk-KQACBBGH.mjs.map 1.47 KB
64
57
  ESM dist/hooks/use-make-copilot-actionable.mjs.map 51.00 B
58
+ ESM dist/chunk-547TMALJ.mjs.map 4.43 KB
59
+ ESM dist/chunk-H23NBUJ7.mjs.map 1.70 KB
60
+ ESM dist/hooks/use-make-copilot-readable.mjs.map 51.00 B
61
+ ESM dist/components/index.mjs.map 51.00 B
62
+ ESM dist/components/copilot-provider.mjs.map 51.00 B
63
+ ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
64
+ ESM dist/chunk-6CBAEPMO.mjs.map 2.07 KB
65
65
  ESM dist/utils/utils.test.mjs.map 351.00 B
66
- ESM dist/utils/utils.mjs.map 51.00 B
67
66
  ESM dist/types/annotated-function.mjs.map 51.00 B
67
+ ESM dist/hooks/use-tree.mjs.map 51.00 B
68
68
  ESM ⚡️ Build success in 89ms
69
69
  DTS Build start
70
- DTS ⚡️ Build success in 824ms
70
+ DTS ⚡️ Build success in 927ms
71
71
  DTS dist/index.d.ts 607.00 B
72
72
  DTS dist/components/copilot-provider.d.ts 157.00 B
73
- DTS dist/context/copilot-context.d.ts 919.00 B
73
+ DTS dist/context/copilot-context.d.ts 927.00 B
74
74
  DTS dist/hooks/use-copilot-chat.d.ts 890.00 B
75
75
  DTS dist/hooks/use-make-copilot-actionable.d.ts 255.00 B
76
76
  DTS dist/hooks/use-make-copilot-readable.d.ts 598.00 B
@@ -79,6 +79,6 @@ DTS dist/hooks/use-tree.d.ts 543.00 B
79
79
  DTS dist/components/index.d.ts 73.00 B
80
80
  DTS dist/context/index.d.ts 210.00 B
81
81
  DTS dist/hooks/index.d.ts 305.00 B
82
+ DTS dist/types/index.d.ts 88.00 B
82
83
  DTS dist/utils/utils.test.d.ts 1.00 B
83
84
  DTS dist/utils/utils.d.ts 1.00 B
84
- DTS dist/types/index.d.ts 88.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # ui
2
2
 
3
+ ## 0.8.0-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - prettify
8
+
9
+ ## 0.8.0-alpha.0
10
+
11
+ ### Minor Changes
12
+
13
+ - textarea insertions deletions etc
14
+
3
15
  ## 0.7.0
4
16
 
5
17
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { CopilotContext } from './chunk-YOYU25BE.mjs';
1
+ import { CopilotContext } from './chunk-6CBAEPMO.mjs';
2
2
  import { __objRest } from './chunk-MRXNTQOX.mjs';
3
3
  import { useContext, useMemo } from 'react';
4
4
  import { useChat } from 'ai/react';
@@ -77,4 +77,4 @@ If you would like to call a function, call it without saying anything else.
77
77
 
78
78
  export { defaultSystemMessage, useCopilotChat };
79
79
  //# sourceMappingURL=out.js.map
80
- //# sourceMappingURL=chunk-FWAPH3V2.mjs.map
80
+ //# sourceMappingURL=chunk-547TMALJ.mjs.map
@@ -23,4 +23,4 @@ function returnAndThrowInDebug(value) {
23
23
 
24
24
  export { CopilotContext };
25
25
  //# sourceMappingURL=out.js.map
26
- //# sourceMappingURL=chunk-YOYU25BE.mjs.map
26
+ //# sourceMappingURL=chunk-6CBAEPMO.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context/copilot-context.tsx"],"names":[],"mappings":";;;;;AAGA,OAAO,WAAW;AAHlB;AA0BA,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,MAAM,sBAAsB,EAAE;AAAA,EAChD,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AACxB;AAEO,IAAM,iBACX,MAAM,cAAoC,mBAAmB;AAE/D,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT","sourcesContent":["\"use client\";\n\nimport { FunctionCallHandler } from \"ai\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, AnnotatedFunction<any[]>>;\n setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;\n removeEntryPoint: (id: string) => void;\n getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n getContextString: (categories?: string[]) => string;\n addContext: (\n context: string,\n parentId?: string,\n categories?: string[]\n ) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: () => returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n};\n\nexport const CopilotContext =\n React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n return value;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { use_tree_default } from './chunk-3BOHSSKR.mjs';
2
- import { CopilotContext } from './chunk-YOYU25BE.mjs';
2
+ import { CopilotContext } from './chunk-6CBAEPMO.mjs';
3
3
  import { __spreadProps, __spreadValues, __async, __objRest } from './chunk-MRXNTQOX.mjs';
4
4
  import { useState, useCallback } from 'react';
5
5
  import { jsx } from 'react/jsx-runtime';
@@ -115,4 +115,4 @@ function annotatedFunctionToChatCompletionFunction(annotatedFunction) {
115
115
 
116
116
  export { CopilotProvider };
117
117
  //# sourceMappingURL=out.js.map
118
- //# sourceMappingURL=chunk-HZM7VSAI.mjs.map
118
+ //# sourceMappingURL=chunk-FCFGH4M4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/copilot-provider.tsx"],"names":[],"mappings":"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","sourcesContent":["\"use client\";\nimport { FunctionCallHandler } from \"ai\";\nimport { ReactNode, useCallback, useState } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport useTree from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\nimport { ChatCompletionCreateParams } from \"openai/resources/chat\";\n\nexport function CopilotProvider({\n children,\n}: {\n children: ReactNode;\n}): JSX.Element {\n const [entryPoints, setEntryPoints] = useState<\n Record<string, AnnotatedFunction<any[]>>\n >({});\n\n const { addElement, removeElement, printTree } = useTree();\n\n const setEntryPoint = useCallback(\n (id: string, entryPoint: AnnotatedFunction<any[]>) => {\n setEntryPoints((prevPoints) => {\n return {\n ...prevPoints,\n [id]: entryPoint,\n };\n });\n },\n []\n );\n\n const removeEntryPoint = useCallback((id: string) => {\n setEntryPoints((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (categories: string[] = [\"global\"]) => {\n return printTree(categories);\n },\n [printTree]\n );\n\n const addContext = useCallback(\n (context: string, parentId?: string, categories: string[] = [\"global\"]) => {\n return addElement(context, categories, parentId);\n },\n [addElement]\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement]\n );\n\n const getChatCompletionFunctionDescriptions = useCallback(() => {\n return entryPointsToChatCompletionFunctions(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getFunctionCallHandler = useCallback(() => {\n return entryPointsToFunctionCallHandler(Object.values(entryPoints));\n }, [entryPoints]);\n\n return (\n <CopilotContext.Provider\n value={{\n entryPoints,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n setEntryPoint,\n removeEntryPoint,\n getContextString,\n addContext,\n removeContext,\n }}\n >\n {children}\n </CopilotContext.Provider>\n );\n}\n\nfunction entryPointsToFunctionCallHandler(\n entryPoints: AnnotatedFunction<any[]>[]\n): FunctionCallHandler {\n return async (chatMessages, functionCall) => {\n let entrypointsByFunctionName: Record<\n string,\n AnnotatedFunction<any[]>\n > = {};\n for (let entryPoint of entryPoints) {\n entrypointsByFunctionName[entryPoint.name] = entryPoint;\n }\n\n const entryPointFunction =\n entrypointsByFunctionName[functionCall.name || \"\"];\n if (entryPointFunction) {\n let parsedFunctionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n parsedFunctionCallArguments = JSON.parse(functionCall.arguments);\n }\n\n const paramsInCorrectOrder: any[] = [];\n for (let arg of entryPointFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(\n parsedFunctionCallArguments[\n arg.name as keyof typeof parsedFunctionCallArguments\n ]\n );\n }\n\n await entryPointFunction.implementation(...paramsInCorrectOrder);\n\n // commented out becasue for now we don't want to return anything\n // const result = await entryPointFunction.implementation(\n // ...parsedFunctionCallArguments\n // );\n // const functionResponse: ChatRequest = {\n // messages: [\n // ...chatMessages,\n // {\n // id: nanoid(),\n // name: functionCall.name,\n // role: 'function' as const,\n // content: JSON.stringify(result),\n // },\n // ],\n // };\n\n // return functionResponse;\n }\n };\n}\n\nfunction entryPointsToChatCompletionFunctions(\n entryPoints: AnnotatedFunction<any[]>[]\n): ChatCompletionCreateParams.Function[] {\n return entryPoints.map(annotatedFunctionToChatCompletionFunction);\n}\n\nfunction annotatedFunctionToChatCompletionFunction(\n annotatedFunction: AnnotatedFunction<any[]>\n): ChatCompletionCreateParams.Function {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let arg of annotatedFunction.argumentAnnotations) {\n // isolate the args we should forward inline\n let { name, required, ...forwardedArgs } = arg;\n parameters[arg.name] = forwardedArgs;\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of annotatedFunction.argumentAnnotations) {\n if (arg.required) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n let chatCompletionFunction: ChatCompletionCreateParams.Function = {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n };\n\n return chatCompletionFunction;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { CopilotContext } from './chunk-YOYU25BE.mjs';
1
+ import { CopilotContext } from './chunk-6CBAEPMO.mjs';
2
2
  import { useRef, useContext, useMemo, useEffect } from 'react';
3
3
  import { nanoid } from 'nanoid';
4
4
 
@@ -27,4 +27,4 @@ function useMakeCopilotActionable(annotatedFunction, dependencies) {
27
27
 
28
28
  export { useMakeCopilotActionable };
29
29
  //# sourceMappingURL=out.js.map
30
- //# sourceMappingURL=chunk-QC54QNRW.mjs.map
30
+ //# sourceMappingURL=chunk-H23NBUJ7.mjs.map
@@ -1,4 +1,4 @@
1
- import { CopilotContext } from './chunk-YOYU25BE.mjs';
1
+ import { CopilotContext } from './chunk-6CBAEPMO.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-MYPA66N5.mjs.map
19
+ //# sourceMappingURL=chunk-KQACBBGH.mjs.map
@@ -1,6 +1,6 @@
1
- export { CopilotProvider } from '../chunk-HZM7VSAI.mjs';
1
+ export { CopilotProvider } from '../chunk-FCFGH4M4.mjs';
2
2
  import '../chunk-3BOHSSKR.mjs';
3
- import '../chunk-YOYU25BE.mjs';
3
+ import '../chunk-6CBAEPMO.mjs';
4
4
  import '../chunk-MRXNTQOX.mjs';
5
5
  //# sourceMappingURL=out.js.map
6
6
  //# sourceMappingURL=copilot-provider.mjs.map
@@ -1,7 +1,7 @@
1
1
  import '../chunk-JD7BAH7U.mjs';
2
- export { CopilotProvider } from '../chunk-HZM7VSAI.mjs';
2
+ export { CopilotProvider } from '../chunk-FCFGH4M4.mjs';
3
3
  import '../chunk-3BOHSSKR.mjs';
4
- import '../chunk-YOYU25BE.mjs';
4
+ import '../chunk-6CBAEPMO.mjs';
5
5
  import '../chunk-MRXNTQOX.mjs';
6
6
  //# sourceMappingURL=out.js.map
7
7
  //# sourceMappingURL=index.mjs.map
@@ -1,14 +1,14 @@
1
1
  import { FunctionCallHandler } from 'ai';
2
- import { CompletionCreateParams } from 'openai/resources/chat';
3
2
  import React from 'react';
4
3
  import { TreeNodeId } from '../hooks/use-tree.js';
5
4
  import { AnnotatedFunction } from '../types/annotated-function.js';
5
+ import { ChatCompletionCreateParams } from 'openai/resources/chat';
6
6
 
7
7
  interface CopilotContextParams {
8
8
  entryPoints: Record<string, AnnotatedFunction<any[]>>;
9
9
  setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;
10
10
  removeEntryPoint: (id: string) => void;
11
- getChatCompletionFunctionDescriptions: () => CompletionCreateParams.Function[];
11
+ getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];
12
12
  getFunctionCallHandler: () => FunctionCallHandler;
13
13
  getContextString: (categories?: string[]) => string;
14
14
  addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;
@@ -1,4 +1,4 @@
1
- export { CopilotContext } from '../chunk-YOYU25BE.mjs';
1
+ export { CopilotContext } from '../chunk-6CBAEPMO.mjs';
2
2
  import '../chunk-MRXNTQOX.mjs';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=copilot-context.mjs.map
@@ -1,6 +1,6 @@
1
1
  export { CopilotContext, CopilotContextParams } from './copilot-context.js';
2
2
  import 'ai';
3
- import 'openai/resources/chat';
4
3
  import 'react';
5
4
  import '../hooks/use-tree.js';
6
5
  import '../types/annotated-function.js';
6
+ import 'openai/resources/chat';
@@ -1,5 +1,5 @@
1
1
  import '../chunk-VNRDQJXW.mjs';
2
- export { CopilotContext } from '../chunk-YOYU25BE.mjs';
2
+ export { CopilotContext } from '../chunk-6CBAEPMO.mjs';
3
3
  import '../chunk-MRXNTQOX.mjs';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=index.mjs.map
@@ -1,8 +1,8 @@
1
1
  import '../chunk-BVQRDAR7.mjs';
2
- export { useMakeCopilotReadable } from '../chunk-MYPA66N5.mjs';
3
- export { useCopilotChat } from '../chunk-FWAPH3V2.mjs';
4
- export { useMakeCopilotActionable } from '../chunk-QC54QNRW.mjs';
5
- import '../chunk-YOYU25BE.mjs';
2
+ export { useMakeCopilotReadable } from '../chunk-KQACBBGH.mjs';
3
+ export { useCopilotChat } from '../chunk-547TMALJ.mjs';
4
+ export { useMakeCopilotActionable } from '../chunk-H23NBUJ7.mjs';
5
+ import '../chunk-6CBAEPMO.mjs';
6
6
  import '../chunk-MRXNTQOX.mjs';
7
7
  //# sourceMappingURL=out.js.map
8
8
  //# sourceMappingURL=index.mjs.map
@@ -1,5 +1,5 @@
1
- export { defaultSystemMessage, useCopilotChat } from '../chunk-FWAPH3V2.mjs';
2
- import '../chunk-YOYU25BE.mjs';
1
+ export { defaultSystemMessage, useCopilotChat } from '../chunk-547TMALJ.mjs';
2
+ import '../chunk-6CBAEPMO.mjs';
3
3
  import '../chunk-MRXNTQOX.mjs';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=use-copilot-chat.mjs.map
@@ -1,5 +1,5 @@
1
- export { useMakeCopilotActionable } from '../chunk-QC54QNRW.mjs';
2
- import '../chunk-YOYU25BE.mjs';
1
+ export { useMakeCopilotActionable } from '../chunk-H23NBUJ7.mjs';
2
+ import '../chunk-6CBAEPMO.mjs';
3
3
  import '../chunk-MRXNTQOX.mjs';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=use-make-copilot-actionable.mjs.map
@@ -1,5 +1,5 @@
1
- export { useMakeCopilotReadable } from '../chunk-MYPA66N5.mjs';
2
- import '../chunk-YOYU25BE.mjs';
1
+ export { useMakeCopilotReadable } from '../chunk-KQACBBGH.mjs';
2
+ import '../chunk-6CBAEPMO.mjs';
3
3
  import '../chunk-MRXNTQOX.mjs';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=use-make-copilot-readable.mjs.map
package/dist/index.d.ts CHANGED
@@ -6,5 +6,5 @@ export { useMakeCopilotReadable } from './hooks/use-make-copilot-readable.js';
6
6
  export { AnnotatedFunction, AnnotatedFunctionArgument } from './types/annotated-function.js';
7
7
  import 'react';
8
8
  import 'ai';
9
- import 'openai/resources/chat';
10
9
  import './hooks/use-tree.js';
10
+ import 'openai/resources/chat';
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import './chunk-EFZPSZWO.mjs';
2
2
  import './chunk-JD7BAH7U.mjs';
3
- export { CopilotProvider } from './chunk-HZM7VSAI.mjs';
3
+ export { CopilotProvider } from './chunk-FCFGH4M4.mjs';
4
4
  import './chunk-3BOHSSKR.mjs';
5
5
  import './chunk-VNRDQJXW.mjs';
6
6
  import './chunk-BVQRDAR7.mjs';
7
- export { useMakeCopilotReadable } from './chunk-MYPA66N5.mjs';
8
- export { useCopilotChat } from './chunk-FWAPH3V2.mjs';
9
- export { useMakeCopilotActionable } from './chunk-QC54QNRW.mjs';
10
- export { CopilotContext } from './chunk-YOYU25BE.mjs';
7
+ export { useMakeCopilotReadable } from './chunk-KQACBBGH.mjs';
8
+ export { useCopilotChat } from './chunk-547TMALJ.mjs';
9
+ export { useMakeCopilotActionable } from './chunk-H23NBUJ7.mjs';
10
+ export { CopilotContext } from './chunk-6CBAEPMO.mjs';
11
11
  import './chunk-MRXNTQOX.mjs';
12
12
  //# sourceMappingURL=out.js.map
13
13
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.7.0",
7
+ "version": "0.8.0-alpha.1",
8
8
  "sideEffects": false,
9
9
  "main": "./dist/index.js",
10
10
  "module": "./dist/index.mjs",
@@ -27,9 +27,9 @@
27
27
  "tsconfig": "0.3.0"
28
28
  },
29
29
  "dependencies": {
30
- "ai": "^2.2.6",
30
+ "ai": "^2.2.12",
31
31
  "nanoid": "^4.0.2",
32
- "openai": "^4.0.0"
32
+ "openai": "^4.6.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "tsup --treeshake",
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import { FunctionCallHandler } from "ai";
3
- import { CompletionCreateParams } from "openai/resources/chat";
4
3
  import { ReactNode, useCallback, useState } from "react";
5
4
  import { CopilotContext } from "../context/copilot-context";
6
5
  import useTree from "../hooks/use-tree";
7
6
  import { AnnotatedFunction } from "../types/annotated-function";
7
+ import { ChatCompletionCreateParams } from "openai/resources/chat";
8
8
 
9
9
  export function CopilotProvider({
10
10
  children,
@@ -138,13 +138,13 @@ function entryPointsToFunctionCallHandler(
138
138
 
139
139
  function entryPointsToChatCompletionFunctions(
140
140
  entryPoints: AnnotatedFunction<any[]>[]
141
- ): CompletionCreateParams.Function[] {
141
+ ): ChatCompletionCreateParams.Function[] {
142
142
  return entryPoints.map(annotatedFunctionToChatCompletionFunction);
143
143
  }
144
144
 
145
145
  function annotatedFunctionToChatCompletionFunction(
146
146
  annotatedFunction: AnnotatedFunction<any[]>
147
- ): CompletionCreateParams.Function {
147
+ ): ChatCompletionCreateParams.Function {
148
148
  // Create the parameters object based on the argumentAnnotations
149
149
  let parameters: { [key: string]: any } = {};
150
150
  for (let arg of annotatedFunction.argumentAnnotations) {
@@ -161,7 +161,7 @@ function annotatedFunctionToChatCompletionFunction(
161
161
  }
162
162
 
163
163
  // Create the ChatCompletionFunctions object
164
- let chatCompletionFunction: CompletionCreateParams.Function = {
164
+ let chatCompletionFunction: ChatCompletionCreateParams.Function = {
165
165
  name: annotatedFunction.name,
166
166
  description: annotatedFunction.description,
167
167
  parameters: {
@@ -1,17 +1,17 @@
1
1
  "use client";
2
2
 
3
3
  import { FunctionCallHandler } from "ai";
4
- import { CompletionCreateParams } from "openai/resources/chat";
5
4
  import React from "react";
6
5
  import { TreeNodeId } from "../hooks/use-tree";
7
6
  import { AnnotatedFunction } from "../types/annotated-function";
7
+ import { ChatCompletionCreateParams } from "openai/resources/chat";
8
8
 
9
9
  export interface CopilotContextParams {
10
10
  // function-calling
11
11
  entryPoints: Record<string, AnnotatedFunction<any[]>>;
12
12
  setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;
13
13
  removeEntryPoint: (id: string) => void;
14
- getChatCompletionFunctionDescriptions: () => CompletionCreateParams.Function[];
14
+ getChatCompletionFunctionDescriptions: () => ChatCompletionCreateParams.Function[];
15
15
  getFunctionCallHandler: () => FunctionCallHandler;
16
16
 
17
17
  // text context
@@ -1,4 +0,0 @@
1
-
2
- > @copilotkit/react-core@0.6.0 check-types /Users/ataibarkai/LocalGit/Recursively.ai/CopilotKit/CopilotKit/packages/react-core
3
- > tsc --noEmit
4
-
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/copilot-provider.tsx"],"names":[],"mappings":"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","sourcesContent":["\"use client\";\nimport { FunctionCallHandler } from \"ai\";\nimport { CompletionCreateParams } from \"openai/resources/chat\";\nimport { ReactNode, useCallback, useState } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport useTree from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\n\nexport function CopilotProvider({\n children,\n}: {\n children: ReactNode;\n}): JSX.Element {\n const [entryPoints, setEntryPoints] = useState<\n Record<string, AnnotatedFunction<any[]>>\n >({});\n\n const { addElement, removeElement, printTree } = useTree();\n\n const setEntryPoint = useCallback(\n (id: string, entryPoint: AnnotatedFunction<any[]>) => {\n setEntryPoints((prevPoints) => {\n return {\n ...prevPoints,\n [id]: entryPoint,\n };\n });\n },\n []\n );\n\n const removeEntryPoint = useCallback((id: string) => {\n setEntryPoints((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (categories: string[] = [\"global\"]) => {\n return printTree(categories);\n },\n [printTree]\n );\n\n const addContext = useCallback(\n (context: string, parentId?: string, categories: string[] = [\"global\"]) => {\n return addElement(context, categories, parentId);\n },\n [addElement]\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement]\n );\n\n const getChatCompletionFunctionDescriptions = useCallback(() => {\n return entryPointsToChatCompletionFunctions(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getFunctionCallHandler = useCallback(() => {\n return entryPointsToFunctionCallHandler(Object.values(entryPoints));\n }, [entryPoints]);\n\n return (\n <CopilotContext.Provider\n value={{\n entryPoints,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n setEntryPoint,\n removeEntryPoint,\n getContextString,\n addContext,\n removeContext,\n }}\n >\n {children}\n </CopilotContext.Provider>\n );\n}\n\nfunction entryPointsToFunctionCallHandler(\n entryPoints: AnnotatedFunction<any[]>[]\n): FunctionCallHandler {\n return async (chatMessages, functionCall) => {\n let entrypointsByFunctionName: Record<\n string,\n AnnotatedFunction<any[]>\n > = {};\n for (let entryPoint of entryPoints) {\n entrypointsByFunctionName[entryPoint.name] = entryPoint;\n }\n\n const entryPointFunction =\n entrypointsByFunctionName[functionCall.name || \"\"];\n if (entryPointFunction) {\n let parsedFunctionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n parsedFunctionCallArguments = JSON.parse(functionCall.arguments);\n }\n\n const paramsInCorrectOrder: any[] = [];\n for (let arg of entryPointFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(\n parsedFunctionCallArguments[\n arg.name as keyof typeof parsedFunctionCallArguments\n ]\n );\n }\n\n await entryPointFunction.implementation(...paramsInCorrectOrder);\n\n // commented out becasue for now we don't want to return anything\n // const result = await entryPointFunction.implementation(\n // ...parsedFunctionCallArguments\n // );\n // const functionResponse: ChatRequest = {\n // messages: [\n // ...chatMessages,\n // {\n // id: nanoid(),\n // name: functionCall.name,\n // role: 'function' as const,\n // content: JSON.stringify(result),\n // },\n // ],\n // };\n\n // return functionResponse;\n }\n };\n}\n\nfunction entryPointsToChatCompletionFunctions(\n entryPoints: AnnotatedFunction<any[]>[]\n): CompletionCreateParams.Function[] {\n return entryPoints.map(annotatedFunctionToChatCompletionFunction);\n}\n\nfunction annotatedFunctionToChatCompletionFunction(\n annotatedFunction: AnnotatedFunction<any[]>\n): CompletionCreateParams.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: CompletionCreateParams.Function = {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n };\n\n return chatCompletionFunction;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/context/copilot-context.tsx"],"names":[],"mappings":";;;;;AAIA,OAAO,WAAW;AAJlB;AA0BA,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,MAAM,sBAAsB,EAAE;AAAA,EAChD,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AACxB;AAEO,IAAM,iBACX,MAAM,cAAoC,mBAAmB;AAE/D,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT","sourcesContent":["\"use client\";\n\nimport { FunctionCallHandler } from \"ai\";\nimport { CompletionCreateParams } from \"openai/resources/chat\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { AnnotatedFunction } from \"../types/annotated-function\";\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: () => CompletionCreateParams.Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n getContextString: (categories?: string[]) => string;\n addContext: (\n context: string,\n parentId?: string,\n categories?: string[]\n ) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: () => returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n};\n\nexport const CopilotContext =\n React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\n \"Remember to wrap your app in a `<CopilotProvider> {...} </CopilotProvider>` !!!\"\n );\n return value;\n}\n"]}