@copilotkit/react-textarea 0.35.0-multi-feature-usecopilotreadable.4 → 0.35.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 +428 -428
- package/CHANGELOG.md +92 -8
- package/dist/{chunk-3B3LGEDJ.mjs → chunk-COQISBP2.mjs} +2 -2
- package/dist/{chunk-FWZ23PN7.mjs → chunk-DMLXXOXD.mjs} +2 -2
- package/dist/{chunk-VPEH6V7T.mjs → chunk-FMQG2ZM3.mjs} +1 -1
- package/dist/chunk-FMQG2ZM3.mjs.map +1 -0
- package/dist/{chunk-Y5LVLSUK.mjs → chunk-OGLVRSCO.mjs} +7 -7
- package/dist/{chunk-HXEH4QQL.mjs → chunk-PQIOU3E5.mjs} +5 -5
- package/dist/{chunk-RT4UTBH3.mjs → chunk-SJ2TM5GA.mjs} +6 -2
- package/dist/chunk-SJ2TM5GA.mjs.map +1 -0
- package/dist/{chunk-QFG55HEW.mjs → chunk-XU5Z5BWV.mjs} +20 -20
- package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +16 -16
- package/dist/components/copilot-textarea/copilot-textarea.js +5 -1
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +23 -23
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +5 -5
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +3 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +4 -4
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +4 -4
- package/dist/components/index.js +5 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +23 -23
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.js.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +5 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -27
- package/package.json +6 -6
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +4 -1
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +6 -1
- package/dist/chunk-RT4UTBH3.mjs.map +0 -1
- package/dist/chunk-VPEH6V7T.mjs.map +0 -1
- /package/dist/{chunk-3B3LGEDJ.mjs.map → chunk-COQISBP2.mjs.map} +0 -0
- /package/dist/{chunk-FWZ23PN7.mjs.map → chunk-DMLXXOXD.mjs.map} +0 -0
- /package/dist/{chunk-Y5LVLSUK.mjs.map → chunk-OGLVRSCO.mjs.map} +0 -0
- /package/dist/{chunk-HXEH4QQL.mjs.map → chunk-PQIOU3E5.mjs.map} +0 -0
- /package/dist/{chunk-QFG55HEW.mjs.map → chunk-XU5Z5BWV.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,112 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 0.35.0
|
|
3
|
+
## 0.35.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 718520b: gpt-4-turbo-april-2024 function calling fixes
|
|
8
|
+
- 95bcbd8: streamline cloud configuration
|
|
9
|
+
- 95bcbd8: Rename
|
|
10
|
+
- 95bcbd8: Upgrade langchain
|
|
11
|
+
- 95bcbd8: Support input guardrails (cloud)
|
|
12
|
+
- 95bcbd8: Unify api key handling
|
|
13
|
+
- CopilotCloud V1, useCopilotReadable and more...
|
|
14
|
+
- 95bcbd8: Get api key from headers dict
|
|
15
|
+
- 95bcbd8: Update comments
|
|
16
|
+
- 95bcbd8: Include reason in guardrails response
|
|
17
|
+
- 718520b: gpt-4-turbo-april-2024
|
|
18
|
+
- 95bcbd8: Update comments
|
|
19
|
+
- 5f6f57a: fix backend function calling return values
|
|
20
|
+
- 95bcbd8: Retrieve public API key
|
|
8
21
|
|
|
9
22
|
### Patch Changes
|
|
10
23
|
|
|
24
|
+
- Updated dependencies [718520b]
|
|
25
|
+
- Updated dependencies [95bcbd8]
|
|
26
|
+
- Updated dependencies [95bcbd8]
|
|
27
|
+
- Updated dependencies [95bcbd8]
|
|
28
|
+
- Updated dependencies [95bcbd8]
|
|
29
|
+
- Updated dependencies [95bcbd8]
|
|
11
30
|
- Updated dependencies
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
- Updated dependencies [95bcbd8]
|
|
32
|
+
- Updated dependencies [95bcbd8]
|
|
33
|
+
- Updated dependencies [95bcbd8]
|
|
34
|
+
- Updated dependencies [718520b]
|
|
35
|
+
- Updated dependencies [95bcbd8]
|
|
36
|
+
- Updated dependencies [5f6f57a]
|
|
37
|
+
- Updated dependencies [95bcbd8]
|
|
38
|
+
- @copilotkit/react-core@0.25.0
|
|
39
|
+
- @copilotkit/shared@0.9.0
|
|
14
40
|
|
|
15
|
-
## 0.35.0-
|
|
41
|
+
## 0.35.0-mme-cloud.7
|
|
16
42
|
|
|
17
43
|
### Minor Changes
|
|
18
44
|
|
|
19
|
-
-
|
|
45
|
+
- Get api key from headers dict
|
|
20
46
|
|
|
21
47
|
### Patch Changes
|
|
22
48
|
|
|
23
49
|
- Updated dependencies
|
|
24
|
-
- @copilotkit/react-core@0.25.0-
|
|
25
|
-
- @copilotkit/shared@0.9.0-
|
|
50
|
+
- @copilotkit/react-core@0.25.0-mme-cloud.7
|
|
51
|
+
- @copilotkit/shared@0.9.0-mme-cloud.7
|
|
52
|
+
|
|
53
|
+
## 0.35.0-mme-cloud.6
|
|
54
|
+
|
|
55
|
+
### Minor Changes
|
|
56
|
+
|
|
57
|
+
- Upgrade langchain
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies
|
|
62
|
+
- @copilotkit/react-core@0.25.0-mme-cloud.6
|
|
63
|
+
- @copilotkit/shared@0.9.0-mme-cloud.6
|
|
64
|
+
|
|
65
|
+
## 0.35.0-mme-cloud.5
|
|
66
|
+
|
|
67
|
+
### Minor Changes
|
|
68
|
+
|
|
69
|
+
- Update comments
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies
|
|
74
|
+
- @copilotkit/react-core@0.25.0-mme-cloud.5
|
|
75
|
+
- @copilotkit/shared@0.9.0-mme-cloud.5
|
|
76
|
+
|
|
77
|
+
## 0.35.0-mme-cloud.4
|
|
78
|
+
|
|
79
|
+
### Minor Changes
|
|
80
|
+
|
|
81
|
+
- Update comments
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- Updated dependencies
|
|
86
|
+
- @copilotkit/react-core@0.25.0-mme-cloud.4
|
|
87
|
+
- @copilotkit/shared@0.9.0-mme-cloud.4
|
|
88
|
+
|
|
89
|
+
## 0.35.0-mme-cloud.3
|
|
90
|
+
|
|
91
|
+
### Minor Changes
|
|
92
|
+
|
|
93
|
+
- 85c029b: streamline cloud configuration
|
|
94
|
+
- Rename
|
|
95
|
+
- a5ade3b: Support input guardrails (cloud)
|
|
96
|
+
- 12ff590: Unify api key handling
|
|
97
|
+
- f0c4745: Include reason in guardrails response
|
|
98
|
+
- 17f4b1b: Retrieve public API key
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [85c029b]
|
|
103
|
+
- Updated dependencies
|
|
104
|
+
- Updated dependencies [a5ade3b]
|
|
105
|
+
- Updated dependencies [12ff590]
|
|
106
|
+
- Updated dependencies [f0c4745]
|
|
107
|
+
- Updated dependencies [17f4b1b]
|
|
108
|
+
- @copilotkit/react-core@0.25.0-mme-cloud.3
|
|
109
|
+
- @copilotkit/shared@0.9.0-mme-cloud.3
|
|
26
110
|
|
|
27
111
|
## 0.35.0-function-calling-fixes.2
|
|
28
112
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HoveringInsertionPromptBoxCore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OGLVRSCO.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -28,4 +28,4 @@ var HoveringInsertionPromptBox = (props) => {
|
|
|
28
28
|
export {
|
|
29
29
|
HoveringInsertionPromptBox
|
|
30
30
|
};
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
31
|
+
//# sourceMappingURL=chunk-COQISBP2.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HoveringInsertionPromptBox
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-COQISBP2.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useHoveringEditorContext
|
|
6
6
|
} from "./chunk-LYB4B6MK.mjs";
|
|
@@ -121,4 +121,4 @@ function editorState(editor, selection) {
|
|
|
121
121
|
export {
|
|
122
122
|
HoveringToolbar
|
|
123
123
|
};
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-DMLXXOXD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts"],"sourcesContent":["import React from \"react\";\nimport { Editor } from \"slate\";\nimport { ReactEditor } from \"slate-react\";\nimport { getFullEditorTextWithNewlines } from \"../../lib/get-text-around-cursor\";\nimport { replaceEditorText } from \"../../lib/slatejs-edits/replace-text\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function usePopulateCopilotTextareaRef(\n editor: Editor,\n ref: React.Ref<HTMLCopilotTextAreaElement>,\n) {\n React.useImperativeHandle(\n ref,\n () => {\n class Combined {\n constructor(\n private customMethods: CustomMethods,\n private editorHtmlElement: HTMLElement,\n ) {}\n\n [key: string]: any;\n\n get(target: any, propKey: string): any {\n if (this.isKeyOfCustomMethods(propKey)) {\n const value = this.customMethods[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.customMethods);\n }\n return value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n const value = this.editorHtmlElement[propKey];\n if (typeof value === \"function\") {\n return value.bind(this.editorHtmlElement);\n }\n return value;\n }\n }\n\n set(target: any, propKey: string, value: any): boolean {\n if (this.isKeyOfCustomMethods(propKey)) {\n (this.customMethods as any)[propKey] = value;\n } else if (this.isKeyOfHTMLElement(propKey)) {\n (this.editorHtmlElement as any)[propKey] = value;\n } else {\n // Default behavior (optional)\n target[propKey] = value;\n }\n return true;\n }\n\n private isKeyOfCustomMethods(key: string): key is keyof CustomMethods {\n return key in this.customMethods;\n }\n\n private isKeyOfHTMLElement(key: string): key is keyof HTMLElement {\n return key in this.editorHtmlElement;\n }\n }\n\n const handler = {\n get(target: any, propKey: keyof CustomMethods | keyof HTMLElement) {\n return target.get(target, propKey);\n },\n set(target: any, propKey: keyof CustomMethods | keyof HTMLElement, value: any) {\n return target.set(target, propKey, value);\n },\n };\n\n class CustomMethods {\n constructor(private editor: CustomEditor) {}\n\n focus() {\n ReactEditor.focus(this.editor);\n }\n\n blur() {\n ReactEditor.blur(this.editor);\n }\n\n get value() {\n return getFullEditorTextWithNewlines(this.editor);\n }\n set value(value: string) {\n replaceEditorText(this.editor, value);\n }\n }\n\n const editorHtmlElement = ReactEditor.toDOMNode(editor, editor);\n const customMethods = new CustomMethods(editor);\n\n const combined = new Combined(customMethods, editorHtmlElement);\n return new Proxy(combined, handler);\n },\n [editor],\n );\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,WAAW;AAElB,SAAS,mBAAmB;AAMrB,SAAS,8BACd,QACA,KACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA,MAAM;AACJ,YAAM,SAAS;AAAA,QACb,YACUA,gBACAC,oBACR;AAFQ,+BAAAD;AACA,mCAAAC;AAAA,QACP;AAAA,QAIH,IAAI,QAAa,SAAsB;AACrC,cAAI,KAAK,qBAAqB,OAAO,GAAG;AACtC,kBAAM,QAAQ,KAAK,cAAc,OAAO;AACxC,gBAAI,OAAO,UAAU,YAAY;AAC/B,qBAAO,MAAM,KAAK,KAAK,aAAa;AAAA,YACtC;AACA,mBAAO;AAAA,UACT,WAAW,KAAK,mBAAmB,OAAO,GAAG;AAC3C,kBAAM,QAAQ,KAAK,kBAAkB,OAAO;AAC5C,gBAAI,OAAO,UAAU,YAAY;AAC/B,qBAAO,MAAM,KAAK,KAAK,iBAAiB;AAAA,YAC1C;AACA,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,QAEA,IAAI,QAAa,SAAiB,OAAqB;AACrD,cAAI,KAAK,qBAAqB,OAAO,GAAG;AACtC,YAAC,KAAK,cAAsB,OAAO,IAAI;AAAA,UACzC,WAAW,KAAK,mBAAmB,OAAO,GAAG;AAC3C,YAAC,KAAK,kBAA0B,OAAO,IAAI;AAAA,UAC7C,OAAO;AAEL,mBAAO,OAAO,IAAI;AAAA,UACpB;AACA,iBAAO;AAAA,QACT;AAAA,QAEQ,qBAAqB,KAAyC;AACpE,iBAAO,OAAO,KAAK;AAAA,QACrB;AAAA,QAEQ,mBAAmB,KAAuC;AAChE,iBAAO,OAAO,KAAK;AAAA,QACrB;AAAA,MACF;AAEA,YAAM,UAAU;AAAA,QACd,IAAI,QAAa,SAAkD;AACjE,iBAAO,OAAO,IAAI,QAAQ,OAAO;AAAA,QACnC;AAAA,QACA,IAAI,QAAa,SAAkD,OAAY;AAC7E,iBAAO,OAAO,IAAI,QAAQ,SAAS,KAAK;AAAA,QAC1C;AAAA,MACF;AAEA,YAAM,cAAc;AAAA,QAClB,YAAoBC,SAAsB;AAAtB,wBAAAA;AAAA,QAAuB;AAAA,QAE3C,QAAQ;AACN,sBAAY,MAAM,KAAK,MAAM;AAAA,QAC/B;AAAA,QAEA,OAAO;AACL,sBAAY,KAAK,KAAK,MAAM;AAAA,QAC9B;AAAA,QAEA,IAAI,QAAQ;AACV,iBAAO,8BAA8B,KAAK,MAAM;AAAA,QAClD;AAAA,QACA,IAAI,MAAM,OAAe;AACvB,4BAAkB,KAAK,QAAQ,KAAK;AAAA,QACtC;AAAA,MACF;AAEA,YAAM,oBAAoB,YAAY,UAAU,QAAQ,MAAM;AAC9D,YAAM,gBAAgB,IAAI,cAAc,MAAM;AAE9C,YAAM,WAAW,IAAI,SAAS,eAAe,iBAAiB;AAC9D,aAAO,IAAI,MAAM,UAAU,OAAO;AAAA,IACpC;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACF;","names":["customMethods","editorHtmlElement","editor"]}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IncludedFilesPreview
|
|
3
3
|
} from "./chunk-YNXNMCDX.mjs";
|
|
4
|
+
import {
|
|
5
|
+
use_autosize_textarea_default
|
|
6
|
+
} from "./chunk-3PQ7GSFE.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Button
|
|
9
|
+
} from "./chunk-WFTAAA7R.mjs";
|
|
4
10
|
import {
|
|
5
11
|
Label
|
|
6
12
|
} from "./chunk-YFK5BFEI.mjs";
|
|
@@ -10,12 +16,6 @@ import {
|
|
|
10
16
|
import {
|
|
11
17
|
SourceSearchBox
|
|
12
18
|
} from "./chunk-4OZR65UB.mjs";
|
|
13
|
-
import {
|
|
14
|
-
Button
|
|
15
|
-
} from "./chunk-WFTAAA7R.mjs";
|
|
16
|
-
import {
|
|
17
|
-
use_autosize_textarea_default
|
|
18
|
-
} from "./chunk-3PQ7GSFE.mjs";
|
|
19
19
|
import {
|
|
20
20
|
streamPromiseFlatten
|
|
21
21
|
} from "./chunk-2QDCE7PD.mjs";
|
|
@@ -222,4 +222,4 @@ var HoveringInsertionPromptBoxCore = ({
|
|
|
222
222
|
export {
|
|
223
223
|
HoveringInsertionPromptBoxCore
|
|
224
224
|
};
|
|
225
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-OGLVRSCO.mjs.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useMakeStandardAutosuggestionFunction
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SJ2TM5GA.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useMakeStandardInsertionOrEditingFunction
|
|
6
6
|
} from "./chunk-QCPS6IYI.mjs";
|
|
7
|
-
import {
|
|
8
|
-
BaseCopilotTextarea
|
|
9
|
-
} from "./chunk-QFG55HEW.mjs";
|
|
10
7
|
import {
|
|
11
8
|
defaultAutosuggestionsConfig
|
|
12
9
|
} from "./chunk-DKE57EAC.mjs";
|
|
10
|
+
import {
|
|
11
|
+
BaseCopilotTextarea
|
|
12
|
+
} from "./chunk-XU5Z5BWV.mjs";
|
|
13
13
|
import {
|
|
14
14
|
__objRest,
|
|
15
15
|
__spreadProps,
|
|
@@ -57,4 +57,4 @@ var CopilotTextarea = React.forwardRef(
|
|
|
57
57
|
export {
|
|
58
58
|
CopilotTextarea
|
|
59
59
|
};
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-PQIOU3E5.mjs.map
|
|
@@ -8,11 +8,14 @@ import {
|
|
|
8
8
|
} from "./chunk-MRXNTQOX.mjs";
|
|
9
9
|
|
|
10
10
|
// src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
|
|
11
|
+
import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER } from "@copilotkit/shared";
|
|
11
12
|
import { CopilotContext } from "@copilotkit/react-core";
|
|
12
13
|
import { useCallback, useContext } from "react";
|
|
13
14
|
import { fetchAndDecodeChatCompletionAsText } from "@copilotkit/react-core";
|
|
14
15
|
function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
|
|
15
16
|
const { getContextString, copilotApiConfig } = useContext(CopilotContext);
|
|
17
|
+
const publicApiKey = copilotApiConfig.publicApiKey;
|
|
18
|
+
const headers = __spreadValues({}, publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
16
19
|
return useCallback(
|
|
17
20
|
(editorState, abortSignal) => __async(this, null, function* () {
|
|
18
21
|
const res = yield retry(() => __async(this, null, function* () {
|
|
@@ -40,7 +43,8 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
40
43
|
messages
|
|
41
44
|
}, apiConfig.forwardedParams), {
|
|
42
45
|
copilotConfig: copilotApiConfig,
|
|
43
|
-
signal: abortSignal
|
|
46
|
+
signal: abortSignal,
|
|
47
|
+
headers
|
|
44
48
|
}));
|
|
45
49
|
if (!response.events) {
|
|
46
50
|
throw new Error("Failed to fetch chat completion");
|
|
@@ -65,4 +69,4 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
65
69
|
export {
|
|
66
70
|
useMakeStandardAutosuggestionFunction
|
|
67
71
|
};
|
|
68
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-SJ2TM5GA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx"],"sourcesContent":["import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, Message } from \"@copilotkit/shared\";\nimport { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport { AutosuggestionsBareFunction, MinimalChatGPTMessage } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\nimport { fetchAndDecodeChatCompletionAsText } from \"@copilotkit/react-core\";\n\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardAutosuggestionFunction(\n textareaPurpose: string,\n contextCategories: string[],\n apiConfig: SuggestionsApiConfig,\n): AutosuggestionsBareFunction {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n const publicApiKey = copilotApiConfig.publicApiKey;\n const headers = {\n ...(publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {}),\n };\n\n return useCallback(\n async (editorState: InsertionEditorState, abortSignal: AbortSignal) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: apiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString([], contextCategories),\n ),\n },\n ...apiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n ];\n\n const response = await fetchAndDecodeChatCompletionAsText({\n messages: messages as Message[],\n ...apiConfig.forwardedParams,\n copilotConfig: copilotApiConfig,\n signal: abortSignal,\n headers: headers,\n });\n\n if (!response.events) {\n throw new Error(\"Failed to fetch chat completion\");\n }\n\n const reader = response.events.getReader();\n\n let result = \"\";\n while (!abortSignal.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n result += value;\n }\n return result;\n });\n\n return res;\n },\n [apiConfig, getContextString, contextCategories, textareaPurpose],\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,2CAAoD;AAC7D,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAKxC,SAAS,0CAA0C;AAe5C,SAAS,sCACd,iBACA,mBACA,WAC6B;AAC7B,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AACxE,QAAM,eAAe,iBAAiB;AACtC,QAAM,UAAU,mBACV,eAAe,EAAE,CAAC,mCAAmC,GAAG,aAAa,IAAI,CAAC;AAGhF,SAAO;AAAA,IACL,CAAO,aAAmC,gBAA6B;AACrE,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,UAAU;AAAA,cACjB;AAAA,cACA,iBAAiB,CAAC,GAAG,iBAAiB;AAAA,YACxC;AAAA,UACF;AAAA,UACA,GAAG,UAAU;AAAA,UACb;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,QACF;AAEA,cAAM,WAAW,MAAM,mCAAmC;AAAA,UACxD;AAAA,WACG,UAAU,kBAF2C;AAAA,UAGxD,eAAe;AAAA,UACf,QAAQ;AAAA,UACR;AAAA,QACF,EAAC;AAED,YAAI,CAAC,SAAS,QAAQ;AACpB,gBAAM,IAAI,MAAM,iCAAiC;AAAA,QACnD;AAEA,cAAM,SAAS,SAAS,OAAO,UAAU;AAEzC,YAAI,SAAS;AACb,eAAO,CAAC,YAAY,SAAS;AAC3B,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR;AAAA,UACF;AACA,oBAAU;AAAA,QACZ;AACA,eAAO;AAAA,MACT,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,WAAW,kBAAkB,mBAAmB,eAAe;AAAA,EAClE;AACF;","names":[]}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useCopilotTextareaEditor
|
|
3
|
+
} from "./chunk-DRV2FOHZ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
usePopulateCopilotTextareaRef
|
|
6
|
+
} from "./chunk-FMQG2ZM3.mjs";
|
|
1
7
|
import {
|
|
2
8
|
addAutocompletionsToEditor
|
|
3
9
|
} from "./chunk-2C7O2EVM.mjs";
|
|
4
10
|
import {
|
|
5
11
|
clearAutocompletionsFromEditor
|
|
6
12
|
} from "./chunk-GQN2HYFJ.mjs";
|
|
13
|
+
import {
|
|
14
|
+
replaceEditorText
|
|
15
|
+
} from "./chunk-5UNJXFUO.mjs";
|
|
16
|
+
import {
|
|
17
|
+
useAutosuggestions
|
|
18
|
+
} from "./chunk-QKS2IOUH.mjs";
|
|
19
|
+
import {
|
|
20
|
+
TrackerTextEditedSinceLastCursorMovement
|
|
21
|
+
} from "./chunk-LQ2OWQU7.mjs";
|
|
7
22
|
import {
|
|
8
23
|
useAddBrandingCss
|
|
9
24
|
} from "./chunk-7LSRNPNI.mjs";
|
|
10
25
|
import {
|
|
11
26
|
HoveringToolbar
|
|
12
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-DMLXXOXD.mjs";
|
|
13
28
|
import {
|
|
14
29
|
HoveringEditorProvider,
|
|
15
30
|
useHoveringEditorContext
|
|
16
31
|
} from "./chunk-LYB4B6MK.mjs";
|
|
32
|
+
import {
|
|
33
|
+
defaultBaseAutosuggestionsConfig
|
|
34
|
+
} from "./chunk-LCDTIJSD.mjs";
|
|
17
35
|
import {
|
|
18
36
|
makeRenderElementFunction
|
|
19
37
|
} from "./chunk-224UKA7C.mjs";
|
|
20
38
|
import {
|
|
21
39
|
makeRenderPlaceholderFunction
|
|
22
40
|
} from "./chunk-XW3ICO4S.mjs";
|
|
23
|
-
import {
|
|
24
|
-
TrackerTextEditedSinceLastCursorMovement
|
|
25
|
-
} from "./chunk-LQ2OWQU7.mjs";
|
|
26
|
-
import {
|
|
27
|
-
defaultBaseAutosuggestionsConfig
|
|
28
|
-
} from "./chunk-LCDTIJSD.mjs";
|
|
29
|
-
import {
|
|
30
|
-
useAutosuggestions
|
|
31
|
-
} from "./chunk-QKS2IOUH.mjs";
|
|
32
|
-
import {
|
|
33
|
-
useCopilotTextareaEditor
|
|
34
|
-
} from "./chunk-DRV2FOHZ.mjs";
|
|
35
|
-
import {
|
|
36
|
-
usePopulateCopilotTextareaRef
|
|
37
|
-
} from "./chunk-VPEH6V7T.mjs";
|
|
38
|
-
import {
|
|
39
|
-
replaceEditorText
|
|
40
|
-
} from "./chunk-5UNJXFUO.mjs";
|
|
41
41
|
import {
|
|
42
42
|
getFullEditorTextWithNewlines,
|
|
43
43
|
getTextAroundCollapsedCursor
|
|
@@ -256,4 +256,4 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
|
|
|
256
256
|
export {
|
|
257
257
|
BaseCopilotTextarea
|
|
258
258
|
};
|
|
259
|
-
//# sourceMappingURL=chunk-
|
|
259
|
+
//# sourceMappingURL=chunk-XU5Z5BWV.mjs.map
|