@copilotkit/react-core 0.18.0-alpha.8 → 0.18.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 (159) hide show
  1. package/.turbo/turbo-build.log +198 -245
  2. package/CHANGELOG.md +43 -0
  3. package/dist/chunk-4CFJ6A6A.mjs +15 -9
  4. package/dist/chunk-4CFJ6A6A.mjs.map +1 -1
  5. package/dist/chunk-5GS7FQPW.mjs +20 -7
  6. package/dist/chunk-5GS7FQPW.mjs.map +1 -1
  7. package/dist/chunk-5UGLWBZJ.mjs +0 -2
  8. package/dist/chunk-5UGLWBZJ.mjs.map +1 -1
  9. package/dist/chunk-7GFKOIO7.mjs +0 -2
  10. package/dist/chunk-7GFKOIO7.mjs.map +1 -1
  11. package/dist/chunk-BABVSMJR.mjs +0 -2
  12. package/dist/chunk-BABVSMJR.mjs.map +1 -1
  13. package/dist/chunk-DGUVNY3V.mjs +9 -5
  14. package/dist/chunk-DGUVNY3V.mjs.map +1 -1
  15. package/dist/chunk-EFZPSZWO.mjs +0 -2
  16. package/dist/chunk-EFZPSZWO.mjs.map +1 -1
  17. package/dist/chunk-F2JIAPZQ.mjs +3 -2
  18. package/dist/chunk-F2JIAPZQ.mjs.map +1 -1
  19. package/dist/chunk-FRAKUJWH.mjs +0 -2
  20. package/dist/chunk-FRAKUJWH.mjs.map +1 -1
  21. package/dist/chunk-GBZZPQ5X.mjs +28 -10
  22. package/dist/chunk-GBZZPQ5X.mjs.map +1 -1
  23. package/dist/chunk-IQEWY7P4.mjs +13 -6
  24. package/dist/chunk-IQEWY7P4.mjs.map +1 -1
  25. package/dist/chunk-IQH5AQQC.mjs +8 -4
  26. package/dist/chunk-IQH5AQQC.mjs.map +1 -1
  27. package/dist/chunk-JD7BAH7U.mjs +0 -2
  28. package/dist/chunk-JD7BAH7U.mjs.map +1 -1
  29. package/dist/chunk-MRXNTQOX.mjs +6 -2
  30. package/dist/chunk-MRXNTQOX.mjs.map +1 -1
  31. package/dist/chunk-MZ5UN3BY.mjs +6 -3
  32. package/dist/chunk-MZ5UN3BY.mjs.map +1 -1
  33. package/dist/chunk-SPCZTZCY.mjs +0 -2
  34. package/dist/chunk-SPCZTZCY.mjs.map +1 -1
  35. package/dist/chunk-UAKLDQMP.mjs +16 -4
  36. package/dist/chunk-UAKLDQMP.mjs.map +1 -1
  37. package/dist/chunk-VNRDQJXW.mjs +0 -2
  38. package/dist/chunk-VNRDQJXW.mjs.map +1 -1
  39. package/dist/chunk-VP2EU4US.mjs +21 -9
  40. package/dist/chunk-VP2EU4US.mjs.map +1 -1
  41. package/dist/chunk-VUY2K2DI.mjs +10 -5
  42. package/dist/chunk-VUY2K2DI.mjs.map +1 -1
  43. package/dist/chunk-YOXWT7I6.mjs +8 -4
  44. package/dist/chunk-YOXWT7I6.mjs.map +1 -1
  45. package/dist/chunk-YULKJPY3.mjs +5 -5
  46. package/dist/chunk-YULKJPY3.mjs.map +1 -1
  47. package/dist/components/copilot-provider/copilotkit-props.js +18 -2
  48. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  49. package/dist/components/copilot-provider/copilotkit-props.mjs +1 -2
  50. package/dist/components/copilot-provider/copilotkit-props.mjs.map +1 -1
  51. package/dist/components/copilot-provider/copilotkit.js +89 -44
  52. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  53. package/dist/components/copilot-provider/copilotkit.mjs +14 -7
  54. package/dist/components/copilot-provider/copilotkit.mjs.map +1 -1
  55. package/dist/components/copilot-provider/index.js +90 -44
  56. package/dist/components/copilot-provider/index.js.map +1 -1
  57. package/dist/components/copilot-provider/index.mjs +14 -8
  58. package/dist/components/copilot-provider/index.mjs.map +1 -1
  59. package/dist/components/copilot-provider/standard-copilot-api-config.js +27 -4
  60. package/dist/components/copilot-provider/standard-copilot-api-config.js.map +1 -1
  61. package/dist/components/copilot-provider/standard-copilot-api-config.mjs +7 -3
  62. package/dist/components/copilot-provider/standard-copilot-api-config.mjs.map +1 -1
  63. package/dist/components/index.js +90 -44
  64. package/dist/components/index.js.map +1 -1
  65. package/dist/components/index.mjs +15 -9
  66. package/dist/components/index.mjs.map +1 -1
  67. package/dist/context/copilot-context.js +68 -16
  68. package/dist/context/copilot-context.js.map +1 -1
  69. package/dist/context/copilot-context.mjs +8 -3
  70. package/dist/context/copilot-context.mjs.map +1 -1
  71. package/dist/context/index.js +68 -15
  72. package/dist/context/index.js.map +1 -1
  73. package/dist/context/index.mjs +8 -4
  74. package/dist/context/index.mjs.map +1 -1
  75. package/dist/hooks/index.js +98 -42
  76. package/dist/hooks/index.js.map +1 -1
  77. package/dist/hooks/index.mjs +29 -16
  78. package/dist/hooks/index.mjs.map +1 -1
  79. package/dist/hooks/use-chat.js +38 -15
  80. package/dist/hooks/use-chat.js.map +1 -1
  81. package/dist/hooks/use-chat.mjs +8 -4
  82. package/dist/hooks/use-chat.mjs.map +1 -1
  83. package/dist/hooks/use-copilot-chat.js +72 -30
  84. package/dist/hooks/use-copilot-chat.js.map +1 -1
  85. package/dist/hooks/use-copilot-chat.mjs +18 -12
  86. package/dist/hooks/use-copilot-chat.mjs.map +1 -1
  87. package/dist/hooks/use-flat-category-store.js +30 -12
  88. package/dist/hooks/use-flat-category-store.js.map +1 -1
  89. package/dist/hooks/use-flat-category-store.mjs +7 -3
  90. package/dist/hooks/use-flat-category-store.mjs.map +1 -1
  91. package/dist/hooks/use-make-copilot-actionable.js +77 -20
  92. package/dist/hooks/use-make-copilot-actionable.js.map +1 -1
  93. package/dist/hooks/use-make-copilot-actionable.mjs +9 -4
  94. package/dist/hooks/use-make-copilot-actionable.mjs.map +1 -1
  95. package/dist/hooks/use-make-copilot-document-readable.js +73 -18
  96. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  97. package/dist/hooks/use-make-copilot-document-readable.mjs +9 -4
  98. package/dist/hooks/use-make-copilot-document-readable.mjs.map +1 -1
  99. package/dist/hooks/use-make-copilot-readable.js +73 -18
  100. package/dist/hooks/use-make-copilot-readable.js.map +1 -1
  101. package/dist/hooks/use-make-copilot-readable.mjs +9 -4
  102. package/dist/hooks/use-make-copilot-readable.mjs.map +1 -1
  103. package/dist/hooks/use-tree.js +30 -13
  104. package/dist/hooks/use-tree.js.map +1 -1
  105. package/dist/hooks/use-tree.mjs +7 -3
  106. package/dist/hooks/use-tree.mjs.map +1 -1
  107. package/dist/index.js +165 -83
  108. package/dist/index.js.map +1 -1
  109. package/dist/index.mjs +57 -23
  110. package/dist/index.mjs.map +1 -1
  111. package/dist/openai-assistants/hooks/index.js +67 -27
  112. package/dist/openai-assistants/hooks/index.js.map +1 -1
  113. package/dist/openai-assistants/hooks/index.mjs +18 -14
  114. package/dist/openai-assistants/hooks/index.mjs.map +1 -1
  115. package/dist/openai-assistants/hooks/use-assistants.js +40 -14
  116. package/dist/openai-assistants/hooks/use-assistants.js.map +1 -1
  117. package/dist/openai-assistants/hooks/use-assistants.mjs +14 -8
  118. package/dist/openai-assistants/hooks/use-assistants.mjs.map +1 -1
  119. package/dist/openai-assistants/hooks/use-copilot-chat-v2.js +67 -28
  120. package/dist/openai-assistants/hooks/use-copilot-chat-v2.js.map +1 -1
  121. package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs +19 -13
  122. package/dist/openai-assistants/hooks/use-copilot-chat-v2.mjs.map +1 -1
  123. package/dist/openai-assistants/index.js +69 -28
  124. package/dist/openai-assistants/index.js.map +1 -1
  125. package/dist/openai-assistants/index.mjs +22 -15
  126. package/dist/openai-assistants/index.mjs.map +1 -1
  127. package/dist/openai-assistants/utils/index.js +29 -5
  128. package/dist/openai-assistants/utils/index.js.map +1 -1
  129. package/dist/openai-assistants/utils/index.mjs +8 -4
  130. package/dist/openai-assistants/utils/index.mjs.map +1 -1
  131. package/dist/openai-assistants/utils/process-message-stream.js +27 -5
  132. package/dist/openai-assistants/utils/process-message-stream.js.map +1 -1
  133. package/dist/openai-assistants/utils/process-message-stream.mjs +7 -3
  134. package/dist/openai-assistants/utils/process-message-stream.mjs.map +1 -1
  135. package/dist/types/document-pointer.js +17 -2
  136. package/dist/types/document-pointer.js.map +1 -1
  137. package/dist/types/document-pointer.mjs +0 -2
  138. package/dist/types/document-pointer.mjs.map +1 -1
  139. package/dist/types/index.js +17 -2
  140. package/dist/types/index.js.map +1 -1
  141. package/dist/types/index.mjs +1 -2
  142. package/dist/types/index.mjs.map +1 -1
  143. package/dist/types/system-message.js +17 -2
  144. package/dist/types/system-message.js.map +1 -1
  145. package/dist/types/system-message.mjs +0 -2
  146. package/dist/types/system-message.mjs.map +1 -1
  147. package/dist/utils/fetch-chat-completion.js +35 -12
  148. package/dist/utils/fetch-chat-completion.js.map +1 -1
  149. package/dist/utils/fetch-chat-completion.mjs +11 -3
  150. package/dist/utils/fetch-chat-completion.mjs.map +1 -1
  151. package/dist/utils/utils.js +17 -2
  152. package/dist/utils/utils.js.map +1 -1
  153. package/dist/utils/utils.mjs +0 -2
  154. package/dist/utils/utils.mjs.map +1 -1
  155. package/dist/utils/utils.test.js +1 -2
  156. package/dist/utils/utils.test.js.map +1 -1
  157. package/dist/utils/utils.test.mjs +0 -1
  158. package/dist/utils/utils.test.mjs.map +1 -1
  159. package/package.json +6 -6
@@ -1,20 +1,24 @@
1
- import './chunk-MRXNTQOX.mjs';
2
- import React from 'react';
1
+ import {
2
+ __async
3
+ } from "./chunk-MRXNTQOX.mjs";
3
4
 
5
+ // src/context/copilot-context.tsx
6
+ import React from "react";
4
7
  var emptyCopilotContext = {
5
8
  entryPoints: {},
6
9
  setEntryPoint: () => {
7
10
  },
8
11
  removeEntryPoint: () => {
9
12
  },
10
- getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug(),
11
- getFunctionCallHandler: () => returnAndThrowInDebug(),
12
- getContextString: (documents, categories) => returnAndThrowInDebug(),
13
+ getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),
14
+ getFunctionCallHandler: () => returnAndThrowInDebug(() => __async(void 0, null, function* () {
15
+ })),
16
+ getContextString: (documents, categories) => returnAndThrowInDebug(""),
13
17
  addContext: () => "",
14
18
  removeContext: () => {
15
19
  },
16
- getDocumentsContext: (categories) => returnAndThrowInDebug(),
17
- addDocumentContext: () => returnAndThrowInDebug(),
20
+ getDocumentsContext: (categories) => returnAndThrowInDebug([]),
21
+ addDocumentContext: () => returnAndThrowInDebug(""),
18
22
  removeDocumentContext: () => {
19
23
  },
20
24
  copilotApiConfig: new class {
@@ -35,8 +39,10 @@ var emptyCopilotContext = {
35
39
  var CopilotContext = React.createContext(emptyCopilotContext);
36
40
  function returnAndThrowInDebug(value) {
37
41
  throw new Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");
42
+ return value;
38
43
  }
39
44
 
40
- export { CopilotContext };
41
- //# sourceMappingURL=out.js.map
45
+ export {
46
+ CopilotContext
47
+ };
42
48
  //# sourceMappingURL=chunk-4CFJ6A6A.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context/copilot-context.tsx"],"names":[],"mappings":";;;;;AAGA,OAAO,WAAW;AAiElB,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,qBAAqB,CAAC,eAAyB,sBAAsB,CAAC,CAAC;AAAA,EACvE,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AAAA,IACA,IAAI,oBAA4B;AAC9B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AAAA,IACA,IAAI,UAAkC;AACpC,aAAO,CAAC;AAAA,IACV;AAAA,IACA,IAAI,OAA4B;AAC9B,aAAO,CAAC;AAAA,IACV;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBAAiB,MAAM,cAAoC,mBAAmB;AAE3F,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT","sourcesContent":["\"use client\";\n\nimport { FunctionCallHandler, AnnotatedFunction, Function } from \"@copilotkit/shared\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the chat API v2.\n */\n chatApiEndpointV2: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Additional body params to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'message': 'Hello, world!'\n * }\n * ```\n */\n body: Record<string, any>;\n}\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, AnnotatedFunction<any[]>>;\n setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;\n removeEntryPoint: (id: string) => void;\n getChatCompletionFunctionDescriptions: () => Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n get chatApiEndpointV2(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n return value;\n}\n"]}
1
+ {"version":3,"sources":["../src/context/copilot-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { FunctionCallHandler, AnnotatedFunction, Function } from \"@copilotkit/shared\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the chat API v2.\n */\n chatApiEndpointV2: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Additional body params to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'message': 'Hello, world!'\n * }\n * ```\n */\n body: Record<string, any>;\n}\n\nexport interface CopilotContextParams {\n // function-calling\n entryPoints: Record<string, AnnotatedFunction<any[]>>;\n setEntryPoint: (id: string, entryPoint: AnnotatedFunction<any[]>) => void;\n removeEntryPoint: (id: string) => void;\n getChatCompletionFunctionDescriptions: () => Function[];\n getFunctionCallHandler: () => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n entryPoints: {},\n setEntryPoint: () => {},\n removeEntryPoint: () => {},\n getChatCompletionFunctionDescriptions: () => returnAndThrowInDebug([]),\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n get chatApiEndpointV2(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nfunction returnAndThrowInDebug<T>(value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n return value;\n}\n"],"mappings":";;;;;AAGA,OAAO,WAAW;AAiElB,IAAM,sBAA4C;AAAA,EAChD,aAAa,CAAC;AAAA,EACd,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,uCAAuC,MAAM,sBAAsB,CAAC,CAAC;AAAA,EACrE,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,qBAAqB,CAAC,eAAyB,sBAAsB,CAAC,CAAC;AAAA,EACvE,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AAAA,IACA,IAAI,oBAA4B;AAC9B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AAAA,IACA,IAAI,UAAkC;AACpC,aAAO,CAAC;AAAA,IACV;AAAA,IACA,IAAI,OAA4B;AAC9B,aAAO,CAAC;AAAA,IACV;AAAA,EACF,EAAG;AACL;AAEO,IAAM,iBAAiB,MAAM,cAAoC,mBAAmB;AAE3F,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;","names":[]}
@@ -1,9 +1,20 @@
1
- import { defaultCopilotContextCategories } from './chunk-GBZZPQ5X.mjs';
2
- import { CopilotContext } from './chunk-4CFJ6A6A.mjs';
3
- import { useChat } from './chunk-IQEWY7P4.mjs';
4
- import { __objRest, __spreadProps, __spreadValues } from './chunk-MRXNTQOX.mjs';
5
- import { useContext, useMemo } from 'react';
1
+ import {
2
+ defaultCopilotContextCategories
3
+ } from "./chunk-GBZZPQ5X.mjs";
4
+ import {
5
+ CopilotContext
6
+ } from "./chunk-4CFJ6A6A.mjs";
7
+ import {
8
+ useChat
9
+ } from "./chunk-IQEWY7P4.mjs";
10
+ import {
11
+ __objRest,
12
+ __spreadProps,
13
+ __spreadValues
14
+ } from "./chunk-MRXNTQOX.mjs";
6
15
 
16
+ // src/hooks/use-copilot-chat.ts
17
+ import { useMemo, useContext } from "react";
7
18
  function useCopilotChat(_a) {
8
19
  var _b = _a, {
9
20
  makeSystemMessage,
@@ -76,6 +87,8 @@ If you would like to call a function, call it without saying anything else.
76
87
  ${additionalInstructions}` : "");
77
88
  }
78
89
 
79
- export { defaultSystemMessage, useCopilotChat };
80
- //# sourceMappingURL=out.js.map
90
+ export {
91
+ useCopilotChat,
92
+ defaultSystemMessage
93
+ };
81
94
  //# sourceMappingURL=chunk-5GS7FQPW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,kBAAkB;AAsB7B,SAAS,eAAe,IAIiB;AAJjB,eAC7B;AAAA;AAAA,IACA;AAAA,EAxBF,IAsB+B,IAG1B,oBAH0B,IAG1B;AAAA,IAFH;AAAA,IACA;AAAA;AAGA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,cAAc;AAE7B,QAAM,gBAAyB,QAAQ,MAAM;AAC3C,UAAM,qBAAqB,qBAAqB;AAChD,UAAM,gBAAgB,iBAAiB,CAAC,GAAG,+BAA+B;AAE1E,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,mBAAmB,eAAe,sBAAsB;AAAA,MACjE,MAAM;AAAA,IACR;AAAA,EACF,GAAG,CAAC,kBAAkB,iBAAiB,CAAC;AAExC,QAAM,uBAAmC,QAAQ,MAAM;AACrD,WAAO,sCAAsC;AAAA,EAC/C,GAAG,CAAC,qCAAqC,CAAC;AAE1C,QAAM,EAAE,UAAU,QAAQ,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,QAAQ,iCAC1E,UAD0E;AAAA,IAE7E,eAAe;AAAA,IACf,IAAI,QAAQ;AAAA,IACZ,iBAAiB,CAAC,aAAa,EAAE,OAAO,QAAQ,mBAAmB,CAAC,CAAC;AAAA,IACrE,WAAW;AAAA,IACX,gBAAgB,uBAAuB;AAAA,IACvC,SAAS,mBAAK,QAAQ;AAAA,IACtB,MAAM,mBACD,QAAQ;AAAA,EAEf,EAAC;AAED,QAAM,kBAAkB,SAAS;AAAA,IAC/B,CAAC,YAAY,QAAQ,SAAS,UAAU,QAAQ,SAAS;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,qBACd,eACA,wBACQ;AACR,SACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAUG,yBAAyB;AAAA;AAAA,EAAO,2BAA2B;AAEhE","sourcesContent":["import { useMemo, useContext } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { Message, Function } from \"@copilotkit/shared\";\nimport { SystemMessageFunction } from \"../types\";\nimport { UseChatOptions, useChat } from \"./use-chat\";\nimport { defaultCopilotContextCategories } from \"../components\";\n\nexport interface UseCopilotChatOptions extends UseChatOptions {\n makeSystemMessage?: SystemMessageFunction;\n additionalInstructions?: string;\n}\n\nexport interface UseCopilotChatReturn {\n visibleMessages: Message[];\n append: (message: Message) => Promise<void>;\n reload: () => Promise<void>;\n stop: () => void;\n isLoading: boolean;\n input: string;\n setInput: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport function useCopilotChat({\n makeSystemMessage,\n additionalInstructions,\n ...options\n}: UseCopilotChatOptions): UseCopilotChatReturn {\n const {\n getContextString,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n copilotApiConfig,\n } = useContext(CopilotContext);\n\n const systemMessage: Message = useMemo(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n const contextString = getContextString([], defaultCopilotContextCategories); // TODO: make the context categories configurable\n\n return {\n id: \"system\",\n content: systemMessageMaker(contextString, additionalInstructions),\n role: \"system\",\n };\n }, [getContextString, makeSystemMessage]);\n\n const functionDescriptions: Function[] = useMemo(() => {\n return getChatCompletionFunctionDescriptions();\n }, [getChatCompletionFunctionDescriptions]);\n\n const { messages, append, reload, stop, isLoading, input, setInput } = useChat({\n ...options,\n copilotConfig: copilotApiConfig,\n id: options.id,\n initialMessages: [systemMessage].concat(options.initialMessages || []),\n functions: functionDescriptions,\n onFunctionCall: getFunctionCallHandler(),\n headers: { ...options.headers },\n body: {\n ...options.body,\n },\n });\n\n const visibleMessages = messages.filter(\n (message) => message.role === \"user\" || message.role === \"assistant\",\n );\n\n return {\n visibleMessages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n\nexport function defaultSystemMessage(\n contextString: string,\n additionalInstructions?: string,\n): string {\n return (\n `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\n` + (additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\")\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"sourcesContent":["import { useMemo, useContext } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { Message, Function } from \"@copilotkit/shared\";\nimport { SystemMessageFunction } from \"../types\";\nimport { UseChatOptions, useChat } from \"./use-chat\";\nimport { defaultCopilotContextCategories } from \"../components\";\n\nexport interface UseCopilotChatOptions extends UseChatOptions {\n makeSystemMessage?: SystemMessageFunction;\n additionalInstructions?: string;\n}\n\nexport interface UseCopilotChatReturn {\n visibleMessages: Message[];\n append: (message: Message) => Promise<void>;\n reload: () => Promise<void>;\n stop: () => void;\n isLoading: boolean;\n input: string;\n setInput: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport function useCopilotChat({\n makeSystemMessage,\n additionalInstructions,\n ...options\n}: UseCopilotChatOptions): UseCopilotChatReturn {\n const {\n getContextString,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n copilotApiConfig,\n } = useContext(CopilotContext);\n\n const systemMessage: Message = useMemo(() => {\n const systemMessageMaker = makeSystemMessage || defaultSystemMessage;\n const contextString = getContextString([], defaultCopilotContextCategories); // TODO: make the context categories configurable\n\n return {\n id: \"system\",\n content: systemMessageMaker(contextString, additionalInstructions),\n role: \"system\",\n };\n }, [getContextString, makeSystemMessage]);\n\n const functionDescriptions: Function[] = useMemo(() => {\n return getChatCompletionFunctionDescriptions();\n }, [getChatCompletionFunctionDescriptions]);\n\n const { messages, append, reload, stop, isLoading, input, setInput } = useChat({\n ...options,\n copilotConfig: copilotApiConfig,\n id: options.id,\n initialMessages: [systemMessage].concat(options.initialMessages || []),\n functions: functionDescriptions,\n onFunctionCall: getFunctionCallHandler(),\n headers: { ...options.headers },\n body: {\n ...options.body,\n },\n });\n\n const visibleMessages = messages.filter(\n (message) => message.role === \"user\" || message.role === \"assistant\",\n );\n\n return {\n visibleMessages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n\nexport function defaultSystemMessage(\n contextString: string,\n additionalInstructions?: string,\n): string {\n return (\n `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\n` + (additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,kBAAkB;AAsB7B,SAAS,eAAe,IAIiB;AAJjB,eAC7B;AAAA;AAAA,IACA;AAAA,EAxBF,IAsB+B,IAG1B,oBAH0B,IAG1B;AAAA,IAFH;AAAA,IACA;AAAA;AAGA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,cAAc;AAE7B,QAAM,gBAAyB,QAAQ,MAAM;AAC3C,UAAM,qBAAqB,qBAAqB;AAChD,UAAM,gBAAgB,iBAAiB,CAAC,GAAG,+BAA+B;AAE1E,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,mBAAmB,eAAe,sBAAsB;AAAA,MACjE,MAAM;AAAA,IACR;AAAA,EACF,GAAG,CAAC,kBAAkB,iBAAiB,CAAC;AAExC,QAAM,uBAAmC,QAAQ,MAAM;AACrD,WAAO,sCAAsC;AAAA,EAC/C,GAAG,CAAC,qCAAqC,CAAC;AAE1C,QAAM,EAAE,UAAU,QAAQ,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,QAAQ,iCAC1E,UAD0E;AAAA,IAE7E,eAAe;AAAA,IACf,IAAI,QAAQ;AAAA,IACZ,iBAAiB,CAAC,aAAa,EAAE,OAAO,QAAQ,mBAAmB,CAAC,CAAC;AAAA,IACrE,WAAW;AAAA,IACX,gBAAgB,uBAAuB;AAAA,IACvC,SAAS,mBAAK,QAAQ;AAAA,IACtB,MAAM,mBACD,QAAQ;AAAA,EAEf,EAAC;AAED,QAAM,kBAAkB,SAAS;AAAA,IAC/B,CAAC,YAAY,QAAQ,SAAS,UAAU,QAAQ,SAAS;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,qBACd,eACA,wBACQ;AACR,SACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAUG,yBAAyB;AAAA;AAAA,EAAO,2BAA2B;AAEhE;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-5UGLWBZJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-7GFKOIO7.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-BABVSMJR.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +1,10 @@
1
- import { CopilotContext } from './chunk-4CFJ6A6A.mjs';
2
- import { useRef, useContext, useMemo, useEffect } from 'react';
3
- import { nanoid } from 'nanoid';
1
+ import {
2
+ CopilotContext
3
+ } from "./chunk-4CFJ6A6A.mjs";
4
4
 
5
+ // src/hooks/use-make-copilot-actionable.ts
6
+ import { useRef, useContext, useEffect, useMemo } from "react";
7
+ import { nanoid } from "nanoid";
5
8
  function useMakeCopilotActionable(annotatedFunction, dependencies) {
6
9
  const idRef = useRef(nanoid());
7
10
  const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);
@@ -22,6 +25,7 @@ function useMakeCopilotActionable(annotatedFunction, dependencies) {
22
25
  }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);
23
26
  }
24
27
 
25
- export { useMakeCopilotActionable };
26
- //# sourceMappingURL=out.js.map
28
+ export {
29
+ useMakeCopilotActionable
30
+ };
27
31
  //# sourceMappingURL=chunk-DGUVNY3V.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/use-make-copilot-actionable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,QAAQ,YAAY,WAAW,eAAe;AAGvD,SAAS,cAAc;AAEhB,SAAS,yBACd,mBACA,cACA;AACA,QAAM,QAAQ,OAAO,OAAO,CAAC;AAC7B,QAAM,EAAE,eAAe,iBAAiB,IAAI,WAAW,cAAc;AAErE,QAAM,4BAA4D;AAAA,IAChE,OAAO;AAAA,MACL,MAAM,kBAAkB;AAAA,MACxB,aAAa,kBAAkB;AAAA,MAC/B,qBAAqB,kBAAkB;AAAA,MACvC,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AAEA,YAAU,MAAM;AACd,kBAAc,MAAM,SAAS,yBAAqD;AAElF,WAAO,MAAM;AACX,uBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,2BAA2B,eAAe,gBAAgB,CAAC;AACjE","sourcesContent":["\"use client\";\n\nimport { useRef, useContext, useEffect, useMemo } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { AnnotatedFunction } from \"@copilotkit/shared\";\nimport { nanoid } from \"nanoid\";\n\nexport function useMakeCopilotActionable<ActionInput extends any[]>(\n annotatedFunction: AnnotatedFunction<ActionInput>,\n dependencies: any[],\n) {\n const idRef = useRef(nanoid()); // generate a unique id\n const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);\n\n const memoizedAnnotatedFunction: AnnotatedFunction<ActionInput> = useMemo(\n () => ({\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n argumentAnnotations: annotatedFunction.argumentAnnotations,\n implementation: annotatedFunction.implementation,\n }),\n dependencies,\n );\n\n useEffect(() => {\n setEntryPoint(idRef.current, memoizedAnnotatedFunction as AnnotatedFunction<any[]>);\n\n return () => {\n removeEntryPoint(idRef.current);\n };\n }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/use-make-copilot-actionable.ts"],"sourcesContent":["\"use client\";\n\nimport { useRef, useContext, useEffect, useMemo } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { AnnotatedFunction } from \"@copilotkit/shared\";\nimport { nanoid } from \"nanoid\";\n\nexport function useMakeCopilotActionable<ActionInput extends any[]>(\n annotatedFunction: AnnotatedFunction<ActionInput>,\n dependencies: any[],\n) {\n const idRef = useRef(nanoid()); // generate a unique id\n const { setEntryPoint, removeEntryPoint } = useContext(CopilotContext);\n\n const memoizedAnnotatedFunction: AnnotatedFunction<ActionInput> = useMemo(\n () => ({\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n argumentAnnotations: annotatedFunction.argumentAnnotations,\n implementation: annotatedFunction.implementation,\n }),\n dependencies,\n );\n\n useEffect(() => {\n setEntryPoint(idRef.current, memoizedAnnotatedFunction as AnnotatedFunction<any[]>);\n\n return () => {\n removeEntryPoint(idRef.current);\n };\n }, [memoizedAnnotatedFunction, setEntryPoint, removeEntryPoint]);\n}\n"],"mappings":";;;;;AAEA,SAAS,QAAQ,YAAY,WAAW,eAAe;AAGvD,SAAS,cAAc;AAEhB,SAAS,yBACd,mBACA,cACA;AACA,QAAM,QAAQ,OAAO,OAAO,CAAC;AAC7B,QAAM,EAAE,eAAe,iBAAiB,IAAI,WAAW,cAAc;AAErE,QAAM,4BAA4D;AAAA,IAChE,OAAO;AAAA,MACL,MAAM,kBAAkB;AAAA,MACxB,aAAa,kBAAkB;AAAA,MAC/B,qBAAqB,kBAAkB;AAAA,MACvC,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AAEA,YAAU,MAAM;AACd,kBAAc,MAAM,SAAS,yBAAqD;AAElF,WAAO,MAAM;AACX,uBAAiB,MAAM,OAAO;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,2BAA2B,eAAe,gBAAgB,CAAC;AACjE;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-EFZPSZWO.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -8,6 +8,7 @@ var StandardCopilotApiConfig = class {
8
8
  }
9
9
  };
10
10
 
11
- export { StandardCopilotApiConfig };
12
- //# sourceMappingURL=out.js.map
11
+ export {
12
+ StandardCopilotApiConfig
13
+ };
13
14
  //# sourceMappingURL=chunk-F2JIAPZQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/copilot-provider/standard-copilot-api-config.tsx"],"names":[],"mappings":";AAUO,IAAM,2BAAN,MAA2D;AAAA,EAMhE,YACE,iBACA,mBACA,SACA,MACA;AACA,SAAK,kBAAkB;AACvB,SAAK,oBAAoB;AACzB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AACF","sourcesContent":["import { CopilotApiConfig } from \"../../context/copilot-context\";\n\n/**\n * A standard implementation of the CopilotApiConfig interface.\n *\n * Pass in the base URL of the chat API, the headers to be sent with each request, and the body to be sent with each request.\n * The rest of the CopilotApiConfig interface is implemented by default.\n *\n */\n\nexport class StandardCopilotApiConfig implements CopilotApiConfig {\n chatApiEndpoint: string;\n chatApiEndpointV2: string;\n headers: Record<string, string>;\n body: Record<string, any>;\n\n constructor(\n chatApiEndpoint: string,\n chatApiEndpointV2: string,\n headers: Record<string, string>,\n body: Record<string, any>,\n ) {\n this.chatApiEndpoint = chatApiEndpoint;\n this.chatApiEndpointV2 = chatApiEndpointV2;\n this.headers = headers;\n this.body = body;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/components/copilot-provider/standard-copilot-api-config.tsx"],"sourcesContent":["import { CopilotApiConfig } from \"../../context/copilot-context\";\n\n/**\n * A standard implementation of the CopilotApiConfig interface.\n *\n * Pass in the base URL of the chat API, the headers to be sent with each request, and the body to be sent with each request.\n * The rest of the CopilotApiConfig interface is implemented by default.\n *\n */\n\nexport class StandardCopilotApiConfig implements CopilotApiConfig {\n chatApiEndpoint: string;\n chatApiEndpointV2: string;\n headers: Record<string, string>;\n body: Record<string, any>;\n\n constructor(\n chatApiEndpoint: string,\n chatApiEndpointV2: string,\n headers: Record<string, string>,\n body: Record<string, any>,\n ) {\n this.chatApiEndpoint = chatApiEndpoint;\n this.chatApiEndpointV2 = chatApiEndpointV2;\n this.headers = headers;\n this.body = body;\n }\n}\n"],"mappings":";AAUO,IAAM,2BAAN,MAA2D;AAAA,EAMhE,YACE,iBACA,mBACA,SACA,MACA;AACA,SAAK,kBAAkB;AACvB,SAAK,oBAAoB;AACzB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-FRAKUJWH.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,12 +1,28 @@
1
- import { StandardCopilotApiConfig } from './chunk-F2JIAPZQ.mjs';
2
- import { use_tree_default } from './chunk-VUY2K2DI.mjs';
3
- import { CopilotContext } from './chunk-4CFJ6A6A.mjs';
4
- import { use_flat_category_store_default } from './chunk-YULKJPY3.mjs';
5
- import { __objRest, __spreadProps, __spreadValues, __async } from './chunk-MRXNTQOX.mjs';
6
- import { useState, useCallback } from 'react';
7
- import { annotatedFunctionToChatCompletionFunction } from '@copilotkit/shared';
8
- import { jsx } from 'react/jsx-runtime';
1
+ import {
2
+ StandardCopilotApiConfig
3
+ } from "./chunk-F2JIAPZQ.mjs";
4
+ import {
5
+ use_tree_default
6
+ } from "./chunk-VUY2K2DI.mjs";
7
+ import {
8
+ CopilotContext
9
+ } from "./chunk-4CFJ6A6A.mjs";
10
+ import {
11
+ use_flat_category_store_default
12
+ } from "./chunk-YULKJPY3.mjs";
13
+ import {
14
+ __async,
15
+ __objRest,
16
+ __spreadProps,
17
+ __spreadValues
18
+ } from "./chunk-MRXNTQOX.mjs";
9
19
 
20
+ // src/components/copilot-provider/copilotkit.tsx
21
+ import { useCallback, useState } from "react";
22
+ import {
23
+ annotatedFunctionToChatCompletionFunction
24
+ } from "@copilotkit/shared";
25
+ import { jsx } from "react/jsx-runtime";
10
26
  function CopilotKit(_a) {
11
27
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
12
28
  const [entryPoints, setEntryPoints] = useState({});
@@ -133,6 +149,8 @@ function entryPointsToChatCompletionFunctions(entryPoints) {
133
149
  return entryPoints.map(annotatedFunctionToChatCompletionFunction);
134
150
  }
135
151
 
136
- export { CopilotKit, defaultCopilotContextCategories };
137
- //# sourceMappingURL=out.js.map
152
+ export {
153
+ CopilotKit,
154
+ defaultCopilotContextCategories
155
+ };
138
156
  //# sourceMappingURL=chunk-GBZZPQ5X.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/copilot-provider/copilotkit.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,SAAS,aAAa,gBAAgB;AAItC;AAAA,EAGE;AAAA,OACK;AAgJH;AAtGG,SAAS,WAAW,IAAyC;AAAzC,eAAE,WArD7B,IAqD2B,IAAe,kBAAf,IAAe,CAAb;AA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AM,uBAA8B,CAAC;AACrC,eAAS,OAAO,mBAAmB,qBAAqB;AACtD,6BAAqB;AAAA,UACnB,sBAAsB,IAAI,IAA0C;AAAA,QACtE;AAAA,MACF;AAEA,YAAM,mBAAmB,eAAe,GAAG,oBAAoB;AAAA,IAmBjE;AAAA,EACF;AACF;AAEA,SAAS,qCAAqC,aAAqD;AACjG,SAAO,YAAY,IAAI,yCAAyC;AAClE","sourcesContent":["\"use client\";\n\nimport { Function } from \"@copilotkit/shared\";\nimport { useCallback, useState } from \"react\";\nimport { CopilotContext, CopilotApiConfig } from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { DocumentPointer } from \"../../types\";\nimport {\n FunctionCallHandler,\n AnnotatedFunction,\n annotatedFunctionToChatCompletionFunction,\n} from \"@copilotkit/shared\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { StandardCopilotApiConfig } from \"./standard-copilot-api-config\";\nimport { CopilotKitProps } from \"./copilotkit-props\";\n\n/**\n * The CopilotKit component.\n * This component provides the Copilot context to its children.\n * It can be configured either with a chat API endpoint or a CopilotApiConfig.\n *\n * NOTE: The backend can use OpenAI, or you can bring your own LLM.\n * For examples of the backend api implementation, see `examples/next-openai` usage (under `src/api/copilotkit`),\n * or read the documentation at https://docs.copilotkit.ai\n * In particular, Getting-Started > Quickstart-Backend: https://docs.copilotkit.ai/getting-started/quickstart-backend\n *\n * Example usage:\n * ```\n * <CopilotKit url=\"https://your.copilotkit.api\">\n * <App />\n * </CopilotKit>\n * ```\n *\n * or\n *\n * ```\n * const copilotApiConfig = new StandardCopilotApiConfig(\n * \"https://your.copilotkit.api/v1\",\n * \"https://your.copilotkit.api/v2\",\n * {},\n * {}\n * );\n *\n * // ...\n *\n * <CopilotKit chatApiConfig={copilotApiConfig}>\n * <App />\n * </CopilotKit>\n * ```\n *\n * @param props - The props for the component.\n * @returns The CopilotKit component.\n */\nexport function CopilotKit({ children, ...props }: CopilotKitProps) {\n // Compute all the functions and properties that we need to pass\n // to the CopilotContext.\n\n const [entryPoints, setEntryPoints] = useState<Record<string, AnnotatedFunction<any[]>>>({});\n\n const { addElement, removeElement, printTree } = useTree();\n\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n const setEntryPoint = useCallback((id: string, entryPoint: AnnotatedFunction<any[]>) => {\n setEntryPoints((prevPoints) => {\n return {\n ...prevPoints,\n [id]: entryPoint,\n };\n });\n }, []);\n\n const removeEntryPoint = useCallback((id: string) => {\n setEntryPoints((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (documents: DocumentPointer[], categories: string[]) => {\n const documentsString = documents\n .map((document) => {\n return `${document.name} (${document.sourceApplication}):\\n${document.getContents()}`;\n })\n .join(\"\\n\\n\");\n\n const nonDocumentStrings = printTree(categories);\n\n return `${documentsString}\\n\\n${nonDocumentStrings}`;\n },\n [printTree],\n );\n\n const addContext = useCallback(\n (\n context: string,\n parentId?: string,\n categories: string[] = defaultCopilotContextCategories,\n ) => {\n return addElement(context, categories, parentId);\n },\n [addElement],\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement],\n );\n\n const getChatCompletionFunctionDescriptions = useCallback(() => {\n return entryPointsToChatCompletionFunctions(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getFunctionCallHandler = useCallback(() => {\n return entryPointsToFunctionCallHandler(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getDocumentsContext = useCallback(\n (categories: string[]) => {\n return allDocuments(categories);\n },\n [allDocuments],\n );\n\n const addDocumentContext = useCallback(\n (documentPointer: DocumentPointer, categories: string[] = defaultCopilotContextCategories) => {\n return addDocument(documentPointer, categories);\n },\n [addDocument],\n );\n\n const removeDocumentContext = useCallback(\n (documentId: string) => {\n removeDocument(documentId);\n },\n [removeDocument],\n );\n\n // get the appropriate CopilotApiConfig from the props\n const copilotApiConfig: CopilotApiConfig = new StandardCopilotApiConfig(\n props.url,\n `${props.url}/v2`,\n props.headers || {},\n props.body || {},\n );\n\n return (\n <CopilotContext.Provider\n value={{\n entryPoints,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n setEntryPoint,\n removeEntryPoint,\n getContextString,\n addContext,\n removeContext,\n getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: copilotApiConfig,\n }}\n >\n {children}\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\n\nfunction entryPointsToFunctionCallHandler(\n entryPoints: AnnotatedFunction<any[]>[],\n): FunctionCallHandler {\n return async (chatMessages, functionCall) => {\n let entrypointsByFunctionName: Record<string, AnnotatedFunction<any[]>> = {};\n for (let entryPoint of entryPoints) {\n entrypointsByFunctionName[entryPoint.name] = entryPoint;\n }\n\n const entryPointFunction = entrypointsByFunctionName[functionCall.name || \"\"];\n if (entryPointFunction) {\n let functionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n functionCallArguments = JSON.parse(functionCall.arguments);\n }\n\n const paramsInCorrectOrder: any[] = [];\n for (let arg of entryPointFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(\n functionCallArguments[arg.name as keyof typeof functionCallArguments],\n );\n }\n\n await entryPointFunction.implementation(...paramsInCorrectOrder);\n\n // commented out becasue for now we don't want to return anything\n // const result = await entryPointFunction.implementation(\n // ...parsedFunctionCallArguments\n // );\n // const functionResponse: ChatRequest = {\n // messages: [\n // ...chatMessages,\n // {\n // id: nanoid(),\n // name: functionCall.name,\n // role: 'function' as const,\n // content: JSON.stringify(result),\n // },\n // ],\n // };\n\n // return functionResponse;\n }\n };\n}\n\nfunction entryPointsToChatCompletionFunctions(entryPoints: AnnotatedFunction<any[]>[]): Function[] {\n return entryPoints.map(annotatedFunctionToChatCompletionFunction);\n}\n"]}
1
+ {"version":3,"sources":["../src/components/copilot-provider/copilotkit.tsx"],"sourcesContent":["\"use client\";\n\nimport { Function } from \"@copilotkit/shared\";\nimport { useCallback, useState } from \"react\";\nimport { CopilotContext, CopilotApiConfig } from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { DocumentPointer } from \"../../types\";\nimport {\n FunctionCallHandler,\n AnnotatedFunction,\n annotatedFunctionToChatCompletionFunction,\n} from \"@copilotkit/shared\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { StandardCopilotApiConfig } from \"./standard-copilot-api-config\";\nimport { CopilotKitProps } from \"./copilotkit-props\";\n\n/**\n * The CopilotKit component.\n * This component provides the Copilot context to its children.\n * It can be configured either with a chat API endpoint or a CopilotApiConfig.\n *\n * NOTE: The backend can use OpenAI, or you can bring your own LLM.\n * For examples of the backend api implementation, see `examples/next-openai` usage (under `src/api/copilotkit`),\n * or read the documentation at https://docs.copilotkit.ai\n * In particular, Getting-Started > Quickstart-Backend: https://docs.copilotkit.ai/getting-started/quickstart-backend\n *\n * Example usage:\n * ```\n * <CopilotKit url=\"https://your.copilotkit.api\">\n * <App />\n * </CopilotKit>\n * ```\n *\n * or\n *\n * ```\n * const copilotApiConfig = new StandardCopilotApiConfig(\n * \"https://your.copilotkit.api/v1\",\n * \"https://your.copilotkit.api/v2\",\n * {},\n * {}\n * );\n *\n * // ...\n *\n * <CopilotKit chatApiConfig={copilotApiConfig}>\n * <App />\n * </CopilotKit>\n * ```\n *\n * @param props - The props for the component.\n * @returns The CopilotKit component.\n */\nexport function CopilotKit({ children, ...props }: CopilotKitProps) {\n // Compute all the functions and properties that we need to pass\n // to the CopilotContext.\n\n const [entryPoints, setEntryPoints] = useState<Record<string, AnnotatedFunction<any[]>>>({});\n\n const { addElement, removeElement, printTree } = useTree();\n\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n const setEntryPoint = useCallback((id: string, entryPoint: AnnotatedFunction<any[]>) => {\n setEntryPoints((prevPoints) => {\n return {\n ...prevPoints,\n [id]: entryPoint,\n };\n });\n }, []);\n\n const removeEntryPoint = useCallback((id: string) => {\n setEntryPoints((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (documents: DocumentPointer[], categories: string[]) => {\n const documentsString = documents\n .map((document) => {\n return `${document.name} (${document.sourceApplication}):\\n${document.getContents()}`;\n })\n .join(\"\\n\\n\");\n\n const nonDocumentStrings = printTree(categories);\n\n return `${documentsString}\\n\\n${nonDocumentStrings}`;\n },\n [printTree],\n );\n\n const addContext = useCallback(\n (\n context: string,\n parentId?: string,\n categories: string[] = defaultCopilotContextCategories,\n ) => {\n return addElement(context, categories, parentId);\n },\n [addElement],\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement],\n );\n\n const getChatCompletionFunctionDescriptions = useCallback(() => {\n return entryPointsToChatCompletionFunctions(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getFunctionCallHandler = useCallback(() => {\n return entryPointsToFunctionCallHandler(Object.values(entryPoints));\n }, [entryPoints]);\n\n const getDocumentsContext = useCallback(\n (categories: string[]) => {\n return allDocuments(categories);\n },\n [allDocuments],\n );\n\n const addDocumentContext = useCallback(\n (documentPointer: DocumentPointer, categories: string[] = defaultCopilotContextCategories) => {\n return addDocument(documentPointer, categories);\n },\n [addDocument],\n );\n\n const removeDocumentContext = useCallback(\n (documentId: string) => {\n removeDocument(documentId);\n },\n [removeDocument],\n );\n\n // get the appropriate CopilotApiConfig from the props\n const copilotApiConfig: CopilotApiConfig = new StandardCopilotApiConfig(\n props.url,\n `${props.url}/v2`,\n props.headers || {},\n props.body || {},\n );\n\n return (\n <CopilotContext.Provider\n value={{\n entryPoints,\n getChatCompletionFunctionDescriptions,\n getFunctionCallHandler,\n setEntryPoint,\n removeEntryPoint,\n getContextString,\n addContext,\n removeContext,\n getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: copilotApiConfig,\n }}\n >\n {children}\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\n\nfunction entryPointsToFunctionCallHandler(\n entryPoints: AnnotatedFunction<any[]>[],\n): FunctionCallHandler {\n return async (chatMessages, functionCall) => {\n let entrypointsByFunctionName: Record<string, AnnotatedFunction<any[]>> = {};\n for (let entryPoint of entryPoints) {\n entrypointsByFunctionName[entryPoint.name] = entryPoint;\n }\n\n const entryPointFunction = entrypointsByFunctionName[functionCall.name || \"\"];\n if (entryPointFunction) {\n let functionCallArguments: Record<string, any>[] = [];\n if (functionCall.arguments) {\n functionCallArguments = JSON.parse(functionCall.arguments);\n }\n\n const paramsInCorrectOrder: any[] = [];\n for (let arg of entryPointFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(\n functionCallArguments[arg.name as keyof typeof functionCallArguments],\n );\n }\n\n await entryPointFunction.implementation(...paramsInCorrectOrder);\n\n // commented out becasue for now we don't want to return anything\n // const result = await entryPointFunction.implementation(\n // ...parsedFunctionCallArguments\n // );\n // const functionResponse: ChatRequest = {\n // messages: [\n // ...chatMessages,\n // {\n // id: nanoid(),\n // name: functionCall.name,\n // role: 'function' as const,\n // content: JSON.stringify(result),\n // },\n // ],\n // };\n\n // return functionResponse;\n }\n };\n}\n\nfunction entryPointsToChatCompletionFunctions(entryPoints: AnnotatedFunction<any[]>[]): Function[] {\n return entryPoints.map(annotatedFunctionToChatCompletionFunction);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,SAAS,aAAa,gBAAgB;AAItC;AAAA,EAGE;AAAA,OACK;AAgJH;AAtGG,SAAS,WAAW,IAAyC;AAAzC,eAAE,WArD7B,IAqD2B,IAAe,kBAAf,IAAe,CAAb;AAI3B,QAAM,CAAC,aAAa,cAAc,IAAI,SAAmD,CAAC,CAAC;AAE3F,QAAM,EAAE,YAAY,eAAe,UAAU,IAAI,iBAAQ;AAEzD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ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Ae,GAAG,oBAAoB;AAAA,IAmBjE;AAAA,EACF;AACF;AAEA,SAAS,qCAAqC,aAAqD;AACjG,SAAO,YAAY,IAAI,yCAAyC;AAClE;","names":[]}
@@ -1,8 +1,14 @@
1
- import { fetchAndDecodeChatCompletion } from './chunk-UAKLDQMP.mjs';
2
- import { __async, __spreadValues } from './chunk-MRXNTQOX.mjs';
3
- import { useState, useRef } from 'react';
4
- import { nanoid } from 'nanoid';
1
+ import {
2
+ fetchAndDecodeChatCompletion
3
+ } from "./chunk-UAKLDQMP.mjs";
4
+ import {
5
+ __async,
6
+ __spreadValues
7
+ } from "./chunk-MRXNTQOX.mjs";
5
8
 
9
+ // src/hooks/use-chat.ts
10
+ import { useRef, useState } from "react";
11
+ import { nanoid } from "nanoid";
6
12
  function useChat(options) {
7
13
  const [messages, setMessages] = useState([]);
8
14
  const [input, setInput] = useState("");
@@ -97,6 +103,7 @@ function useChat(options) {
97
103
  };
98
104
  }
99
105
 
100
- export { useChat };
101
- //# sourceMappingURL=out.js.map
106
+ export {
107
+ useChat
108
+ };
102
109
  //# sourceMappingURL=chunk-IQEWY7P4.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/use-chat.ts"],"names":["messages"],"mappings":";;;;;;;;;AAAA,SAAS,QAAQ,gBAAgB;AAEjC,SAAS,cAAc;AAgFhB,SAAS,QAAQ,SAA0D;AAChF,QAAM,CAAC,UAAU,WAAW,IAAI,SAAoB,CAAC,CAAC;AACtD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AACrC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,qBAAqB,OAAwB;AAEnD,QAAM,oBAAoB,CAAOA,cAA0C;AACzE,iBAAa,IAAI;AACjB,UAAM,mBAA4B;AAAA,MAChC,IAAI,OAAO;AAAA,MACX,WAAW,oBAAI,KAAK;AAAA,MACpB,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AACA,UAAM,kBAAkB,I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AAEA,QAAM,SAAS,CAAO,YAAoC;AACxD,QAAI,WAAW;AACb;AAAA,IACF;AACA,UAAM,cAAc,CAAC,GAAG,UAAU,OAAO;AACzC,gBAAY,WAAW;AACvB,WAAO,uCAAuC,WAAW;AAAA,EAC3D;AAEA,QAAM,SAAS,MAA2B;AACxC,QAAI,aAAa,SAAS,WAAW,GAAG;AACtC;AAAA,IACF;AACA,QAAI,cAAc,CAAC,GAAG,QAAQ;AAC9B,UAAM,cAAc,SAAS,SAAS,SAAS,CAAC;AAEhD,QAAI,YAAY,SAAS,aAAa;AACpC,oBAAc,YAAY,MAAM,GAAG,EAAE;AAAA,IACvC;AACA,gBAAY,WAAW;AAEvB,WAAO,uCAAuC,WAAW;AAAA,EAC3D;AAEA,QAAM,OAAO,MAAY;AAhL3B;AAiLI,6BAAmB,YAAnB,mBAA4B;AAAA,EAC9B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF","sourcesContent":["import { useRef, useState } from \"react\";\nimport { Message, Function, FunctionCallHandler, FunctionCall } from \"@copilotkit/shared\";\nimport { nanoid } from \"nanoid\";\nimport { fetchAndDecodeChatCompletion } from \"../utils/fetch-chat-completion\";\nimport { CopilotApiConfig } from \"../context\";\n\nexport type UseChatOptions = {\n /**\n * The API endpoint that accepts a `{ messages: Message[] }` object and returns\n * a stream of tokens of the AI chat response. Defaults to `/api/chat`.\n */\n api?: string;\n /**\n * A unique identifier for the chat. If not provided, a random one will be\n * generated. When provided, the `useChat` hook with the same `id` will\n * have shared states across components.\n */\n id?: string;\n /**\n * System messages of the chat. Defaults to an empty array.\n */\n initialMessages?: Message[];\n /**\n * Callback function to be called when a function call is received.\n * If the function returns a `ChatRequest` object, the request will be sent\n * automatically to the API and will be used to update the chat.\n */\n onFunctionCall?: FunctionCallHandler;\n /**\n * HTTP headers to be sent with the API request.\n */\n headers?: Record<string, string> | Headers;\n /**\n * Extra body object to be sent with the API request.\n * @example\n * Send a `sessionId` to the API along with the messages.\n * ```js\n * useChat({\n * body: {\n * sessionId: '123',\n * }\n * })\n * ```\n */\n body?: object;\n /**\n * Function definitions to be sent to the API.\n */\n functions?: Function[];\n};\n\nexport type UseChatHelpers = {\n /** Current messages in the chat */\n messages: Message[];\n /**\n * Append a user message to the chat list. This triggers the API call to fetch\n * the assistant's response.\n * @param message The message to append\n */\n append: (message: Message) => Promise<void>;\n /**\n * Reload the last AI chat response for the given chat history. If the last\n * message isn't from the assistant, it will request the API to generate a\n * new response.\n */\n reload: () => Promise<void>;\n /**\n * Abort the current request immediately, keep the generated tokens if any.\n */\n stop: () => void;\n /** The current value of the input */\n input: string;\n /** setState-powered method to update the input value */\n setInput: React.Dispatch<React.SetStateAction<string>>;\n /** Whether the API request is in progress */\n isLoading: boolean;\n};\n\nexport type UseChatOptionsWithCopilotConfig = UseChatOptions & {\n copilotConfig: CopilotApiConfig;\n};\n\nexport function useChat(options: UseChatOptionsWithCopilotConfig): UseChatHelpers {\n const [messages, setMessages] = useState<Message[]>([]);\n const [input, setInput] = useState(\"\");\n const [isLoading, setIsLoading] = useState(false);\n const abortControllerRef = useRef<AbortController>();\n\n const runChatCompletion = async (messages: Message[]): Promise<Message> => {\n setIsLoading(true);\n const assistantMessage: Message = {\n id: nanoid(),\n createdAt: new Date(),\n content: \"\",\n role: \"assistant\",\n };\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setMessages([...messages, { ...assistantMessage }]);\n\n const messagesWithContext = [...(options.initialMessages || []), ...messages];\n const response = await fetchAndDecodeChatCompletion({\n copilotConfig: options.copilotConfig,\n messages: messagesWithContext,\n functions: options.functions,\n headers: options.headers,\n signal: abortController.signal,\n });\n\n if (!response.events) {\n throw new Error(\"Failed to fetch chat completion\");\n }\n\n const reader = response.events.getReader();\n\n while (true) {\n try {\n const { done, value } = await reader.read();\n\n if (done) {\n setIsLoading(false);\n return { ...assistantMessage };\n }\n\n if (value.type === \"content\") {\n assistantMessage.content += value.content;\n setMessages([...messages, { ...assistantMessage }]);\n } else if (value.type === \"function\") {\n assistantMessage.function_call = {\n name: value.name,\n arguments: JSON.stringify(value.arguments),\n };\n setMessages([...messages, { ...assistantMessage }]);\n // quit early if we get a function call\n setIsLoading(false);\n return { ...assistantMessage };\n }\n } catch (error) {\n setIsLoading(false);\n throw error;\n }\n }\n };\n\n const runChatCompletionAndHandleFunctionCall = async (messages: Message[]): Promise<void> => {\n const message = await runChatCompletion(messages);\n if (message.function_call && options.onFunctionCall) {\n await options.onFunctionCall(messages, message.function_call as FunctionCall);\n }\n };\n\n const append = async (message: Message): Promise<void> => {\n if (isLoading) {\n return;\n }\n const newMessages = [...messages, message];\n setMessages(newMessages);\n return runChatCompletionAndHandleFunctionCall(newMessages);\n };\n\n const reload = async (): Promise<void> => {\n if (isLoading || messages.length === 0) {\n return;\n }\n let newMessages = [...messages];\n const lastMessage = messages[messages.length - 1];\n\n if (lastMessage.role === \"assistant\") {\n newMessages = newMessages.slice(0, -1);\n }\n setMessages(newMessages);\n\n return runChatCompletionAndHandleFunctionCall(newMessages);\n };\n\n const stop = (): void => {\n abortControllerRef.current?.abort();\n };\n\n return {\n messages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/use-chat.ts"],"sourcesContent":["import { useRef, useState } from \"react\";\nimport { Message, Function, FunctionCallHandler, FunctionCall } from \"@copilotkit/shared\";\nimport { nanoid } from \"nanoid\";\nimport { fetchAndDecodeChatCompletion } from \"../utils/fetch-chat-completion\";\nimport { CopilotApiConfig } from \"../context\";\n\nexport type UseChatOptions = {\n /**\n * The API endpoint that accepts a `{ messages: Message[] }` object and returns\n * a stream of tokens of the AI chat response. Defaults to `/api/chat`.\n */\n api?: string;\n /**\n * A unique identifier for the chat. If not provided, a random one will be\n * generated. When provided, the `useChat` hook with the same `id` will\n * have shared states across components.\n */\n id?: string;\n /**\n * System messages of the chat. Defaults to an empty array.\n */\n initialMessages?: Message[];\n /**\n * Callback function to be called when a function call is received.\n * If the function returns a `ChatRequest` object, the request will be sent\n * automatically to the API and will be used to update the chat.\n */\n onFunctionCall?: FunctionCallHandler;\n /**\n * HTTP headers to be sent with the API request.\n */\n headers?: Record<string, string> | Headers;\n /**\n * Extra body object to be sent with the API request.\n * @example\n * Send a `sessionId` to the API along with the messages.\n * ```js\n * useChat({\n * body: {\n * sessionId: '123',\n * }\n * })\n * ```\n */\n body?: object;\n /**\n * Function definitions to be sent to the API.\n */\n functions?: Function[];\n};\n\nexport type UseChatHelpers = {\n /** Current messages in the chat */\n messages: Message[];\n /**\n * Append a user message to the chat list. This triggers the API call to fetch\n * the assistant's response.\n * @param message The message to append\n */\n append: (message: Message) => Promise<void>;\n /**\n * Reload the last AI chat response for the given chat history. If the last\n * message isn't from the assistant, it will request the API to generate a\n * new response.\n */\n reload: () => Promise<void>;\n /**\n * Abort the current request immediately, keep the generated tokens if any.\n */\n stop: () => void;\n /** The current value of the input */\n input: string;\n /** setState-powered method to update the input value */\n setInput: React.Dispatch<React.SetStateAction<string>>;\n /** Whether the API request is in progress */\n isLoading: boolean;\n};\n\nexport type UseChatOptionsWithCopilotConfig = UseChatOptions & {\n copilotConfig: CopilotApiConfig;\n};\n\nexport function useChat(options: UseChatOptionsWithCopilotConfig): UseChatHelpers {\n const [messages, setMessages] = useState<Message[]>([]);\n const [input, setInput] = useState(\"\");\n const [isLoading, setIsLoading] = useState(false);\n const abortControllerRef = useRef<AbortController>();\n\n const runChatCompletion = async (messages: Message[]): Promise<Message> => {\n setIsLoading(true);\n const assistantMessage: Message = {\n id: nanoid(),\n createdAt: new Date(),\n content: \"\",\n role: \"assistant\",\n };\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setMessages([...messages, { ...assistantMessage }]);\n\n const messagesWithContext = [...(options.initialMessages || []), ...messages];\n const response = await fetchAndDecodeChatCompletion({\n copilotConfig: options.copilotConfig,\n messages: messagesWithContext,\n functions: options.functions,\n headers: options.headers,\n signal: abortController.signal,\n });\n\n if (!response.events) {\n throw new Error(\"Failed to fetch chat completion\");\n }\n\n const reader = response.events.getReader();\n\n while (true) {\n try {\n const { done, value } = await reader.read();\n\n if (done) {\n setIsLoading(false);\n return { ...assistantMessage };\n }\n\n if (value.type === \"content\") {\n assistantMessage.content += value.content;\n setMessages([...messages, { ...assistantMessage }]);\n } else if (value.type === \"function\") {\n assistantMessage.function_call = {\n name: value.name,\n arguments: JSON.stringify(value.arguments),\n };\n setMessages([...messages, { ...assistantMessage }]);\n // quit early if we get a function call\n setIsLoading(false);\n return { ...assistantMessage };\n }\n } catch (error) {\n setIsLoading(false);\n throw error;\n }\n }\n };\n\n const runChatCompletionAndHandleFunctionCall = async (messages: Message[]): Promise<void> => {\n const message = await runChatCompletion(messages);\n if (message.function_call && options.onFunctionCall) {\n await options.onFunctionCall(messages, message.function_call as FunctionCall);\n }\n };\n\n const append = async (message: Message): Promise<void> => {\n if (isLoading) {\n return;\n }\n const newMessages = [...messages, message];\n setMessages(newMessages);\n return runChatCompletionAndHandleFunctionCall(newMessages);\n };\n\n const reload = async (): Promise<void> => {\n if (isLoading || messages.length === 0) {\n return;\n }\n let newMessages = [...messages];\n const lastMessage = messages[messages.length - 1];\n\n if (lastMessage.role === \"assistant\") {\n newMessages = newMessages.slice(0, -1);\n }\n setMessages(newMessages);\n\n return runChatCompletionAndHandleFunctionCall(newMessages);\n };\n\n const stop = (): void => {\n abortControllerRef.current?.abort();\n };\n\n return {\n messages,\n append,\n reload,\n stop,\n isLoading,\n input,\n setInput,\n };\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,QAAQ,gBAAgB;AAEjC,SAAS,cAAc;AAgFhB,SAAS,QAAQ,SAA0D;AAChF,QAAM,CAAC,UAAU,WAAW,IAAI,SAAoB,CAAC,CAAC;AACtD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AACrC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;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AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,yCAAyC,CAAOA,cAAuC;AAC3F,UAAM,UAAU,MAAM,kBAAkBA,SAAQ;AAChD,QAAI,QAAQ,iBAAiB,QAAQ,gBAAgB;AACnD,YAAM,QAAQ,eAAeA,WAAU,QAAQ,aAA6B;AAAA,IAC9E;AAAA,EACF;AAEA,QAAM,SAAS,CAAO,YAAoC;AACxD,QAAI,WAAW;AACb;AAAA,IACF;AACA,UAAM,cAAc,CAAC,GAAG,UAAU,OAAO;AACzC,gBAAY,WAAW;AACvB,WAAO,uCAAuC,WAAW;AAAA,EAC3D;AAEA,QAAM,SAAS,MAA2B;AACxC,QAAI,aAAa,SAAS,WAAW,GAAG;AACtC;AAAA,IACF;AACA,QAAI,cAAc,CAAC,GAAG,QAAQ;AAC9B,UAAM,cAAc,SAAS,SAAS,SAAS,CAAC;AAEhD,QAAI,YAAY,SAAS,aAAa;AACpC,oBAAc,YAAY,MAAM,GAAG,EAAE;AAAA,IACvC;AACA,gBAAY,WAAW;AAEvB,WAAO,uCAAuC,WAAW;AAAA,EAC3D;AAEA,QAAM,OAAO,MAAY;AAhL3B;AAiLI,6BAAmB,YAAnB,mBAA4B;AAAA,EAC9B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["messages"]}
@@ -1,6 +1,9 @@
1
- import { CopilotContext } from './chunk-4CFJ6A6A.mjs';
2
- import { useContext, useRef, useEffect } from 'react';
1
+ import {
2
+ CopilotContext
3
+ } from "./chunk-4CFJ6A6A.mjs";
3
4
 
5
+ // src/hooks/use-make-copilot-document-readable.ts
6
+ import { useContext, useEffect, useRef } from "react";
4
7
  function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
5
8
  const { addDocumentContext, removeDocumentContext } = useContext(CopilotContext);
6
9
  const idRef = useRef();
@@ -14,6 +17,7 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
14
17
  return idRef.current;
15
18
  }
16
19
 
17
- export { useMakeCopilotDocumentReadable };
18
- //# sourceMappingURL=out.js.map
20
+ export {
21
+ useMakeCopilotDocumentReadable
22
+ };
19
23
  //# sourceMappingURL=chunk-IQH5AQQC.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/use-make-copilot-document-readable.ts"],"names":[],"mappings":";;;;;AAEA,SAAS,YAAY,WAAW,cAAc;AAWvC,SAAS,+BACd,UACA,YACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAAI,WAAW,cAAc;AAC/E,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE/D,SAAO,MAAM;AACf","sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Makes a document readable by Copilot.\n * @param document The document to make readable.\n * @param categories The categories to associate with the document.\n * @param dependencies The dependencies to use for the effect.\n * @returns The id of the document.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = [],\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } = useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n"]}
1
+ {"version":3,"sources":["../src/hooks/use-make-copilot-document-readable.ts"],"sourcesContent":["\"use client\";\n\nimport { useContext, useEffect, useRef } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Makes a document readable by Copilot.\n * @param document The document to make readable.\n * @param categories The categories to associate with the document.\n * @param dependencies The dependencies to use for the effect.\n * @returns The id of the document.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = [],\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } = useContext(CopilotContext);\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n"],"mappings":";;;;;AAEA,SAAS,YAAY,WAAW,cAAc;AAWvC,SAAS,+BACd,UACA,YACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAAI,WAAW,cAAc;AAC/E,QAAM,QAAQ,OAAe;AAE7B,YAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE/D,SAAO,MAAM;AACf;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-JD7BAH7U.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -50,6 +50,10 @@ var __async = (__this, __arguments, generator) => {
50
50
  });
51
51
  };
52
52
 
53
- export { __async, __objRest, __spreadProps, __spreadValues };
54
- //# sourceMappingURL=out.js.map
53
+ export {
54
+ __spreadValues,
55
+ __spreadProps,
56
+ __objRest,
57
+ __async
58
+ };
55
59
  //# sourceMappingURL=chunk-MRXNTQOX.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,4 +1,6 @@
1
- import { __async } from './chunk-MRXNTQOX.mjs';
1
+ import {
2
+ __async
3
+ } from "./chunk-MRXNTQOX.mjs";
2
4
 
3
5
  // src/openai-assistants/utils/process-message-stream.ts
4
6
  function processMessageStream(reader, processMessage) {
@@ -23,6 +25,7 @@ function processMessageStream(reader, processMessage) {
23
25
  });
24
26
  }
25
27
 
26
- export { processMessageStream };
27
- //# sourceMappingURL=out.js.map
28
+ export {
29
+ processMessageStream
30
+ };
28
31
  //# sourceMappingURL=chunk-MZ5UN3BY.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/openai-assistants/utils/process-message-stream.ts"],"names":[],"mappings":";;;;;AAAA,SAAsB,qBACpB,QACA,gBACA;AAAA;AACA,UAAM,UAAU,IAAI,YAAY;AAChC,QAAI,SAAS;AACb,WAAO,MAAM;AACX,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAE1C,UAAI,MAAM;AACR,YAAI,OAAO,SAAS,GAAG;AACrB,yBAAe,MAAM;AAAA,QACvB;AACA;AAAA,MACF;AAEA,gBAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAEhD,UAAI;AACJ,cAAQ,WAAW,OAAO,QAAQ,IAAI,OAAO,IAAI;AAC/C,uBAAe,OAAO,UAAU,GAAG,QAAQ,EAAE,KAAK,CAAC;AACnD,iBAAS,OAAO,UAAU,WAAW,CAAC;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA","sourcesContent":["export async function processMessageStream(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n processMessage: (message: string) => void | Promise<void>,\n) {\n const decoder = new TextDecoder();\n let buffer = \"\";\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n if (buffer.length > 0) {\n processMessage(buffer);\n }\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n\n let endIndex: number;\n while ((endIndex = buffer.indexOf(\"\\n\")) !== -1) {\n processMessage(buffer.substring(0, endIndex).trim());\n buffer = buffer.substring(endIndex + 1); // Remove the processed instruction + delimiter\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/openai-assistants/utils/process-message-stream.ts"],"sourcesContent":["export async function processMessageStream(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n processMessage: (message: string) => void | Promise<void>,\n) {\n const decoder = new TextDecoder();\n let buffer = \"\";\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n if (buffer.length > 0) {\n processMessage(buffer);\n }\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n\n let endIndex: number;\n while ((endIndex = buffer.indexOf(\"\\n\")) !== -1) {\n processMessage(buffer.substring(0, endIndex).trim());\n buffer = buffer.substring(endIndex + 1); // Remove the processed instruction + delimiter\n }\n }\n}\n"],"mappings":";;;;;AAAA,SAAsB,qBACpB,QACA,gBACA;AAAA;AACA,UAAM,UAAU,IAAI,YAAY;AAChC,QAAI,SAAS;AACb,WAAO,MAAM;AACX,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAE1C,UAAI,MAAM;AACR,YAAI,OAAO,SAAS,GAAG;AACrB,yBAAe,MAAM;AAAA,QACvB;AACA;AAAA,MACF;AAEA,gBAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAEhD,UAAI;AACJ,cAAQ,WAAW,OAAO,QAAQ,IAAI,OAAO,IAAI;AAC/C,uBAAe,OAAO,UAAU,GAAG,QAAQ,EAAE,KAAK,CAAC;AACnD,iBAAS,OAAO,UAAU,WAAW,CAAC;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-SPCZTZCY.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,15 @@
1
- import { __async, __spreadValues, __spreadProps } from './chunk-MRXNTQOX.mjs';
2
- import { decodeChatCompletion, parseChatCompletion, decodeChatCompletionAsText } from '@copilotkit/shared';
1
+ import {
2
+ __async,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-MRXNTQOX.mjs";
3
6
 
7
+ // src/utils/fetch-chat-completion.ts
8
+ import {
9
+ decodeChatCompletion,
10
+ parseChatCompletion,
11
+ decodeChatCompletionAsText
12
+ } from "@copilotkit/shared";
4
13
  function fetchChatCompletion(_0) {
5
14
  return __async(this, arguments, function* ({
6
15
  copilotConfig,
@@ -56,6 +65,9 @@ function fetchAndDecodeChatCompletionAsText(params) {
56
65
  });
57
66
  }
58
67
 
59
- export { fetchAndDecodeChatCompletion, fetchAndDecodeChatCompletionAsText, fetchChatCompletion };
60
- //# sourceMappingURL=out.js.map
68
+ export {
69
+ fetchChatCompletion,
70
+ fetchAndDecodeChatCompletion,
71
+ fetchAndDecodeChatCompletionAsText
72
+ };
61
73
  //# sourceMappingURL=chunk-UAKLDQMP.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/fetch-chat-completion.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAeP,SAAsB,oBAAoB,IASO;AAAA,6CATP;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAiD;AAC/C,kCAAgB;AAChB,8BAAc,CAAC;AAGf,UAAM,kBAAkB,SAAS,IAAI,CAAC,YAAY;AAChD,YAAM,EAAE,SAAS,MAAM,MAAM,cAAc,IAAI;AAC/C,aAAO,EAAE,SAAS,MAAM,MAAM,cAAc;AAAA,IAC9C,CAAC;AAED,UAAM,WAAW,MAAM,MAAM,cAAc,iBAAiB;AAAA,MAC1D,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,SACb,cAAc,UACb,UAAU,mBAAK,WAAY,CAAC;AAAA,MAElC,MAAM,KAAK,UAAU;AAAA,QACnB;AAAA,QACA,UAAU;AAAA,QACV,QAAQ;AAAA,SACJ,UAAU,SAAS,EAAE,UAAU,IAAI,CAAC,IACpC,cAAc,EAAE,YAAY,IAAI,CAAC,IACjC,UAAU,UAAU,IAAI,EAAE,eAAe,OAAO,IAAI,CAAC,IACtD,cAAc,OACb,OAAO,mBAAK,QAAS,CAAC,EAC3B;AAAA,MACD;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAMA,SAAsB,6BACpB,QACwC;AAAA;AACxC,UAAM,WAAW,MAAM,oBAAoB,MAAM;AACjD,QAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAClC,aAAO,iCAAK,WAAL,EAAe,QAAQ,KAAK;AAAA,IACrC;AACA,UAAM,SAAS,MAAM,qBAAqB,oBAAoB,SAAS,IAAI,CAAC;AAC5E,WAAO,iCAAK,WAAL,EAAe,OAAO;AAAA,EAC/B;AAAA;AAMA,SAAsB,mCACpB,QAC8C;AAAA;AAC9C,UAAM,WAAW,MAAM,oBAAoB,MAAM;AACjD,QAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAClC,aAAO,iCAAK,WAAL,EAAe,QAAQ,KAAK;AAAA,IACrC;AACA,UAAM,SAAS,MAAM;AAAA,MACnB,qBAAqB,oBAAoB,SAAS,IAAI,CAAC;AAAA,IACzD;AACA,WAAO,iCAAK,WAAL,EAAe,OAAO;AAAA,EAC/B;AAAA","sourcesContent":["import {\n Message,\n Function,\n ChatCompletionEvent,\n decodeChatCompletion,\n parseChatCompletion,\n decodeChatCompletionAsText,\n} from \"@copilotkit/shared\";\nimport { CopilotApiConfig } from \"../context\";\n\nexport interface FetchChatCompletionParams {\n copilotConfig: CopilotApiConfig;\n model?: string;\n messages: Message[];\n functions?: Function[];\n temperature?: number;\n maxTokens?: number;\n headers?: Record<string, string> | Headers;\n body?: object;\n signal?: AbortSignal;\n}\n\nexport async function fetchChatCompletion({\n copilotConfig,\n model,\n messages,\n functions,\n temperature,\n headers,\n body,\n signal,\n}: FetchChatCompletionParams): Promise<Response> {\n temperature ||= 0.5;\n functions ||= [];\n\n // clean up any extra properties from messages\n const cleanedMessages = messages.map((message) => {\n const { content, role, name, function_call } = message;\n return { content, role, name, function_call };\n });\n\n const response = await fetch(copilotConfig.chatApiEndpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...copilotConfig.headers,\n ...(headers ? { ...headers } : {}),\n },\n body: JSON.stringify({\n model,\n messages: cleanedMessages,\n stream: true,\n ...(functions.length ? { functions } : {}),\n ...(temperature ? { temperature } : {}),\n ...(functions.length != 0 ? { function_call: \"auto\" } : {}),\n ...copilotConfig.body,\n ...(body ? { ...body } : {}),\n }),\n signal,\n });\n\n return response;\n}\n\nexport interface DecodedChatCompletionResponse extends Response {\n events: ReadableStream<ChatCompletionEvent> | null;\n}\n\nexport async function fetchAndDecodeChatCompletion(\n params: FetchChatCompletionParams,\n): Promise<DecodedChatCompletionResponse> {\n const response = await fetchChatCompletion(params);\n if (!response.ok || !response.body) {\n return { ...response, events: null };\n }\n const events = await decodeChatCompletion(parseChatCompletion(response.body));\n return { ...response, events };\n}\n\nexport interface DecodedChatCompletionResponseAsText extends Response {\n events: ReadableStream<string> | null;\n}\n\nexport async function fetchAndDecodeChatCompletionAsText(\n params: FetchChatCompletionParams,\n): Promise<DecodedChatCompletionResponseAsText> {\n const response = await fetchChatCompletion(params);\n if (!response.ok || !response.body) {\n return { ...response, events: null };\n }\n const events = await decodeChatCompletionAsText(\n decodeChatCompletion(parseChatCompletion(response.body)),\n );\n return { ...response, events };\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/fetch-chat-completion.ts"],"sourcesContent":["import {\n Message,\n Function,\n ChatCompletionEvent,\n decodeChatCompletion,\n parseChatCompletion,\n decodeChatCompletionAsText,\n} from \"@copilotkit/shared\";\nimport { CopilotApiConfig } from \"../context\";\n\nexport interface FetchChatCompletionParams {\n copilotConfig: CopilotApiConfig;\n model?: string;\n messages: Message[];\n functions?: Function[];\n temperature?: number;\n maxTokens?: number;\n headers?: Record<string, string> | Headers;\n body?: object;\n signal?: AbortSignal;\n}\n\nexport async function fetchChatCompletion({\n copilotConfig,\n model,\n messages,\n functions,\n temperature,\n headers,\n body,\n signal,\n}: FetchChatCompletionParams): Promise<Response> {\n temperature ||= 0.5;\n functions ||= [];\n\n // clean up any extra properties from messages\n const cleanedMessages = messages.map((message) => {\n const { content, role, name, function_call } = message;\n return { content, role, name, function_call };\n });\n\n const response = await fetch(copilotConfig.chatApiEndpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...copilotConfig.headers,\n ...(headers ? { ...headers } : {}),\n },\n body: JSON.stringify({\n model,\n messages: cleanedMessages,\n stream: true,\n ...(functions.length ? { functions } : {}),\n ...(temperature ? { temperature } : {}),\n ...(functions.length != 0 ? { function_call: \"auto\" } : {}),\n ...copilotConfig.body,\n ...(body ? { ...body } : {}),\n }),\n signal,\n });\n\n return response;\n}\n\nexport interface DecodedChatCompletionResponse extends Response {\n events: ReadableStream<ChatCompletionEvent> | null;\n}\n\nexport async function fetchAndDecodeChatCompletion(\n params: FetchChatCompletionParams,\n): Promise<DecodedChatCompletionResponse> {\n const response = await fetchChatCompletion(params);\n if (!response.ok || !response.body) {\n return { ...response, events: null };\n }\n const events = await decodeChatCompletion(parseChatCompletion(response.body));\n return { ...response, events };\n}\n\nexport interface DecodedChatCompletionResponseAsText extends Response {\n events: ReadableStream<string> | null;\n}\n\nexport async function fetchAndDecodeChatCompletionAsText(\n params: FetchChatCompletionParams,\n): Promise<DecodedChatCompletionResponseAsText> {\n const response = await fetchChatCompletion(params);\n if (!response.ok || !response.body) {\n return { ...response, events: null };\n }\n const events = await decodeChatCompletionAsText(\n decodeChatCompletion(parseChatCompletion(response.body)),\n );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AAM,oBAAoB,MAAM;AACjD,QAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAClC,aAAO,iCAAK,WAAL,EAAe,QAAQ,KAAK;AAAA,IACrC;AACA,UAAM,SAAS,MAAM;AAAA,MACnB,qBAAqB,oBAAoB,SAAS,IAAI,CAAC;AAAA,IACzD;AACA,WAAO,iCAAK,WAAL,EAAe,OAAO;AAAA,EAC/B;AAAA;","names":[]}
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=out.js.map
3
1
  //# sourceMappingURL=chunk-VNRDQJXW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,10 +1,20 @@
1
- import { processMessageStream } from './chunk-MZ5UN3BY.mjs';
2
- import { defaultCopilotContextCategories } from './chunk-GBZZPQ5X.mjs';
3
- import { CopilotContext } from './chunk-4CFJ6A6A.mjs';
4
- import { __async, __spreadValues } from './chunk-MRXNTQOX.mjs';
5
- import { useContext, useState, useMemo } from 'react';
6
- import { parseStreamPart } from '@copilotkit/shared';
1
+ import {
2
+ processMessageStream
3
+ } from "./chunk-MZ5UN3BY.mjs";
4
+ import {
5
+ defaultCopilotContextCategories
6
+ } from "./chunk-GBZZPQ5X.mjs";
7
+ import {
8
+ CopilotContext
9
+ } from "./chunk-4CFJ6A6A.mjs";
10
+ import {
11
+ __async,
12
+ __spreadValues
13
+ } from "./chunk-MRXNTQOX.mjs";
7
14
 
15
+ // src/openai-assistants/hooks/use-copilot-chat-v2.ts
16
+ import { useContext, useMemo, useState } from "react";
17
+ import { parseStreamPart } from "@copilotkit/shared";
8
18
  function useCopilotChatV2(options) {
9
19
  const {
10
20
  getContextString,
@@ -17,7 +27,7 @@ function useCopilotChatV2(options) {
17
27
  const [threadId, setThreadId] = useState(void 0);
18
28
  const [status, setStatus] = useState("awaiting_message");
19
29
  const [error, setError] = useState(void 0);
20
- useMemo(() => {
30
+ const systemMessage = useMemo(() => {
21
31
  const systemMessageMaker = options.makeSystemMessage || defaultSystemMessage;
22
32
  const contextString = getContextString([], defaultCopilotContextCategories);
23
33
  return {
@@ -120,6 +130,8 @@ If you would like to call a function, call it without saying anything else.
120
130
  `;
121
131
  }
122
132
 
123
- export { defaultSystemMessage, useCopilotChatV2 };
124
- //# sourceMappingURL=out.js.map
133
+ export {
134
+ useCopilotChatV2,
135
+ defaultSystemMessage
136
+ };
125
137
  //# sourceMappingURL=chunk-VP2EU4US.mjs.map