@copilotkit/react-textarea 0.26.0-alpha.3 → 0.26.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +189 -185
- package/CHANGELOG.md +11 -0
- package/dist/chunk-224UKA7C.mjs +33 -0
- package/dist/chunk-224UKA7C.mjs.map +1 -0
- package/dist/chunk-2C7O2EVM.mjs +27 -0
- package/dist/chunk-2C7O2EVM.mjs.map +1 -0
- package/dist/chunk-2QDCE7PD.mjs +29 -0
- package/dist/chunk-2QDCE7PD.mjs.map +1 -0
- package/dist/chunk-3PQ7GSFE.mjs +17 -0
- package/dist/chunk-3PQ7GSFE.mjs.map +1 -0
- package/dist/chunk-47L4PLG4.mjs +45 -0
- package/dist/chunk-47L4PLG4.mjs.map +1 -0
- package/dist/chunk-4NHVQZ67.mjs +107 -0
- package/dist/chunk-4NHVQZ67.mjs.map +1 -0
- package/dist/chunk-5FO6ISW4.mjs +3 -0
- package/dist/chunk-5FO6ISW4.mjs.map +1 -0
- package/dist/chunk-5UNJXFUO.mjs +29 -0
- package/dist/chunk-5UNJXFUO.mjs.map +1 -0
- package/dist/chunk-72P3KOHZ.mjs +91 -0
- package/dist/chunk-72P3KOHZ.mjs.map +1 -0
- package/dist/chunk-7LSRNPNI.mjs +59 -0
- package/dist/chunk-7LSRNPNI.mjs.map +1 -0
- package/dist/chunk-7SUZ6CXM.mjs +47 -0
- package/dist/chunk-7SUZ6CXM.mjs.map +1 -0
- package/dist/chunk-DE5K76I2.mjs +3 -0
- package/dist/chunk-DE5K76I2.mjs.map +1 -0
- package/dist/chunk-DRV2FOHZ.mjs +65 -0
- package/dist/chunk-DRV2FOHZ.mjs.map +1 -0
- package/dist/chunk-ECR45NSD.mjs +101 -0
- package/dist/chunk-ECR45NSD.mjs.map +1 -0
- package/dist/chunk-ELEY7HWW.mjs +202 -0
- package/dist/chunk-ELEY7HWW.mjs.map +1 -0
- package/dist/chunk-EPBVNDKE.mjs +46 -0
- package/dist/chunk-EPBVNDKE.mjs.map +1 -0
- package/dist/chunk-FJNUPSQK.mjs +72 -0
- package/dist/chunk-FJNUPSQK.mjs.map +1 -0
- package/dist/chunk-FP2EKU3L.mjs +28 -0
- package/dist/chunk-FP2EKU3L.mjs.map +1 -0
- package/dist/chunk-FRIYJQCI.mjs +99 -0
- package/dist/chunk-FRIYJQCI.mjs.map +1 -0
- package/dist/chunk-GQN2HYFJ.mjs +22 -0
- package/dist/chunk-GQN2HYFJ.mjs.map +1 -0
- package/dist/chunk-H4VKQGVU.mjs +3 -0
- package/dist/chunk-H4VKQGVU.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +3 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-JJLQVT7S.mjs +10 -0
- package/dist/chunk-JJLQVT7S.mjs.map +1 -0
- package/dist/chunk-K5LNB36H.mjs +80 -0
- package/dist/chunk-K5LNB36H.mjs.map +1 -0
- package/dist/chunk-KDVMG3XF.mjs +63 -0
- package/dist/chunk-KDVMG3XF.mjs.map +1 -0
- package/dist/chunk-KFQZHRPJ.mjs +19 -0
- package/dist/chunk-KFQZHRPJ.mjs.map +1 -0
- package/dist/chunk-KNBNKEXR.mjs +27 -0
- package/dist/chunk-KNBNKEXR.mjs.map +1 -0
- package/dist/chunk-KNQIEOFP.mjs +18 -0
- package/dist/chunk-KNQIEOFP.mjs.map +1 -0
- package/dist/chunk-L7VVZH4Q.mjs +3 -0
- package/dist/chunk-L7VVZH4Q.mjs.map +1 -0
- package/dist/chunk-LP2REBM5.mjs +217 -0
- package/dist/chunk-LP2REBM5.mjs.map +1 -0
- package/dist/chunk-M2DR4KVB.mjs +33 -0
- package/dist/chunk-M2DR4KVB.mjs.map +1 -0
- package/dist/chunk-MMVDU6DF.mjs +3 -0
- package/dist/chunk-MMVDU6DF.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +55 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-MTDBPK5D.mjs +53 -0
- package/dist/chunk-MTDBPK5D.mjs.map +1 -0
- package/dist/chunk-NRTYAQJE.mjs +46 -0
- package/dist/chunk-NRTYAQJE.mjs.map +1 -0
- package/dist/chunk-NTLVQENP.mjs +19 -0
- package/dist/chunk-NTLVQENP.mjs.map +1 -0
- package/dist/chunk-OHO4G6DR.mjs +19 -0
- package/dist/chunk-OHO4G6DR.mjs.map +1 -0
- package/dist/chunk-P4QVFRLY.mjs +103 -0
- package/dist/chunk-P4QVFRLY.mjs.map +1 -0
- package/dist/chunk-PTZVE6NC.mjs +94 -0
- package/dist/chunk-PTZVE6NC.mjs.map +1 -0
- package/dist/chunk-QDFAIRQF.mjs +45 -0
- package/dist/chunk-QDFAIRQF.mjs.map +1 -0
- package/dist/chunk-RBR32FWA.mjs +74 -0
- package/dist/chunk-RBR32FWA.mjs.map +1 -0
- package/dist/chunk-T6MTDQZ7.mjs +45 -0
- package/dist/chunk-T6MTDQZ7.mjs.map +1 -0
- package/dist/chunk-VPEH6V7T.mjs +83 -0
- package/dist/chunk-VPEH6V7T.mjs.map +1 -0
- package/dist/chunk-WADHCMPK.mjs +3 -0
- package/dist/chunk-WADHCMPK.mjs.map +1 -0
- package/dist/chunk-WFTAAA7R.mjs +44 -0
- package/dist/chunk-WFTAAA7R.mjs.map +1 -0
- package/dist/chunk-WJHSY5T6.mjs +3 -0
- package/dist/chunk-WJHSY5T6.mjs.map +1 -0
- package/dist/chunk-WTASPE2W.mjs +105 -0
- package/dist/chunk-WTASPE2W.mjs.map +1 -0
- package/dist/chunk-XV7MLLXQ.mjs +18 -0
- package/dist/chunk-XV7MLLXQ.mjs.map +1 -0
- package/dist/chunk-Y473E2ZQ.mjs +112 -0
- package/dist/chunk-Y473E2ZQ.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +35 -1745
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +3 -51
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +3 -49
- package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +4 -86
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +3 -57
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +47 -2202
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +3 -17
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +3 -137
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +18 -875
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +12 -558
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +13 -581
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +5 -102
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +14 -581
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.mjs +48 -2203
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +6 -5
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +6 -211
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.mjs +4 -85
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/card.mjs +7 -53
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.mjs +5 -244
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.mjs +4 -144
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.mjs +4 -60
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.mjs +8 -50
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.mjs +7 -48
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/context/index.mjs +2 -0
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +6 -158
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +4 -168
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +5 -148
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +14 -147
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +14 -193
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +3 -15
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.mjs +50 -2206
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.mjs +3 -51
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.mjs +3 -43
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +3 -102
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.mjs +3 -17
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +3 -25
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +3 -20
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +3 -27
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +3 -106
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +3 -47
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.mjs +3 -71
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.mjs +1 -0
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +2 -0
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +8 -265
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +3 -81
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +10 -327
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +3 -75
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +3 -83
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +2 -0
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +2 -0
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +3 -64
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/autosuggestion-state.mjs +2 -0
- package/dist/types/base/autosuggestion-state.mjs.map +1 -1
- package/dist/types/base/autosuggestions-bare-function.mjs +2 -0
- package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +3 -26
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/base-copilot-textarea-props.mjs +2 -0
- package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
- package/dist/types/base/custom-editor.mjs +2 -0
- package/dist/types/base/custom-editor.mjs.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +4 -17
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.mjs +4 -26
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +2 -0
- package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
- package/dist/types/index.mjs +12 -328
- package/dist/types/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { __async, __objRest, __spreadProps, __spreadValues };
|
|
54
|
+
//# sourceMappingURL=out.js.map
|
|
55
|
+
//# sourceMappingURL=chunk-MRXNTQOX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ChatlikeApiEndpoint } from './chunk-QDFAIRQF.mjs';
|
|
2
|
+
import { retry } from './chunk-KNQIEOFP.mjs';
|
|
3
|
+
import { __async } from './chunk-MRXNTQOX.mjs';
|
|
4
|
+
import { CopilotContext } from '@copilotkit/react-core';
|
|
5
|
+
import { useContext, useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
|
|
8
|
+
const { getContextString, copilotApiConfig } = useContext(CopilotContext);
|
|
9
|
+
return useCallback(
|
|
10
|
+
(editorState, abortSignal) => __async(this, null, function* () {
|
|
11
|
+
const res = yield retry(() => __async(this, null, function* () {
|
|
12
|
+
const messages = [
|
|
13
|
+
{
|
|
14
|
+
role: "system",
|
|
15
|
+
content: apiConfig.makeSystemPrompt(
|
|
16
|
+
textareaPurpose,
|
|
17
|
+
getContextString([], contextCategories)
|
|
18
|
+
)
|
|
19
|
+
},
|
|
20
|
+
...apiConfig.fewShotMessages,
|
|
21
|
+
{
|
|
22
|
+
role: "user",
|
|
23
|
+
name: "TextAfterCursor",
|
|
24
|
+
content: editorState.textAfterCursor
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
role: "user",
|
|
28
|
+
name: "TextBeforeCursor",
|
|
29
|
+
content: editorState.textBeforeCursor
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
|
|
33
|
+
const stream = yield apiEndpoint.run(abortSignal, messages, apiConfig.forwardedParams);
|
|
34
|
+
const reader = stream.getReader();
|
|
35
|
+
let result = "";
|
|
36
|
+
while (true) {
|
|
37
|
+
const { done, value } = yield reader.read();
|
|
38
|
+
if (done) {
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
result += value;
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}));
|
|
45
|
+
return res;
|
|
46
|
+
}),
|
|
47
|
+
[apiConfig, getContextString, contextCategories, textareaPurpose]
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { useMakeStandardAutosuggestionFunction };
|
|
52
|
+
//# sourceMappingURL=out.js.map
|
|
53
|
+
//# sourceMappingURL=chunk-MTDBPK5D.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAsBjC,SAAS,sCACd,iBACA,mBACA,WAC6B;AAC7B,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AAExE,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,cAAc,oBAAoB,qBAAqB,gBAAgB;AAC7E,cAAM,SAAS,MAAM,YAAY,IAAI,aAAa,UAAU,UAAU,eAAe;AAGrF,cAAM,SAAS,OAAO,UAAU;AAChC,YAAI,SAAS;AAEb,eAAO,MAAM;AACX,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR;AAAA,UACF;AACA,oBAAU;AAAA,QACZ;AAEA,eAAO;AAAA,MACT,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,WAAW,kBAAkB,mBAAmB,eAAe;AAAA,EAClE;AACF","sourcesContent":["import { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport {\n AutosuggestionsBareFunction,\n ChatlikeApiEndpoint,\n MinimalChatGPTMessage,\n} from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\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\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 apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);\n const stream = await apiEndpoint.run(abortSignal, messages, apiConfig.forwardedParams);\n\n // read the stream:\n const reader = stream.getReader();\n let result = \"\";\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n result += value;\n }\n\n return result;\n });\n\n return res;\n },\n [apiConfig, getContextString, contextCategories, textareaPurpose],\n );\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useMakeStandardAutosuggestionFunction } from './chunk-MTDBPK5D.mjs';
|
|
2
|
+
import { useMakeStandardInsertionOrEditingFunction } from './chunk-FRIYJQCI.mjs';
|
|
3
|
+
import { BaseCopilotTextarea } from './chunk-LP2REBM5.mjs';
|
|
4
|
+
import { defaultAutosuggestionsConfig } from './chunk-NTLVQENP.mjs';
|
|
5
|
+
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import merge from 'lodash.merge';
|
|
8
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
var CopilotTextarea = React.forwardRef(
|
|
11
|
+
(props, ref) => {
|
|
12
|
+
const _a = props, { autosuggestionsConfig: autosuggestionsConfigUserSpecified } = _a, forwardedProps = __objRest(_a, ["autosuggestionsConfig"]);
|
|
13
|
+
const autosuggestionsConfig = merge(
|
|
14
|
+
defaultAutosuggestionsConfig,
|
|
15
|
+
autosuggestionsConfigUserSpecified
|
|
16
|
+
);
|
|
17
|
+
const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(
|
|
18
|
+
autosuggestionsConfig.textareaPurpose,
|
|
19
|
+
autosuggestionsConfig.contextCategories,
|
|
20
|
+
autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig
|
|
21
|
+
);
|
|
22
|
+
const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(
|
|
23
|
+
autosuggestionsConfig.textareaPurpose,
|
|
24
|
+
autosuggestionsConfig.contextCategories,
|
|
25
|
+
autosuggestionsConfig.chatApiConfigs.insertionApiConfig,
|
|
26
|
+
autosuggestionsConfig.chatApiConfigs.editingApiConfig
|
|
27
|
+
);
|
|
28
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
29
|
+
BaseCopilotTextarea,
|
|
30
|
+
__spreadProps(__spreadValues({
|
|
31
|
+
ref
|
|
32
|
+
}, forwardedProps), {
|
|
33
|
+
baseAutosuggestionsConfig: __spreadProps(__spreadValues({}, autosuggestionsConfig), {
|
|
34
|
+
apiConfig: {
|
|
35
|
+
insertionOrEditingFunction,
|
|
36
|
+
autosuggestionsFunction
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
) });
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export { CopilotTextarea };
|
|
45
|
+
//# sourceMappingURL=out.js.map
|
|
46
|
+
//# sourceMappingURL=chunk-NRTYAQJE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/copilot-textarea/copilot-textarea.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAUlB,OAAO,WAAW;AAqCZ,mBACE,WADF;AAxBC,IAAM,kBAAkB,MAAM;AAAA,EACnC,CAAC,OAA6B,QAA4D;AAExF,UAAyF,YAAjF,yBAAuB,mCA3BnC,IA2B6F,IAAnB,2BAAmB,IAAnB,CAA9D;AAER,UAAM,wBAA+C;AAAA,MACnD;AAAA,MACA;AAAA,IACF;AAEA,UAAM,0BAA0B;AAAA,MAC9B,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,IACvC;AAEA,UAAM,6BAA6B;AAAA,MACjC,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,sBAAsB,eAAe;AAAA,MACrC,sBAAsB,eAAe;AAAA,IACvC;AAEA,WACE,gCACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,SACI,iBAFL;AAAA,QAGC,2BAA2B,iCACtB,wBADsB;AAAA,UAEzB,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF","sourcesContent":["// This example is for an Editor with `ReactEditor` and `HistoryEditor`\nimport React from \"react\";\nimport { useMakeStandardAutosuggestionFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function\";\nimport { HTMLCopilotTextAreaElement } from \"../../types\";\nimport { BaseCopilotTextareaProps } from \"../../types/base/base-copilot-textarea-props\";\nimport {\n AutosuggestionsConfig,\n defaultAutosuggestionsConfig,\n} from \"../../types/autosuggestions-config\";\nimport { BaseCopilotTextarea } from \"../base-copilot-textarea/base-copilot-textarea\";\nimport { useMakeStandardInsertionOrEditingFunction } from \"../../hooks/make-autosuggestions-function/use-make-standard-insertion-function\";\nimport merge from \"lodash.merge\";\nimport { AutosuggestionsConfigUserSpecified } from \"../../types/autosuggestions-config/autosuggestions-config-user-specified\";\n\n// Like the base copilot textarea props,\n// but with baseAutosuggestionsConfig replaced with autosuggestionsConfig.\nexport interface CopilotTextareaProps\n extends Omit<BaseCopilotTextareaProps, \"baseAutosuggestionsConfig\"> {\n autosuggestionsConfig: AutosuggestionsConfigUserSpecified;\n}\n\n/**\n * A copilot textarea that uses the standard autosuggestions function.\n */\nexport const CopilotTextarea = React.forwardRef(\n (props: CopilotTextareaProps, ref: React.Ref<HTMLCopilotTextAreaElement>): JSX.Element => {\n // separate the AutosuggestionsConfigUserSpecified from the rest of the props\n const { autosuggestionsConfig: autosuggestionsConfigUserSpecified, ...forwardedProps } = props;\n\n const autosuggestionsConfig: AutosuggestionsConfig = merge(\n defaultAutosuggestionsConfig,\n autosuggestionsConfigUserSpecified,\n );\n\n const autosuggestionsFunction = useMakeStandardAutosuggestionFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.contextCategories,\n autosuggestionsConfig.chatApiConfigs.suggestionsApiConfig,\n );\n\n const insertionOrEditingFunction = useMakeStandardInsertionOrEditingFunction(\n autosuggestionsConfig.textareaPurpose,\n autosuggestionsConfig.contextCategories,\n autosuggestionsConfig.chatApiConfigs.insertionApiConfig,\n autosuggestionsConfig.chatApiConfigs.editingApiConfig,\n );\n\n return (\n <>\n <BaseCopilotTextarea\n ref={ref}\n {...forwardedProps}\n baseAutosuggestionsConfig={{\n ...autosuggestionsConfig,\n apiConfig: {\n insertionOrEditingFunction: insertionOrEditingFunction,\n autosuggestionsFunction: autosuggestionsFunction,\n },\n }}\n />\n </>\n );\n },\n);\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defaultEditingApiConfig } from './chunk-K5LNB36H.mjs';
|
|
2
|
+
import { defaultInsertionsApiConfig } from './chunk-RBR32FWA.mjs';
|
|
3
|
+
import { defaultSuggestionsApiConfig } from './chunk-KDVMG3XF.mjs';
|
|
4
|
+
import { defaultBaseAutosuggestionsConfig } from './chunk-FP2EKU3L.mjs';
|
|
5
|
+
import { __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
6
|
+
import { defaultCopilotContextCategories } from '@copilotkit/react-core';
|
|
7
|
+
|
|
8
|
+
var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseAutosuggestionsConfig), {
|
|
9
|
+
contextCategories: defaultCopilotContextCategories,
|
|
10
|
+
chatApiConfigs: {
|
|
11
|
+
suggestionsApiConfig: defaultSuggestionsApiConfig,
|
|
12
|
+
insertionApiConfig: defaultInsertionsApiConfig,
|
|
13
|
+
editingApiConfig: defaultEditingApiConfig
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { defaultAutosuggestionsConfig };
|
|
18
|
+
//# sourceMappingURL=out.js.map
|
|
19
|
+
//# sourceMappingURL=chunk-NTLVQENP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/autosuggestions-config/autosuggestions-config.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAKA,SAAS,uCAAuC;AAczC,IAAM,+BAGT,iCACC,mCADD;AAAA,EAEF,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,IACd,sBAAsB;AAAA,IACtB,oBAAoB;AAAA,IACpB,kBAAkB;AAAA,EACpB;AACF","sourcesContent":["import { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from \"../base\";\nimport { SuggestionsApiConfig, defaultSuggestionsApiConfig } from \"./suggestions-api-config\";\nimport { InsertionsApiConfig, defaultInsertionsApiConfig } from \"./insertions-api-config\";\nimport { ChatlikeApiEndpoint } from \".\";\nimport { EditingApiConfig, defaultEditingApiConfig } from \"./editing-api-config\";\nimport { defaultCopilotContextCategories } from \"@copilotkit/react-core\";\n\n// Like the base autosuggestions config, with 2 additional fields:\n// 1. contextCategories: string[] | undefined;\n// 2. instead of apiConfigs, we have chatApiConfigs: a higher-level abstraction that uses a ChatGPT-like API endpoint.\nexport interface AutosuggestionsConfig extends Omit<BaseAutosuggestionsConfig, \"apiConfig\"> {\n contextCategories: string[];\n chatApiConfigs: {\n suggestionsApiConfig: SuggestionsApiConfig;\n insertionApiConfig: InsertionsApiConfig;\n editingApiConfig: EditingApiConfig;\n };\n}\n\nexport const defaultAutosuggestionsConfig: Omit<\n AutosuggestionsConfig,\n \"textareaPurpose\" | \"apiEndpoint\"\n> = {\n ...defaultBaseAutosuggestionsConfig,\n contextCategories: defaultCopilotContextCategories,\n chatApiConfigs: {\n suggestionsApiConfig: defaultSuggestionsApiConfig,\n insertionApiConfig: defaultInsertionsApiConfig,\n editingApiConfig: defaultEditingApiConfig,\n },\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
function makeRenderPlaceholderFunction(placeholderStyle) {
|
|
5
|
+
return (props) => {
|
|
6
|
+
const _a = props.attributes, { style } = _a, restAttributes = __objRest(_a, ["style"]);
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"div",
|
|
9
|
+
__spreadProps(__spreadValues({}, restAttributes), {
|
|
10
|
+
style: __spreadValues(__spreadValues({}, style), placeholderStyle),
|
|
11
|
+
children: props.children
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { makeRenderPlaceholderFunction };
|
|
18
|
+
//# sourceMappingURL=out.js.map
|
|
19
|
+
//# sourceMappingURL=chunk-OHO4G6DR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/base-copilot-textarea/render-placeholder.tsx"],"names":[],"mappings":";;;;;;;AAWM;AAPC,SAAS,8BACd,kBAC2B;AAC3B,SAAO,CAAC,UAAkC;AACxC,UAAqC,WAAM,YAAnC,QARZ,IAQyC,IAAnB,2BAAmB,IAAnB,CAAV;AAER,WACE;AAAA,MAAC;AAAA,uCACK,iBADL;AAAA,QAEC,OAAO,kCACF,QACA;AAAA,QAGJ,gBAAM;AAAA;AAAA,IACT;AAAA,EAEJ;AACF","sourcesContent":["import { RenderElementProps, RenderPlaceholderProps } from \"slate-react\";\n\nexport type RenderPlaceholderFunction = (props: RenderPlaceholderProps) => JSX.Element;\n\nexport function makeRenderPlaceholderFunction(\n placeholderStyle?: React.CSSProperties,\n): RenderPlaceholderFunction {\n return (props: RenderPlaceholderProps) => {\n const { style, ...restAttributes } = props.attributes;\n\n return (\n <div\n {...restAttributes}\n style={{\n ...style,\n ...placeholderStyle,\n }}\n >\n {props.children}\n </div>\n );\n };\n}\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
|
|
2
|
+
import { cx, css } from '@emotion/css';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var Button = React.forwardRef(
|
|
8
|
+
(_a, ref) => {
|
|
9
|
+
var _b = _a, {
|
|
10
|
+
className,
|
|
11
|
+
active,
|
|
12
|
+
reversed
|
|
13
|
+
} = _b, props = __objRest(_b, [
|
|
14
|
+
"className",
|
|
15
|
+
"active",
|
|
16
|
+
"reversed"
|
|
17
|
+
]);
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
"span",
|
|
20
|
+
__spreadProps(__spreadValues({}, props), {
|
|
21
|
+
ref,
|
|
22
|
+
className: cx(
|
|
23
|
+
className,
|
|
24
|
+
css`
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
color: ${reversed ? active ? "white" : "#aaa" : active ? "black" : "#ccc"};
|
|
27
|
+
`
|
|
28
|
+
)
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
var Icon = React.forwardRef(
|
|
34
|
+
(_a, ref) => {
|
|
35
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
"span",
|
|
38
|
+
__spreadProps(__spreadValues({}, props), {
|
|
39
|
+
ref,
|
|
40
|
+
className: cx(
|
|
41
|
+
"material-icons",
|
|
42
|
+
className,
|
|
43
|
+
css`
|
|
44
|
+
font-size: 18px;
|
|
45
|
+
vertical-align: text-bottom;
|
|
46
|
+
`
|
|
47
|
+
)
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
var Menu = React.forwardRef(
|
|
53
|
+
(_a, ref) => {
|
|
54
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
"div",
|
|
57
|
+
__spreadProps(__spreadValues({}, props), {
|
|
58
|
+
"data-test-id": "menu",
|
|
59
|
+
ref,
|
|
60
|
+
className: cx(
|
|
61
|
+
className,
|
|
62
|
+
css`
|
|
63
|
+
& > * {
|
|
64
|
+
display: inline-block;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
& > * + * {
|
|
68
|
+
margin-left: 15px;
|
|
69
|
+
}
|
|
70
|
+
`
|
|
71
|
+
)
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
var Portal = ({ children }) => {
|
|
77
|
+
return typeof document === "object" ? ReactDOM.createPortal(children, document.body) : null;
|
|
78
|
+
};
|
|
79
|
+
var Toolbar = React.forwardRef(
|
|
80
|
+
(_a, ref) => {
|
|
81
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
82
|
+
return /* @__PURE__ */ jsx(
|
|
83
|
+
Menu,
|
|
84
|
+
__spreadProps(__spreadValues({}, props), {
|
|
85
|
+
ref,
|
|
86
|
+
className: cx(
|
|
87
|
+
className,
|
|
88
|
+
css`
|
|
89
|
+
position: relative;
|
|
90
|
+
padding: 1px 18px 17px;
|
|
91
|
+
margin: 0 -20px;
|
|
92
|
+
border-bottom: 2px solid #eee;
|
|
93
|
+
margin-bottom: 20px;
|
|
94
|
+
`
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export { Button, Icon, Menu, Portal, Toolbar };
|
|
102
|
+
//# sourceMappingURL=out.js.map
|
|
103
|
+
//# sourceMappingURL=chunk-P4QVFRLY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/hovering-toolbar/hovering-toolbar-components.tsx"],"names":[],"mappings":";;;;;;;AAAA,SAAS,KAAK,UAAU;AACxB,OAAO,WAAuC;AAC9C,OAAO,cAAc;AAsBjB;AAfG,IAAM,SAAS,MAAM;AAAA,EAC1B,CACE,IAWA,QACA;AAZA,iBACE;AAAA;AAAA,MACA;AAAA,MACA;AAAA,IAdN,IAWI,IAIK,kBAJL,IAIK;AAAA,MAHH;AAAA,MACA;AAAA,MACA;AAAA;AAUF;AAAA,MAAC;AAAA,uCACK,QADL;AAAA,QAEC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA;AAAA,mBAEW,WAAY,SAAS,UAAU,SAAU,SAAS,UAAU;AAAA;AAAA,QAEzE;AAAA;AAAA,IACF;AAAA;AAEJ;AAEO,IAAM,OAAO,MAAM;AAAA,EACxB,CAAC,IAAuD,QAAkC;AAAzF,iBAAE,YAvCL,IAuCG,IAAgB,kBAAhB,IAAgB,CAAd;AACD;AAAA,MAAC;AAAA,uCACK,QADL;AAAA,QAEC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA;AAAA;AAAA;AAAA,QAIF;AAAA;AAAA,IACF;AAAA;AAEJ;AAEO,IAAM,OAAO,MAAM;AAAA,EACxB,CAAC,IAAuD,QAAiC;AAAxF,iBAAE,YAxDL,IAwDG,IAAgB,kBAAhB,IAAgB,CAAd;AACD;AAAA,MAAC;AAAA,uCACK,QADL;AAAA,QAEC,gBAAa;AAAA,QACb;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QASF;AAAA;AAAA,IACF;AAAA;AAEJ;AACO,IAAM,SAAS,CAAC,EAAE,SAAS,MAAqC;AACrE,SAAO,OAAO,aAAa,WAAW,SAAS,aAAa,UAAU,SAAS,IAAI,IAAI;AACzF;AAEO,IAAM,UAAU,MAAM;AAAA,EAC3B,CAAC,IAAuD,QAA2B;AAAlF,iBAAE,YAjFL,IAiFG,IAAgB,kBAAhB,IAAgB,CAAd;AACD;AAAA,MAAC;AAAA,uCACK,QADL;AAAA,QAEC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOF;AAAA;AAAA,IACF;AAAA;AAEJ","sourcesContent":["import { css, cx } from \"@emotion/css\";\nimport React, { PropsWithChildren, Ref } from \"react\";\nimport ReactDOM from \"react-dom\";\n\ninterface BaseProps {\n className: string;\n [key: string]: unknown;\n}\n\nexport const Button = React.forwardRef(\n (\n {\n className,\n active,\n reversed,\n ...props\n }: PropsWithChildren<\n {\n active: boolean;\n reversed: boolean;\n } & BaseProps\n >,\n ref: Ref<HTMLSpanElement | null>,\n ) => (\n <span\n {...props}\n ref={ref as Ref<HTMLSpanElement>}\n className={cx(\n className,\n css`\n cursor: pointer;\n color: ${reversed ? (active ? \"white\" : \"#aaa\") : active ? \"black\" : \"#ccc\"};\n `,\n )}\n />\n ),\n);\n\nexport const Icon = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLSpanElement | null>) => (\n <span\n {...props}\n ref={ref as Ref<HTMLSpanElement>}\n className={cx(\n \"material-icons\",\n className,\n css`\n font-size: 18px;\n vertical-align: text-bottom;\n `,\n )}\n />\n ),\n);\n\nexport const Menu = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLDivElement | null>) => (\n <div\n {...props}\n data-test-id=\"menu\"\n ref={ref as Ref<HTMLDivElement>}\n className={cx(\n className,\n css`\n & > * {\n display: inline-block;\n }\n\n & > * + * {\n margin-left: 15px;\n }\n `,\n )}\n />\n ),\n);\nexport const Portal = ({ children }: { children: React.ReactNode }) => {\n return typeof document === \"object\" ? ReactDOM.createPortal(children, document.body) : null;\n};\n\nexport const Toolbar = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref?: Ref<HTMLDivElement>) => (\n <Menu\n {...props}\n ref={ref}\n className={cx(\n className,\n css`\n position: relative;\n padding: 1px 18px 17px;\n margin: 0 -20px;\n border-bottom: 2px solid #eee;\n margin-bottom: 20px;\n `,\n )}\n />\n ),\n);\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { cn } from './chunk-7SUZ6CXM.mjs';
|
|
2
|
+
import { __objRest, __spreadValues, __spreadProps } from './chunk-MRXNTQOX.mjs';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
5
|
+
import { X } from 'lucide-react';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var Dialog = DialogPrimitive.Root;
|
|
9
|
+
var DialogTrigger = DialogPrimitive.Trigger;
|
|
10
|
+
var DialogPortal = (_a) => {
|
|
11
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
12
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Portal, __spreadValues({ className: cn(className) }, props));
|
|
13
|
+
};
|
|
14
|
+
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
15
|
+
var DialogOverlay = React.forwardRef((_a, ref) => {
|
|
16
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
DialogPrimitive.Overlay,
|
|
19
|
+
__spreadValues({
|
|
20
|
+
ref,
|
|
21
|
+
className: cn(
|
|
22
|
+
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
23
|
+
className
|
|
24
|
+
)
|
|
25
|
+
}, props)
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
29
|
+
var DialogContent = React.forwardRef((_a, ref) => {
|
|
30
|
+
var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
|
|
31
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
32
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
33
|
+
/* @__PURE__ */ jsxs(
|
|
34
|
+
DialogPrimitive.Content,
|
|
35
|
+
__spreadProps(__spreadValues({
|
|
36
|
+
ref,
|
|
37
|
+
className: cn(
|
|
38
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",
|
|
39
|
+
className
|
|
40
|
+
)
|
|
41
|
+
}, props), {
|
|
42
|
+
children: [
|
|
43
|
+
children,
|
|
44
|
+
/* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
|
|
45
|
+
/* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
|
|
46
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
47
|
+
] })
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
)
|
|
51
|
+
] });
|
|
52
|
+
});
|
|
53
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
54
|
+
var DialogHeader = (_a) => {
|
|
55
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
56
|
+
return /* @__PURE__ */ jsx("div", __spreadValues({ className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className) }, props));
|
|
57
|
+
};
|
|
58
|
+
DialogHeader.displayName = "DialogHeader";
|
|
59
|
+
var DialogFooter = (_a) => {
|
|
60
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
"div",
|
|
63
|
+
__spreadValues({
|
|
64
|
+
className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)
|
|
65
|
+
}, props)
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
DialogFooter.displayName = "DialogFooter";
|
|
69
|
+
var DialogTitle = React.forwardRef((_a, ref) => {
|
|
70
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
72
|
+
DialogPrimitive.Title,
|
|
73
|
+
__spreadValues({
|
|
74
|
+
ref,
|
|
75
|
+
className: cn("text-lg font-semibold leading-none tracking-tight", className)
|
|
76
|
+
}, props)
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
80
|
+
var DialogDescription = React.forwardRef((_a, ref) => {
|
|
81
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
82
|
+
return /* @__PURE__ */ jsx(
|
|
83
|
+
DialogPrimitive.Description,
|
|
84
|
+
__spreadValues({
|
|
85
|
+
ref,
|
|
86
|
+
className: cn("text-sm text-muted-foreground", className)
|
|
87
|
+
}, props)
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
91
|
+
|
|
92
|
+
export { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
|
|
93
|
+
//# sourceMappingURL=out.js.map
|
|
94
|
+
//# sourceMappingURL=chunk-PTZVE6NC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ui/dialog.tsx"],"names":[],"mappings":";;;;;;;;;;AAEA,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,SAAS,SAAS;AAShB,cAkCI,YAlCJ;AALF,IAAM,SAAyB;AAE/B,IAAM,gBAAgC;AAEtC,IAAM,eAAe,CAAC,OAA4D;AAA5D,eAAE,YAZxB,IAYsB,IAAgB,kBAAhB,IAAgB,CAAd;AACtB,6BAAiB,wBAAhB,iBAAuB,WAAW,GAAG,SAAS,KAAO,MAAO;AAAA;AAE/D,aAAa,cAA8B,uBAAO;AAElD,IAAM,gBAAsB,iBAG1B,CAAC,IAAyB,QAAK;AAA9B,eAAE,YApBL,IAoBG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,OACI;AAAA,EACN;AAAA,CACD;AACD,cAAc,cAA8B,wBAAQ;AAEpD,IAAM,gBAAsB,iBAG1B,CAAC,IAAmC,QAAK;AAAxC,eAAE,aAAW,SAnChB,IAmCG,IAA0B,kBAA1B,IAA0B,CAAxB,aAAW;AACd,8BAAC,gBACC;AAAA,wBAAC,iBAAc;AAAA,IACf;AAAA,MAAiB;AAAA,MAAhB;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,SACI,QANL;AAAA,QAQE;AAAA;AAAA,UACD,qBAAiB,uBAAhB,EAAsB,WAAU,iRAC/B;AAAA,gCAAC,KAAE,WAAU,WAAU;AAAA,YACvB,oBAAC,UAAK,WAAU,WAAU,mBAAK;AAAA,aACjC;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAAA,CACD;AACD,cAAc,cAA8B,wBAAQ;AAEpD,IAAM,eAAe,CAAC,OAA+D;AAA/D,eAAE,YAxDxB,IAwDsB,IAAgB,kBAAhB,IAAgB,CAAd;AACtB,6BAAC,wBAAI,WAAW,GAAG,sDAAsD,SAAS,KAAO,MAAO;AAAA;AAElG,aAAa,cAAc;AAE3B,IAAM,eAAe,CAAC,OAA+D;AAA/D,eAAE,YA7DxB,IA6DsB,IAAgB,kBAAhB,IAAgB,CAAd;AACtB;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,iEAAiE,SAAS;AAAA,OACpF;AAAA,EACN;AAAA;AAEF,aAAa,cAAc;AAE3B,IAAM,cAAoB,iBAGxB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAxEL,IAwEG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,WAAW,GAAG,qDAAqD,SAAS;AAAA,OACxE;AAAA,EACN;AAAA,CACD;AACD,YAAY,cAA8B,sBAAM;AAEhD,IAAM,oBAA0B,iBAG9B,CAAC,IAAyB,QAAK;AAA9B,eAAE,YApFL,IAoFG,IAAgB,kBAAhB,IAAgB,CAAd;AACH;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,WAAW,GAAG,iCAAiC,SAAS;AAAA,OACpD;AAAA,EACN;AAAA,CACD;AACD,kBAAkB,cAA8B,4BAAY","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = ({ className, ...props }: DialogPrimitive.DialogPortalProps) => (\n <DialogPrimitive.Portal className={cn(className)} {...props} />\n);\nDialogPortal.displayName = DialogPrimitive.Portal.displayName;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"flex flex-col space-y-1.5 text-center sm:text-left\", className)} {...props} />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\", className)}\n {...props}\n />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"text-lg font-semibold leading-none tracking-tight\", className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __async, __spreadValues, __spreadProps } from './chunk-MRXNTQOX.mjs';
|
|
2
|
+
import { copilotApiConfigExtrapolator } from '@copilotkit/react-core';
|
|
3
|
+
|
|
4
|
+
var ChatlikeApiEndpoint = class {
|
|
5
|
+
constructor(run) {
|
|
6
|
+
this.run = run;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new instance of ChatlikeApiEndpoint with the provided API endpoint.
|
|
10
|
+
* @param apiEndpoint The URL of the OpenAI-compatible API endpoint.
|
|
11
|
+
* @returns A new instance of ChatlikeApiEndpoint.
|
|
12
|
+
*/
|
|
13
|
+
static fromCopilotApiConfig(copilotApiConfig) {
|
|
14
|
+
return new ChatlikeApiEndpoint(
|
|
15
|
+
(abortSignal, messages, forwardedProps) => __async(this, null, function* () {
|
|
16
|
+
const res = yield fetch(copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint, {
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers: __spreadValues({}, copilotApiConfig.headers),
|
|
19
|
+
body: JSON.stringify(__spreadProps(__spreadValues(__spreadValues({}, forwardedProps), copilotApiConfig.body), {
|
|
20
|
+
messages
|
|
21
|
+
})),
|
|
22
|
+
signal: abortSignal
|
|
23
|
+
});
|
|
24
|
+
const bodySteram = res.body;
|
|
25
|
+
if (!bodySteram) {
|
|
26
|
+
throw new Error("The response body is empty.");
|
|
27
|
+
}
|
|
28
|
+
const stringStream = bodySteram.pipeThrough(new TextDecoderStream());
|
|
29
|
+
return stringStream;
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a fully customized instance of ChatlikeApiEndpoint.
|
|
35
|
+
* @param run - The implementation of the ChatlikeApiEndpointImpl interface.
|
|
36
|
+
* @returns A new instance of ChatlikeApiEndpoint .
|
|
37
|
+
*/
|
|
38
|
+
static custom(run) {
|
|
39
|
+
return new ChatlikeApiEndpoint(run);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { ChatlikeApiEndpoint };
|
|
44
|
+
//# sourceMappingURL=out.js.map
|
|
45
|
+
//# sourceMappingURL=chunk-QDFAIRQF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx"],"names":[],"mappings":";;;;;;;AAAA,SAA2B,oCAAoC;AAexD,IAAM,sBAAN,MAA0B;AAAA,EAG/B,YAAY,KAAuC;AACjD,SAAK,MAAM;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,qBAAqB,kBAAyD;AACnF,WAAO,IAAI;AAAA,MACT,CACE,aACA,UACA,mBACG;AACH,cAAM,MAAM,MAAM,MAAM,6BAA6B,gBAAgB,EAAE,iBAAiB;AAAA,UACtF,QAAQ;AAAA,UACR,SAAS,mBACJ,iBAAiB;AAAA,UAEtB,MAAM,KAAK,UAAU,gDAChB,iBACA,iBAAiB,OAFD;AAAA,YAGnB;AAAA,UACF,EAAC;AAAA,UACD,QAAQ;AAAA,QACV,CAAC;AAED,cAAM,aAAgD,IAAI;AAC1D,YAAI,CAAC,YAAY;AACf,gBAAM,IAAI,MAAM,6BAA6B;AAAA,QAC/C;AAGA,cAAM,eAAe,WAAW,YAAY,IAAI,kBAAkB,CAAC;AAEnE,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,OAAO,KAA4D;AACxE,WAAO,IAAI,oBAAoB,GAAG;AAAA,EACpC;AACF","sourcesContent":["import { CopilotApiConfig, copilotApiConfigExtrapolator } from \"@copilotkit/react-core\";\nimport { MinimalChatGPTMessage } from \"./minimal-chat-gpt-message\";\n\nexport type ChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n) => Promise<string>;\n\nexport type StreamingChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n) => Promise<ReadableStream<string>>;\n\nexport class ChatlikeApiEndpoint {\n public run: StreamingChatlikeApiEndpointImpl;\n\n constructor(run: StreamingChatlikeApiEndpointImpl) {\n this.run = run;\n }\n\n /**\n * Creates a new instance of ChatlikeApiEndpoint with the provided API endpoint.\n * @param apiEndpoint The URL of the OpenAI-compatible API endpoint.\n * @returns A new instance of ChatlikeApiEndpoint.\n */\n static fromCopilotApiConfig(copilotApiConfig: CopilotApiConfig): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(\n async (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n ) => {\n const res = await fetch(copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint, {\n method: \"POST\",\n headers: {\n ...copilotApiConfig.headers,\n },\n body: JSON.stringify({\n ...forwardedProps,\n ...copilotApiConfig.body,\n messages: messages,\n }),\n signal: abortSignal,\n });\n\n const bodySteram: ReadableStream<Uint8Array> | null = res.body;\n if (!bodySteram) {\n throw new Error(\"The response body is empty.\");\n }\n\n // map the stream to a stream of strings\n const stringStream = bodySteram.pipeThrough(new TextDecoderStream());\n\n return stringStream;\n },\n );\n }\n\n /**\n * Creates a fully customized instance of ChatlikeApiEndpoint.\n * @param run - The implementation of the ChatlikeApiEndpointImpl interface.\n * @returns A new instance of ChatlikeApiEndpoint .\n */\n static custom(run: StreamingChatlikeApiEndpointImpl): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(run);\n }\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// src/types/autosuggestions-config/insertions-api-config.tsx
|
|
2
|
+
var defaultInsertionsMakeSystemPrompt = (textareaPurpose, contextString) => {
|
|
3
|
+
return `You are a versatile writing assistant.
|
|
4
|
+
|
|
5
|
+
The user is writing some text.
|
|
6
|
+
The purpose is: "${textareaPurpose}"
|
|
7
|
+
|
|
8
|
+
The following external context is also provided. Use it to help you make better suggestions!!!
|
|
9
|
+
\`\`\`
|
|
10
|
+
${contextString}
|
|
11
|
+
\`\`\`
|
|
12
|
+
|
|
13
|
+
The user also provides you with a prompt for INSERTIONS into the text they are writing.
|
|
14
|
+
Your job is to come up with an INSERTION into the text that the user would like AS BEST YOU CAN.
|
|
15
|
+
Only insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.
|
|
16
|
+
|
|
17
|
+
Adjust yourself to the user's style and implied intent.
|
|
18
|
+
|
|
19
|
+
The user will provide the text before and after the cursor, as well as the insertion prompt. You should use this to infer the best relevant insertion.
|
|
20
|
+
<TextAfterCursor>
|
|
21
|
+
<TextBeforeCursor>
|
|
22
|
+
<InsertionPrompt>
|
|
23
|
+
<YourSuggestion>
|
|
24
|
+
`;
|
|
25
|
+
};
|
|
26
|
+
var defaultInsertionsFewShotMessages = [
|
|
27
|
+
{
|
|
28
|
+
role: "user",
|
|
29
|
+
name: "TextAfterCursor",
|
|
30
|
+
content: "While I was there I also picked up some apples, oranges, and bananas."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
role: "user",
|
|
34
|
+
name: "TextBeforeCursor",
|
|
35
|
+
content: "This morning I woke up and went straight to the grocery store."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
role: "user",
|
|
39
|
+
name: "InsertionPrompt",
|
|
40
|
+
content: "I bought a big watermelon"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
role: "assistant",
|
|
44
|
+
content: " When I arrived I went straight to the produce section and picked out a big watermelon. "
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
role: "user",
|
|
48
|
+
name: "TextAfterCursor",
|
|
49
|
+
content: "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
role: "user",
|
|
53
|
+
name: "TextBeforeCursor",
|
|
54
|
+
content: `The Optionholder, in the Optionholder's capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an "Equityholder" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an "Equityholder" thereunder;`
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
role: "user",
|
|
58
|
+
name: "InsertionPrompt",
|
|
59
|
+
content: "add section about the optionholder's pro rata share"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
role: "assistant",
|
|
63
|
+
content: ` (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder's "Pro Rata Share"; `
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
var defaultInsertionsApiConfig = {
|
|
67
|
+
makeSystemPrompt: defaultInsertionsMakeSystemPrompt,
|
|
68
|
+
fewShotMessages: defaultInsertionsFewShotMessages,
|
|
69
|
+
forwardedParams: void 0
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { defaultInsertionsApiConfig, defaultInsertionsFewShotMessages, defaultInsertionsMakeSystemPrompt };
|
|
73
|
+
//# sourceMappingURL=out.js.map
|
|
74
|
+
//# sourceMappingURL=chunk-RBR32FWA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/autosuggestions-config/insertions-api-config.tsx"],"names":[],"mappings":";AASO,IAAM,oCAAsD,CACjE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA,EAIlB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeF;AAEO,IAAM,mCAA4D;AAAA,EACvE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,6BAAkD;AAAA,EAC7D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB","sourcesContent":["import { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface InsertionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultInsertionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString,\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user also provides you with a prompt for INSERTIONS into the text they are writing. \nYour job is to come up with an INSERTION into the text that the user would like AS BEST YOU CAN.\nOnly insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide the text before and after the cursor, as well as the insertion prompt. You should use this to infer the best relevant insertion.\n<TextAfterCursor>\n<TextBeforeCursor>\n<InsertionPrompt>\n<YourSuggestion>\n`;\n};\n\nexport const defaultInsertionsFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"While I was there I also picked up some apples, oranges, and bananas.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: \"I bought a big watermelon\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n 'The Optionholder, in the Optionholder\\'s capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an \"Equityholder\" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an \"Equityholder\" thereunder;',\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: \"add section about the optionholder's pro rata share\",\n },\n {\n role: \"assistant\",\n content:\n ' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\\'s \"Pro Rata Share\"; ',\n },\n];\n\nexport const defaultInsertionsApiConfig: InsertionsApiConfig = {\n makeSystemPrompt: defaultInsertionsMakeSystemPrompt,\n fewShotMessages: defaultInsertionsFewShotMessages,\n forwardedParams: undefined,\n};\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Element } from 'slate';
|
|
2
|
+
|
|
3
|
+
// src/lib/editor-to-text.ts
|
|
4
|
+
function nodeChildrenToTextComponents(editor, nodes) {
|
|
5
|
+
const indeciesOfInlineElements = new Set(
|
|
6
|
+
nodes.map((node, index) => {
|
|
7
|
+
if (Element.isElement(node) && editor.isInline(node)) {
|
|
8
|
+
return index;
|
|
9
|
+
}
|
|
10
|
+
return -1;
|
|
11
|
+
}).filter((index) => index !== -1)
|
|
12
|
+
);
|
|
13
|
+
const nonIgnorableItems = nodes.filter((node, index) => {
|
|
14
|
+
const isInline = indeciesOfInlineElements.has(index);
|
|
15
|
+
if (isInline) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const isNeighbourOfInline = indeciesOfInlineElements.has(index - 1) || indeciesOfInlineElements.has(index + 1);
|
|
19
|
+
if (isNeighbourOfInline) {
|
|
20
|
+
return node.text !== "";
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
return nonIgnorableItems.map((node) => {
|
|
25
|
+
if (Element.isElement(node)) {
|
|
26
|
+
switch (node.type) {
|
|
27
|
+
case "paragraph":
|
|
28
|
+
return nodeChildrenToTextComponents(editor, node.children);
|
|
29
|
+
case "suggestion":
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
return [node];
|
|
34
|
+
}
|
|
35
|
+
}).reduce((acc, val) => acc.concat(val), []);
|
|
36
|
+
}
|
|
37
|
+
var editorToText = (editor) => {
|
|
38
|
+
const flattened = nodeChildrenToTextComponents(editor, editor.children);
|
|
39
|
+
const text = flattened.map((textComponent) => textComponent.text).join("\n");
|
|
40
|
+
return text;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { editorToText };
|
|
44
|
+
//# sourceMappingURL=out.js.map
|
|
45
|
+
//# sourceMappingURL=chunk-T6MTDQZ7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/editor-to-text.ts"],"names":[],"mappings":";AAAA,SAAiC,eAAe;AAKhD,SAAS,6BACP,QACA,OACuB;AAEvB,QAAM,2BAA2B,IAAI;AAAA,IACnC,MACG,IAAI,CAAC,MAAM,UAAU;AACpB,UAAI,QAAQ,UAAU,IAAI,KAAK,OAAO,SAAS,IAAI,GAAG;AACpD,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC,EACA,OAAO,CAAC,UAAU,UAAU,EAAE;AAAA,EACnC;AAIA,QAAM,oBAAoB,MAAM,OAAO,CAAC,MAAM,UAAU;AACtD,UAAM,WAAW,yBAAyB,IAAI,KAAK;AACnD,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAEA,UAAM,sBACJ,yBAAyB,IAAI,QAAQ,CAAC,KAAK,yBAAyB,IAAI,QAAQ,CAAC;AACnF,QAAI,qBAAqB;AACvB,aAAQ,KAAa,SAAS;AAAA,IAChC;AAEA,WAAO;AAAA,EACT,CAAC;AAED,SAAO,kBACJ,IAAI,CAAC,SAAS;AACb,QAAI,QAAQ,UAAU,IAAI,GAAG;AAC3B,cAAQ,KAAK,MAAM;AAAA,QACjB,KAAK;AACH,iBAAO,6BAA6B,QAAQ,KAAK,QAAQ;AAAA,QAC3D,KAAK;AACH,iBAAO,CAAC;AAAA,MACZ;AAAA,IACF,OAAO;AACL,aAAO,CAAC,IAAI;AAAA,IACd;AAAA,EACF,CAAC,EACA,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC;AAC7C;AAEO,IAAM,eAAe,CAAC,WAAqD;AAChF,QAAM,YAAY,6BAA6B,QAAQ,OAAO,QAAQ;AAEtE,QAAM,OAAO,UAAU,IAAI,CAAC,kBAAkB,cAAc,IAAI,EAAE,KAAK,IAAI;AAE3E,SAAO;AACT","sourcesContent":["import { BaseEditor, Descendant, Element } from \"slate\";\nimport { HistoryEditor } from \"slate-history\";\nimport { ReactEditor } from \"slate-react\";\nimport { SuggestionAwareText } from \"../types/base/custom-editor\";\n\nfunction nodeChildrenToTextComponents(\n editor: BaseEditor & ReactEditor & HistoryEditor,\n nodes: Descendant[],\n): SuggestionAwareText[] {\n // find inlineable elements\n const indeciesOfInlineElements = new Set(\n nodes\n .map((node, index) => {\n if (Element.isElement(node) && editor.isInline(node)) {\n return index;\n }\n return -1;\n })\n .filter((index) => index !== -1),\n );\n\n // ignorable elements = inline elements,\n // or neighbors of inline elements that are {text: \"\"}\n const nonIgnorableItems = nodes.filter((node, index) => {\n const isInline = indeciesOfInlineElements.has(index);\n if (isInline) {\n return false;\n }\n\n const isNeighbourOfInline =\n indeciesOfInlineElements.has(index - 1) || indeciesOfInlineElements.has(index + 1);\n if (isNeighbourOfInline) {\n return (node as any).text !== \"\";\n }\n\n return true;\n });\n\n return nonIgnorableItems\n .map((node) => {\n if (Element.isElement(node)) {\n switch (node.type) {\n case \"paragraph\":\n return nodeChildrenToTextComponents(editor, node.children);\n case \"suggestion\":\n return [];\n }\n } else {\n return [node];\n }\n })\n .reduce((acc, val) => acc.concat(val), []);\n}\n\nexport const editorToText = (editor: BaseEditor & ReactEditor & HistoryEditor) => {\n const flattened = nodeChildrenToTextComponents(editor, editor.children);\n\n const text = flattened.map((textComponent) => textComponent.text).join(\"\\n\");\n\n return text;\n};\n"]}
|