@copilotkit/react-textarea 0.37.0 → 0.38.0-beta.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.
Files changed (114) hide show
  1. package/.turbo/turbo-build.log +216 -224
  2. package/CHANGELOG.md +13 -0
  3. package/dist/chunk-3SVQJA5A.mjs +169 -0
  4. package/dist/chunk-3SVQJA5A.mjs.map +1 -0
  5. package/dist/chunk-5KLAWLCD.mjs +88 -0
  6. package/dist/chunk-5KLAWLCD.mjs.map +1 -0
  7. package/dist/{chunk-QKS2IOUH.mjs → chunk-7QFH4E7C.mjs} +7 -5
  8. package/dist/chunk-7QFH4E7C.mjs.map +1 -0
  9. package/dist/chunk-CVO5T3PA.mjs +82 -0
  10. package/dist/chunk-CVO5T3PA.mjs.map +1 -0
  11. package/dist/{chunk-DKE57EAC.mjs → chunk-H3PGQHLG.mjs} +5 -5
  12. package/dist/{chunk-RKQ6RTZM.mjs → chunk-I6DJQ7D7.mjs} +33 -38
  13. package/dist/chunk-I6DJQ7D7.mjs.map +1 -0
  14. package/dist/{chunk-VAJHETSN.mjs → chunk-IF7CDWEH.mjs} +5 -5
  15. package/dist/{chunk-VAJHETSN.mjs.map → chunk-IF7CDWEH.mjs.map} +1 -1
  16. package/dist/{chunk-LCDTIJSD.mjs → chunk-OJXLHIYQ.mjs} +4 -2
  17. package/dist/chunk-OJXLHIYQ.mjs.map +1 -0
  18. package/dist/{chunk-ZRKQLLC7.mjs → chunk-R77MK6QS.mjs} +10 -5
  19. package/dist/{chunk-ZRKQLLC7.mjs.map → chunk-R77MK6QS.mjs.map} +1 -1
  20. package/dist/{chunk-O4LDWYJB.mjs → chunk-TNGDQV3I.mjs} +1 -2
  21. package/dist/{chunk-O4LDWYJB.mjs.map → chunk-TNGDQV3I.mjs.map} +1 -1
  22. package/dist/{chunk-KDVMG3XF.mjs → chunk-WMHVBGPR.mjs} +23 -25
  23. package/dist/chunk-WMHVBGPR.mjs.map +1 -0
  24. package/dist/components/base-copilot-textarea/base-copilot-textarea.js +15 -7
  25. package/dist/components/base-copilot-textarea/base-copilot-textarea.js.map +1 -1
  26. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +4 -4
  27. package/dist/components/copilot-textarea/copilot-textarea.d.ts +2 -2
  28. package/dist/components/copilot-textarea/copilot-textarea.js +255 -207
  29. package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
  30. package/dist/components/copilot-textarea/copilot-textarea.mjs +11 -11
  31. package/dist/components/hovering-toolbar/hovering-toolbar.js +0 -1
  32. package/dist/components/hovering-toolbar/hovering-toolbar.js.map +1 -1
  33. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +1 -1
  34. package/dist/components/index.d.ts +1 -1
  35. package/dist/components/index.js +251 -203
  36. package/dist/components/index.js.map +1 -1
  37. package/dist/components/index.mjs +11 -11
  38. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +2 -1
  39. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js +6 -4
  40. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.js.map +1 -1
  41. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +1 -1
  42. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts +1 -1
  43. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +39 -31
  44. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
  45. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
  46. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.d.ts +1 -1
  47. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js +100 -60
  48. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.js.map +1 -1
  49. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +1 -1
  50. package/dist/index.d.ts +1 -1
  51. package/dist/index.js +251 -203
  52. package/dist/index.js.map +1 -1
  53. package/dist/index.mjs +11 -11
  54. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +1 -1
  55. package/dist/types/autosuggestions-config/autosuggestions-config.d.ts +1 -1
  56. package/dist/types/autosuggestions-config/autosuggestions-config.js +96 -108
  57. package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
  58. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +5 -5
  59. package/dist/types/autosuggestions-config/editing-api-config.d.ts +3 -3
  60. package/dist/types/autosuggestions-config/editing-api-config.js +39 -46
  61. package/dist/types/autosuggestions-config/editing-api-config.js.map +1 -1
  62. package/dist/types/autosuggestions-config/editing-api-config.mjs +1 -1
  63. package/dist/types/autosuggestions-config/index.d.ts +1 -1
  64. package/dist/types/autosuggestions-config/index.js +96 -108
  65. package/dist/types/autosuggestions-config/index.js.map +1 -1
  66. package/dist/types/autosuggestions-config/index.mjs +5 -5
  67. package/dist/types/autosuggestions-config/insertions-api-config.d.ts +3 -3
  68. package/dist/types/autosuggestions-config/insertions-api-config.js +32 -37
  69. package/dist/types/autosuggestions-config/insertions-api-config.js.map +1 -1
  70. package/dist/types/autosuggestions-config/insertions-api-config.mjs +1 -1
  71. package/dist/types/autosuggestions-config/suggestions-api-config.d.ts +3 -3
  72. package/dist/types/autosuggestions-config/suggestions-api-config.js +22 -24
  73. package/dist/types/autosuggestions-config/suggestions-api-config.js.map +1 -1
  74. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +1 -1
  75. package/dist/types/base/base-autosuggestions-config.d.ts +14 -0
  76. package/dist/types/base/base-autosuggestions-config.js +3 -1
  77. package/dist/types/base/base-autosuggestions-config.js.map +1 -1
  78. package/dist/types/base/base-autosuggestions-config.mjs +1 -1
  79. package/dist/types/base/index.js +3 -1
  80. package/dist/types/base/index.js.map +1 -1
  81. package/dist/types/base/index.mjs +1 -1
  82. package/dist/types/index.d.ts +1 -1
  83. package/dist/types/index.js +96 -108
  84. package/dist/types/index.js.map +1 -1
  85. package/dist/types/index.mjs +5 -5
  86. package/package.json +7 -6
  87. package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +5 -0
  88. package/src/components/copilot-textarea/copilot-textarea.tsx +1 -1
  89. package/src/components/hovering-toolbar/hovering-toolbar.tsx +0 -1
  90. package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +11 -4
  91. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +51 -31
  92. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +116 -62
  93. package/src/types/autosuggestions-config/editing-api-config.tsx +48 -49
  94. package/src/types/autosuggestions-config/index.ts +0 -1
  95. package/src/types/autosuggestions-config/insertions-api-config.tsx +38 -40
  96. package/src/types/autosuggestions-config/suggestions-api-config.tsx +26 -27
  97. package/src/types/base/base-autosuggestions-config.tsx +17 -0
  98. package/dist/chunk-4OJ3H65F.mjs +0 -89
  99. package/dist/chunk-4OJ3H65F.mjs.map +0 -1
  100. package/dist/chunk-HE4GMS2P.mjs +0 -121
  101. package/dist/chunk-HE4GMS2P.mjs.map +0 -1
  102. package/dist/chunk-KDVMG3XF.mjs.map +0 -1
  103. package/dist/chunk-LCDTIJSD.mjs.map +0 -1
  104. package/dist/chunk-QKS2IOUH.mjs.map +0 -1
  105. package/dist/chunk-RKQ6RTZM.mjs.map +0 -1
  106. package/dist/chunk-SJ2TM5GA.mjs +0 -72
  107. package/dist/chunk-SJ2TM5GA.mjs.map +0 -1
  108. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.d.ts +0 -7
  109. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js +0 -19
  110. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js.map +0 -1
  111. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -1
  112. package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +0 -1
  113. package/src/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.tsx +0 -5
  114. /package/dist/{chunk-DKE57EAC.mjs.map → chunk-H3PGQHLG.mjs.map} +0 -0
@@ -1,9 +1,10 @@
1
+ import { Message, Role, TextMessage } from "@copilotkit/runtime-client-gql";
1
2
  import { MakeSystemPrompt } from "./subtypes/make-system-prompt";
2
- import { MinimalChatGPTMessage } from "./subtypes/minimal-chat-gpt-message";
3
+ import { nanoid } from "nanoid";
3
4
 
4
5
  export interface InsertionsApiConfig {
5
6
  makeSystemPrompt: MakeSystemPrompt;
6
- fewShotMessages: MinimalChatGPTMessage[];
7
+ fewShotMessages: Message[];
7
8
  forwardedParams: { [key: string]: any } | undefined;
8
9
  }
9
10
 
@@ -38,49 +39,46 @@ The conversation will be structured as follows:
38
39
  `;
39
40
  };
40
41
 
41
- export const defaultInsertionsFewShotMessages: MinimalChatGPTMessage[] = [
42
- {
43
- role: "user",
44
- name: "TextAfterCursor",
45
- content: "While I was there I also picked up some apples, oranges, and bananas.",
46
- },
47
- {
48
- role: "user",
49
- name: "TextBeforeCursor",
50
- content: "This morning I woke up and went straight to the grocery store.",
51
- },
52
- {
53
- role: "user",
54
- name: "InsertionPrompt",
55
- content: "I bought a big watermelon",
56
- },
57
- {
58
- role: "assistant",
42
+ export const defaultInsertionsFewShotMessages: Message[] = [
43
+ new TextMessage({
44
+ role: Role.User,
59
45
  content:
60
- " When I arrived I went straight to the produce section and picked out a big watermelon. ",
61
- },
62
- {
63
- role: "user",
64
- name: "TextAfterCursor",
46
+ "<TextAfterCursor>While I was there I also picked up some apples, oranges, and bananas.</TextAfterCursor>",
47
+ }),
48
+ new TextMessage({
49
+ role: Role.User,
65
50
  content:
66
- "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.",
67
- },
68
- {
69
- role: "user",
70
- name: "TextBeforeCursor",
51
+ "<TextBeforeCursor>This morning I woke up and went straight to the grocery store.</TextBeforeCursor>",
52
+ }),
53
+ new TextMessage({
54
+ role: Role.User,
55
+ content: "<InsertionPrompt>I bought a big watermelon</InsertionPrompt>",
56
+ }),
57
+ new TextMessage({
58
+ role: Role.Assistant,
71
59
  content:
72
- '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;',
73
- },
74
- {
75
- role: "user",
76
- name: "InsertionPrompt",
77
- content: "add section about the optionholder's pro rata share",
78
- },
79
- {
80
- role: "assistant",
60
+ "When I arrived I went straight to the produce section and picked out a big watermelon.",
61
+ }),
62
+ new TextMessage({
63
+ role: Role.User,
64
+ content:
65
+ "<TextAfterCursor>and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.</TextAfterCursor>",
66
+ }),
67
+ new TextMessage({
68
+ role: Role.User,
69
+ content:
70
+ '<TextBeforeCursor>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;</TextBeforeCursor>',
71
+ }),
72
+ new TextMessage({
73
+ role: Role.User,
74
+ content:
75
+ "<InsertionPrompt>add section about the optionholder's pro rata share</InsertionPrompt>",
76
+ }),
77
+ new TextMessage({
78
+ role: Role.Assistant,
81
79
  content:
82
80
  ' (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"; ',
83
- },
81
+ }),
84
82
  ];
85
83
 
86
84
  export const defaultInsertionsApiConfig: InsertionsApiConfig = {
@@ -1,9 +1,10 @@
1
- import { MinimalChatGPTMessage } from "./subtypes/minimal-chat-gpt-message";
1
+ import { Message, Role, TextMessage } from "@copilotkit/runtime-client-gql";
2
2
  import { MakeSystemPrompt } from "./subtypes/make-system-prompt";
3
+ import { nanoid } from "nanoid";
3
4
 
4
5
  export interface SuggestionsApiConfig {
5
6
  makeSystemPrompt: MakeSystemPrompt;
6
- fewShotMessages: MinimalChatGPTMessage[];
7
+ fewShotMessages: Message[];
7
8
  forwardedParams: { [key: string]: any } | undefined;
8
9
  }
9
10
 
@@ -35,38 +36,36 @@ ${contextString}
35
36
  `;
36
37
  };
37
38
 
38
- export const defaultSuggestionsFewShotMessages: MinimalChatGPTMessage[] = [
39
- {
40
- role: "user",
41
- name: "TextAfterCursor",
42
- content: "While I was there I also picked up some apples, oranges, and bananas.",
43
- },
44
- {
45
- role: "user",
39
+ export const defaultSuggestionsFewShotMessages: Message[] = [
40
+ new TextMessage({
41
+ role: Role.User,
42
+ content:
43
+ "<TextAfterCursor>While I was there I also picked up some apples, oranges, and bananas.</TextAfterCursor>",
44
+ }),
45
+ new TextMessage({
46
+ role: Role.User,
46
47
  content: "This morning I woke up and went straight to the grocery store.",
47
- },
48
- {
49
- role: "assistant",
48
+ }),
49
+ new TextMessage({
50
+ role: Role.Assistant,
50
51
  content:
51
52
  " When I arrived I went straight to the produce section and picked out a big watermelon. ",
52
- },
53
- {
54
- role: "user",
55
- name: "TextAfterCursor",
53
+ }),
54
+ new TextMessage({
55
+ role: Role.User,
56
56
  content:
57
- "and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.",
58
- },
59
- {
60
- role: "user",
61
- name: "TextBeforeCursor",
57
+ "<TextAfterCursor>and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.</TextAfterCursor>",
58
+ }),
59
+ new TextMessage({
60
+ role: Role.User,
62
61
  content:
63
- '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;',
64
- },
65
- {
66
- role: "assistant",
62
+ '<TextBeforeCursor>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;</TextBeforeCursor>',
63
+ }),
64
+ new TextMessage({
65
+ role: Role.Assistant,
67
66
  content:
68
67
  ' (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"; ',
69
- },
68
+ }),
70
69
  ];
71
70
 
72
71
  export const defaultSuggestionsApiConfig: SuggestionsApiConfig = {
@@ -30,6 +30,18 @@ import { defaultCopilotContextCategories } from "@copilotkit/react-core";
30
30
  * }
31
31
  * ```
32
32
  *
33
+ * @property {(event: React.TouchEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnTouch - A function that determines whether to accept the current autosuggestion based on a mobile touch event. By default, the touching the end of a suggestion will accept it. Example code:
34
+ *
35
+ * ```typescript
36
+ * const shouldAcceptAutosuggestionOnTouch = (event: React.TouchEvent<HTMLDivElement>) => {
37
+ * // if tab, accept the autosuggestion
38
+ * if (event.type === "touchstart") {
39
+ * return true;
40
+ * }
41
+ * return false;
42
+ * }
43
+ * ```
44
+ *
33
45
  * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event. By default, the Command + K key combination is used to toggle the hovering editor. Example code:
34
46
  *
35
47
  * ```typescript
@@ -52,6 +64,7 @@ export interface BaseAutosuggestionsConfig {
52
64
  disabled: boolean;
53
65
  temporarilyDisableWhenMovingCursorWithoutChangingText: boolean;
54
66
  shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;
67
+ shouldAcceptAutosuggestionOnTouch: (event: React.TouchEvent<HTMLDivElement>) => boolean;
55
68
  shouldToggleHoveringEditorOnKeyPress: (
56
69
  event: React.KeyboardEvent<HTMLDivElement>,
57
70
  shortcut: string,
@@ -80,6 +93,8 @@ const defaultShouldAcceptAutosuggestionOnKeyPress = (
80
93
  return false;
81
94
  };
82
95
 
96
+ const defaultShouldAcceptAutosuggestionOnTouch = () => true;
97
+
83
98
  /**
84
99
  * Default configuration for the BaseAutosuggestions.
85
100
  *
@@ -90,6 +105,7 @@ const defaultShouldAcceptAutosuggestionOnKeyPress = (
90
105
  * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable the autosuggestions when the cursor is moved without changing the text.
91
106
  * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event.
92
107
  * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the autosuggestion based on a key press event.
108
+ * @property {() => boolean} defaultShouldAcceptAutosuggestionOnTouch - A function that determines whether to accept the autosuggestion based on a mobile touch event.
93
109
  */
94
110
 
95
111
  export const defaultBaseAutosuggestionsConfig: Omit<
@@ -103,4 +119,5 @@ export const defaultBaseAutosuggestionsConfig: Omit<
103
119
  temporarilyDisableWhenMovingCursorWithoutChangingText: true,
104
120
  shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,
105
121
  shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress,
122
+ shouldAcceptAutosuggestionOnTouch: defaultShouldAcceptAutosuggestionOnTouch,
106
123
  };
@@ -1,89 +0,0 @@
1
- // src/types/autosuggestions-config/editing-api-config.tsx
2
- var defaultEditingMakeSystemPrompt = (textareaPurpose, contextString) => {
3
- return `You are a versatile writing assistant helping the user edit a portion of their text.
4
-
5
- The user is writing some text.
6
- The purpose is: "${textareaPurpose}"
7
-
8
- The following external context is also provided. Use it when relevant.
9
- \`\`\`
10
- ${contextString}
11
- \`\`\`
12
-
13
- The user has provided you with a PROMPT for EDITING a PORTION of the text.
14
- Your job is to come up with a new EDITED version OF THE SEGMENT IN QUESTION - AS BEST YOU CAN.
15
- Only rewrite the portion of the text that the user has marked as "TextToEdit"!!!
16
-
17
- Adjust yourself to the user's style and implied intent.
18
-
19
- The conversation will be structured as follows:
20
- <TextBeforeCursor>
21
- <TextToEdit>
22
- <TextAfterCursor>
23
- <EditingPrompt>
24
-
25
- <YourEditSuggestion>
26
- `;
27
- };
28
- var defaultEditingFewShotMessages = [
29
- {
30
- role: "user",
31
- name: "TextBeforeCursor",
32
- content: "This morning I woke up and went straight to the grocery store. "
33
- },
34
- {
35
- role: "user",
36
- name: "TextToEdit",
37
- content: "While I was there I picked up some apples, oranges, and bananas. "
38
- },
39
- {
40
- role: "user",
41
- name: "TextAfterCursor",
42
- content: "The grocery store was having a sale on fruit, so I decided to stock up."
43
- },
44
- {
45
- role: "user",
46
- name: "EditingPrompt",
47
- content: "I also bought a big watermelon"
48
- },
49
- {
50
- role: "assistant",
51
- content: "While I was there I picked up some apples, oranges, and bananas, and a big watermelon."
52
- },
53
- {
54
- role: "user",
55
- name: "TextBeforeCursor",
56
- content: "Yesterday, I spent the afternoon working on my new project. "
57
- },
58
- {
59
- role: "user",
60
- name: "TextToEdit",
61
- content: "It's quite challenging and requires a lot of focus. "
62
- },
63
- {
64
- role: "user",
65
- name: "TextAfterCursor",
66
- content: "I'm really excited about the potential outcomes of this project."
67
- },
68
- {
69
- role: "user",
70
- name: "EditingPrompt",
71
- content: "emphasize the complexity and my enthusiasm for the project"
72
- },
73
- {
74
- role: "assistant",
75
- content: "It's a highly complex task that demands intense concentration, but I'm incredibly enthusiastic about the promising prospects of this project."
76
- }
77
- ];
78
- var defaultEditingApiConfig = {
79
- makeSystemPrompt: defaultEditingMakeSystemPrompt,
80
- fewShotMessages: defaultEditingFewShotMessages,
81
- forwardedParams: void 0
82
- };
83
-
84
- export {
85
- defaultEditingMakeSystemPrompt,
86
- defaultEditingFewShotMessages,
87
- defaultEditingApiConfig
88
- };
89
- //# sourceMappingURL=chunk-4OJ3H65F.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/autosuggestions-config/editing-api-config.tsx"],"sourcesContent":["import { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface EditingApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultEditingMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString,\n) => {\n return `You are a versatile writing assistant helping the user edit a portion of their text.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it when relevant.\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user has provided you with a PROMPT for EDITING a PORTION of the text. \nYour job is to come up with a new EDITED version OF THE SEGMENT IN QUESTION - AS BEST YOU CAN.\nOnly rewrite the portion of the text that the user has marked as \"TextToEdit\"!!!\n\nAdjust yourself to the user's style and implied intent.\n\nThe conversation will be structured as follows:\n<TextBeforeCursor>\n<TextToEdit>\n<TextAfterCursor>\n<EditingPrompt>\n\n<YourEditSuggestion>\n`;\n};\n\nexport const defaultEditingFewShotMessages: MinimalChatGPTMessage[] = [\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: \"TextToEdit\",\n content: \"While I was there I picked up some apples, oranges, and bananas. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"The grocery store was having a sale on fruit, so I decided to stock up.\",\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: \"I also bought a big watermelon\",\n },\n {\n role: \"assistant\",\n content:\n \"While I was there I picked up some apples, oranges, and bananas, and a big watermelon.\",\n },\n\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: \"Yesterday, I spent the afternoon working on my new project. \",\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content: \"It's quite challenging and requires a lot of focus. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"I'm really excited about the potential outcomes of this project.\",\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: \"emphasize the complexity and my enthusiasm for the project\",\n },\n {\n role: \"assistant\",\n content:\n \"It's a highly complex task that demands intense concentration, but I'm incredibly enthusiastic about the promising prospects of this project.\",\n },\n];\n\nexport const defaultEditingApiConfig: EditingApiConfig = {\n makeSystemPrompt: defaultEditingMakeSystemPrompt,\n fewShotMessages: defaultEditingFewShotMessages,\n forwardedParams: undefined,\n};\n"],"mappings":";AASO,IAAM,iCAAmD,CAC9D,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;AAAA;AAAA;AAiBF;AAEO,IAAM,gCAAyD;AAAA,EACpE;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,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EAEA;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,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,0BAA4C;AAAA,EACvD,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB;","names":[]}
@@ -1,121 +0,0 @@
1
- import {
2
- retry
3
- } from "./chunk-KNQIEOFP.mjs";
4
- import {
5
- __async,
6
- __spreadProps,
7
- __spreadValues
8
- } from "./chunk-MRXNTQOX.mjs";
9
-
10
- // src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
11
- import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER } from "@copilotkit/shared";
12
- import { CopilotContext } from "@copilotkit/react-core";
13
- import { useCallback, useContext } from "react";
14
- import { fetchAndDecodeChatCompletionAsText } from "@copilotkit/react-core";
15
- function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
16
- const { getContextString, copilotApiConfig } = useContext(CopilotContext);
17
- const headers = __spreadValues({}, copilotApiConfig.publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {});
18
- const insertionFunction = useCallback(
19
- (editorState, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
20
- const res = yield retry(() => __async(this, null, function* () {
21
- const messages = [
22
- {
23
- role: "system",
24
- content: insertionApiConfig.makeSystemPrompt(
25
- textareaPurpose,
26
- getContextString(documents, contextCategories)
27
- )
28
- },
29
- ...insertionApiConfig.fewShotMessages,
30
- {
31
- role: "user",
32
- name: "TextAfterCursor",
33
- content: editorState.textAfterCursor
34
- },
35
- {
36
- role: "user",
37
- name: "TextBeforeCursor",
38
- content: editorState.textBeforeCursor
39
- },
40
- {
41
- role: "user",
42
- name: "InsertionPrompt",
43
- content: insertionPrompt
44
- }
45
- ];
46
- const stream = yield fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
47
- messages
48
- }, insertionApiConfig.forwardedParams), {
49
- copilotConfig: copilotApiConfig,
50
- signal: abortSignal,
51
- headers
52
- }));
53
- return stream.events;
54
- }));
55
- return res;
56
- }),
57
- [insertionApiConfig, getContextString, contextCategories, textareaPurpose]
58
- );
59
- const editingFunction = useCallback(
60
- (editorState, editingPrompt, documents, abortSignal) => __async(this, null, function* () {
61
- const res = yield retry(() => __async(this, null, function* () {
62
- const messages = [
63
- {
64
- role: "system",
65
- content: editingApiConfig.makeSystemPrompt(
66
- textareaPurpose,
67
- getContextString(documents, contextCategories)
68
- )
69
- },
70
- ...editingApiConfig.fewShotMessages,
71
- {
72
- role: "user",
73
- name: "TextBeforeCursor",
74
- content: editorState.textBeforeCursor
75
- },
76
- {
77
- role: "user",
78
- name: "TextToEdit",
79
- content: editorState.selectedText
80
- },
81
- {
82
- role: "user",
83
- name: "TextAfterCursor",
84
- content: editorState.textAfterCursor
85
- },
86
- {
87
- role: "user",
88
- name: "EditingPrompt",
89
- content: editingPrompt
90
- }
91
- ];
92
- const stream = yield fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
93
- messages
94
- }, editingApiConfig.forwardedParams), {
95
- copilotConfig: copilotApiConfig,
96
- signal: abortSignal,
97
- headers
98
- }));
99
- return stream.events;
100
- }));
101
- return res;
102
- }),
103
- [editingApiConfig, getContextString, contextCategories, textareaPurpose]
104
- );
105
- const insertionOrEditingFunction = useCallback(
106
- (editorState, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
107
- if (editorState.selectedText === "") {
108
- return yield insertionFunction(editorState, insertionPrompt, documents, abortSignal);
109
- } else {
110
- return yield editingFunction(editorState, insertionPrompt, documents, abortSignal);
111
- }
112
- }),
113
- [insertionFunction, editingFunction]
114
- );
115
- return insertionOrEditingFunction;
116
- }
117
-
118
- export {
119
- useMakeStandardInsertionOrEditingFunction
120
- };
121
- //# sourceMappingURL=chunk-HE4GMS2P.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-insertion-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 { MinimalChatGPTMessage } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n InsertionEditorApiConfig,\n InsertionEditorState,\n} from \"../../types/base/autosuggestions-bare-function\";\nimport { InsertionsApiConfig } from \"../../types/autosuggestions-config/insertions-api-config\";\nimport { EditingApiConfig } from \"../../types/autosuggestions-config/editing-api-config\";\nimport { DocumentPointer } from \"@copilotkit/react-core\";\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 useMakeStandardInsertionOrEditingFunction(\n textareaPurpose: string,\n contextCategories: string[],\n insertionApiConfig: InsertionsApiConfig,\n editingApiConfig: EditingApiConfig,\n): Generator_InsertionOrEditingSuggestion {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n const headers = {\n ...(copilotApiConfig.publicApiKey\n ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }\n : {}),\n };\n\n const insertionFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: insertionApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n },\n ...insertionApiConfig.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 role: \"user\",\n name: \"InsertionPrompt\",\n content: insertionPrompt,\n },\n ];\n\n const stream = await fetchAndDecodeChatCompletionAsText({\n messages: messages as Message[],\n ...insertionApiConfig.forwardedParams,\n copilotConfig: copilotApiConfig,\n signal: abortSignal,\n headers,\n });\n return stream.events!;\n });\n\n return res;\n },\n [insertionApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const editingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n editingPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: editingApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n },\n ...editingApiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content: editorState.selectedText,\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: editingPrompt,\n },\n ];\n\n const stream = await fetchAndDecodeChatCompletionAsText({\n messages: messages as Message[],\n ...editingApiConfig.forwardedParams,\n copilotConfig: copilotApiConfig,\n signal: abortSignal,\n headers,\n });\n return stream.events!;\n });\n\n return res;\n },\n [editingApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const insertionOrEditingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n if (editorState.selectedText === \"\") {\n return await insertionFunction(editorState, insertionPrompt, documents, abortSignal);\n } else {\n return await editingFunction(editorState, insertionPrompt, documents, abortSignal);\n }\n },\n [insertionFunction, editingFunction],\n );\n\n return insertionOrEditingFunction;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,2CAAoD;AAC7D,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAYxC,SAAS,0CAA0C;AAe5C,SAAS,0CACd,iBACA,mBACA,oBACA,kBACwC;AACxC,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AACxE,QAAM,UAAU,mBACV,iBAAiB,eACjB,EAAE,CAAC,mCAAmC,GAAG,iBAAiB,aAAa,IACvE,CAAC;AAGP,QAAM,oBAAoB;AAAA,IACxB,CACE,aACA,iBACA,WACA,gBACG;AACH,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,mBAAmB;AAAA,cAC1B;AAAA,cACA,iBAAiB,WAAW,iBAAiB;AAAA,YAC/C;AAAA,UACF;AAAA,UACA,GAAG,mBAAmB;AAAA,UACtB;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,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,UACX;AAAA,QACF;AAEA,cAAM,SAAS,MAAM,mCAAmC;AAAA,UACtD;AAAA,WACG,mBAAmB,kBAFgC;AAAA,UAGtD,eAAe;AAAA,UACf,QAAQ;AAAA,UACR;AAAA,QACF,EAAC;AACD,eAAO,OAAO;AAAA,MAChB,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,oBAAoB,kBAAkB,mBAAmB,eAAe;AAAA,EAC3E;AAEA,QAAM,kBAAkB;AAAA,IACtB,CACE,aACA,eACA,WACA,gBACG;AACH,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,iBAAiB;AAAA,cACxB;AAAA,cACA,iBAAiB,WAAW,iBAAiB;AAAA,YAC/C;AAAA,UACF;AAAA,UACA,GAAG,iBAAiB;AAAA,UACpB;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,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,UACX;AAAA,QACF;AAEA,cAAM,SAAS,MAAM,mCAAmC;AAAA,UACtD;AAAA,WACG,iBAAiB,kBAFkC;AAAA,UAGtD,eAAe;AAAA,UACf,QAAQ;AAAA,UACR;AAAA,QACF,EAAC;AACD,eAAO,OAAO;AAAA,MAChB,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,kBAAkB,kBAAkB,mBAAmB,eAAe;AAAA,EACzE;AAEA,QAAM,6BAA6B;AAAA,IACjC,CACE,aACA,iBACA,WACA,gBACG;AACH,UAAI,YAAY,iBAAiB,IAAI;AACnC,eAAO,MAAM,kBAAkB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACrF,OAAO;AACL,eAAO,MAAM,gBAAgB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACnF;AAAA,IACF;AAAA,IACA,CAAC,mBAAmB,eAAe;AAAA,EACrC;AAEA,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/autosuggestions-config/suggestions-api-config.tsx"],"sourcesContent":["import { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\nimport { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\n\nexport interface SuggestionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultSuggestionsMakeSystemPrompt: 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\nYour job is to guess what the user will write next AS BEST YOU CAN.\nOnly guess a SHORT distance ahead. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide both the text before and after the cursor. You should use this to infer what the user is likely to write next.\n<TextAfterCursor>\n<TextBeforeCursor>\n<YourSuggestion>\n\nIf we need to add a whitespace character to the suggested text, make sure to explicitly add it in.\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n`;\n};\n\nexport const defaultSuggestionsFewShotMessages: 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 content: \"This morning I woke up and went straight to the grocery store.\",\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: \"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 defaultSuggestionsApiConfig: SuggestionsApiConfig = {\n makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,\n fewShotMessages: defaultSuggestionsFewShotMessages,\n forwardedParams: undefined,\n};\n"],"mappings":";AASO,IAAM,qCAAuD,CAClE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBlB;AAAA;AAAA;AAGF;AAEO,IAAM,oCAA6D;AAAA,EACxE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,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,SACE;AAAA,EACJ;AACF;AAEO,IAAM,8BAAoD;AAAA,EAC/D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/base/base-autosuggestions-config.tsx"],"sourcesContent":["import { BaseCopilotTextareaApiConfig } from \"./autosuggestions-bare-function\";\nimport { defaultCopilotContextCategories } from \"@copilotkit/react-core\";\n\n/**\n * @interface BaseAutosuggestionsConfig\n *\n * @property {string} textareaPurpose - The purpose of the textarea. This is used to guide the autosuggestions.\n *\n * @property {string[]} contextCategories - The categories of context to consider when providing autosuggestions.\n *\n * @property {number} debounceTime - The amount of time (in milliseconds) to wait before triggering autosuggestions after the user has stopped typing.\n *\n * @property {BaseCopilotTextareaApiConfig} apiConfig - The configuration for the API that provides the autosuggestions.\n *\n * @property {boolean} disableWhenEmpty - Whether to disable autosuggestions when the textarea is empty.\n *\n * @property {boolean} disabled - Whether to disable autosuggestions entirely.\n *\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable autosuggestions when the user moves the cursor without changing the text.\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the current autosuggestion based on a key press event. By default, the Tab key is used to accept the autosuggestion. Example code:\n *\n * ```typescript\n * const defaultShouldAcceptAutosuggestionOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if tab, accept the autosuggestion\n * if (event.key === \"Tab\") {\n * return true;\n * }\n * return false;\n * }\n * ```\n *\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event. By default, the Command + K key combination is used to toggle the hovering editor. Example code:\n *\n * ```typescript\n * const defaultShouldToggleHoveringEditorOnKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {\n * // if command-k, toggle the hovering editor\n * if (event.key === \"k\" && event.metaKey) {\n * return true;\n * }\n * return false;\n * }\n * ```\n */\nexport interface BaseAutosuggestionsConfig {\n textareaPurpose: string;\n contextCategories: string[];\n debounceTime: number;\n apiConfig: BaseCopilotTextareaApiConfig;\n\n disableWhenEmpty: boolean;\n disabled: boolean;\n temporarilyDisableWhenMovingCursorWithoutChangingText: boolean;\n shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean;\n shouldToggleHoveringEditorOnKeyPress: (\n event: React.KeyboardEvent<HTMLDivElement>,\n shortcut: string,\n ) => boolean;\n}\n\n// by default, command-k toggles the hovering editor\nconst defaultShouldToggleHoveringEditorOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n shortcut: string,\n) => {\n // if command-k, toggle the hovering editor\n if (event.key === shortcut && event.metaKey) {\n return true;\n }\n return false;\n};\n\nconst defaultShouldAcceptAutosuggestionOnKeyPress = (\n event: React.KeyboardEvent<HTMLDivElement>,\n) => {\n // if tab, accept the autosuggestion\n if (event.key === \"Tab\") {\n return true;\n }\n return false;\n};\n\n/**\n * Default configuration for the BaseAutosuggestions.\n *\n * @property {number} debounceTime - The amount of time to wait before triggering the autosuggestions API call.\n * @property {string[]} contextCategories - The categories to use for context when making the autosuggestions API call.\n * @property {boolean} disableWhenEmpty - Whether to disable the autosuggestions when the textarea is empty.\n * @property {boolean} disabled - Whether to disable the autosuggestions feature entirely.\n * @property {boolean} temporarilyDisableWhenMovingCursorWithoutChangingText - Whether to temporarily disable the autosuggestions when the cursor is moved without changing the text.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldToggleHoveringEditorOnKeyPress - A function that determines whether to toggle the hovering editor based on a key press event.\n * @property {(event: React.KeyboardEvent<HTMLDivElement>) => boolean} shouldAcceptAutosuggestionOnKeyPress - A function that determines whether to accept the autosuggestion based on a key press event.\n */\n\nexport const defaultBaseAutosuggestionsConfig: Omit<\n BaseAutosuggestionsConfig,\n \"textareaPurpose\" | \"apiConfig\"\n> = {\n debounceTime: 250,\n contextCategories: defaultCopilotContextCategories,\n disableWhenEmpty: true,\n disabled: false,\n temporarilyDisableWhenMovingCursorWithoutChangingText: true,\n shouldToggleHoveringEditorOnKeyPress: defaultShouldToggleHoveringEditorOnKeyPress,\n shouldAcceptAutosuggestionOnKeyPress: defaultShouldAcceptAutosuggestionOnKeyPress,\n};\n"],"mappings":";AACA,SAAS,uCAAuC;AA4DhD,IAAM,8CAA8C,CAClD,OACA,aACG;AAEH,MAAI,MAAM,QAAQ,YAAY,MAAM,SAAS;AAC3C,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAM,8CAA8C,CAClD,UACG;AAEH,MAAI,MAAM,QAAQ,OAAO;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAcO,IAAM,mCAGT;AAAA,EACF,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,uDAAuD;AAAA,EACvD,sCAAsC;AAAA,EACtC,sCAAsC;AACxC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Debouncer } from \"../../lib/debouncer\";\nimport { nullableCompatibleEqualityCheck } from \"../../lib/utils\";\nimport { AutosuggestionsBareFunction } from \"../../types/base\";\nimport { AutosuggestionState } from \"../../types/base/autosuggestion-state\";\nimport {\n EditorAutocompleteState,\n areEqual_autocompleteState,\n} from \"../../types/base/editor-autocomplete-state\";\n\nexport interface UseAutosuggestionsResult {\n currentAutocompleteSuggestion: AutosuggestionState | null;\n onChangeHandler: (newEditorState: EditorAutocompleteState | null) => void;\n onKeyDownHandler: (event: React.KeyboardEvent<HTMLDivElement>) => void;\n}\n\nexport function useAutosuggestions(\n debounceTime: number,\n shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean,\n autosuggestionFunction: AutosuggestionsBareFunction,\n insertAutocompleteSuggestion: (suggestion: AutosuggestionState) => void,\n disableWhenEmpty: boolean,\n disabled: boolean,\n): UseAutosuggestionsResult {\n const [previousAutocompleteState, setPreviousAutocompleteState] =\n useState<EditorAutocompleteState | null>(null);\n\n const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] =\n useState<AutosuggestionState | null>(null);\n\n const awaitForAndAppendSuggestion: (\n editorAutocompleteState: EditorAutocompleteState,\n abortSignal: AbortSignal,\n ) => Promise<void> = useCallback(\n async (editorAutocompleteState: EditorAutocompleteState, abortSignal: AbortSignal) => {\n // early return if disabled\n if (disabled) {\n return;\n }\n\n if (\n disableWhenEmpty &&\n editorAutocompleteState.textBeforeCursor === \"\" &&\n editorAutocompleteState.textAfterCursor === \"\"\n ) {\n return;\n }\n\n // fetch the suggestion\n const suggestion = await autosuggestionFunction(editorAutocompleteState, abortSignal);\n\n // We'll assume for now that the autocomplete function might or might not respect the abort signal.\n if (!suggestion || abortSignal.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n\n setCurrentAutocompleteSuggestion({\n text: suggestion,\n point: editorAutocompleteState.cursorPoint,\n });\n },\n [autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled],\n );\n\n const debouncedFunction = useMemo(\n () => new Debouncer<[editorAutocompleteState: EditorAutocompleteState]>(debounceTime),\n [debounceTime],\n );\n\n // clean current state when unmounting or disabling\n useEffect(() => {\n return () => {\n debouncedFunction.cancel();\n setCurrentAutocompleteSuggestion(null);\n };\n }, [debouncedFunction, disabled]);\n\n const onChange = useCallback(\n (newEditorState: EditorAutocompleteState | null) => {\n const editorStateHasChanged = !nullableCompatibleEqualityCheck(\n areEqual_autocompleteState,\n previousAutocompleteState,\n newEditorState,\n );\n setPreviousAutocompleteState(newEditorState);\n\n // if no change, do nothing\n if (!editorStateHasChanged) {\n return;\n }\n\n // if change, then first null out the current suggestion\n setCurrentAutocompleteSuggestion(null);\n\n // then try to get a new suggestion, debouncing to avoid too many requests while typing\n if (newEditorState) {\n debouncedFunction.debounce(awaitForAndAppendSuggestion, newEditorState);\n } else {\n debouncedFunction.cancel();\n }\n },\n [\n previousAutocompleteState,\n setPreviousAutocompleteState,\n debouncedFunction,\n awaitForAndAppendSuggestion,\n setCurrentAutocompleteSuggestion,\n ],\n );\n\n const keyDownHandler = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (currentAutocompleteSuggestion) {\n if (shouldAcceptAutosuggestionOnKeyPress(event)) {\n event.preventDefault();\n insertAutocompleteSuggestion(currentAutocompleteSuggestion);\n setCurrentAutocompleteSuggestion(null);\n }\n }\n },\n [\n currentAutocompleteSuggestion,\n setCurrentAutocompleteSuggestion,\n insertAutocompleteSuggestion,\n shouldAcceptAutosuggestionOnKeyPress,\n ],\n );\n\n return {\n currentAutocompleteSuggestion,\n onChangeHandler: onChange,\n onKeyDownHandler: keyDownHandler,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,aAAa,WAAW,SAAS,gBAAgB;AAgBnD,SAAS,mBACd,cACA,sCACA,wBACA,8BACA,kBACA,UAC0B;AAC1B,QAAM,CAAC,2BAA2B,4BAA4B,IAC5D,SAAyC,IAAI;AAE/C,QAAM,CAAC,+BAA+B,gCAAgC,IACpE,SAAqC,IAAI;AAE3C,QAAM,8BAGe;AAAA,IACnB,CAAO,yBAAkD,gBAA6B;AAEpF,UAAI,UAAU;AACZ;AAAA,MACF;AAEA,UACE,oBACA,wBAAwB,qBAAqB,MAC7C,wBAAwB,oBAAoB,IAC5C;AACA;AAAA,MACF;AAGA,YAAM,aAAa,MAAM,uBAAuB,yBAAyB,WAAW;AAGpF,UAAI,CAAC,cAAc,YAAY,SAAS;AACtC,cAAM,IAAI,aAAa,WAAW,YAAY;AAAA,MAChD;AAEA,uCAAiC;AAAA,QAC/B,MAAM;AAAA,QACN,OAAO,wBAAwB;AAAA,MACjC,CAAC;AAAA,IACH;AAAA,IACA,CAAC,wBAAwB,kCAAkC,kBAAkB,QAAQ;AAAA,EACvF;AAEA,QAAM,oBAAoB;AAAA,IACxB,MAAM,IAAI,UAA8D,YAAY;AAAA,IACpF,CAAC,YAAY;AAAA,EACf;AAGA,YAAU,MAAM;AACd,WAAO,MAAM;AACX,wBAAkB,OAAO;AACzB,uCAAiC,IAAI;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,mBAAmB,QAAQ,CAAC;AAEhC,QAAM,WAAW;AAAA,IACf,CAAC,mBAAmD;AAClD,YAAM,wBAAwB,CAAC;AAAA,QAC7B;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,mCAA6B,cAAc;AAG3C,UAAI,CAAC,uBAAuB;AAC1B;AAAA,MACF;AAGA,uCAAiC,IAAI;AAGrC,UAAI,gBAAgB;AAClB,0BAAkB,SAAS,6BAA6B,cAAc;AAAA,MACxE,OAAO;AACL,0BAAkB,OAAO;AAAA,MAC3B;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB;AAAA,IACrB,CAAC,UAA+C;AAC9C,UAAI,+BAA+B;AACjC,YAAI,qCAAqC,KAAK,GAAG;AAC/C,gBAAM,eAAe;AACrB,uCAA6B,6BAA6B;AAC1D,2CAAiC,IAAI;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,EACpB;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/autosuggestions-config/insertions-api-config.tsx"],"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 helping the user insert new text into their existing work.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it to inform your suggestions when relevant!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user will provide you with a prompt for an INSERTION into the text they are writing. \nYour job is to come up with an INSERTION into the text that the user would like to use, 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\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.\nThe conversation will be structured as follows:\n<TextAfterCursor>\n<TextBeforeCursor>\n<InsertionPrompt>\n\n<YourInsertionSuggestion>\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"],"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;AAAA;AAAA;AAAA;AAkBF;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;","names":[]}
@@ -1,72 +0,0 @@
1
- import {
2
- retry
3
- } from "./chunk-KNQIEOFP.mjs";
4
- import {
5
- __async,
6
- __spreadProps,
7
- __spreadValues
8
- } from "./chunk-MRXNTQOX.mjs";
9
-
10
- // src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx
11
- import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER } from "@copilotkit/shared";
12
- import { CopilotContext } from "@copilotkit/react-core";
13
- import { useCallback, useContext } from "react";
14
- import { fetchAndDecodeChatCompletionAsText } from "@copilotkit/react-core";
15
- function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
16
- const { getContextString, copilotApiConfig } = useContext(CopilotContext);
17
- const publicApiKey = copilotApiConfig.publicApiKey;
18
- const headers = __spreadValues({}, publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
19
- return useCallback(
20
- (editorState, abortSignal) => __async(this, null, function* () {
21
- const res = yield retry(() => __async(this, null, function* () {
22
- const messages = [
23
- {
24
- role: "system",
25
- content: apiConfig.makeSystemPrompt(
26
- textareaPurpose,
27
- getContextString([], contextCategories)
28
- )
29
- },
30
- ...apiConfig.fewShotMessages,
31
- {
32
- role: "user",
33
- name: "TextAfterCursor",
34
- content: editorState.textAfterCursor
35
- },
36
- {
37
- role: "user",
38
- name: "TextBeforeCursor",
39
- content: editorState.textBeforeCursor
40
- }
41
- ];
42
- const response = yield fetchAndDecodeChatCompletionAsText(__spreadProps(__spreadValues({
43
- messages
44
- }, apiConfig.forwardedParams), {
45
- copilotConfig: copilotApiConfig,
46
- signal: abortSignal,
47
- headers
48
- }));
49
- if (!response.events) {
50
- throw new Error("Failed to fetch chat completion");
51
- }
52
- const reader = response.events.getReader();
53
- let result = "";
54
- while (!abortSignal.aborted) {
55
- const { done, value } = yield reader.read();
56
- if (done) {
57
- break;
58
- }
59
- result += value;
60
- }
61
- return result;
62
- }));
63
- return res;
64
- }),
65
- [apiConfig, getContextString, contextCategories, textareaPurpose]
66
- );
67
- }
68
-
69
- export {
70
- useMakeStandardAutosuggestionFunction
71
- };
72
- //# sourceMappingURL=chunk-SJ2TM5GA.mjs.map
@@ -1 +0,0 @@
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,7 +0,0 @@
1
- interface MinimalChatGPTMessage {
2
- role: string;
3
- content: string;
4
- name?: string;
5
- }
6
-
7
- export { MinimalChatGPTMessage };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.tsx
17
- var minimal_chat_gpt_message_exports = {};
18
- module.exports = __toCommonJS(minimal_chat_gpt_message_exports);
19
- //# sourceMappingURL=minimal-chat-gpt-message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.tsx"],"sourcesContent":["export interface MinimalChatGPTMessage {\n role: string;\n content: string;\n name?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=minimal-chat-gpt-message.mjs.map