@copilotkit/react-textarea 0.12.0 → 0.14.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 (36) hide show
  1. package/.turbo/turbo-build.log +51 -42
  2. package/CHANGELOG.md +12 -0
  3. package/dist/{chunk-EHQ5TN4R.mjs → chunk-3OR5RMJQ.mjs} +5 -2
  4. package/dist/chunk-3OR5RMJQ.mjs.map +1 -0
  5. package/dist/{chunk-A3SFEHWZ.mjs → chunk-4ES2IIB6.mjs} +24 -31
  6. package/dist/chunk-4ES2IIB6.mjs.map +1 -0
  7. package/dist/chunk-4YM33JFV.mjs +28 -0
  8. package/dist/chunk-4YM33JFV.mjs.map +1 -0
  9. package/dist/{chunk-DCQ27XRF.mjs → chunk-RXISUUUY.mjs} +3 -3
  10. package/dist/components/copilot-textarea/copilot-textarea.d.ts +1 -0
  11. package/dist/components/copilot-textarea/copilot-textarea.mjs +4 -3
  12. package/dist/components/index.d.ts +1 -0
  13. package/dist/components/index.mjs +4 -3
  14. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts +2 -1
  15. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
  16. package/dist/index.css +3 -0
  17. package/dist/index.css.map +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.mjs +4 -3
  20. package/dist/types/index.d.ts +1 -0
  21. package/dist/types/index.mjs +2 -1
  22. package/dist/types/standard-autosuggestions/autosuggestions-config.d.ts +2 -1
  23. package/dist/types/standard-autosuggestions/autosuggestions-config.mjs +2 -1
  24. package/dist/types/standard-autosuggestions/chatlike-api-endpoint.d.ts +12 -0
  25. package/dist/types/standard-autosuggestions/chatlike-api-endpoint.mjs +4 -0
  26. package/dist/types/standard-autosuggestions/chatlike-api-endpoint.mjs.map +1 -0
  27. package/dist/types/standard-autosuggestions/index.d.ts +1 -0
  28. package/dist/types/standard-autosuggestions/index.mjs +2 -1
  29. package/package.json +1 -1
  30. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +25 -32
  31. package/src/types/standard-autosuggestions/autosuggestions-config.tsx +5 -2
  32. package/src/types/standard-autosuggestions/chatlike-api-endpoint.tsx +39 -0
  33. package/src/types/standard-autosuggestions/index.ts +10 -5
  34. package/dist/chunk-A3SFEHWZ.mjs.map +0 -1
  35. package/dist/chunk-EHQ5TN4R.mjs.map +0 -1
  36. /package/dist/{chunk-DCQ27XRF.mjs.map → chunk-RXISUUUY.mjs.map} +0 -0
@@ -1,8 +1,8 @@
1
1
 
2
- > @copilotkit/react-textarea@0.12.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-textarea
2
+ > @copilotkit/react-textarea@0.14.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-textarea
3
3
  > tsup --treeshake
4
4
 
5
- CLI Building entry: src/index.tsx, src/components/index.ts, src/context/index.ts, src/hooks/index.ts, src/lib/debouncer.ts, src/lib/editor-to-text.ts, src/lib/get-text-around-cursor.ts, src/lib/utils.test.ts, src/lib/utils.ts, src/types/html-copilot-textarea-element.ts, src/types/index.ts, src/components/base-copilot-textarea/base-copilot-textarea.tsx, src/components/base-copilot-textarea/render-element.tsx, src/components/base-copilot-textarea/render-placeholder.tsx, src/components/base-copilot-textarea/use-add-branding-css.tsx, src/components/copilot-textarea/copilot-textarea.tsx, src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts, src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx, src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts, src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx, src/lib/slatejs-edits/add-autocompletions.ts, src/lib/slatejs-edits/clear-autocompletions.ts, src/lib/slatejs-edits/replace-text.ts, src/lib/slatejs-edits/with-partial-history.ts, src/types/base/autosuggestion-state.ts, src/types/base/autosuggestions-bare-function.ts, src/types/base/base-autosuggestions-config.tsx, src/types/base/base-copilot-textarea-props.tsx, src/types/base/custom-editor.tsx, src/types/base/editor-autocomplete-state.ts, src/types/base/index.ts, src/types/standard-autosuggestions/autosuggestions-config.tsx, src/types/standard-autosuggestions/index.ts, src/types/standard-autosuggestions/minimal-chat-gpt-message.tsx
5
+ CLI Building entry: src/index.tsx, src/components/index.ts, src/context/index.ts, src/hooks/index.ts, src/lib/debouncer.ts, src/lib/editor-to-text.ts, src/lib/get-text-around-cursor.ts, src/lib/utils.test.ts, src/lib/utils.ts, src/types/html-copilot-textarea-element.ts, src/types/index.ts, src/components/base-copilot-textarea/base-copilot-textarea.tsx, src/components/base-copilot-textarea/render-element.tsx, src/components/base-copilot-textarea/render-placeholder.tsx, src/components/base-copilot-textarea/use-add-branding-css.tsx, src/components/copilot-textarea/copilot-textarea.tsx, src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts, src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx, src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts, src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx, src/lib/slatejs-edits/add-autocompletions.ts, src/lib/slatejs-edits/clear-autocompletions.ts, src/lib/slatejs-edits/replace-text.ts, src/lib/slatejs-edits/with-partial-history.ts, src/types/base/autosuggestion-state.ts, src/types/base/autosuggestions-bare-function.ts, src/types/base/base-autosuggestions-config.tsx, src/types/base/base-copilot-textarea-props.tsx, src/types/base/custom-editor.tsx, src/types/base/editor-autocomplete-state.ts, src/types/base/index.ts, src/types/standard-autosuggestions/autosuggestions-config.tsx, src/types/standard-autosuggestions/chatlike-api-endpoint.tsx, src/types/standard-autosuggestions/index.ts, src/types/standard-autosuggestions/minimal-chat-gpt-message.tsx
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v6.5.0
8
8
  CLI Using tsup config: /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-textarea/tsup.config.ts
@@ -25,21 +25,19 @@ Generated an empty chunk: "chunk-AZQCUNBV".
25
25
  Generated an empty chunk: "chunk-WJHSY5T6".
26
26
  Generated an empty chunk: "chunk-IU3WTXLQ".
27
27
  Generated an empty chunk: "chunk-H4VKQGVU".
28
- ESM dist/index.css 5.96 KB
28
+ ESM dist/index.css 5.99 KB
29
29
  ESM dist/components/index.css 242.00 B
30
30
  ESM dist/components/base-copilot-textarea/base-copilot-textarea.css 258.00 B
31
31
  ESM dist/components/copilot-textarea/copilot-textarea.css 253.00 B
32
- ESM dist/index.css.map 12.61 KB
32
+ ESM dist/index.css.map 12.66 KB
33
33
  ESM dist/components/index.css.map 429.00 B
34
- ESM dist/components/base-copilot-textarea/base-copilot-textarea.css.map 432.00 B
35
- ESM dist/components/copilot-textarea/copilot-textarea.css.map 432.00 B
36
34
  ESM dist/lib/utils.test.mjs 200.00 B
37
35
  ESM dist/lib/slatejs-edits/add-autocompletions.mjs 186.00 B
38
36
  ESM dist/types/html-copilot-textarea-element.mjs 122.00 B
39
37
  ESM dist/context/index.mjs 98.00 B
40
38
  ESM dist/hooks/index.mjs 98.00 B
41
- ESM dist/chunk-WADHCMPK.mjs 76.00 B
42
39
  ESM dist/chunk-DE5K76I2.mjs 76.00 B
40
+ ESM dist/chunk-WADHCMPK.mjs 76.00 B
43
41
  ESM dist/chunk-MMVDU6DF.mjs 76.00 B
44
42
  ESM dist/chunk-AZQCUNBV.mjs 76.00 B
45
43
  ESM dist/chunk-WJHSY5T6.mjs 76.00 B
@@ -48,29 +46,30 @@ Generated an empty chunk: "chunk-H4VKQGVU".
48
46
  ESM dist/chunk-H4VKQGVU.mjs 76.00 B
49
47
  ESM dist/chunk-MRXNTQOX.mjs 1.92 KB
50
48
  ESM dist/lib/slatejs-edits/clear-autocompletions.mjs 192.00 B
51
- ESM dist/lib/slatejs-edits/with-partial-history.mjs 198.00 B
52
49
  ESM dist/lib/slatejs-edits/replace-text.mjs 170.00 B
50
+ ESM dist/lib/slatejs-edits/with-partial-history.mjs 198.00 B
53
51
  ESM dist/lib/utils.mjs 220.00 B
54
- ESM dist/types/index.mjs 419.00 B
52
+ ESM dist/types/index.mjs 451.00 B
55
53
  ESM dist/components/base-copilot-textarea/base-copilot-textarea.mjs 741.00 B
56
54
  ESM dist/components/base-copilot-textarea/render-element.mjs 180.00 B
57
55
  ESM dist/components/base-copilot-textarea/render-placeholder.mjs 188.00 B
58
56
  ESM dist/components/base-copilot-textarea/use-add-branding-css.mjs 178.00 B
59
- ESM dist/components/copilot-textarea/copilot-textarea.mjs 872.00 B
60
- ESM dist/index.mjs 1.06 KB
61
- ESM dist/chunk-DCQ27XRF.mjs 1.23 KB
62
- ESM dist/components/index.mjs 856.00 B
63
- ESM dist/chunk-A3SFEHWZ.mjs 2.09 KB
64
- ESM dist/chunk-EHQ5TN4R.mjs 2.75 KB
57
+ ESM dist/components/copilot-textarea/copilot-textarea.mjs 907.00 B
58
+ ESM dist/index.mjs 1.09 KB
59
+ ESM dist/components/index.mjs 888.00 B
60
+ ESM dist/chunk-RXISUUUY.mjs 1.23 KB
61
+ ESM dist/chunk-4ES2IIB6.mjs 1.76 KB
62
+ ESM dist/chunk-3OR5RMJQ.mjs 2.86 KB
63
+ ESM dist/chunk-4YM33JFV.mjs 881.00 B
65
64
  ESM dist/chunk-M6QFKIBE.mjs 5.99 KB
66
65
  ESM dist/chunk-HZGSG7ST.mjs 3.02 KB
67
66
  ESM dist/chunk-UW3ITU2Y.mjs 496.00 B
68
67
  ESM dist/chunk-CSGFJU3L.mjs 2.01 KB
69
68
  ESM dist/chunk-AOEXKPIX.mjs 2.57 KB
70
69
  ESM dist/chunk-WJYQWL4I.mjs 595.00 B
70
+ ESM dist/chunk-4XYYSJ5C.mjs 527.00 B
71
71
  ESM dist/chunk-TSF4AJIK.mjs 716.00 B
72
72
  ESM dist/chunk-KCHYD3EB.mjs 3.08 KB
73
- ESM dist/chunk-4XYYSJ5C.mjs 527.00 B
74
73
  ESM dist/chunk-KGKLUWKW.mjs 1.37 KB
75
74
  ESM dist/chunk-LNAIMEB2.mjs 1.09 KB
76
75
  ESM dist/chunk-OELUUJZY.mjs 625.00 B
@@ -80,18 +79,21 @@ Generated an empty chunk: "chunk-H4VKQGVU".
80
79
  ESM dist/lib/editor-to-text.mjs 1.34 KB
81
80
  ESM dist/lib/get-text-around-cursor.mjs 232.00 B
82
81
  ESM dist/chunk-3UQM3NLM.mjs 1.76 KB
82
+ ESM dist/components/base-copilot-textarea/base-copilot-textarea.css.map 432.00 B
83
+ ESM dist/components/copilot-textarea/copilot-textarea.css.map 432.00 B
83
84
  ESM dist/types/standard-autosuggestions/minimal-chat-gpt-message.mjs 86.00 B
84
- ESM dist/types/base/autosuggestions-bare-function.mjs 91.00 B
85
+ ESM dist/types/base/autosuggestion-state.mjs 82.00 B
85
86
  ESM dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs 283.00 B
86
87
  ESM dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs 220.00 B
88
+ ESM dist/types/base/autosuggestions-bare-function.mjs 91.00 B
87
89
  ESM dist/types/base/base-copilot-textarea-props.mjs 89.00 B
88
- ESM dist/types/base/autosuggestion-state.mjs 82.00 B
89
90
  ESM dist/types/base/custom-editor.mjs 75.00 B
90
- ESM dist/types/standard-autosuggestions/index.mjs 328.00 B
91
- ESM dist/types/base/editor-autocomplete-state.mjs 227.00 B
92
- ESM dist/types/standard-autosuggestions/autosuggestions-config.mjs 310.00 B
91
+ ESM dist/types/standard-autosuggestions/chatlike-api-endpoint.mjs 181.00 B
92
+ ESM dist/types/standard-autosuggestions/index.mjs 363.00 B
93
93
  ESM dist/types/base/base-autosuggestions-config.mjs 200.00 B
94
+ ESM dist/types/base/editor-autocomplete-state.mjs 227.00 B
94
95
  ESM dist/types/base/index.mjs 213.00 B
96
+ ESM dist/types/standard-autosuggestions/autosuggestions-config.mjs 345.00 B
95
97
  ESM dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs 227.00 B
96
98
  ESM dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs 273.00 B
97
99
  ESM dist/lib/utils.test.mjs.map 349.00 B
@@ -104,69 +106,76 @@ Generated an empty chunk: "chunk-H4VKQGVU".
104
106
  ESM dist/chunk-MMVDU6DF.mjs.map 51.00 B
105
107
  ESM dist/chunk-AZQCUNBV.mjs.map 51.00 B
106
108
  ESM dist/chunk-WJHSY5T6.mjs.map 51.00 B
109
+ ESM dist/chunk-7KWRVIYV.mjs.map 623.00 B
107
110
  ESM dist/chunk-IU3WTXLQ.mjs.map 51.00 B
108
111
  ESM dist/chunk-H4VKQGVU.mjs.map 51.00 B
109
112
  ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
110
- ESM dist/chunk-7KWRVIYV.mjs.map 623.00 B
111
113
  ESM dist/lib/slatejs-edits/clear-autocompletions.mjs.map 51.00 B
112
114
  ESM dist/lib/slatejs-edits/replace-text.mjs.map 51.00 B
115
+ ESM dist/lib/slatejs-edits/with-partial-history.mjs.map 51.00 B
113
116
  ESM dist/lib/utils.mjs.map 51.00 B
114
117
  ESM dist/types/index.mjs.map 51.00 B
115
- ESM dist/lib/slatejs-edits/with-partial-history.mjs.map 51.00 B
116
118
  ESM dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map 51.00 B
117
119
  ESM dist/components/base-copilot-textarea/render-element.mjs.map 51.00 B
118
120
  ESM dist/components/base-copilot-textarea/render-placeholder.mjs.map 51.00 B
119
121
  ESM dist/components/base-copilot-textarea/use-add-branding-css.mjs.map 51.00 B
120
122
  ESM dist/components/copilot-textarea/copilot-textarea.mjs.map 51.00 B
121
- ESM dist/chunk-DCQ27XRF.mjs.map 2.17 KB
122
123
  ESM dist/index.mjs.map 51.00 B
123
124
  ESM dist/components/index.mjs.map 51.00 B
124
- ESM dist/chunk-EHQ5TN4R.mjs.map 4.01 KB
125
+ ESM dist/chunk-RXISUUUY.mjs.map 2.17 KB
126
+ ESM dist/chunk-4ES2IIB6.mjs.map 4.41 KB
127
+ ESM dist/chunk-3OR5RMJQ.mjs.map 4.17 KB
128
+ ESM dist/chunk-4YM33JFV.mjs.map 1.57 KB
125
129
  ESM dist/chunk-M6QFKIBE.mjs.map 10.78 KB
126
130
  ESM dist/chunk-HZGSG7ST.mjs.map 5.83 KB
127
131
  ESM dist/chunk-UW3ITU2Y.mjs.map 878.00 B
128
132
  ESM dist/chunk-CSGFJU3L.mjs.map 3.82 KB
129
- ESM dist/chunk-A3SFEHWZ.mjs.map 4.73 KB
130
133
  ESM dist/chunk-AOEXKPIX.mjs.map 4.80 KB
131
134
  ESM dist/chunk-WJYQWL4I.mjs.map 1.04 KB
135
+ ESM dist/chunk-4XYYSJ5C.mjs.map 921.00 B
132
136
  ESM dist/chunk-TSF4AJIK.mjs.map 1.31 KB
137
+ ESM dist/chunk-KCHYD3EB.mjs.map 6.12 KB
133
138
  ESM dist/chunk-KGKLUWKW.mjs.map 2.45 KB
134
139
  ESM dist/chunk-LNAIMEB2.mjs.map 1.73 KB
135
- ESM dist/chunk-KCHYD3EB.mjs.map 6.12 KB
136
140
  ESM dist/chunk-OELUUJZY.mjs.map 957.00 B
137
- ESM dist/chunk-4XYYSJ5C.mjs.map 921.00 B
138
141
  ESM dist/chunk-IGQI27NI.mjs.map 3.42 KB
139
142
  ESM dist/lib/debouncer.mjs.map 51.00 B
140
143
  ESM dist/chunk-NKW5OU2S.mjs.map 1.60 KB
141
144
  ESM dist/lib/editor-to-text.mjs.map 2.83 KB
142
- ESM dist/chunk-3UQM3NLM.mjs.map 3.63 KB
143
145
  ESM dist/lib/get-text-around-cursor.mjs.map 51.00 B
146
+ ESM dist/chunk-3UQM3NLM.mjs.map 3.63 KB
144
147
  ESM dist/types/standard-autosuggestions/minimal-chat-gpt-message.mjs.map 51.00 B
145
- ESM dist/types/base/autosuggestions-bare-function.mjs.map 51.00 B
148
+ ESM dist/types/base/autosuggestion-state.mjs.map 51.00 B
146
149
  ESM dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map 51.00 B
147
150
  ESM dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map 51.00 B
151
+ ESM dist/types/base/autosuggestions-bare-function.mjs.map 51.00 B
148
152
  ESM dist/types/base/base-copilot-textarea-props.mjs.map 51.00 B
149
- ESM dist/types/base/autosuggestion-state.mjs.map 51.00 B
150
153
  ESM dist/types/base/custom-editor.mjs.map 51.00 B
154
+ ESM dist/types/standard-autosuggestions/chatlike-api-endpoint.mjs.map 51.00 B
151
155
  ESM dist/types/standard-autosuggestions/index.mjs.map 51.00 B
152
- ESM dist/types/standard-autosuggestions/autosuggestions-config.mjs.map 51.00 B
153
- ESM dist/types/base/editor-autocomplete-state.mjs.map 51.00 B
154
156
  ESM dist/types/base/base-autosuggestions-config.mjs.map 51.00 B
157
+ ESM dist/types/base/editor-autocomplete-state.mjs.map 51.00 B
155
158
  ESM dist/types/base/index.mjs.map 51.00 B
159
+ ESM dist/types/standard-autosuggestions/autosuggestions-config.mjs.map 51.00 B
156
160
  ESM dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map 51.00 B
157
161
  ESM dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map 51.00 B
158
- ESM ⚡️ Build success in 3071ms
159
- DTS ⚡️ Build success in 5297ms
160
- DTS dist/index.d.ts 912.00 B
162
+ ESM ⚡️ Build success in 3617ms
163
+ Export "AutosuggestionsConfig" of module "src/types/standard-autosuggestions/autosuggestions-config.tsx" was reexported through module "src/types/standard-autosuggestions/index.ts" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
164
+ Either change the import in "src/components/copilot-textarea/copilot-textarea.tsx" to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.
165
+ Export "MakeSystemPrompt" of module "src/types/standard-autosuggestions/autosuggestions-config.tsx" was reexported through module "src/types/standard-autosuggestions/index.ts" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
166
+ Either change the import in "src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx" to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.
167
+ DTS ⚡️ Build success in 6723ms
168
+ DTS dist/index.d.ts 1.01 KB
161
169
  DTS dist/components/base-copilot-textarea/base-copilot-textarea.d.ts 669.00 B
162
- DTS dist/components/copilot-textarea/copilot-textarea.d.ts 803.00 B
170
+ DTS dist/components/copilot-textarea/copilot-textarea.d.ts 875.00 B
163
171
  DTS dist/types/base/base-autosuggestions-config.d.ts 355.00 B
164
172
  DTS dist/types/base/autosuggestions-bare-function.d.ts 162.00 B
165
173
  DTS dist/types/base/base-copilot-textarea-props.d.ts 1.89 KB
166
174
  DTS dist/types/html-copilot-textarea-element.d.ts 165.00 B
167
- DTS dist/types/standard-autosuggestions/autosuggestions-config.d.ts 884.00 B
175
+ DTS dist/types/standard-autosuggestions/autosuggestions-config.d.ts 963.00 B
168
176
  DTS dist/types/standard-autosuggestions/minimal-chat-gpt-message.d.ts 129.00 B
169
- DTS dist/components/index.d.ts 561.00 B
177
+ DTS dist/types/standard-autosuggestions/chatlike-api-endpoint.d.ts 485.00 B
178
+ DTS dist/components/index.d.ts 630.00 B
170
179
  DTS dist/context/index.d.ts 1.00 B
171
180
  DTS dist/hooks/index.d.ts 1.00 B
172
181
  DTS dist/lib/debouncer.d.ts 372.00 B
@@ -175,7 +184,7 @@ Generated an empty chunk: "chunk-H4VKQGVU".
175
184
  DTS dist/types/base/editor-autocomplete-state.d.ts 342.00 B
176
185
  DTS dist/lib/utils.test.d.ts 1.00 B
177
186
  DTS dist/lib/utils.d.ts 638.00 B
178
- DTS dist/types/index.d.ts 670.00 B
187
+ DTS dist/types/index.d.ts 786.00 B
179
188
  DTS dist/components/base-copilot-textarea/render-element.d.ts 292.00 B
180
189
  DTS dist/components/base-copilot-textarea/render-placeholder.d.ts 321.00 B
181
190
  DTS dist/components/base-copilot-textarea/use-add-branding-css.d.ts 158.00 B
@@ -184,10 +193,10 @@ Generated an empty chunk: "chunk-H4VKQGVU".
184
193
  DTS dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.d.ts 226.00 B
185
194
  DTS dist/types/base/custom-editor.d.ts 801.00 B
186
195
  DTS dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.d.ts 308.00 B
187
- DTS dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts 1.79 KB
196
+ DTS dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts 1.90 KB
188
197
  DTS dist/lib/slatejs-edits/add-autocompletions.d.ts 302.00 B
189
198
  DTS dist/lib/slatejs-edits/clear-autocompletions.d.ts 250.00 B
190
199
  DTS dist/lib/slatejs-edits/replace-text.d.ts 139.00 B
191
200
  DTS dist/lib/slatejs-edits/with-partial-history.d.ts 542.00 B
192
201
  DTS dist/types/base/index.d.ts 287.00 B
193
- DTS dist/types/standard-autosuggestions/index.d.ts 286.00 B
202
+ DTS dist/types/standard-autosuggestions/index.d.ts 377.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # ui
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cfdc367: export ChatlikeApiEndpoint types in original name
8
+
9
+ ## 0.13.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 1f26798: standard CopilotTextarea apiEndpoint takes an implementation, not just a string endpoint
14
+
3
15
  ## 0.12.0
4
16
 
5
17
  ### Minor Changes
@@ -1,3 +1,4 @@
1
+ import { ChatlikeApiEndpoint } from './chunk-4YM33JFV.mjs';
1
2
  import { defaultBaseAutosuggestionsConfig } from './chunk-7KWRVIYV.mjs';
2
3
  import { __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
3
4
 
@@ -57,7 +58,9 @@ var defaultFewShotMessages = [
57
58
  }
58
59
  ];
59
60
  var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseAutosuggestionsConfig), {
60
- apiEndpoint: "api/autosuggestions",
61
+ apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(
62
+ "api/autosuggestions"
63
+ ),
61
64
  makeSystemPrompt: defaultMakeSystemPrompt,
62
65
  fewShotMessages: defaultFewShotMessages,
63
66
  externalContextCategories: void 0,
@@ -66,4 +69,4 @@ var defaultAutosuggestionsConfig = __spreadProps(__spreadValues({}, defaultBaseA
66
69
 
67
70
  export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt };
68
71
  //# sourceMappingURL=out.js.map
69
- //# sourceMappingURL=chunk-EHQ5TN4R.mjs.map
72
+ //# sourceMappingURL=chunk-3OR5RMJQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/standard-autosuggestions/autosuggestions-config.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAoBO,IAAM,0BAA4C,CACvD,eACA,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,yBAAkD;AAAA,EAC7D;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;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;AACO,IAAM,+BAGT,iCACC,mCADD;AAAA,EAGF,aAAa,oBAAoB;AAAA,IAC/B;AAAA,EACF;AAAA,EACA,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,2BAA2B;AAAA,EAC3B,iBAAiB;AACnB","sourcesContent":["import {\n BaseAutosuggestionsConfig,\n defaultBaseAutosuggestionsConfig,\n} from \"../base\";\nimport { ChatlikeApiEndpoint } from \"./chatlike-api-endpoint\";\nimport { MinimalChatGPTMessage } from \"./minimal-chat-gpt-message\";\n\nexport type MakeSystemPrompt = (\n purposePrompt: string,\n contextString: string\n) => string;\n\nexport interface AutosuggestionsConfig extends BaseAutosuggestionsConfig {\n apiEndpoint: ChatlikeApiEndpoint;\n externalContextCategories: string[] | undefined;\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultMakeSystemPrompt: MakeSystemPrompt = (\n purposePrompt,\n contextString\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${purposePrompt}\\\"\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 defaultFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"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: \"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];\nexport const defaultAutosuggestionsConfig: Omit<\n AutosuggestionsConfig,\n \"purposePrompt\"\n> = {\n ...defaultBaseAutosuggestionsConfig,\n\n apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(\n \"api/autosuggestions\"\n ),\n makeSystemPrompt: defaultMakeSystemPrompt,\n fewShotMessages: defaultFewShotMessages,\n externalContextCategories: undefined,\n forwardedParams: undefined,\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { __async, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
1
+ import { __async } from './chunk-MRXNTQOX.mjs';
2
2
  import { CopilotContext } from '@copilotkit/react-core';
3
3
  import { useContext, useCallback } from 'react';
4
4
 
@@ -7,36 +7,29 @@ function useMakeStandardAutosuggestionFunction(purposePrompt, apiEndpoint, makeS
7
7
  return useCallback(
8
8
  (beforeText, afterText, abortSignal) => __async(this, null, function* () {
9
9
  const res = yield retry(() => __async(this, null, function* () {
10
- return yield fetch(apiEndpoint, {
11
- method: "POST",
12
- body: JSON.stringify(__spreadProps(__spreadValues({}, forwardedProps), {
13
- messages: [
14
- {
15
- role: "system",
16
- content: makeSystemPrompt(
17
- purposePrompt,
18
- getContextString(contextCategories)
19
- )
20
- },
21
- ...fewShotMessages,
22
- {
23
- role: "user",
24
- name: "TextAfterCursor",
25
- content: afterText
26
- },
27
- {
28
- role: "user",
29
- name: "TextBeforeCursor",
30
- content: beforeText
31
- }
32
- ]
33
- })),
34
- signal: abortSignal
35
- });
10
+ const messages = [
11
+ {
12
+ role: "system",
13
+ content: makeSystemPrompt(
14
+ purposePrompt,
15
+ getContextString(contextCategories)
16
+ )
17
+ },
18
+ ...fewShotMessages,
19
+ {
20
+ role: "user",
21
+ name: "TextAfterCursor",
22
+ content: afterText
23
+ },
24
+ {
25
+ role: "user",
26
+ name: "TextBeforeCursor",
27
+ content: beforeText
28
+ }
29
+ ];
30
+ return yield apiEndpoint.run(abortSignal, messages, forwardedProps);
36
31
  }));
37
- const json = yield res.json();
38
- const suggestion = json.choices[0].message.content;
39
- return suggestion;
32
+ return res;
40
33
  }),
41
34
  [
42
35
  apiEndpoint,
@@ -64,4 +57,4 @@ function retry(fn, retriesLeft = 2, interval = 200, backoff = 1.5) {
64
57
 
65
58
  export { useMakeStandardAutosuggestionFunction };
66
59
  //# sourceMappingURL=out.js.map
67
- //# sourceMappingURL=chunk-A3SFEHWZ.mjs.map
60
+ //# sourceMappingURL=chunk-4ES2IIB6.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;AAoBjC,SAAS,sCACd,eACA,aACA,kBACA,iBACA,mBACA,gBAC6B;AAC7B,QAAM,EAAE,iBAAiB,IAAI,WAAW,cAAc;AAEtD,SAAO;AAAA,IACL,CAAO,YAAoB,WAAmB,gBAA6B;AACzE,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS;AAAA,cACP;AAAA,cACA,iBAAiB,iBAAiB;AAAA,YACpC;AAAA,UACF;AAAA,UACA,GAAG;AAAA,UACH;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,UACX;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,UACX;AAAA,QACF;AAEA,eAAO,MAAM,YAAY,IAAI,aAAa,UAAU,cAAc;AAAA,MACpE,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,MACP,IACA,cAAsB,GACtB,WAAmB,KACnB,UAAkB,KACN;AACZ,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,OAAG,EACA,KAAK,OAAO,EACZ,MAAM,CAAC,UAAU;AAChB,UAAI,gBAAgB,GAAG;AACrB,eAAO,KAAK;AACZ;AAAA,MACF;AAEA,iBAAW,MAAM;AACf,cAAM,IAAI,cAAc,GAAG,WAAW,SAAS,OAAO,EACnD,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,MACjB,GAAG,QAAQ;AAAA,IACb,CAAC;AAAA,EACL,CAAC;AACH","sourcesContent":["import { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport {\n AutosuggestionsBareFunction,\n MakeSystemPrompt,\n MinimalChatGPTMessage,\n} from \"../../types\";\nimport { ChatlikeApiEndpoint } from \"../../types/standard-autosuggestions/chatlike-api-endpoint\";\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 purposePrompt - 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 purposePrompt: string,\n apiEndpoint: ChatlikeApiEndpoint,\n makeSystemPrompt: MakeSystemPrompt,\n fewShotMessages: MinimalChatGPTMessage[],\n contextCategories: string[] | undefined,\n forwardedProps?: { [key: string]: any }\n): AutosuggestionsBareFunction {\n const { getContextString } = useContext(CopilotContext);\n\n return useCallback(\n async (beforeText: string, afterText: string, abortSignal: AbortSignal) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: makeSystemPrompt(\n purposePrompt,\n getContextString(contextCategories)\n ),\n },\n ...fewShotMessages,\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: afterText,\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: beforeText,\n },\n ];\n\n return await apiEndpoint.run(abortSignal, messages, forwardedProps);\n });\n\n return res;\n },\n [\n apiEndpoint,\n makeSystemPrompt,\n fewShotMessages,\n getContextString,\n contextCategories,\n purposePrompt,\n ]\n );\n}\n\nfunction retry<T>(\n fn: () => Promise<T>,\n retriesLeft: number = 2,\n interval: number = 200,\n backoff: number = 1.5\n): Promise<T> {\n return new Promise((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n if (retriesLeft === 1) {\n reject(error);\n return;\n }\n\n setTimeout(() => {\n retry(fn, retriesLeft - 1, interval * backoff, backoff)\n .then(resolve)\n .catch(reject);\n }, interval);\n });\n });\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { __async, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
2
+
3
+ // src/types/standard-autosuggestions/chatlike-api-endpoint.tsx
4
+ var ChatlikeApiEndpoint = class {
5
+ constructor(run) {
6
+ this.run = run;
7
+ }
8
+ static standardOpenAIEndpoint(apiEndpoint) {
9
+ return new ChatlikeApiEndpoint(
10
+ (abortSignal, messages, forwardedProps) => __async(this, null, function* () {
11
+ const res = yield fetch(apiEndpoint, {
12
+ method: "POST",
13
+ body: JSON.stringify(__spreadProps(__spreadValues({}, forwardedProps), {
14
+ messages
15
+ })),
16
+ signal: abortSignal
17
+ });
18
+ const json = yield res.json();
19
+ const suggestion = json.choices[0].message.content;
20
+ return suggestion;
21
+ })
22
+ );
23
+ }
24
+ };
25
+
26
+ export { ChatlikeApiEndpoint };
27
+ //# sourceMappingURL=out.js.map
28
+ //# sourceMappingURL=chunk-4YM33JFV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/standard-autosuggestions/chatlike-api-endpoint.tsx"],"names":[],"mappings":";;;;;;;AAQO,IAAM,sBAAN,MAA0B;AAAA,EAG/B,YAAY,KAA8B;AACxC,SAAK,MAAM;AAAA,EACb;AAAA,EAGA,OAAO,uBAAuB,aAA0C;AACtE,WAAO,IAAI;AAAA,MACT,CACE,aACA,UACA,mBACG;AACH,cAAM,MAAM,MAAM,MAAM,aAAa;AAAA,UACnC,QAAQ;AAAA,UACR,MAAM,KAAK,UAAU,iCAChB,iBADgB;AAAA,YAEnB;AAAA,UACF,EAAC;AAAA,UACD,QAAQ;AAAA,QACV,CAAC;AAED,cAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,cAAM,aAAa,KAAK,QAAQ,GAAG,QAAQ;AAC3C,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["import { MinimalChatGPTMessage } from \"..\";\n\nexport type ChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n) => Promise<string>;\n\nexport class ChatlikeApiEndpoint {\n public run: ChatlikeApiEndpointImpl;\n\n constructor(run: ChatlikeApiEndpointImpl) {\n this.run = run;\n }\n\n // Static method\n static standardOpenAIEndpoint(apiEndpoint: string): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(\n async (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n ) => {\n const res = await fetch(apiEndpoint, {\n method: \"POST\",\n body: JSON.stringify({\n ...forwardedProps,\n messages: messages,\n }),\n signal: abortSignal,\n });\n\n const json = await res.json();\n const suggestion = json.choices[0].message.content;\n return suggestion;\n }\n );\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { useMakeStandardAutosuggestionFunction } from './chunk-A3SFEHWZ.mjs';
2
- import { defaultAutosuggestionsConfig } from './chunk-EHQ5TN4R.mjs';
1
+ import { useMakeStandardAutosuggestionFunction } from './chunk-4ES2IIB6.mjs';
2
+ import { defaultAutosuggestionsConfig } from './chunk-3OR5RMJQ.mjs';
3
3
  import { BaseCopilotTextarea } from './chunk-M6QFKIBE.mjs';
4
4
  import { __spreadValues, __spreadProps } from './chunk-MRXNTQOX.mjs';
5
5
  import React from 'react';
@@ -29,4 +29,4 @@ var CopilotTextarea = React.forwardRef(
29
29
 
30
30
  export { CopilotTextarea };
31
31
  //# sourceMappingURL=out.js.map
32
- //# sourceMappingURL=chunk-DCQ27XRF.mjs.map
32
+ //# sourceMappingURL=chunk-RXISUUUY.mjs.map
@@ -3,6 +3,7 @@ import { BaseCopilotTextareaProps } from '../../types/base/base-copilot-textarea
3
3
  import { HTMLCopilotTextAreaElement } from '../../types/html-copilot-textarea-element.js';
4
4
  import { AutosuggestionsConfig } from '../../types/standard-autosuggestions/autosuggestions-config.js';
5
5
  import '../../types/base/base-autosuggestions-config.js';
6
+ import '../../types/standard-autosuggestions/chatlike-api-endpoint.js';
6
7
  import '../../types/standard-autosuggestions/minimal-chat-gpt-message.js';
7
8
 
8
9
  interface CopilotTextareaProps extends BaseCopilotTextareaProps {
@@ -1,7 +1,8 @@
1
- export { CopilotTextarea } from '../../chunk-DCQ27XRF.mjs';
2
- import '../../chunk-A3SFEHWZ.mjs';
1
+ export { CopilotTextarea } from '../../chunk-RXISUUUY.mjs';
2
+ import '../../chunk-4ES2IIB6.mjs';
3
3
  import '../../chunk-AZQCUNBV.mjs';
4
- import '../../chunk-EHQ5TN4R.mjs';
4
+ import '../../chunk-3OR5RMJQ.mjs';
5
+ import '../../chunk-4YM33JFV.mjs';
5
6
  import '../../chunk-M6QFKIBE.mjs';
6
7
  import '../../chunk-HZGSG7ST.mjs';
7
8
  import '../../chunk-UW3ITU2Y.mjs';
@@ -6,4 +6,5 @@ import '../types/base/base-copilot-textarea-props.js';
6
6
  import '../types/base/base-autosuggestions-config.js';
7
7
  import '../types/html-copilot-textarea-element.js';
8
8
  import '../types/standard-autosuggestions/autosuggestions-config.js';
9
+ import '../types/standard-autosuggestions/chatlike-api-endpoint.js';
9
10
  import '../types/standard-autosuggestions/minimal-chat-gpt-message.js';
@@ -1,8 +1,9 @@
1
1
  import '../chunk-MMVDU6DF.mjs';
2
- export { CopilotTextarea } from '../chunk-DCQ27XRF.mjs';
3
- import '../chunk-A3SFEHWZ.mjs';
2
+ export { CopilotTextarea } from '../chunk-RXISUUUY.mjs';
3
+ import '../chunk-4ES2IIB6.mjs';
4
4
  import '../chunk-AZQCUNBV.mjs';
5
- import '../chunk-EHQ5TN4R.mjs';
5
+ import '../chunk-3OR5RMJQ.mjs';
6
+ import '../chunk-4YM33JFV.mjs';
6
7
  export { BaseCopilotTextarea } from '../chunk-M6QFKIBE.mjs';
7
8
  import '../chunk-HZGSG7ST.mjs';
8
9
  import '../chunk-UW3ITU2Y.mjs';
@@ -1,6 +1,7 @@
1
1
  import { AutosuggestionsBareFunction } from '../../types/base/autosuggestions-bare-function.js';
2
2
  import { MakeSystemPrompt } from '../../types/standard-autosuggestions/autosuggestions-config.js';
3
3
  import { MinimalChatGPTMessage } from '../../types/standard-autosuggestions/minimal-chat-gpt-message.js';
4
+ import { ChatlikeApiEndpoint } from '../../types/standard-autosuggestions/chatlike-api-endpoint.js';
4
5
  import '../../types/base/base-autosuggestions-config.js';
5
6
 
6
7
  /**
@@ -16,7 +17,7 @@ import '../../types/base/base-autosuggestions-config.js';
16
17
  * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) "global" context category.
17
18
  * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.
18
19
  */
19
- declare function useMakeStandardAutosuggestionFunction(purposePrompt: string, apiEndpoint: string, makeSystemPrompt: MakeSystemPrompt, fewShotMessages: MinimalChatGPTMessage[], contextCategories: string[] | undefined, forwardedProps?: {
20
+ declare function useMakeStandardAutosuggestionFunction(purposePrompt: string, apiEndpoint: ChatlikeApiEndpoint, makeSystemPrompt: MakeSystemPrompt, fewShotMessages: MinimalChatGPTMessage[], contextCategories: string[] | undefined, forwardedProps?: {
20
21
  [key: string]: any;
21
22
  }): AutosuggestionsBareFunction;
22
23
 
@@ -1,4 +1,4 @@
1
- export { useMakeStandardAutosuggestionFunction } from '../../chunk-A3SFEHWZ.mjs';
1
+ export { useMakeStandardAutosuggestionFunction } from '../../chunk-4ES2IIB6.mjs';
2
2
  import '../../chunk-MRXNTQOX.mjs';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=use-make-standard-autosuggestions-function.mjs.map
package/dist/index.css CHANGED
@@ -315,6 +315,9 @@ video {
315
315
  --tw-backdrop-saturate: ;
316
316
  --tw-backdrop-sepia: ;
317
317
  }
318
+ .static {
319
+ position: static;
320
+ }
318
321
  .block {
319
322
  display: block;
320
323
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styles.css","../src/components/base-copilot-textarea/base-copilot-textarea.css"],"sourcesContent":["/*\n! tailwindcss v3.3.0 | MIT License | https://tailwindcss.com\n*//*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n\n::before,\n::after {\n --tw-content: '';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user's configured `sans` font-family by default.\n5. Use the user's configured `sans` font-feature-settings by default.\n6. Use the user's configured `sans` font-variation-settings by default.\n*/\n\nhtml {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n -o-tab-size: 4;\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user's configured `mono` font family by default.\n2. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\n[type='button'],\n[type='reset'],\n[type='submit'] {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type='search'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user's configured gray 400 color.\n*/\n\ninput::-moz-placeholder, textarea::-moz-placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don't get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n.block {\n display: block;\n}\n.inline {\n display: inline;\n}\n.resize-y {\n resize: vertical;\n}\n.overflow-y-auto {\n overflow-y: auto;\n}\n.border {\n border-width: 1px;\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity));\n}\n.italic {\n font-style: italic;\n}\n.blur {\n --tw-blur: blur(8px);\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n.filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n",".copilot-textarea.with-branding::after {\n content: ''; /* Initially empty because we overrdie this CSS dynamically and we want to avoid flashing */\n position: absolute;\n}\n \n \n.copilot-textarea.no-branding::after {\n content: '';\n}"],"mappings":";AAOA;AAAA;AAAA;AAGE;AACA;AACA;AACA;AAAA;AAGF;AAAA;AAEE;AAAA;AAYF;AACE;AACA;AACA;AACA;AACG;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAQF;AACE;AACA;AAAA;AASF;AACE;AACA;AACA;AAAA;AAOF;AACE;AACQ;AAAA;AAOV;AAAA;AAAA;AAAA;AAAA;AAAA;AAME;AACA;AAAA;AAOF;AACE;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AAAA;AAAA;AAAA;AAIE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAEE;AACA;AACA;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AAAA;AASF;AACE;AACA;AACA;AAAA;AASF;AAAA;AAAA;AAAA;AAAA;AAKE;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AAAA;AAAA;AAAA;AAIE;AACA;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AACE;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AACE;AACA;AAAA;AAOF;AACE;AAAA;AAQF;AACE;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaE;AAAA;AAGF;AACE;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AAAA;AAAA;AAGE;AACA;AACA;AAAA;AAOF;AACE;AAAA;AAQF;AAAA;AACE;AACA;AAAA;AAGF;AAAA;AAEE;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAMF;AACE;AAAA;AASF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQE;AACA;AAAA;AAOF;AAAA;AAEE;AACA;AAAA;AAIF;AACE;AAAA;AAGF;AAAA;AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGF;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AACA;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AACA;AAAA;AAEF;AACE;AAAA;;;ACnfF;AACI;AACA;AAAA;AAIJ;AACI;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/styles.css","../src/components/base-copilot-textarea/base-copilot-textarea.css"],"sourcesContent":["/*\n! tailwindcss v3.3.0 | MIT License | https://tailwindcss.com\n*//*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n\n::before,\n::after {\n --tw-content: '';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user's configured `sans` font-family by default.\n5. Use the user's configured `sans` font-feature-settings by default.\n6. Use the user's configured `sans` font-variation-settings by default.\n*/\n\nhtml {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n -o-tab-size: 4;\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user's configured `mono` font family by default.\n2. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\n[type='button'],\n[type='reset'],\n[type='submit'] {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type='search'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user's configured gray 400 color.\n*/\n\ninput::-moz-placeholder, textarea::-moz-placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don't get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n.static {\n position: static;\n}\n.block {\n display: block;\n}\n.inline {\n display: inline;\n}\n.resize-y {\n resize: vertical;\n}\n.overflow-y-auto {\n overflow-y: auto;\n}\n.border {\n border-width: 1px;\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity));\n}\n.italic {\n font-style: italic;\n}\n.blur {\n --tw-blur: blur(8px);\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n.filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n",".copilot-textarea.with-branding::after {\n content: ''; /* Initially empty because we overrdie this CSS dynamically and we want to avoid flashing */\n position: absolute;\n}\n \n \n.copilot-textarea.no-branding::after {\n content: '';\n}"],"mappings":";AAOA;AAAA;AAAA;AAGE;AACA;AACA;AACA;AAAA;AAGF;AAAA;AAEE;AAAA;AAYF;AACE;AACA;AACA;AACA;AACG;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAQF;AACE;AACA;AAAA;AASF;AACE;AACA;AACA;AAAA;AAOF;AACE;AACQ;AAAA;AAOV;AAAA;AAAA;AAAA;AAAA;AAAA;AAME;AACA;AAAA;AAOF;AACE;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AAAA;AAAA;AAAA;AAIE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAEE;AACA;AACA;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AAAA;AASF;AACE;AACA;AACA;AAAA;AASF;AAAA;AAAA;AAAA;AAAA;AAKE;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AAAA;AAAA;AAAA;AAIE;AACA;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AACE;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AACE;AACA;AAAA;AAOF;AACE;AAAA;AAQF;AACE;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaE;AAAA;AAGF;AACE;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AAAA;AAAA;AAGE;AACA;AACA;AAAA;AAOF;AACE;AAAA;AAQF;AAAA;AACE;AACA;AAAA;AAGF;AAAA;AAEE;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAMF;AACE;AAAA;AASF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQE;AACA;AAAA;AAOF;AAAA;AAEE;AACA;AAAA;AAIF;AACE;AAAA;AAGF;AAAA;AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGF;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AACA;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AACA;AAAA;AAEF;AACE;AAAA;;;ACtfF;AACI;AACA;AAAA;AAIJ;AACI;AAAA;","names":[]}
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@ export { BaseCopilotTextareaProps } from './types/base/base-copilot-textarea-pro
6
6
  export { HTMLCopilotTextAreaElement } from './types/html-copilot-textarea-element.js';
7
7
  export { AutosuggestionsConfig, MakeSystemPrompt, defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './types/standard-autosuggestions/autosuggestions-config.js';
8
8
  export { MinimalChatGPTMessage } from './types/standard-autosuggestions/minimal-chat-gpt-message.js';
9
+ export { ChatlikeApiEndpoint, ChatlikeApiEndpointImpl } from './types/standard-autosuggestions/chatlike-api-endpoint.js';
9
10
  import 'react';
package/dist/index.mjs CHANGED
@@ -1,10 +1,11 @@
1
1
  import './chunk-DE5K76I2.mjs';
2
2
  import './chunk-WADHCMPK.mjs';
3
3
  import './chunk-MMVDU6DF.mjs';
4
- export { CopilotTextarea } from './chunk-DCQ27XRF.mjs';
5
- import './chunk-A3SFEHWZ.mjs';
4
+ export { CopilotTextarea } from './chunk-RXISUUUY.mjs';
5
+ import './chunk-4ES2IIB6.mjs';
6
6
  import './chunk-AZQCUNBV.mjs';
7
- export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './chunk-EHQ5TN4R.mjs';
7
+ export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './chunk-3OR5RMJQ.mjs';
8
+ import './chunk-4YM33JFV.mjs';
8
9
  export { BaseCopilotTextarea } from './chunk-M6QFKIBE.mjs';
9
10
  import './chunk-HZGSG7ST.mjs';
10
11
  import './chunk-UW3ITU2Y.mjs';
@@ -4,4 +4,5 @@ export { BaseCopilotTextareaProps } from './base/base-copilot-textarea-props.js'
4
4
  export { HTMLCopilotTextAreaElement } from './html-copilot-textarea-element.js';
5
5
  export { AutosuggestionsConfig, MakeSystemPrompt, defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './standard-autosuggestions/autosuggestions-config.js';
6
6
  export { MinimalChatGPTMessage } from './standard-autosuggestions/minimal-chat-gpt-message.js';
7
+ export { ChatlikeApiEndpoint, ChatlikeApiEndpointImpl } from './standard-autosuggestions/chatlike-api-endpoint.js';
7
8
  import 'react';
@@ -1,7 +1,8 @@
1
1
  import '../chunk-DE5K76I2.mjs';
2
2
  import '../chunk-WADHCMPK.mjs';
3
3
  import '../chunk-AZQCUNBV.mjs';
4
- export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from '../chunk-EHQ5TN4R.mjs';
4
+ export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from '../chunk-3OR5RMJQ.mjs';
5
+ import '../chunk-4YM33JFV.mjs';
5
6
  import '../chunk-WJHSY5T6.mjs';
6
7
  export { defaultBaseAutosuggestionsConfig } from '../chunk-7KWRVIYV.mjs';
7
8
  import '../chunk-MRXNTQOX.mjs';
@@ -1,9 +1,10 @@
1
1
  import { BaseAutosuggestionsConfig } from '../base/base-autosuggestions-config.js';
2
+ import { ChatlikeApiEndpoint } from './chatlike-api-endpoint.js';
2
3
  import { MinimalChatGPTMessage } from './minimal-chat-gpt-message.js';
3
4
 
4
5
  type MakeSystemPrompt = (purposePrompt: string, contextString: string) => string;
5
6
  interface AutosuggestionsConfig extends BaseAutosuggestionsConfig {
6
- apiEndpoint: string;
7
+ apiEndpoint: ChatlikeApiEndpoint;
7
8
  externalContextCategories: string[] | undefined;
8
9
  makeSystemPrompt: MakeSystemPrompt;
9
10
  fewShotMessages: MinimalChatGPTMessage[];
@@ -1,4 +1,5 @@
1
- export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from '../../chunk-EHQ5TN4R.mjs';
1
+ export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from '../../chunk-3OR5RMJQ.mjs';
2
+ import '../../chunk-4YM33JFV.mjs';
2
3
  import '../../chunk-WJHSY5T6.mjs';
3
4
  import '../../chunk-7KWRVIYV.mjs';
4
5
  import '../../chunk-MRXNTQOX.mjs';
@@ -0,0 +1,12 @@
1
+ import { MinimalChatGPTMessage } from './minimal-chat-gpt-message.js';
2
+
3
+ type ChatlikeApiEndpointImpl = (abortSignal: AbortSignal, messages: MinimalChatGPTMessage[], forwardedProps?: {
4
+ [key: string]: any;
5
+ }) => Promise<string>;
6
+ declare class ChatlikeApiEndpoint {
7
+ run: ChatlikeApiEndpointImpl;
8
+ constructor(run: ChatlikeApiEndpointImpl);
9
+ static standardOpenAIEndpoint(apiEndpoint: string): ChatlikeApiEndpoint;
10
+ }
11
+
12
+ export { ChatlikeApiEndpoint, ChatlikeApiEndpointImpl };
@@ -0,0 +1,4 @@
1
+ export { ChatlikeApiEndpoint } from '../../chunk-4YM33JFV.mjs';
2
+ import '../../chunk-MRXNTQOX.mjs';
3
+ //# sourceMappingURL=out.js.map
4
+ //# sourceMappingURL=chatlike-api-endpoint.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
1
  export { AutosuggestionsConfig, MakeSystemPrompt, defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './autosuggestions-config.js';
2
2
  export { MinimalChatGPTMessage } from './minimal-chat-gpt-message.js';
3
+ export { ChatlikeApiEndpoint, ChatlikeApiEndpointImpl } from './chatlike-api-endpoint.js';
3
4
  import '../base/base-autosuggestions-config.js';
@@ -1,5 +1,6 @@
1
1
  import '../../chunk-AZQCUNBV.mjs';
2
- export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from '../../chunk-EHQ5TN4R.mjs';
2
+ export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from '../../chunk-3OR5RMJQ.mjs';
3
+ import '../../chunk-4YM33JFV.mjs';
3
4
  import '../../chunk-WJHSY5T6.mjs';
4
5
  import '../../chunk-7KWRVIYV.mjs';
5
6
  import '../../chunk-MRXNTQOX.mjs';
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.12.0",
7
+ "version": "0.14.0",
8
8
  "sideEffects": [
9
9
  "**/*.css"
10
10
  ],
@@ -5,6 +5,7 @@ import {
5
5
  MakeSystemPrompt,
6
6
  MinimalChatGPTMessage,
7
7
  } from "../../types";
8
+ import { ChatlikeApiEndpoint } from "../../types/standard-autosuggestions/chatlike-api-endpoint";
8
9
  /**
9
10
  * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.
10
11
  * The function takes in the text before and after the cursor, and an abort signal.
@@ -20,7 +21,7 @@ import {
20
21
  */
21
22
  export function useMakeStandardAutosuggestionFunction(
22
23
  purposePrompt: string,
23
- apiEndpoint: string,
24
+ apiEndpoint: ChatlikeApiEndpoint,
24
25
  makeSystemPrompt: MakeSystemPrompt,
25
26
  fewShotMessages: MinimalChatGPTMessage[],
26
27
  contextCategories: string[] | undefined,
@@ -31,39 +32,31 @@ export function useMakeStandardAutosuggestionFunction(
31
32
  return useCallback(
32
33
  async (beforeText: string, afterText: string, abortSignal: AbortSignal) => {
33
34
  const res = await retry(async () => {
34
- return await fetch(apiEndpoint, {
35
- method: "POST",
36
- body: JSON.stringify({
37
- ...forwardedProps,
38
- messages: [
39
- {
40
- role: "system",
41
- content: makeSystemPrompt(
42
- purposePrompt,
43
- getContextString(contextCategories)
44
- ),
45
- },
46
- ...fewShotMessages,
47
- {
48
- role: "user",
49
- name: "TextAfterCursor",
50
- content: afterText,
51
- },
52
- {
53
- role: "user",
54
- name: "TextBeforeCursor",
55
- content: beforeText,
56
- },
57
- ],
58
- }),
59
- signal: abortSignal,
60
- });
61
- });
35
+ const messages: MinimalChatGPTMessage[] = [
36
+ {
37
+ role: "system",
38
+ content: makeSystemPrompt(
39
+ purposePrompt,
40
+ getContextString(contextCategories)
41
+ ),
42
+ },
43
+ ...fewShotMessages,
44
+ {
45
+ role: "user",
46
+ name: "TextAfterCursor",
47
+ content: afterText,
48
+ },
49
+ {
50
+ role: "user",
51
+ name: "TextBeforeCursor",
52
+ content: beforeText,
53
+ },
54
+ ];
62
55
 
63
- const json = await res.json();
64
- const suggestion = json.choices[0].message.content;
56
+ return await apiEndpoint.run(abortSignal, messages, forwardedProps);
57
+ });
65
58
 
66
- return suggestion;
59
+ return res;
67
60
  },
68
61
  [
69
62
  apiEndpoint,
@@ -2,6 +2,7 @@ import {
2
2
  BaseAutosuggestionsConfig,
3
3
  defaultBaseAutosuggestionsConfig,
4
4
  } from "../base";
5
+ import { ChatlikeApiEndpoint } from "./chatlike-api-endpoint";
5
6
  import { MinimalChatGPTMessage } from "./minimal-chat-gpt-message";
6
7
 
7
8
  export type MakeSystemPrompt = (
@@ -10,7 +11,7 @@ export type MakeSystemPrompt = (
10
11
  ) => string;
11
12
 
12
13
  export interface AutosuggestionsConfig extends BaseAutosuggestionsConfig {
13
- apiEndpoint: string;
14
+ apiEndpoint: ChatlikeApiEndpoint;
14
15
  externalContextCategories: string[] | undefined;
15
16
  makeSystemPrompt: MakeSystemPrompt;
16
17
  fewShotMessages: MinimalChatGPTMessage[];
@@ -86,7 +87,9 @@ export const defaultAutosuggestionsConfig: Omit<
86
87
  > = {
87
88
  ...defaultBaseAutosuggestionsConfig,
88
89
 
89
- apiEndpoint: "api/autosuggestions",
90
+ apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(
91
+ "api/autosuggestions"
92
+ ),
90
93
  makeSystemPrompt: defaultMakeSystemPrompt,
91
94
  fewShotMessages: defaultFewShotMessages,
92
95
  externalContextCategories: undefined,
@@ -0,0 +1,39 @@
1
+ import { MinimalChatGPTMessage } from "..";
2
+
3
+ export type ChatlikeApiEndpointImpl = (
4
+ abortSignal: AbortSignal,
5
+ messages: MinimalChatGPTMessage[],
6
+ forwardedProps?: { [key: string]: any }
7
+ ) => Promise<string>;
8
+
9
+ export class ChatlikeApiEndpoint {
10
+ public run: ChatlikeApiEndpointImpl;
11
+
12
+ constructor(run: ChatlikeApiEndpointImpl) {
13
+ this.run = run;
14
+ }
15
+
16
+ // Static method
17
+ static standardOpenAIEndpoint(apiEndpoint: string): ChatlikeApiEndpoint {
18
+ return new ChatlikeApiEndpoint(
19
+ async (
20
+ abortSignal: AbortSignal,
21
+ messages: MinimalChatGPTMessage[],
22
+ forwardedProps?: { [key: string]: any }
23
+ ) => {
24
+ const res = await fetch(apiEndpoint, {
25
+ method: "POST",
26
+ body: JSON.stringify({
27
+ ...forwardedProps,
28
+ messages: messages,
29
+ }),
30
+ signal: abortSignal,
31
+ });
32
+
33
+ const json = await res.json();
34
+ const suggestion = json.choices[0].message.content;
35
+ return suggestion;
36
+ }
37
+ );
38
+ }
39
+ }
@@ -1,11 +1,16 @@
1
+ export {
2
+ defaultAutosuggestionsConfig,
3
+ defaultFewShotMessages,
4
+ defaultMakeSystemPrompt,
5
+ } from "./autosuggestions-config";
1
6
  export type {
2
7
  AutosuggestionsConfig,
3
8
  MakeSystemPrompt,
4
9
  } from "./autosuggestions-config";
5
- export {
6
- defaultMakeSystemPrompt,
7
- defaultFewShotMessages,
8
- defaultAutosuggestionsConfig,
9
- } from "./autosuggestions-config";
10
10
 
11
11
  export type { MinimalChatGPTMessage } from "./minimal-chat-gpt-message";
12
+
13
+ export type {
14
+ ChatlikeApiEndpoint,
15
+ ChatlikeApiEndpointImpl,
16
+ } from "./chatlike-api-endpoint";
@@ -1 +0,0 @@
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;AAmBjC,SAAS,sCACd,eACA,aACA,kBACA,iBACA,mBACA,gBAC6B;AAC7B,QAAM,EAAE,iBAAiB,IAAI,WAAW,cAAc;AAEtD,SAAO;AAAA,IACL,CAAO,YAAoB,WAAmB,gBAA6B;AACzE,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,eAAO,MAAM,MAAM,aAAa;AAAA,UAC9B,QAAQ;AAAA,UACR,MAAM,KAAK,UAAU,iCAChB,iBADgB;AAAA,YAEnB,UAAU;AAAA,cACR;AAAA,gBACE,MAAM;AAAA,gBACN,SAAS;AAAA,kBACP;AAAA,kBACA,iBAAiB,iBAAiB;AAAA,gBACpC;AAAA,cACF;AAAA,cACA,GAAG;AAAA,cACH;AAAA,gBACE,MAAM;AAAA,gBACN,MAAM;AAAA,gBACN,SAAS;AAAA,cACX;AAAA,cACA;AAAA,gBACE,MAAM;AAAA,gBACN,MAAM;AAAA,gBACN,SAAS;AAAA,cACX;AAAA,YACF;AAAA,UACF,EAAC;AAAA,UACD,QAAQ;AAAA,QACV,CAAC;AAAA,MACH,EAAC;AAED,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,YAAM,aAAa,KAAK,QAAQ,GAAG,QAAQ;AAE3C,aAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,MACP,IACA,cAAsB,GACtB,WAAmB,KACnB,UAAkB,KACN;AACZ,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,OAAG,EACA,KAAK,OAAO,EACZ,MAAM,CAAC,UAAU;AAChB,UAAI,gBAAgB,GAAG;AACrB,eAAO,KAAK;AACZ;AAAA,MACF;AAEA,iBAAW,MAAM;AACf,cAAM,IAAI,cAAc,GAAG,WAAW,SAAS,OAAO,EACnD,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,MACjB,GAAG,QAAQ;AAAA,IACb,CAAC;AAAA,EACL,CAAC;AACH","sourcesContent":["import { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport {\n AutosuggestionsBareFunction,\n MakeSystemPrompt,\n MinimalChatGPTMessage,\n} from \"../../types\";\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 purposePrompt - 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 purposePrompt: string,\n apiEndpoint: string,\n makeSystemPrompt: MakeSystemPrompt,\n fewShotMessages: MinimalChatGPTMessage[],\n contextCategories: string[] | undefined,\n forwardedProps?: { [key: string]: any }\n): AutosuggestionsBareFunction {\n const { getContextString } = useContext(CopilotContext);\n\n return useCallback(\n async (beforeText: string, afterText: string, abortSignal: AbortSignal) => {\n const res = await retry(async () => {\n return await fetch(apiEndpoint, {\n method: \"POST\",\n body: JSON.stringify({\n ...forwardedProps,\n messages: [\n {\n role: \"system\",\n content: makeSystemPrompt(\n purposePrompt,\n getContextString(contextCategories)\n ),\n },\n ...fewShotMessages,\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: afterText,\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: beforeText,\n },\n ],\n }),\n signal: abortSignal,\n });\n });\n\n const json = await res.json();\n const suggestion = json.choices[0].message.content;\n\n return suggestion;\n },\n [\n apiEndpoint,\n makeSystemPrompt,\n fewShotMessages,\n getContextString,\n contextCategories,\n purposePrompt,\n ]\n );\n}\n\nfunction retry<T>(\n fn: () => Promise<T>,\n retriesLeft: number = 2,\n interval: number = 200,\n backoff: number = 1.5\n): Promise<T> {\n return new Promise((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n if (retriesLeft === 1) {\n reject(error);\n return;\n }\n\n setTimeout(() => {\n retry(fn, retriesLeft - 1, interval * backoff, backoff)\n .then(resolve)\n .catch(reject);\n }, interval);\n });\n });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/standard-autosuggestions/autosuggestions-config.tsx"],"names":[],"mappings":";;;;;;;;;AAmBO,IAAM,0BAA4C,CACvD,eACA,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,yBAAkD;AAAA,EAC7D;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;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;AACO,IAAM,+BAGT,iCACC,mCADD;AAAA,EAGF,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,2BAA2B;AAAA,EAC3B,iBAAiB;AACnB","sourcesContent":["import {\n BaseAutosuggestionsConfig,\n defaultBaseAutosuggestionsConfig,\n} from \"../base\";\nimport { MinimalChatGPTMessage } from \"./minimal-chat-gpt-message\";\n\nexport type MakeSystemPrompt = (\n purposePrompt: string,\n contextString: string\n) => string;\n\nexport interface AutosuggestionsConfig extends BaseAutosuggestionsConfig {\n apiEndpoint: string;\n externalContextCategories: string[] | undefined;\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultMakeSystemPrompt: MakeSystemPrompt = (\n purposePrompt,\n contextString\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${purposePrompt}\\\"\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 defaultFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"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: \"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];\nexport const defaultAutosuggestionsConfig: Omit<\n AutosuggestionsConfig,\n \"purposePrompt\"\n> = {\n ...defaultBaseAutosuggestionsConfig,\n\n apiEndpoint: \"api/autosuggestions\",\n makeSystemPrompt: defaultMakeSystemPrompt,\n fewShotMessages: defaultFewShotMessages,\n externalContextCategories: undefined,\n forwardedParams: undefined,\n};\n"]}