@copilotkit/react-textarea 1.71.1 → 1.72.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.
package/dist/index.umd.js CHANGED
@@ -1691,7 +1691,13 @@ The conversation will be structured as follows:
1691
1691
 
1692
1692
  //#endregion
1693
1693
  //#region src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx
1694
- /**
1694
+ let warnedDeprecated = false;
1695
+ function warnDeprecatedOnce() {
1696
+ if (warnedDeprecated) return;
1697
+ warnedDeprecated = true;
1698
+ console.warn("[CopilotKit] CopilotTextarea insertion and editing are no longer functional. @copilotkit/react-textarea is a deprecated v1 package and the backend it called was removed in v1.50.0. There is no 1:1 v2 replacement; start from @copilotkit/react-core/v2.");
1699
+ }
1700
+ /**
1695
1701
  * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.
1696
1702
  * The function takes in the text before and after the cursor, and an abort signal.
1697
1703
  * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.
@@ -1705,110 +1711,23 @@ The conversation will be structured as follows:
1705
1711
  * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.
1706
1712
  */
1707
1713
  function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCategories, insertionApiConfig, editingApiConfig) {
1708
- const runtimeClient = { generateCopilotResponse: (...args) => {} };
1709
- const { getContextString, copilotApiConfig } = (0, _copilotkit_react_core.useCopilotContext)();
1710
- copilotApiConfig.publicApiKey && copilotApiConfig.publicApiKey;
1711
- async function runtimeClientResponseToStringStream(responsePromise) {
1712
- const messagesStream = runtimeClient.asStream(responsePromise);
1713
- return new ReadableStream({ async start(controller) {
1714
- const reader = messagesStream.getReader();
1715
- let sentContent = "";
1716
- while (true) {
1717
- const { done, value } = await reader.read();
1718
- if (done) break;
1719
- const messages = (0, _copilotkit_runtime_client_gql.convertGqlOutputToMessages)(value.generateCopilotResponse.messages);
1720
- let newContent = "";
1721
- for (const message of messages) if (message.isTextMessage()) newContent += message.content;
1722
- if (newContent) {
1723
- const contentToSend = newContent.slice(sentContent.length);
1724
- controller.enqueue(contentToSend);
1725
- sentContent += contentToSend;
1726
- }
1727
- }
1714
+ const emptySuggestionStream = () => {
1715
+ warnDeprecatedOnce();
1716
+ return new ReadableStream({ start(controller) {
1728
1717
  controller.close();
1729
1718
  } });
1730
- }
1719
+ };
1731
1720
  const insertionFunction = (0, react.useCallback)(async (editorState, insertionPrompt, documents, abortSignal) => {
1732
- return await retry(async () => {
1733
- const messages = [
1734
- new _copilotkit_runtime_client_gql.TextMessage({
1735
- role: _copilotkit_runtime_client_gql.Role.System,
1736
- content: insertionApiConfig.makeSystemPrompt(textareaPurpose, getContextString(documents, contextCategories))
1737
- }),
1738
- ...insertionApiConfig.fewShotMessages,
1739
- new _copilotkit_runtime_client_gql.TextMessage({
1740
- role: _copilotkit_runtime_client_gql.Role.User,
1741
- content: `<TextAfterCursor>${editorState.textAfterCursor}</TextAfterCursor>`
1742
- }),
1743
- new _copilotkit_runtime_client_gql.TextMessage({
1744
- role: _copilotkit_runtime_client_gql.Role.User,
1745
- content: `<TextBeforeCursor>${editorState.textBeforeCursor}</TextBeforeCursor>`
1746
- }),
1747
- new _copilotkit_runtime_client_gql.TextMessage({
1748
- role: _copilotkit_runtime_client_gql.Role.User,
1749
- content: `<InsertionPrompt>${insertionPrompt}</InsertionPrompt>`
1750
- })
1751
- ];
1752
- return runtimeClientResponseToStringStream(runtimeClient.generateCopilotResponse({
1753
- data: {
1754
- frontend: {
1755
- actions: [],
1756
- url: window.location.href
1757
- },
1758
- messages: (0, _copilotkit_runtime_client_gql.convertMessagesToGqlInput)((0, _copilotkit_runtime_client_gql.filterAgentStateMessages)(messages)),
1759
- metadata: { requestType: _copilotkit_runtime_client_gql.CopilotRequestType.TextareaCompletion }
1760
- },
1761
- properties: copilotApiConfig.properties,
1762
- signal: abortSignal
1763
- }));
1764
- });
1721
+ return emptySuggestionStream();
1765
1722
  }, [
1766
1723
  insertionApiConfig,
1767
- getContextString,
1768
1724
  contextCategories,
1769
1725
  textareaPurpose
1770
1726
  ]);
1771
1727
  const editingFunction = (0, react.useCallback)(async (editorState, editingPrompt, documents, abortSignal) => {
1772
- return await retry(async () => {
1773
- const messages = [
1774
- new _copilotkit_runtime_client_gql.TextMessage({
1775
- role: _copilotkit_runtime_client_gql.Role.System,
1776
- content: editingApiConfig.makeSystemPrompt(textareaPurpose, getContextString(documents, contextCategories))
1777
- }),
1778
- ...editingApiConfig.fewShotMessages,
1779
- new _copilotkit_runtime_client_gql.TextMessage({
1780
- role: _copilotkit_runtime_client_gql.Role.User,
1781
- content: `<TextBeforeCursor>${editorState.textBeforeCursor}</TextBeforeCursor>`
1782
- }),
1783
- new _copilotkit_runtime_client_gql.TextMessage({
1784
- role: _copilotkit_runtime_client_gql.Role.User,
1785
- content: `<TextToEdit>${editorState.selectedText}</TextToEdit>`
1786
- }),
1787
- new _copilotkit_runtime_client_gql.TextMessage({
1788
- role: _copilotkit_runtime_client_gql.Role.User,
1789
- content: `<TextAfterCursor>${editorState.textAfterCursor}</TextAfterCursor>`
1790
- }),
1791
- new _copilotkit_runtime_client_gql.TextMessage({
1792
- role: _copilotkit_runtime_client_gql.Role.User,
1793
- content: `<EditingPrompt>${editingPrompt}</EditingPrompt>`
1794
- })
1795
- ];
1796
- return runtimeClientResponseToStringStream(runtimeClient.generateCopilotResponse({
1797
- data: {
1798
- frontend: {
1799
- actions: [],
1800
- url: window.location.href
1801
- },
1802
- messages: (0, _copilotkit_runtime_client_gql.convertMessagesToGqlInput)((0, _copilotkit_runtime_client_gql.filterAgentStateMessages)(messages)),
1803
- metadata: { requestType: _copilotkit_runtime_client_gql.CopilotRequestType.TextareaCompletion }
1804
- },
1805
- properties: copilotApiConfig.properties,
1806
- signal: abortSignal
1807
- }));
1808
- });
1728
+ return emptySuggestionStream();
1809
1729
  }, [
1810
1730
  editingApiConfig,
1811
- getContextString,
1812
1731
  contextCategories,
1813
1732
  textareaPurpose
1814
1733
  ]);