@copilotkit/react-textarea 0.19.0-alpha.6 → 0.19.0-alpha.7

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 (71) hide show
  1. package/.turbo/turbo-build.log +206 -206
  2. package/CHANGELOG.md +11 -0
  3. package/dist/{chunk-QL2GYGG5.mjs → chunk-2TQBFDO7.mjs} +4 -4
  4. package/dist/{chunk-XDT7BF3V.mjs → chunk-66BDXIX4.mjs} +1 -6
  5. package/dist/chunk-66BDXIX4.mjs.map +1 -0
  6. package/dist/{chunk-N4JMCC7P.mjs → chunk-7XKICWEE.mjs} +5 -5
  7. package/dist/{chunk-55EGOC5T.mjs → chunk-HRTFMM7P.mjs} +1 -6
  8. package/dist/chunk-HRTFMM7P.mjs.map +1 -0
  9. package/dist/{chunk-A2RRLD23.mjs → chunk-JHTAOLEW.mjs} +1 -7
  10. package/dist/chunk-JHTAOLEW.mjs.map +1 -0
  11. package/dist/{chunk-HAFHLU4N.mjs → chunk-K2AVA67P.mjs} +5 -3
  12. package/dist/chunk-K2AVA67P.mjs.map +1 -0
  13. package/dist/{chunk-5ARCOTW3.mjs → chunk-KIRROE2K.mjs} +13 -10
  14. package/dist/chunk-KIRROE2K.mjs.map +1 -0
  15. package/dist/{chunk-IWTOQKC5.mjs → chunk-NKA6K7FW.mjs} +7 -7
  16. package/dist/{chunk-VBIJPE3H.mjs → chunk-OXPXFYUG.mjs} +7 -4
  17. package/dist/chunk-OXPXFYUG.mjs.map +1 -0
  18. package/dist/{chunk-YSZ7DO3X.mjs → chunk-U5AJ5PBH.mjs} +2 -2
  19. package/dist/{chunk-FBDXI5QA.mjs → chunk-XYXKONR4.mjs} +3 -3
  20. package/dist/{chunk-6XP7KEMW.mjs → chunk-ZA3R6NZI.mjs} +2 -2
  21. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +19 -19
  22. package/dist/components/copilot-textarea/copilot-textarea.d.ts +0 -1
  23. package/dist/components/copilot-textarea/copilot-textarea.mjs +29 -27
  24. package/dist/components/hovering-toolbar/hovering-toolbar.mjs +7 -7
  25. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +3 -3
  26. package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +4 -4
  27. package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +4 -4
  28. package/dist/components/index.d.ts +0 -1
  29. package/dist/components/index.mjs +29 -27
  30. package/dist/components/source-search-box/source-search-box.mjs +3 -3
  31. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.d.ts +0 -1
  32. package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +11 -1
  33. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.d.ts +1 -2
  34. package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +11 -1
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.mjs +31 -31
  37. package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.d.ts +2 -5
  38. package/dist/types/autosuggestions-config/autosuggestions-config.d.ts +0 -1
  39. package/dist/types/autosuggestions-config/autosuggestions-config.mjs +4 -5
  40. package/dist/types/autosuggestions-config/editing-api-config.d.ts +0 -2
  41. package/dist/types/autosuggestions-config/editing-api-config.mjs +1 -2
  42. package/dist/types/autosuggestions-config/index.d.ts +1 -0
  43. package/dist/types/autosuggestions-config/index.mjs +5 -5
  44. package/dist/types/autosuggestions-config/insertions-api-config.d.ts +0 -2
  45. package/dist/types/autosuggestions-config/insertions-api-config.mjs +1 -2
  46. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.d.ts +2 -1
  47. package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +1 -1
  48. package/dist/types/autosuggestions-config/suggestions-api-config.d.ts +0 -2
  49. package/dist/types/autosuggestions-config/suggestions-api-config.mjs +1 -2
  50. package/dist/types/index.d.ts +1 -0
  51. package/dist/types/index.mjs +6 -6
  52. package/package.json +3 -3
  53. package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +5 -2
  54. package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +8 -4
  55. package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +2 -6
  56. package/src/types/autosuggestions-config/editing-api-config.tsx +0 -5
  57. package/src/types/autosuggestions-config/insertions-api-config.tsx +0 -5
  58. package/src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx +18 -9
  59. package/src/types/autosuggestions-config/suggestions-api-config.tsx +0 -6
  60. package/dist/chunk-55EGOC5T.mjs.map +0 -1
  61. package/dist/chunk-5ARCOTW3.mjs.map +0 -1
  62. package/dist/chunk-A2RRLD23.mjs.map +0 -1
  63. package/dist/chunk-HAFHLU4N.mjs.map +0 -1
  64. package/dist/chunk-VBIJPE3H.mjs.map +0 -1
  65. package/dist/chunk-XDT7BF3V.mjs.map +0 -1
  66. /package/dist/{chunk-QL2GYGG5.mjs.map → chunk-2TQBFDO7.mjs.map} +0 -0
  67. /package/dist/{chunk-N4JMCC7P.mjs.map → chunk-7XKICWEE.mjs.map} +0 -0
  68. /package/dist/{chunk-IWTOQKC5.mjs.map → chunk-NKA6K7FW.mjs.map} +0 -0
  69. /package/dist/{chunk-YSZ7DO3X.mjs.map → chunk-U5AJ5PBH.mjs.map} +0 -0
  70. /package/dist/{chunk-FBDXI5QA.mjs.map → chunk-XYXKONR4.mjs.map} +0 -0
  71. /package/dist/{chunk-6XP7KEMW.mjs.map → chunk-ZA3R6NZI.mjs.map} +0 -0
@@ -1,5 +1,3 @@
1
- import { ChatlikeApiEndpoint } from './chunk-5ARCOTW3.mjs';
2
-
3
1
  // src/types/autosuggestions-config/insertions-api-config.tsx
4
2
  var defaultInsertionsMakeSystemPrompt = (textareaPurpose, contextString) => {
5
3
  return `You are a versatile writing assistant.
@@ -68,9 +66,6 @@ var defaultInsertionsFewShotMessages = [
68
66
  }
69
67
  ];
70
68
  var defaultInsertionsApiConfig = {
71
- apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(
72
- "/api/copilotkit_chatlike"
73
- ),
74
69
  makeSystemPrompt: defaultInsertionsMakeSystemPrompt,
75
70
  fewShotMessages: defaultInsertionsFewShotMessages,
76
71
  forwardedParams: void 0
@@ -78,4 +73,4 @@ var defaultInsertionsApiConfig = {
78
73
 
79
74
  export { defaultInsertionsApiConfig, defaultInsertionsFewShotMessages, defaultInsertionsMakeSystemPrompt };
80
75
  //# sourceMappingURL=out.js.map
81
- //# sourceMappingURL=chunk-XDT7BF3V.mjs.map
76
+ //# sourceMappingURL=chunk-66BDXIX4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/autosuggestions-config/insertions-api-config.tsx"],"names":[],"mappings":";AASO,IAAM,oCAAsD,CACjE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBlB;AAAA;AAAA;AAGF;AAEO,IAAM,mCAA4D;AAAA,EACvE;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,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,6BAAkD;AAAA,EAC7D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB","sourcesContent":["import { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface InsertionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultInsertionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe user also provides you with a prompt for INSERTIONS into the text they are writing. \nYour job is to come up with an INSERTION into the text that the user would like AS BEST YOU CAN.\nOnly 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 the text before and after the cursor, as well as the insertion prompt. You should use this to infer the best relevant insertion.\n<TextAfterCursor>\n<TextBeforeCursor>\n<InsertionPrompt>\n<YourSuggestion>\n\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 defaultInsertionsFewShotMessages: 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: \"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"]}
@@ -1,7 +1,7 @@
1
- import { useMakeStandardAutosuggestionFunction } from './chunk-HAFHLU4N.mjs';
2
- import { useMakeStandardInsertionOrEditingFunction } from './chunk-VBIJPE3H.mjs';
3
- import { BaseCopilotTextarea } from './chunk-IWTOQKC5.mjs';
4
- import { defaultAutosuggestionsConfig } from './chunk-QL2GYGG5.mjs';
1
+ import { useMakeStandardAutosuggestionFunction } from './chunk-K2AVA67P.mjs';
2
+ import { useMakeStandardInsertionOrEditingFunction } from './chunk-OXPXFYUG.mjs';
3
+ import { BaseCopilotTextarea } from './chunk-NKA6K7FW.mjs';
4
+ import { defaultAutosuggestionsConfig } from './chunk-2TQBFDO7.mjs';
5
5
  import { __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
6
6
  import React from 'react';
7
7
  import merge from 'lodash.merge';
@@ -41,4 +41,4 @@ var CopilotTextarea = React.forwardRef(
41
41
 
42
42
  export { CopilotTextarea };
43
43
  //# sourceMappingURL=out.js.map
44
- //# sourceMappingURL=chunk-N4JMCC7P.mjs.map
44
+ //# sourceMappingURL=chunk-7XKICWEE.mjs.map
@@ -1,5 +1,3 @@
1
- import { ChatlikeApiEndpoint } from './chunk-5ARCOTW3.mjs';
2
-
3
1
  // src/types/autosuggestions-config/editing-api-config.tsx
4
2
  var defaultEditingMakeSystemPrompt = (textareaPurpose, contextString) => {
5
3
  return `You are a versatile writing assistant.
@@ -74,9 +72,6 @@ var defaultEditingFewShotMessages = [
74
72
  }
75
73
  ];
76
74
  var defaultEditingApiConfig = {
77
- apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(
78
- "/api/copilotkit_chatlike"
79
- ),
80
75
  makeSystemPrompt: defaultEditingMakeSystemPrompt,
81
76
  fewShotMessages: defaultEditingFewShotMessages,
82
77
  forwardedParams: void 0
@@ -84,4 +79,4 @@ var defaultEditingApiConfig = {
84
79
 
85
80
  export { defaultEditingApiConfig, defaultEditingFewShotMessages, defaultEditingMakeSystemPrompt };
86
81
  //# sourceMappingURL=out.js.map
87
- //# sourceMappingURL=chunk-55EGOC5T.mjs.map
82
+ //# sourceMappingURL=chunk-HRTFMM7P.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/autosuggestions-config/editing-api-config.tsx"],"names":[],"mappings":";AASO,IAAM,iCAAmD,CAC9D,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBlB;AAAA;AAAA;AAGF;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,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;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,0BAA4C;AAAA,EACvD,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB","sourcesContent":["import { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface 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.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe user also provides you with a prompt for EDITING some text they are writing. \nYour job is to come up with an EDIT of the text that the user would like to use - AS BEST YOU CAN.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide the following information; use this to infer the best relevant EDIT:\n<TextBeforeCursor>\n<TextToEdit>\n<TextAfterCursor>\n<EditingPrompt>\n\n<YourEditSuggestion>\n\nIf we need to add a whitespace character to the suggested edit 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 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:\n \"While I was there I also picked up some apples, oranges, and bananas. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"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 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 defaultEditingApiConfig: EditingApiConfig = {\n makeSystemPrompt: defaultEditingMakeSystemPrompt,\n fewShotMessages: defaultEditingFewShotMessages,\n forwardedParams: undefined,\n};\n"]}
@@ -1,5 +1,3 @@
1
- import { ChatlikeApiEndpoint } from './chunk-5ARCOTW3.mjs';
2
-
3
1
  // src/types/autosuggestions-config/suggestions-api-config.tsx
4
2
  var defaultSuggestionsMakeSystemPrompt = (textareaPurpose, contextString) => {
5
3
  return `You are a versatile writing assistant.
@@ -33,7 +31,6 @@ var defaultSuggestionsFewShotMessages = [
33
31
  },
34
32
  {
35
33
  role: "user",
36
- name: "TextBeforeCursor",
37
34
  content: "This morning I woke up and went straight to the grocery store."
38
35
  },
39
36
  {
@@ -56,9 +53,6 @@ var defaultSuggestionsFewShotMessages = [
56
53
  }
57
54
  ];
58
55
  var defaultSuggestionsApiConfig = {
59
- apiEndpoint: ChatlikeApiEndpoint.standardOpenAIEndpoint(
60
- "/api/copilotkit_chatlike"
61
- ),
62
56
  makeSystemPrompt: defaultSuggestionsMakeSystemPrompt,
63
57
  fewShotMessages: defaultSuggestionsFewShotMessages,
64
58
  forwardedParams: void 0
@@ -66,4 +60,4 @@ var defaultSuggestionsApiConfig = {
66
60
 
67
61
  export { defaultSuggestionsApiConfig, defaultSuggestionsFewShotMessages, defaultSuggestionsMakeSystemPrompt };
68
62
  //# sourceMappingURL=out.js.map
69
- //# sourceMappingURL=chunk-A2RRLD23.mjs.map
63
+ //# sourceMappingURL=chunk-JHTAOLEW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/autosuggestions-config/suggestions-api-config.tsx"],"names":[],"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,SACE;AAAA,EACJ;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","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:\n \"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"]}
@@ -1,10 +1,11 @@
1
+ import { ChatlikeApiEndpoint } from './chunk-KIRROE2K.mjs';
1
2
  import { retry } from './chunk-4S5ZJH3I.mjs';
2
3
  import { __async } from './chunk-MRXNTQOX.mjs';
3
4
  import { CopilotContext } from '@copilotkit/react-core';
4
5
  import { useContext, useCallback } from 'react';
5
6
 
6
7
  function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategories, apiConfig) {
7
- const { getContextString } = useContext(CopilotContext);
8
+ const { getContextString, copilotApiConfig } = useContext(CopilotContext);
8
9
  return useCallback(
9
10
  (editorState, abortSignal) => __async(this, null, function* () {
10
11
  const res = yield retry(() => __async(this, null, function* () {
@@ -28,7 +29,8 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
28
29
  content: editorState.textBeforeCursor
29
30
  }
30
31
  ];
31
- const stream = yield apiConfig.apiEndpoint.run(
32
+ const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
33
+ const stream = yield apiEndpoint.run(
32
34
  abortSignal,
33
35
  messages,
34
36
  apiConfig.forwardedParams
@@ -52,4 +54,4 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
52
54
 
53
55
  export { useMakeStandardAutosuggestionFunction };
54
56
  //# sourceMappingURL=out.js.map
55
- //# sourceMappingURL=chunk-HAFHLU4N.mjs.map
57
+ //# sourceMappingURL=chunk-K2AVA67P.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAsBjC,SAAS,sCACd,iBACA,mBACA,WAC6B;AAC7B,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AAExE,SAAO;AAAA,IACL,CAAO,aAAmC,gBAA6B;AACrE,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,UAAU;AAAA,cACjB;AAAA,cACA,iBAAiB,iBAAiB;AAAA,YACpC;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,cACJ,oBAAoB,qBAAqB,gBAAgB;AAC3D,cAAM,SAAS,MAAM,YAAY;AAAA,UAC/B;AAAA,UACA;AAAA,UACA,UAAU;AAAA,QACZ;AAGA,cAAM,SAAS,OAAO,UAAU;AAChC,YAAI,SAAS;AAEb,eAAO,MAAM;AACX,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR;AAAA,UACF;AACA,oBAAU;AAAA,QACZ;AAEA,eAAO;AAAA,MACT,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,WAAW,kBAAkB,mBAAmB,eAAe;AAAA,EAClE;AACF","sourcesContent":["import { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport {\n AutosuggestionsBareFunction,\n ChatlikeApiEndpoint,\n MinimalChatGPTMessage,\n} from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardAutosuggestionFunction(\n textareaPurpose: string,\n contextCategories: string[] | undefined,\n apiConfig: SuggestionsApiConfig\n): AutosuggestionsBareFunction {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n\n return useCallback(\n async (editorState: InsertionEditorState, abortSignal: AbortSignal) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: apiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(contextCategories)\n ),\n },\n ...apiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n ];\n\n const apiEndpoint =\n ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);\n const stream = await apiEndpoint.run(\n abortSignal,\n messages,\n apiConfig.forwardedParams\n );\n\n // read the stream:\n const reader = stream.getReader();\n let result = \"\";\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n result += value;\n }\n\n return result;\n });\n\n return res;\n },\n [apiConfig, getContextString, contextCategories, textareaPurpose]\n );\n}\n"]}
@@ -1,20 +1,23 @@
1
1
  import { __async, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
2
+ import { copilotApiConfigExtrapolator } from '@copilotkit/react-core';
2
3
 
3
- // src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx
4
4
  var ChatlikeApiEndpoint = class {
5
5
  constructor(run) {
6
6
  this.run = run;
7
7
  }
8
- static standardOpenAIEndpoint(apiEndpoint) {
8
+ static fromCopilotApiConfig(copilotApiConfig) {
9
9
  return new ChatlikeApiEndpoint(
10
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
- });
11
+ const res = yield fetch(
12
+ copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint,
13
+ {
14
+ method: "POST",
15
+ body: JSON.stringify(__spreadProps(__spreadValues({}, forwardedProps), {
16
+ messages
17
+ })),
18
+ signal: abortSignal
19
+ }
20
+ );
18
21
  const bodySteram = res.body;
19
22
  if (!bodySteram) {
20
23
  throw new Error("The response body is empty.");
@@ -31,4 +34,4 @@ var ChatlikeApiEndpoint = class {
31
34
 
32
35
  export { ChatlikeApiEndpoint };
33
36
  //# sourceMappingURL=out.js.map
34
- //# sourceMappingURL=chunk-5ARCOTW3.mjs.map
37
+ //# sourceMappingURL=chunk-KIRROE2K.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx"],"names":[],"mappings":";;;;;;;AAAA;AAAA,EAEE;AAAA,OACK;AAeA,IAAM,sBAAN,MAA0B;AAAA,EAG/B,YAAY,KAAuC;AACjD,SAAK,MAAM;AAAA,EACb;AAAA,EAOA,OAAO,qBACL,kBACqB;AACrB,WAAO,IAAI;AAAA,MACT,CACE,aACA,UACA,mBACG;AACH,cAAM,MAAM,MAAM;AAAA,UAChB,6BAA6B,gBAAgB,EAAE;AAAA,UAC/C;AAAA,YACE,QAAQ;AAAA,YACR,MAAM,KAAK,UAAU,iCAChB,iBADgB;AAAA,cAEnB;AAAA,YACF,EAAC;AAAA,YACD,QAAQ;AAAA,UACV;AAAA,QACF;AAEA,cAAM,aAAgD,IAAI;AAC1D,YAAI,CAAC,YAAY;AACf,gBAAM,IAAI,MAAM,6BAA6B;AAAA,QAC/C;AAGA,cAAM,eAAe,WAAW,YAAY,IAAI,kBAAkB,CAAC;AAEnE,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAAA,EAOA,OAAO,OAAO,KAA4D;AACxE,WAAO,IAAI,oBAAoB,GAAG;AAAA,EACpC;AACF","sourcesContent":["import {\n CopilotApiConfig,\n copilotApiConfigExtrapolator,\n} from \"@copilotkit/react-core\";\nimport { MinimalChatGPTMessage } from \"./minimal-chat-gpt-message\";\n\nexport type ChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n) => Promise<string>;\n\nexport type StreamingChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n) => Promise<ReadableStream<string>>;\n\nexport class ChatlikeApiEndpoint {\n public run: StreamingChatlikeApiEndpointImpl;\n\n constructor(run: StreamingChatlikeApiEndpointImpl) {\n this.run = run;\n }\n\n /**\n * Creates a new instance of ChatlikeApiEndpoint with the provided API endpoint.\n * @param apiEndpoint The URL of the OpenAI-compatible API endpoint.\n * @returns A new instance of ChatlikeApiEndpoint.\n */\n static fromCopilotApiConfig(\n copilotApiConfig: CopilotApiConfig\n ): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(\n async (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any }\n ) => {\n const res = await fetch(\n copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint,\n {\n method: \"POST\",\n body: JSON.stringify({\n ...forwardedProps,\n messages: messages,\n }),\n signal: abortSignal,\n }\n );\n\n const bodySteram: ReadableStream<Uint8Array> | null = res.body;\n if (!bodySteram) {\n throw new Error(\"The response body is empty.\");\n }\n\n // map the stream to a stream of strings\n const stringStream = bodySteram.pipeThrough(new TextDecoderStream());\n\n return stringStream;\n }\n );\n }\n\n /**\n * Creates a fully customized instance of ChatlikeApiEndpoint.\n * @param run - The implementation of the ChatlikeApiEndpointImpl interface.\n * @returns A new instance of ChatlikeApiEndpoint .\n */\n static custom(run: StreamingChatlikeApiEndpointImpl): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(run);\n }\n}\n"]}
@@ -1,16 +1,16 @@
1
- import { useCopilotTextareaEditor } from './chunk-CSGFJU3L.mjs';
2
- import { usePopulateCopilotTextareaRef } from './chunk-YQU7WG7T.mjs';
3
1
  import { addAutocompletionsToEditor } from './chunk-WJYQWL4I.mjs';
4
2
  import { clearAutocompletionsFromEditor } from './chunk-F3MHL6ZY.mjs';
5
- import { replaceEditorText } from './chunk-RQHOUUXQ.mjs';
6
- import { useAutosuggestions } from './chunk-UHD44NC5.mjs';
3
+ import { HoveringToolbar } from './chunk-U5AJ5PBH.mjs';
4
+ import { useHoveringEditorContext, HoveringEditorProvider } from './chunk-YW3REYX6.mjs';
7
5
  import { makeRenderElementFunction } from './chunk-LNAIMEB2.mjs';
8
6
  import { makeRenderPlaceholderFunction } from './chunk-OELUUJZY.mjs';
9
7
  import { TrackerTextEditedSinceLastCursorMovement } from './chunk-OD7ZMOVE.mjs';
10
8
  import { useAddBrandingCss } from './chunk-MPME5BW2.mjs';
11
9
  import { defaultBaseAutosuggestionsConfig } from './chunk-D7SEV5PR.mjs';
12
- import { HoveringToolbar } from './chunk-YSZ7DO3X.mjs';
13
- import { useHoveringEditorContext, HoveringEditorProvider } from './chunk-YW3REYX6.mjs';
10
+ import { useAutosuggestions } from './chunk-UHD44NC5.mjs';
11
+ import { useCopilotTextareaEditor } from './chunk-CSGFJU3L.mjs';
12
+ import { usePopulateCopilotTextareaRef } from './chunk-YQU7WG7T.mjs';
13
+ import { replaceEditorText } from './chunk-RQHOUUXQ.mjs';
14
14
  import { getTextAroundCollapsedCursor, getFullEditorTextWithNewlines } from './chunk-IXJ2HCOA.mjs';
15
15
  import { __spreadValues, __objRest, __spreadProps } from './chunk-MRXNTQOX.mjs';
16
16
  import React, { useMemo, useState, useCallback, useEffect } from 'react';
@@ -198,4 +198,4 @@ var BaseCopilotTextarea = React.forwardRef(
198
198
 
199
199
  export { BaseCopilotTextarea };
200
200
  //# sourceMappingURL=out.js.map
201
- //# sourceMappingURL=chunk-IWTOQKC5.mjs.map
201
+ //# sourceMappingURL=chunk-NKA6K7FW.mjs.map
@@ -1,10 +1,11 @@
1
+ import { ChatlikeApiEndpoint } from './chunk-KIRROE2K.mjs';
1
2
  import { retry } from './chunk-4S5ZJH3I.mjs';
2
3
  import { __async } from './chunk-MRXNTQOX.mjs';
3
4
  import { CopilotContext } from '@copilotkit/react-core';
4
5
  import { useContext, useCallback } from 'react';
5
6
 
6
7
  function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
7
- const { getContextString } = useContext(CopilotContext);
8
+ const { getContextString, copilotApiConfig } = useContext(CopilotContext);
8
9
  const insertionFunction = useCallback(
9
10
  (editorState, insertionPrompt, abortSignal) => __async(this, null, function* () {
10
11
  const res = yield retry(() => __async(this, null, function* () {
@@ -33,7 +34,8 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
33
34
  content: insertionPrompt
34
35
  }
35
36
  ];
36
- return yield insertionApiConfig.apiEndpoint.run(
37
+ const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
38
+ return yield apiEndpoint.run(
37
39
  abortSignal,
38
40
  messages,
39
41
  insertionApiConfig.forwardedParams
@@ -76,7 +78,8 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
76
78
  content: editingPrompt
77
79
  }
78
80
  ];
79
- return yield editingApiConfig.apiEndpoint.run(
81
+ const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
82
+ return yield apiEndpoint.run(
80
83
  abortSignal,
81
84
  messages,
82
85
  editingApiConfig.forwardedParams
@@ -105,4 +108,4 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
105
108
 
106
109
  export { useMakeStandardInsertionOrEditingFunction };
107
110
  //# sourceMappingURL=out.js.map
108
- //# sourceMappingURL=chunk-VBIJPE3H.mjs.map
111
+ //# sourceMappingURL=chunk-OXPXFYUG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AAyBjC,SAAS,0CACd,iBACA,mBACA,oBACA,kBACwC;AACxC,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AAExE,QAAM,oBAAoB;AAAA,IACxB,CACE,aACA,iBACA,gBACG;AACH,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,mBAAmB;AAAA,cAC1B;AAAA,cACA,iBAAiB,iBAAiB;AAAA,YACpC;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,cACJ,oBAAoB,qBAAqB,gBAAgB;AAC3D,eAAO,MAAM,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,UACA,mBAAmB;AAAA,QACrB;AAAA,MACF,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,oBAAoB,kBAAkB,mBAAmB,eAAe;AAAA,EAC3E;AAEA,QAAM,kBAAkB;AAAA,IACtB,CACE,aACA,eACA,gBACG;AACH,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,iBAAiB;AAAA,cACxB;AAAA,cACA,iBAAiB,iBAAiB;AAAA,YACpC;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,cACJ,oBAAoB,qBAAqB,gBAAgB;AAC3D,eAAO,MAAM,YAAY;AAAA,UACvB;AAAA,UACA;AAAA,UACA,iBAAiB;AAAA,QACnB;AAAA,MACF,EAAC;AAED,aAAO;AAAA,IACT;AAAA,IACA,CAAC,kBAAkB,kBAAkB,mBAAmB,eAAe;AAAA,EACzE;AAEA,QAAM,6BAA6B;AAAA,IACjC,CACE,aACA,iBACA,gBACG;AACH,UAAI,YAAY,iBAAiB,IAAI;AACnC,eAAO,MAAM;AAAA,UACX;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF,OAAO;AACL,eAAO,MAAM,gBAAgB,aAAa,iBAAiB,WAAW;AAAA,MACxE;AAAA,IACF;AAAA,IACA,CAAC,mBAAmB,eAAe;AAAA,EACrC;AAEA,SAAO;AACT","sourcesContent":["import { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport { ChatlikeApiEndpoint, 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\";\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[] | undefined,\n insertionApiConfig: InsertionsApiConfig,\n editingApiConfig: EditingApiConfig\n): Generator_InsertionOrEditingSuggestion {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n\n const insertionFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\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(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 apiEndpoint =\n ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);\n return await apiEndpoint.run(\n abortSignal,\n messages,\n insertionApiConfig.forwardedParams\n );\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 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(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 apiEndpoint =\n ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);\n return await apiEndpoint.run(\n abortSignal,\n messages,\n editingApiConfig.forwardedParams\n );\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 abortSignal: AbortSignal\n ) => {\n if (editorState.selectedText === \"\") {\n return await insertionFunction(\n editorState,\n insertionPrompt,\n abortSignal\n );\n } else {\n return await editingFunction(editorState, insertionPrompt, abortSignal);\n }\n },\n [insertionFunction, editingFunction]\n );\n\n return insertionOrEditingFunction;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { HoveringInsertionPromptBox } from './chunk-6XP7KEMW.mjs';
1
+ import { HoveringInsertionPromptBox } from './chunk-ZA3R6NZI.mjs';
2
2
  import { useHoveringEditorContext } from './chunk-YW3REYX6.mjs';
3
3
  import { Portal, Menu } from './chunk-XHUMROEY.mjs';
4
4
  import { getTextAroundSelection, getFullEditorTextWithNewlines } from './chunk-IXJ2HCOA.mjs';
@@ -104,4 +104,4 @@ function editorState(editor, selection) {
104
104
 
105
105
  export { HoveringToolbar };
106
106
  //# sourceMappingURL=out.js.map
107
- //# sourceMappingURL=chunk-YSZ7DO3X.mjs.map
107
+ //# sourceMappingURL=chunk-U5AJ5PBH.mjs.map
@@ -1,7 +1,7 @@
1
- import { use_autosize_textarea_default } from './chunk-ND5PXTAW.mjs';
2
- import { Button } from './chunk-2NURR2DX.mjs';
3
1
  import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator } from './chunk-XA7M72ZO.mjs';
4
2
  import { Label } from './chunk-5EJ5XOGP.mjs';
3
+ import { Button } from './chunk-2NURR2DX.mjs';
4
+ import { use_autosize_textarea_default } from './chunk-ND5PXTAW.mjs';
5
5
  import { streamPromiseFlatten } from './chunk-FN7GDKKG.mjs';
6
6
  import { __objRest, __spreadProps, __spreadValues, __async } from './chunk-MRXNTQOX.mjs';
7
7
  import { useState, useRef, useEffect } from 'react';
@@ -498,4 +498,4 @@ function Logo({
498
498
 
499
499
  export { FileChipPreview, HoveringInsertionPromptBoxCore, IconForFilePointer, IncludedFilesPreview, Logo, SourceSearchBox };
500
500
  //# sourceMappingURL=out.js.map
501
- //# sourceMappingURL=chunk-FBDXI5QA.mjs.map
501
+ //# sourceMappingURL=chunk-XYXKONR4.mjs.map
@@ -1,4 +1,4 @@
1
- import { HoveringInsertionPromptBoxCore } from './chunk-FBDXI5QA.mjs';
1
+ import { HoveringInsertionPromptBoxCore } from './chunk-XYXKONR4.mjs';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
 
4
4
  var HoveringInsertionPromptBox = (props) => {
@@ -17,4 +17,4 @@ var HoveringInsertionPromptBox = (props) => {
17
17
 
18
18
  export { HoveringInsertionPromptBox };
19
19
  //# sourceMappingURL=out.js.map
20
- //# sourceMappingURL=chunk-6XP7KEMW.mjs.map
20
+ //# sourceMappingURL=chunk-ZA3R6NZI.mjs.map
@@ -1,31 +1,31 @@
1
- export { BaseCopilotTextarea } from '../../chunk-IWTOQKC5.mjs';
2
- import '../../chunk-CSGFJU3L.mjs';
3
- import '../../chunk-KCHYD3EB.mjs';
4
- import '../../chunk-YQU7WG7T.mjs';
1
+ export { BaseCopilotTextarea } from '../../chunk-NKA6K7FW.mjs';
5
2
  import '../../chunk-WJYQWL4I.mjs';
6
3
  import '../../chunk-F3MHL6ZY.mjs';
7
- import '../../chunk-RQHOUUXQ.mjs';
8
- import '../../chunk-UHD44NC5.mjs';
9
- import '../../chunk-JAFCXEPU.mjs';
4
+ import '../../chunk-U5AJ5PBH.mjs';
5
+ import '../../chunk-L7VVZH4Q.mjs';
6
+ import '../../chunk-ZA3R6NZI.mjs';
7
+ import '../../chunk-YW3REYX6.mjs';
8
+ import '../../chunk-XHUMROEY.mjs';
9
+ import '../../chunk-XYXKONR4.mjs';
10
+ import '../../chunk-XA7M72ZO.mjs';
11
+ import '../../chunk-O5OWT5GE.mjs';
12
+ import '../../chunk-5EJ5XOGP.mjs';
13
+ import '../../chunk-2NURR2DX.mjs';
14
+ import '../../chunk-ND5PXTAW.mjs';
10
15
  import '../../chunk-LNAIMEB2.mjs';
11
16
  import '../../chunk-OELUUJZY.mjs';
12
17
  import '../../chunk-OD7ZMOVE.mjs';
13
18
  import '../../chunk-MPME5BW2.mjs';
19
+ import '../../chunk-FN7GDKKG.mjs';
14
20
  import '../../chunk-WJHSY5T6.mjs';
15
21
  import '../../chunk-D7SEV5PR.mjs';
16
- import '../../chunk-YSZ7DO3X.mjs';
17
- import '../../chunk-L7VVZH4Q.mjs';
18
- import '../../chunk-6XP7KEMW.mjs';
19
- import '../../chunk-FBDXI5QA.mjs';
20
- import '../../chunk-ND5PXTAW.mjs';
21
- import '../../chunk-2NURR2DX.mjs';
22
- import '../../chunk-XA7M72ZO.mjs';
23
- import '../../chunk-O5OWT5GE.mjs';
24
- import '../../chunk-5EJ5XOGP.mjs';
25
- import '../../chunk-FN7GDKKG.mjs';
22
+ import '../../chunk-UHD44NC5.mjs';
23
+ import '../../chunk-JAFCXEPU.mjs';
26
24
  import '../../chunk-KGKLUWKW.mjs';
27
- import '../../chunk-YW3REYX6.mjs';
28
- import '../../chunk-XHUMROEY.mjs';
25
+ import '../../chunk-CSGFJU3L.mjs';
26
+ import '../../chunk-KCHYD3EB.mjs';
27
+ import '../../chunk-YQU7WG7T.mjs';
28
+ import '../../chunk-RQHOUUXQ.mjs';
29
29
  import '../../chunk-NKW5OU2S.mjs';
30
30
  import '../../chunk-YTOPHPSG.mjs';
31
31
  import '../../chunk-IXJ2HCOA.mjs';
@@ -8,7 +8,6 @@ import '../../types/autosuggestions-config/autosuggestions-config.js';
8
8
  import '../../types/autosuggestions-config/suggestions-api-config.js';
9
9
  import '../../types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js';
10
10
  import '../../types/autosuggestions-config/subtypes/make-system-prompt.js';
11
- import '../../types/autosuggestions-config/subtypes/chatlike-api-endpoint.js';
12
11
  import '../../types/autosuggestions-config/insertions-api-config.js';
13
12
  import '../../types/autosuggestions-config/editing-api-config.js';
14
13
 
@@ -1,40 +1,42 @@
1
- export { CopilotTextarea } from '../../chunk-N4JMCC7P.mjs';
2
- import '../../chunk-HAFHLU4N.mjs';
3
- import '../../chunk-VBIJPE3H.mjs';
4
- import '../../chunk-IWTOQKC5.mjs';
5
- import '../../chunk-CSGFJU3L.mjs';
6
- import '../../chunk-KCHYD3EB.mjs';
7
- import '../../chunk-YQU7WG7T.mjs';
1
+ export { CopilotTextarea } from '../../chunk-7XKICWEE.mjs';
2
+ import '../../chunk-K2AVA67P.mjs';
3
+ import '../../chunk-OXPXFYUG.mjs';
4
+ import '../../chunk-NKA6K7FW.mjs';
8
5
  import '../../chunk-WJYQWL4I.mjs';
9
6
  import '../../chunk-F3MHL6ZY.mjs';
10
- import '../../chunk-RQHOUUXQ.mjs';
11
- import '../../chunk-UHD44NC5.mjs';
12
- import '../../chunk-JAFCXEPU.mjs';
7
+ import '../../chunk-U5AJ5PBH.mjs';
8
+ import '../../chunk-L7VVZH4Q.mjs';
9
+ import '../../chunk-ZA3R6NZI.mjs';
10
+ import '../../chunk-YW3REYX6.mjs';
11
+ import '../../chunk-XHUMROEY.mjs';
12
+ import '../../chunk-XYXKONR4.mjs';
13
+ import '../../chunk-XA7M72ZO.mjs';
14
+ import '../../chunk-O5OWT5GE.mjs';
15
+ import '../../chunk-5EJ5XOGP.mjs';
16
+ import '../../chunk-2NURR2DX.mjs';
17
+ import '../../chunk-ND5PXTAW.mjs';
13
18
  import '../../chunk-LNAIMEB2.mjs';
14
19
  import '../../chunk-OELUUJZY.mjs';
15
20
  import '../../chunk-OD7ZMOVE.mjs';
16
21
  import '../../chunk-MPME5BW2.mjs';
22
+ import '../../chunk-FN7GDKKG.mjs';
23
+ import '../../chunk-DE5K76I2.mjs';
17
24
  import '../../chunk-5FO6ISW4.mjs';
18
- import '../../chunk-QL2GYGG5.mjs';
19
- import '../../chunk-55EGOC5T.mjs';
20
- import '../../chunk-XDT7BF3V.mjs';
21
- import '../../chunk-A2RRLD23.mjs';
22
- import '../../chunk-5ARCOTW3.mjs';
25
+ import '../../chunk-KIRROE2K.mjs';
26
+ import '../../chunk-2TQBFDO7.mjs';
27
+ import '../../chunk-HRTFMM7P.mjs';
28
+ import '../../chunk-66BDXIX4.mjs';
29
+ import '../../chunk-JHTAOLEW.mjs';
23
30
  import '../../chunk-WJHSY5T6.mjs';
24
31
  import '../../chunk-D7SEV5PR.mjs';
25
- import '../../chunk-YSZ7DO3X.mjs';
26
- import '../../chunk-L7VVZH4Q.mjs';
27
- import '../../chunk-6XP7KEMW.mjs';
28
- import '../../chunk-FBDXI5QA.mjs';
29
- import '../../chunk-ND5PXTAW.mjs';
30
- import '../../chunk-2NURR2DX.mjs';
31
- import '../../chunk-XA7M72ZO.mjs';
32
- import '../../chunk-O5OWT5GE.mjs';
33
- import '../../chunk-5EJ5XOGP.mjs';
34
- import '../../chunk-FN7GDKKG.mjs';
32
+ import '../../chunk-WADHCMPK.mjs';
33
+ import '../../chunk-UHD44NC5.mjs';
34
+ import '../../chunk-JAFCXEPU.mjs';
35
35
  import '../../chunk-KGKLUWKW.mjs';
36
- import '../../chunk-YW3REYX6.mjs';
37
- import '../../chunk-XHUMROEY.mjs';
36
+ import '../../chunk-CSGFJU3L.mjs';
37
+ import '../../chunk-KCHYD3EB.mjs';
38
+ import '../../chunk-YQU7WG7T.mjs';
39
+ import '../../chunk-RQHOUUXQ.mjs';
38
40
  import '../../chunk-NKW5OU2S.mjs';
39
41
  import '../../chunk-YTOPHPSG.mjs';
40
42
  import '../../chunk-IXJ2HCOA.mjs';
@@ -1,16 +1,16 @@
1
- export { HoveringToolbar } from '../../chunk-YSZ7DO3X.mjs';
1
+ export { HoveringToolbar } from '../../chunk-U5AJ5PBH.mjs';
2
2
  import '../../chunk-L7VVZH4Q.mjs';
3
- import '../../chunk-6XP7KEMW.mjs';
4
- import '../../chunk-FBDXI5QA.mjs';
5
- import '../../chunk-ND5PXTAW.mjs';
6
- import '../../chunk-2NURR2DX.mjs';
3
+ import '../../chunk-ZA3R6NZI.mjs';
4
+ import '../../chunk-YW3REYX6.mjs';
5
+ import '../../chunk-XHUMROEY.mjs';
6
+ import '../../chunk-XYXKONR4.mjs';
7
7
  import '../../chunk-XA7M72ZO.mjs';
8
8
  import '../../chunk-O5OWT5GE.mjs';
9
9
  import '../../chunk-5EJ5XOGP.mjs';
10
+ import '../../chunk-2NURR2DX.mjs';
11
+ import '../../chunk-ND5PXTAW.mjs';
10
12
  import '../../chunk-FN7GDKKG.mjs';
11
13
  import '../../chunk-KGKLUWKW.mjs';
12
- import '../../chunk-YW3REYX6.mjs';
13
- import '../../chunk-XHUMROEY.mjs';
14
14
  import '../../chunk-IXJ2HCOA.mjs';
15
15
  import '../../chunk-MRXNTQOX.mjs';
16
16
  //# sourceMappingURL=out.js.map
@@ -1,9 +1,9 @@
1
- export { FileChipPreview, HoveringInsertionPromptBoxCore, IconForFilePointer, IncludedFilesPreview } from '../../../chunk-FBDXI5QA.mjs';
2
- import '../../../chunk-ND5PXTAW.mjs';
3
- import '../../../chunk-2NURR2DX.mjs';
1
+ export { FileChipPreview, HoveringInsertionPromptBoxCore, IconForFilePointer, IncludedFilesPreview } from '../../../chunk-XYXKONR4.mjs';
4
2
  import '../../../chunk-XA7M72ZO.mjs';
5
3
  import '../../../chunk-O5OWT5GE.mjs';
6
4
  import '../../../chunk-5EJ5XOGP.mjs';
5
+ import '../../../chunk-2NURR2DX.mjs';
6
+ import '../../../chunk-ND5PXTAW.mjs';
7
7
  import '../../../chunk-FN7GDKKG.mjs';
8
8
  import '../../../chunk-KGKLUWKW.mjs';
9
9
  import '../../../chunk-MRXNTQOX.mjs';
@@ -1,10 +1,10 @@
1
- export { HoveringInsertionPromptBox } from '../../../chunk-6XP7KEMW.mjs';
2
- import '../../../chunk-FBDXI5QA.mjs';
3
- import '../../../chunk-ND5PXTAW.mjs';
4
- import '../../../chunk-2NURR2DX.mjs';
1
+ export { HoveringInsertionPromptBox } from '../../../chunk-ZA3R6NZI.mjs';
2
+ import '../../../chunk-XYXKONR4.mjs';
5
3
  import '../../../chunk-XA7M72ZO.mjs';
6
4
  import '../../../chunk-O5OWT5GE.mjs';
7
5
  import '../../../chunk-5EJ5XOGP.mjs';
6
+ import '../../../chunk-2NURR2DX.mjs';
7
+ import '../../../chunk-ND5PXTAW.mjs';
8
8
  import '../../../chunk-FN7GDKKG.mjs';
9
9
  import '../../../chunk-KGKLUWKW.mjs';
10
10
  import '../../../chunk-MRXNTQOX.mjs';
@@ -1,11 +1,11 @@
1
1
  import '../../../chunk-L7VVZH4Q.mjs';
2
- export { HoveringInsertionPromptBox } from '../../../chunk-6XP7KEMW.mjs';
3
- import '../../../chunk-FBDXI5QA.mjs';
4
- import '../../../chunk-ND5PXTAW.mjs';
5
- import '../../../chunk-2NURR2DX.mjs';
2
+ export { HoveringInsertionPromptBox } from '../../../chunk-ZA3R6NZI.mjs';
3
+ import '../../../chunk-XYXKONR4.mjs';
6
4
  import '../../../chunk-XA7M72ZO.mjs';
7
5
  import '../../../chunk-O5OWT5GE.mjs';
8
6
  import '../../../chunk-5EJ5XOGP.mjs';
7
+ import '../../../chunk-2NURR2DX.mjs';
8
+ import '../../../chunk-ND5PXTAW.mjs';
9
9
  import '../../../chunk-FN7GDKKG.mjs';
10
10
  import '../../../chunk-KGKLUWKW.mjs';
11
11
  import '../../../chunk-MRXNTQOX.mjs';
@@ -10,6 +10,5 @@ import '../types/autosuggestions-config/autosuggestions-config.js';
10
10
  import '../types/autosuggestions-config/suggestions-api-config.js';
11
11
  import '../types/autosuggestions-config/subtypes/minimal-chat-gpt-message.js';
12
12
  import '../types/autosuggestions-config/subtypes/make-system-prompt.js';
13
- import '../types/autosuggestions-config/subtypes/chatlike-api-endpoint.js';
14
13
  import '../types/autosuggestions-config/insertions-api-config.js';
15
14
  import '../types/autosuggestions-config/editing-api-config.js';