@copilotkit/react-core 1.72.0 → 1.73.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
@@ -5283,6 +5283,7 @@ react_markdown = __toESM(react_markdown);
5283
5283
  }
5284
5284
  function CopilotKitInternal(cpkProps) {
5285
5285
  const { children, ...props } = cpkProps;
5286
+ const { copilotkit } = useCopilotKit();
5286
5287
  /**
5287
5288
  * This will throw an error if the props are invalid.
5288
5289
  */
@@ -5318,10 +5319,14 @@ react_markdown = __toESM(react_markdown);
5318
5319
  });
5319
5320
  }, []);
5320
5321
  const getContextString = (0, react.useCallback)((documents, categories) => {
5321
- return `${documents.map((document) => {
5322
+ const documentsString = documents.map((document) => {
5322
5323
  return `${document.name} (${document.sourceApplication}):\n${document.getContents()}`;
5323
- }).join("\n\n")}\n\n${printTree(categories)}`;
5324
- }, [printTree]);
5324
+ }).join("\n\n");
5325
+ const nonDocumentStrings = printTree(categories);
5326
+ const readableContextString = copilotkit.getContextForAgent().map(({ description, value }) => `${description}:\n${value}`).join("\n\n");
5327
+ const existingContextString = `${documentsString}\n\n${nonDocumentStrings}`;
5328
+ return readableContextString ? `${existingContextString}\n\n${readableContextString}` : existingContextString;
5329
+ }, [copilotkit, printTree]);
5325
5330
  const addContext = (0, react.useCallback)((context, parentId, categories = defaultCopilotContextCategories) => {
5326
5331
  return addElement(context, categories, parentId);
5327
5332
  }, [addElement]);