@copilotkit/react-textarea 1.4.8-next.2 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -16
- package/dist/{chunk-BNBGJBBM.mjs → chunk-53RID4IZ.mjs} +3 -3
- package/dist/{chunk-QFXR6DOA.mjs → chunk-GUZIMGGZ.mjs} +1 -1
- package/dist/chunk-GUZIMGGZ.mjs.map +1 -0
- package/dist/{chunk-F6GMWOLE.mjs → chunk-PTPNOBEI.mjs} +3 -4
- package/dist/chunk-PTPNOBEI.mjs.map +1 -0
- package/dist/{chunk-MGYT7RNL.mjs → chunk-ZTYA6QOT.mjs} +2 -2
- package/dist/components/copilot-textarea/copilot-textarea.js +2 -3
- package/dist/components/copilot-textarea/copilot-textarea.js.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +4 -4
- package/dist/components/index.js +2 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js +2 -3
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/types/autosuggestions-config/autosuggestions-config.js.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +2 -2
- package/dist/types/autosuggestions-config/index.js.map +1 -1
- package/dist/types/autosuggestions-config/index.mjs +2 -2
- package/dist/types/autosuggestions-config/suggestions-api-config.d.ts +0 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.js.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +2 -2
- package/package.json +4 -4
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +2 -2
- package/src/types/autosuggestions-config/suggestions-api-config.tsx +0 -1
- package/dist/chunk-F6GMWOLE.mjs.map +0 -1
- package/dist/chunk-QFXR6DOA.mjs.map +0 -1
- /package/dist/{chunk-BNBGJBBM.mjs.map → chunk-53RID4IZ.mjs.map} +0 -0
- /package/dist/{chunk-MGYT7RNL.mjs.map → chunk-ZTYA6QOT.mjs.map} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "../chunk-MMVDU6DF.mjs";
|
|
2
2
|
import {
|
|
3
3
|
CopilotTextarea
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-53RID4IZ.mjs";
|
|
5
5
|
import "../chunk-RXV67GJN.mjs";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-PTPNOBEI.mjs";
|
|
7
7
|
import "../chunk-RUV6NBIF.mjs";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-ZTYA6QOT.mjs";
|
|
9
9
|
import "../chunk-EJGGLWWR.mjs";
|
|
10
10
|
import "../chunk-MCNXIA4Q.mjs";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-GUZIMGGZ.mjs";
|
|
12
12
|
import {
|
|
13
13
|
BaseCopilotTextarea
|
|
14
14
|
} from "../chunk-PZYM7K4Y.mjs";
|
package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js
CHANGED
|
@@ -82,7 +82,7 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
82
82
|
const { getContextString, copilotApiConfig, runtimeClient } = (0, import_react_core.useCopilotContext)();
|
|
83
83
|
const { chatApiEndpoint: url, publicApiKey, credentials, properties } = copilotApiConfig;
|
|
84
84
|
const headers = __spreadValues(__spreadValues({}, copilotApiConfig.headers), publicApiKey ? { [import_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
85
|
-
const { maxTokens, stop
|
|
85
|
+
const { maxTokens, stop } = apiConfig;
|
|
86
86
|
return (0, import_react.useCallback)(
|
|
87
87
|
(editorState, abortSignal) => __async(this, null, function* () {
|
|
88
88
|
const res = yield retry(() => __async(this, null, function* () {
|
|
@@ -121,8 +121,7 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
121
121
|
},
|
|
122
122
|
forwardedParameters: {
|
|
123
123
|
maxTokens,
|
|
124
|
-
stop
|
|
125
|
-
temperature
|
|
124
|
+
stop
|
|
126
125
|
}
|
|
127
126
|
},
|
|
128
127
|
properties,
|
package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx","../../../src/lib/retry.tsx"],"sourcesContent":["import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER } from \"@copilotkit/shared\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback } from \"react\";\nimport { AutosuggestionsBareFunction } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\nimport {\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n CopilotRequestType,\n} from \"@copilotkit/runtime-client-gql\";\n\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardAutosuggestionFunction(\n textareaPurpose: string,\n contextCategories: string[],\n apiConfig: SuggestionsApiConfig,\n): AutosuggestionsBareFunction {\n const { getContextString, copilotApiConfig, runtimeClient } = useCopilotContext();\n const { chatApiEndpoint: url, publicApiKey, credentials, properties } = copilotApiConfig;\n const headers = {\n ...copilotApiConfig.headers,\n ...(publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {}),\n };\n const { maxTokens, stop
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx","../../../src/lib/retry.tsx"],"sourcesContent":["import { COPILOT_CLOUD_PUBLIC_API_KEY_HEADER } from \"@copilotkit/shared\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback } from \"react\";\nimport { AutosuggestionsBareFunction } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport { InsertionEditorState } from \"../../types/base/autosuggestions-bare-function\";\nimport { SuggestionsApiConfig } from \"../../types/autosuggestions-config/suggestions-api-config\";\nimport {\n CopilotRuntimeClient,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n CopilotRequestType,\n} from \"@copilotkit/runtime-client-gql\";\n\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardAutosuggestionFunction(\n textareaPurpose: string,\n contextCategories: string[],\n apiConfig: SuggestionsApiConfig,\n): AutosuggestionsBareFunction {\n const { getContextString, copilotApiConfig, runtimeClient } = useCopilotContext();\n const { chatApiEndpoint: url, publicApiKey, credentials, properties } = copilotApiConfig;\n const headers = {\n ...copilotApiConfig.headers,\n ...(publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {}),\n };\n const { maxTokens, stop } = apiConfig;\n\n return useCallback(\n async (editorState: InsertionEditorState, abortSignal: AbortSignal) => {\n const res = await retry(async () => {\n // @ts-expect-error -- Passing null is forbidden, but we're filtering it later\n const messages: Message[] = [\n new TextMessage({\n role: Role.System,\n content: apiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString([], contextCategories),\n ),\n }),\n ...apiConfig.fewShotMessages,\n editorState.textAfterCursor != \"\"\n ? new TextMessage({\n role: Role.User,\n content: editorState.textAfterCursor,\n })\n : null,\n new TextMessage({\n role: Role.User,\n content: `<TextAfterCursor>${editorState.textAfterCursor}</TextAfterCursor>`,\n }),\n new TextMessage({\n role: Role.User,\n content: `<TextBeforeCursor>${editorState.textBeforeCursor}</TextBeforeCursor>`,\n }),\n ].filter(Boolean);\n\n const response = await runtimeClient\n .generateCopilotResponse({\n data: {\n frontend: {\n actions: [],\n url: window.location.href,\n },\n messages: convertMessagesToGqlInput(filterAgentStateMessages(messages)),\n metadata: {\n requestType: CopilotRequestType.TextareaCompletion,\n },\n forwardedParameters: {\n maxTokens,\n stop,\n },\n },\n properties,\n signal: abortSignal,\n })\n .toPromise();\n\n let result = \"\";\n for (const message of convertGqlOutputToMessages(\n response.data?.generateCopilotResponse?.messages ?? [],\n )) {\n if (abortSignal.aborted) {\n break;\n }\n if (message.isTextMessage()) {\n result += message.content;\n }\n }\n\n return result;\n });\n\n return res;\n },\n [apiConfig, getContextString, contextCategories, textareaPurpose],\n );\n}\n","export function 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAoD;AACpD,wBAAkC;AAClC,mBAA4B;;;ACFrB,SAAS,MACd,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;;;ADfA,gCASO;AAeA,SAAS,sCACd,iBACA,mBACA,WAC6B;AAC7B,QAAM,EAAE,kBAAkB,kBAAkB,cAAc,QAAI,qCAAkB;AAChF,QAAM,EAAE,iBAAiB,KAAK,cAAc,aAAa,WAAW,IAAI;AACxE,QAAM,UAAU,kCACX,iBAAiB,UAChB,eAAe,EAAE,CAAC,iDAAmC,GAAG,aAAa,IAAI,CAAC;AAEhF,QAAM,EAAE,WAAW,KAAK,IAAI;AAE5B,aAAO;AAAA,IACL,CAAO,aAAmC,gBAA6B;AACrE,YAAM,MAAM,MAAM,MAAM,MAAY;AA9C1C;AAgDQ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AAA,EAClE;AACF;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1824,7 +1824,7 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
1824
1824
|
const { getContextString, copilotApiConfig, runtimeClient } = (0, import_react_core3.useCopilotContext)();
|
|
1825
1825
|
const { chatApiEndpoint: url, publicApiKey, credentials, properties } = copilotApiConfig;
|
|
1826
1826
|
const headers = __spreadValues(__spreadValues({}, copilotApiConfig.headers), publicApiKey ? { [import_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
1827
|
-
const { maxTokens, stop
|
|
1827
|
+
const { maxTokens, stop } = apiConfig;
|
|
1828
1828
|
return (0, import_react13.useCallback)(
|
|
1829
1829
|
(editorState2, abortSignal) => __async(this, null, function* () {
|
|
1830
1830
|
const res = yield retry(() => __async(this, null, function* () {
|
|
@@ -1863,8 +1863,7 @@ function useMakeStandardAutosuggestionFunction(textareaPurpose, contextCategorie
|
|
|
1863
1863
|
},
|
|
1864
1864
|
forwardedParameters: {
|
|
1865
1865
|
maxTokens,
|
|
1866
|
-
stop
|
|
1867
|
-
temperature
|
|
1866
|
+
stop
|
|
1868
1867
|
}
|
|
1869
1868
|
},
|
|
1870
1869
|
properties,
|