@agentscope-ai/chat 1.1.4

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 (476) hide show
  1. package/README.md +88 -0
  2. package/dist/_util/hooks/use-proxy-imperative-handle.d.ts +4 -0
  3. package/dist/_util/hooks/use-proxy-imperative-handle.js +18 -0
  4. package/dist/_util/type.d.ts +1 -0
  5. package/dist/_util/type.js +1 -0
  6. package/dist/_util/warning.d.ts +30 -0
  7. package/dist/_util/warning.js +63 -0
  8. package/dist/accordion/Accordion.d.ts +22 -0
  9. package/dist/accordion/Accordion.js +93 -0
  10. package/dist/accordion/BodyContent.d.ts +8 -0
  11. package/dist/accordion/BodyContent.js +18 -0
  12. package/dist/accordion/DeepThink.d.ts +7 -0
  13. package/dist/accordion/DeepThink.js +35 -0
  14. package/dist/accordion/index.d.ts +2 -0
  15. package/dist/accordion/index.js +1 -0
  16. package/dist/accordion/index.less +170 -0
  17. package/dist/attachments/DropArea.d.ts +8 -0
  18. package/dist/attachments/DropArea.js +87 -0
  19. package/dist/attachments/FileList/AudioIcon.d.ts +2 -0
  20. package/dist/attachments/FileList/AudioIcon.js +19 -0
  21. package/dist/attachments/FileList/FileListCard.d.ts +12 -0
  22. package/dist/attachments/FileList/FileListCard.js +229 -0
  23. package/dist/attachments/FileList/Progress.d.ts +6 -0
  24. package/dist/attachments/FileList/Progress.js +21 -0
  25. package/dist/attachments/FileList/VideoIcon.d.ts +2 -0
  26. package/dist/attachments/FileList/VideoIcon.js +19 -0
  27. package/dist/attachments/FileList/index.d.ts +16 -0
  28. package/dist/attachments/FileList/index.js +132 -0
  29. package/dist/attachments/PlaceholderUploader.d.ts +17 -0
  30. package/dist/attachments/PlaceholderUploader.js +79 -0
  31. package/dist/attachments/SilentUploader.d.ts +9 -0
  32. package/dist/attachments/SilentUploader.js +23 -0
  33. package/dist/attachments/context.d.ts +5 -0
  34. package/dist/attachments/context.js +2 -0
  35. package/dist/attachments/index.d.ts +33 -0
  36. package/dist/attachments/index.js +166 -0
  37. package/dist/attachments/style/fileCard.d.ts +4 -0
  38. package/dist/attachments/style/fileCard.js +124 -0
  39. package/dist/attachments/style/index.d.ts +10 -0
  40. package/dist/attachments/style/index.js +211 -0
  41. package/dist/attachments/util.d.ts +2 -0
  42. package/dist/attachments/util.js +53 -0
  43. package/dist/bubble/Avatar.d.ts +10 -0
  44. package/dist/bubble/Avatar.js +22 -0
  45. package/dist/bubble/Bubble.d.ts +11 -0
  46. package/dist/bubble/Bubble.js +102 -0
  47. package/dist/bubble/BubbleList.d.ts +15 -0
  48. package/dist/bubble/BubbleList.js +44 -0
  49. package/dist/bubble/Cards.d.ts +21 -0
  50. package/dist/bubble/Cards.js +47 -0
  51. package/dist/bubble/ScrollToBottom.d.ts +7 -0
  52. package/dist/bubble/ScrollToBottom.js +45 -0
  53. package/dist/bubble/Spin.d.ts +2 -0
  54. package/dist/bubble/Spin.js +18 -0
  55. package/dist/bubble/hooks/useDisplayData.d.ts +0 -0
  56. package/dist/bubble/hooks/useDisplayData.js +0 -0
  57. package/dist/bubble/hooks/useListData.d.ts +0 -0
  58. package/dist/bubble/hooks/useListData.js +0 -0
  59. package/dist/bubble/index.d.ts +8 -0
  60. package/dist/bubble/index.js +4 -0
  61. package/dist/bubble/interface.d.ts +26 -0
  62. package/dist/bubble/interface.js +1 -0
  63. package/dist/bubble/loading.d.ts +6 -0
  64. package/dist/bubble/loading.js +17 -0
  65. package/dist/bubble/style/avatar.less +40 -0
  66. package/dist/bubble/style/content.d.ts +4 -0
  67. package/dist/bubble/style/content.js +43 -0
  68. package/dist/bubble/style/index.d.ts +9 -0
  69. package/dist/bubble/style/index.js +53 -0
  70. package/dist/bubble/style/list.less +15 -0
  71. package/dist/bubble/style/scrollToBottom.less +174 -0
  72. package/dist/chat-anywhere/Chat/Ref.d.ts +3 -0
  73. package/dist/chat-anywhere/Chat/Ref.js +19 -0
  74. package/dist/chat-anywhere/Chat/index.d.ts +4 -0
  75. package/dist/chat-anywhere/Chat/index.js +65 -0
  76. package/dist/chat-anywhere/Chat/index.less +54 -0
  77. package/dist/chat-anywhere/Header/index.d.ts +3 -0
  78. package/dist/chat-anywhere/Header/index.js +32 -0
  79. package/dist/chat-anywhere/Header/index.less +24 -0
  80. package/dist/chat-anywhere/Input/index.d.ts +3 -0
  81. package/dist/chat-anywhere/Input/index.js +170 -0
  82. package/dist/chat-anywhere/Input/index.less +12 -0
  83. package/dist/chat-anywhere/Layout/index.d.ts +10 -0
  84. package/dist/chat-anywhere/Layout/index.js +73 -0
  85. package/dist/chat-anywhere/Layout/index.less +61 -0
  86. package/dist/chat-anywhere/SessionList/index.d.ts +5 -0
  87. package/dist/chat-anywhere/SessionList/index.js +115 -0
  88. package/dist/chat-anywhere/SessionList/index.less +52 -0
  89. package/dist/chat-anywhere/hooks/ChatAnywhereProvider.d.ts +43 -0
  90. package/dist/chat-anywhere/hooks/ChatAnywhereProvider.js +90 -0
  91. package/dist/chat-anywhere/hooks/types.d.ts +57 -0
  92. package/dist/chat-anywhere/hooks/types.js +1 -0
  93. package/dist/chat-anywhere/hooks/useInput.d.ts +7 -0
  94. package/dist/chat-anywhere/hooks/useInput.js +21 -0
  95. package/dist/chat-anywhere/hooks/useMessages.d.ts +11 -0
  96. package/dist/chat-anywhere/hooks/useMessages.js +56 -0
  97. package/dist/chat-anywhere/hooks/useSessionList.d.ts +24 -0
  98. package/dist/chat-anywhere/hooks/useSessionList.js +120 -0
  99. package/dist/chat-anywhere/index.d.ts +9 -0
  100. package/dist/chat-anywhere/index.js +58 -0
  101. package/dist/conversations/GroupTitle.d.ts +10 -0
  102. package/dist/conversations/GroupTitle.js +15 -0
  103. package/dist/conversations/Item.d.ts +14 -0
  104. package/dist/conversations/Item.js +96 -0
  105. package/dist/conversations/hooks/useGroupable.d.ts +9 -0
  106. package/dist/conversations/hooks/useGroupable.js +72 -0
  107. package/dist/conversations/index.d.ts +62 -0
  108. package/dist/conversations/index.js +124 -0
  109. package/dist/conversations/interface.d.ts +60 -0
  110. package/dist/conversations/interface.js +1 -0
  111. package/dist/conversations/style/index.d.ts +9 -0
  112. package/dist/conversations/style/index.js +80 -0
  113. package/dist/default-cards/Count/index.d.ts +3 -0
  114. package/dist/default-cards/Count/index.js +16 -0
  115. package/dist/default-cards/Count/index.less +19 -0
  116. package/dist/default-cards/DeepThink/index.d.ts +11 -0
  117. package/dist/default-cards/DeepThink/index.js +11 -0
  118. package/dist/default-cards/DeepThink/index.less +0 -0
  119. package/dist/default-cards/Files/index.d.ts +2 -0
  120. package/dist/default-cards/Files/index.js +18 -0
  121. package/dist/default-cards/Footer/index.d.ts +19 -0
  122. package/dist/default-cards/Footer/index.js +50 -0
  123. package/dist/default-cards/Footer/index.less +41 -0
  124. package/dist/default-cards/Images/index.d.ts +3 -0
  125. package/dist/default-cards/Images/index.js +33 -0
  126. package/dist/default-cards/Images/index.less +17 -0
  127. package/dist/default-cards/Interrupted/index.d.ts +11 -0
  128. package/dist/default-cards/Interrupted/index.js +40 -0
  129. package/dist/default-cards/Interrupted/index.less +57 -0
  130. package/dist/default-cards/Text/index.d.ts +2 -0
  131. package/dist/default-cards/Text/index.js +12 -0
  132. package/dist/default-cards/index.d.ts +6 -0
  133. package/dist/default-cards/index.js +6 -0
  134. package/dist/disclaimer/index.d.ts +11 -0
  135. package/dist/disclaimer/index.js +26 -0
  136. package/dist/docs/1896.async.js +457 -0
  137. package/dist/docs/2710.async.js +62 -0
  138. package/dist/docs/2863.async.js +400 -0
  139. package/dist/docs/3057.async.js +46 -0
  140. package/dist/docs/3364.async.js +25 -0
  141. package/dist/docs/404.html +15 -0
  142. package/dist/docs/4820.async.js +1381 -0
  143. package/dist/docs/5623.async.js +60 -0
  144. package/dist/docs/5757.async.js +1 -0
  145. package/dist/docs/5804.async.js +271 -0
  146. package/dist/docs/6198.async.js +18 -0
  147. package/dist/docs/6671.async.js +137 -0
  148. package/dist/docs/7195.async.js +1 -0
  149. package/dist/docs/7485.async.js +29 -0
  150. package/dist/docs/7931.async.js +19 -0
  151. package/dist/docs/7997.async.js +5 -0
  152. package/dist/docs/8156.async.js +110 -0
  153. package/dist/docs/8368.async.js +2 -0
  154. package/dist/docs/8480.async.js +1449 -0
  155. package/dist/docs/8618.async.js +246 -0
  156. package/dist/docs/9016.async.js +32 -0
  157. package/dist/docs/9016.chunk.css +1 -0
  158. package/dist/docs/9335.async.js +11 -0
  159. package/dist/docs/accordion__demos.async.js +9 -0
  160. package/dist/docs/attachments__demos.async.js +1 -0
  161. package/dist/docs/bubble__demos.async.js +50 -0
  162. package/dist/docs/components/accordion/index.html +15 -0
  163. package/dist/docs/components/accordion-cn/index.html +15 -0
  164. package/dist/docs/components/attachments/index.html +15 -0
  165. package/dist/docs/components/attachments-cn/index.html +15 -0
  166. package/dist/docs/components/bubble/index.html +15 -0
  167. package/dist/docs/components/bubble-cn/index.html +15 -0
  168. package/dist/docs/components/bubble-list/index.html +15 -0
  169. package/dist/docs/components/bubble-list-cn/index.html +15 -0
  170. package/dist/docs/components/conversations/index.html +15 -0
  171. package/dist/docs/components/conversations-cn/index.html +15 -0
  172. package/dist/docs/components/disclaimer/index.html +15 -0
  173. package/dist/docs/components/disclaimer-cn/index.html +15 -0
  174. package/dist/docs/components/footer/index.html +15 -0
  175. package/dist/docs/components/footer-cn/index.html +15 -0
  176. package/dist/docs/components/markdown/index.html +15 -0
  177. package/dist/docs/components/markdown-cn/index.html +15 -0
  178. package/dist/docs/components/sender/index.html +15 -0
  179. package/dist/docs/components/sender-cn/index.html +15 -0
  180. package/dist/docs/components/status/index.html +15 -0
  181. package/dist/docs/components/status-cn/index.html +15 -0
  182. package/dist/docs/components/welcome/index.html +15 -0
  183. package/dist/docs/components/welcome-cn/index.html +15 -0
  184. package/dist/docs/components__accordion__index.en-US.md.async.js +6 -0
  185. package/dist/docs/components__accordion__index.en-US.md.chunk.css +1 -0
  186. package/dist/docs/components__accordion__index.zh-CN.md.async.js +6 -0
  187. package/dist/docs/components__accordion__index.zh-CN.md.chunk.css +1 -0
  188. package/dist/docs/components__attachments__index.en-US.md.async.js +1 -0
  189. package/dist/docs/components__attachments__index.en-US.md.chunk.css +1 -0
  190. package/dist/docs/components__attachments__index.zh-CN.md.async.js +1 -0
  191. package/dist/docs/components__attachments__index.zh-CN.md.chunk.css +1 -0
  192. package/dist/docs/components__bubble-list__index.en-US.md.async.js +2 -0
  193. package/dist/docs/components__bubble-list__index.en-US.md.chunk.css +1 -0
  194. package/dist/docs/components__bubble-list__index.zh-CN.md.async.js +2 -0
  195. package/dist/docs/components__bubble-list__index.zh-CN.md.chunk.css +1 -0
  196. package/dist/docs/components__bubble__index.en-US.md.async.js +1 -0
  197. package/dist/docs/components__bubble__index.en-US.md.chunk.css +1 -0
  198. package/dist/docs/components__bubble__index.zh-CN.md.async.js +1 -0
  199. package/dist/docs/components__bubble__index.zh-CN.md.chunk.css +1 -0
  200. package/dist/docs/components__conversations__index.en-US.md.async.js +2 -0
  201. package/dist/docs/components__conversations__index.en-US.md.chunk.css +1 -0
  202. package/dist/docs/components__conversations__index.zh-CN.md.async.js +1 -0
  203. package/dist/docs/components__conversations__index.zh-CN.md.chunk.css +1 -0
  204. package/dist/docs/components__disclaimer__index.en-US.md.async.js +1 -0
  205. package/dist/docs/components__disclaimer__index.en-US.md.chunk.css +1 -0
  206. package/dist/docs/components__disclaimer__index.zh-CN.md.async.js +1 -0
  207. package/dist/docs/components__disclaimer__index.zh-CN.md.chunk.css +1 -0
  208. package/dist/docs/components__footer__index.en-US.md.async.js +1 -0
  209. package/dist/docs/components__footer__index.en-US.md.chunk.css +1 -0
  210. package/dist/docs/components__footer__index.zh-CN.md.async.js +2 -0
  211. package/dist/docs/components__footer__index.zh-CN.md.chunk.css +1 -0
  212. package/dist/docs/components__markdown__index.en-US.md.async.js +1 -0
  213. package/dist/docs/components__markdown__index.en-US.md.chunk.css +1 -0
  214. package/dist/docs/components__markdown__index.zh-CN.md.async.js +1 -0
  215. package/dist/docs/components__markdown__index.zh-CN.md.chunk.css +1 -0
  216. package/dist/docs/components__sender__index.en-US.md.async.js +1 -0
  217. package/dist/docs/components__sender__index.en-US.md.chunk.css +1 -0
  218. package/dist/docs/components__sender__index.zh-CN.md.async.js +1 -0
  219. package/dist/docs/components__sender__index.zh-CN.md.chunk.css +1 -0
  220. package/dist/docs/components__status__index.en-US.md.async.js +1 -0
  221. package/dist/docs/components__status__index.en-US.md.chunk.css +1 -0
  222. package/dist/docs/components__status__index.zh-CN.md.async.js +2 -0
  223. package/dist/docs/components__status__index.zh-CN.md.chunk.css +1 -0
  224. package/dist/docs/components__welcome__index.en-US.md.async.js +2 -0
  225. package/dist/docs/components__welcome__index.en-US.md.chunk.css +1 -0
  226. package/dist/docs/components__welcome__index.zh-CN.md.async.js +2 -0
  227. package/dist/docs/components__welcome__index.zh-CN.md.chunk.css +1 -0
  228. package/dist/docs/conversations__demos.async.js +1 -0
  229. package/dist/docs/demos.async.js +47 -0
  230. package/dist/docs/demos.chunk.css +1 -0
  231. package/dist/docs/disclaimer__demos.async.js +1 -0
  232. package/dist/docs/docs/development/ag-ui/index.html +15 -0
  233. package/dist/docs/docs/development/ag-ui-cn/index.html +15 -0
  234. package/dist/docs/docs/development/backend/index.html +15 -0
  235. package/dist/docs/docs/development/backend-cn/index.html +15 -0
  236. package/dist/docs/docs/development/cards/index.html +15 -0
  237. package/dist/docs/docs/development/cards-cn/index.html +15 -0
  238. package/dist/docs/docs/development/chatanywhere/index.html +15 -0
  239. package/dist/docs/docs/development/chatanywhere-api/index.html +15 -0
  240. package/dist/docs/docs/development/chatanywhere-api-cn/index.html +15 -0
  241. package/dist/docs/docs/development/chatanywhere-cn/index.html +15 -0
  242. package/dist/docs/docs/development/custom/index.html +15 -0
  243. package/dist/docs/docs/development/custom-cn/index.html +15 -0
  244. package/dist/docs/docs/development/overview/index.html +15 -0
  245. package/dist/docs/docs/development/overview-cn/index.html +15 -0
  246. package/dist/docs/docs/development/qwen/index.html +15 -0
  247. package/dist/docs/docs/development/qwen-cn/index.html +15 -0
  248. package/dist/docs/docs/templates/copilot/index.html +15 -0
  249. package/dist/docs/docs/templates/copilot-cn/index.html +15 -0
  250. package/dist/docs/docs/templates/native/index.html +15 -0
  251. package/dist/docs/docs/templates/native-cn/index.html +15 -0
  252. package/dist/docs/docs/templates/voice/index.html +15 -0
  253. package/dist/docs/docs/templates/voice-cn/index.html +15 -0
  254. package/dist/docs/docs__development__ag-ui.en-US.md.async.js +210 -0
  255. package/dist/docs/docs__development__ag-ui.en-US.md.chunk.css +1 -0
  256. package/dist/docs/docs__development__ag-ui.zh-CN.md.async.js +210 -0
  257. package/dist/docs/docs__development__ag-ui.zh-CN.md.chunk.css +1 -0
  258. package/dist/docs/docs__development__backend.en-US.md.async.js +12 -0
  259. package/dist/docs/docs__development__backend.en-US.md.chunk.css +1 -0
  260. package/dist/docs/docs__development__backend.zh-CN.md.async.js +12 -0
  261. package/dist/docs/docs__development__backend.zh-CN.md.chunk.css +1 -0
  262. package/dist/docs/docs__development__cards.en-US.md.async.js +27 -0
  263. package/dist/docs/docs__development__cards.en-US.md.chunk.css +1 -0
  264. package/dist/docs/docs__development__cards.zh-CN.md.async.js +27 -0
  265. package/dist/docs/docs__development__cards.zh-CN.md.chunk.css +1 -0
  266. package/dist/docs/docs__development__chatanywhere-api.en-US.md.async.js +69 -0
  267. package/dist/docs/docs__development__chatanywhere-api.en-US.md.chunk.css +1 -0
  268. package/dist/docs/docs__development__chatanywhere-api.zh-CN.md.async.js +69 -0
  269. package/dist/docs/docs__development__chatanywhere-api.zh-CN.md.chunk.css +1 -0
  270. package/dist/docs/docs__development__chatanywhere.en-US.md.async.js +77 -0
  271. package/dist/docs/docs__development__chatanywhere.en-US.md.chunk.css +1 -0
  272. package/dist/docs/docs__development__chatanywhere.zh-CN.md.async.js +77 -0
  273. package/dist/docs/docs__development__chatanywhere.zh-CN.md.chunk.css +1 -0
  274. package/dist/docs/docs__development__custom.en-US.md.async.js +22 -0
  275. package/dist/docs/docs__development__custom.en-US.md.chunk.css +1 -0
  276. package/dist/docs/docs__development__custom.zh-CN.md.async.js +22 -0
  277. package/dist/docs/docs__development__custom.zh-CN.md.chunk.css +1 -0
  278. package/dist/docs/docs__development__overview.en-US.md.async.js +21 -0
  279. package/dist/docs/docs__development__overview.en-US.md.chunk.css +1 -0
  280. package/dist/docs/docs__development__overview.zh-CN.md.async.js +21 -0
  281. package/dist/docs/docs__development__overview.zh-CN.md.chunk.css +1 -0
  282. package/dist/docs/docs__development__qwen.en-US.md.async.js +25 -0
  283. package/dist/docs/docs__development__qwen.en-US.md.chunk.css +1 -0
  284. package/dist/docs/docs__development__qwen.zh-CN.md.async.js +25 -0
  285. package/dist/docs/docs__development__qwen.zh-CN.md.chunk.css +1 -0
  286. package/dist/docs/docs__templates__copilot.en-US.md.async.js +1 -0
  287. package/dist/docs/docs__templates__copilot.en-US.md.chunk.css +1 -0
  288. package/dist/docs/docs__templates__copilot.zh-CN.md.async.js +1 -0
  289. package/dist/docs/docs__templates__copilot.zh-CN.md.chunk.css +1 -0
  290. package/dist/docs/docs__templates__native.en-US.md.async.js +1 -0
  291. package/dist/docs/docs__templates__native.en-US.md.chunk.css +1 -0
  292. package/dist/docs/docs__templates__native.zh-CN.md.async.js +1 -0
  293. package/dist/docs/docs__templates__native.zh-CN.md.chunk.css +1 -0
  294. package/dist/docs/docs__templates__voice.en-US.md.async.js +20 -0
  295. package/dist/docs/docs__templates__voice.en-US.md.chunk.css +1 -0
  296. package/dist/docs/docs__templates__voice.zh-CN.md.async.js +1 -0
  297. package/dist/docs/docs__templates__voice.zh-CN.md.chunk.css +1 -0
  298. package/dist/docs/dumi__pages__index__index.en-US.async.js +1 -0
  299. package/dist/docs/dumi__pages__index__index.en-US.chunk.css +1 -0
  300. package/dist/docs/dumi__pages__index__index.zh-CN.async.js +1 -0
  301. package/dist/docs/dumi__pages__index__index.zh-CN.chunk.css +1 -0
  302. package/dist/docs/dumi__theme__layouts__DocLayout__index.async.js +1 -0
  303. package/dist/docs/dumi__theme__layouts__DocLayout__index.chunk.css +1 -0
  304. package/dist/docs/dumi__theme__layouts__GlobalLayout__index.async.js +18 -0
  305. package/dist/docs/dumi__theme__layouts__GlobalLayout__index.chunk.css +1 -0
  306. package/dist/docs/dumi__tmp-production__dumi__theme__ContextWrapper.async.js +1 -0
  307. package/dist/docs/index/index.html +15 -0
  308. package/dist/docs/index-cn/index.html +15 -0
  309. package/dist/docs/markdown__demos.async.js +164 -0
  310. package/dist/docs/meta__components__en-US.async.js +9 -0
  311. package/dist/docs/meta__components__zh-CN.async.js +10 -0
  312. package/dist/docs/meta__docs__en-US.async.js +475 -0
  313. package/dist/docs/meta__docs__en-US.chunk.css +1 -0
  314. package/dist/docs/meta__docs__zh-CN.async.js +456 -0
  315. package/dist/docs/meta__docs__zh-CN.chunk.css +1 -0
  316. package/dist/docs/nm__dumi__dist__client__pages__404.async.js +1 -0
  317. package/dist/docs/nm__dumi__dist__client__pages__Demo__index.async.js +1 -0
  318. package/dist/docs/nm__dumi__dist__client__pages__Demo__index.chunk.css +1 -0
  319. package/dist/docs/preload_helper.js +1 -0
  320. package/dist/docs/sender__demos.async.js +1 -0
  321. package/dist/docs/umi.css +1 -0
  322. package/dist/docs/umi.js +107 -0
  323. package/dist/docs/welcome__demos.async.js +1 -0
  324. package/dist/docs/~demos/:id/index.html +15 -0
  325. package/dist/docs/~demos/accordion-demo-inline/index.html +15 -0
  326. package/dist/docs/~demos/accordion-demo-mutisteps/index.html +15 -0
  327. package/dist/docs/~demos/accordion-demo-thinking/index.html +15 -0
  328. package/dist/docs/~demos/attachments-demo-files/index.html +15 -0
  329. package/dist/docs/~demos/bubble-demo-basic/index.html +15 -0
  330. package/dist/docs/~demos/bubble-demo-havestopped/index.html +15 -0
  331. package/dist/docs/~demos/bubble-demo-userwithfile/index.html +15 -0
  332. package/dist/docs/~demos/bubble-demo-userwithimage/index.html +15 -0
  333. package/dist/docs/~demos/bubble-demo-userwithnormal/index.html +15 -0
  334. package/dist/docs/~demos/bubble-demo-withavatar/index.html +15 -0
  335. package/dist/docs/~demos/bubble-demo-withcode/index.html +15 -0
  336. package/dist/docs/~demos/bubble-demo-witherror/index.html +15 -0
  337. package/dist/docs/~demos/bubble-demo-witherrordetail/index.html +15 -0
  338. package/dist/docs/~demos/bubble-demo-withimage/index.html +15 -0
  339. package/dist/docs/~demos/bubble-demo-withusage/index.html +15 -0
  340. package/dist/docs/~demos/bubble-demo-withwaitingmessage/index.html +15 -0
  341. package/dist/docs/~demos/components-bubble-list-demo-basic/index.html +15 -0
  342. package/dist/docs/~demos/components-footer-demo-basic/index.html +15 -0
  343. package/dist/docs/~demos/components-footer-demo-withusage/index.html +15 -0
  344. package/dist/docs/~demos/components-status-demo-basic/index.html +15 -0
  345. package/dist/docs/~demos/conversations-demo-basic/index.html +15 -0
  346. package/dist/docs/~demos/disclaimer-demo-demo/index.html +15 -0
  347. package/dist/docs/~demos/disclaimer-demo-withlink/index.html +15 -0
  348. package/dist/docs/~demos/docs-development-ag-ui-demo-with-copilotkit/index.html +15 -0
  349. package/dist/docs/~demos/docs-development-cards-demo-file/index.html +15 -0
  350. package/dist/docs/~demos/docs-development-cards-demo-footer/index.html +15 -0
  351. package/dist/docs/~demos/docs-development-cards-demo-image/index.html +15 -0
  352. package/dist/docs/~demos/docs-development-cards-demo-text/index.html +15 -0
  353. package/dist/docs/~demos/docs-development-custom-demo-custom/index.html +15 -0
  354. package/dist/docs/~demos/docs-templates-copilot-demo-copilot/index.html +15 -0
  355. package/dist/docs/~demos/docs-templates-native-demo-basic/index.html +15 -0
  356. package/dist/docs/~demos/docs-templates-voice-demo-demo/index.html +15 -0
  357. package/dist/docs/~demos/markdown-demo-citations/index.html +15 -0
  358. package/dist/docs/~demos/markdown-demo-cursor/index.html +15 -0
  359. package/dist/docs/~demos/markdown-demo-mathjax/index.html +15 -0
  360. package/dist/docs/~demos/markdown-demo-md/index.html +15 -0
  361. package/dist/docs/~demos/sender-demo-basic/index.html +15 -0
  362. package/dist/docs/~demos/sender-demo-disabled/index.html +15 -0
  363. package/dist/docs/~demos/sender-demo-loading/index.html +15 -0
  364. package/dist/docs/~demos/sender-demo-moreprefixaction/index.html +15 -0
  365. package/dist/docs/~demos/sender-demo-withfile/index.html +15 -0
  366. package/dist/docs/~demos/welcome-demo-demo0/index.html +15 -0
  367. package/dist/docs/~demos/welcome-demo-demo1/index.html +15 -0
  368. package/dist/docs/~demos/welcome-demo-demo2/index.html +15 -0
  369. package/dist/index.d.ts +26 -0
  370. package/dist/index.js +20 -0
  371. package/dist/index.less +1 -0
  372. package/dist/markdown/Citation.d.ts +16 -0
  373. package/dist/markdown/Citation.js +55 -0
  374. package/dist/markdown/CodeBlock.d.ts +6 -0
  375. package/dist/markdown/CodeBlock.js +88 -0
  376. package/dist/markdown/ImageOrVideo.d.ts +2 -0
  377. package/dist/markdown/ImageOrVideo.js +81 -0
  378. package/dist/markdown/Link.d.ts +3 -0
  379. package/dist/markdown/Link.js +28 -0
  380. package/dist/markdown/Markdown.d.ts +4 -0
  381. package/dist/markdown/Markdown.js +121 -0
  382. package/dist/markdown/cursor/Blur.d.ts +3 -0
  383. package/dist/markdown/cursor/Blur.js +7 -0
  384. package/dist/markdown/cursor/Dot.d.ts +3 -0
  385. package/dist/markdown/cursor/Dot.js +16 -0
  386. package/dist/markdown/cursor/Underline.d.ts +3 -0
  387. package/dist/markdown/cursor/Underline.js +7 -0
  388. package/dist/markdown/cursor/index.less +124 -0
  389. package/dist/markdown/hooks/index.d.ts +1 -0
  390. package/dist/markdown/hooks/index.js +49 -0
  391. package/dist/markdown/hooks/useTypedEffect.d.ts +6 -0
  392. package/dist/markdown/hooks/useTypedEffect.js +56 -0
  393. package/dist/markdown/index.d.ts +16 -0
  394. package/dist/markdown/index.js +37 -0
  395. package/dist/markdown/index.less +204 -0
  396. package/dist/markdown/plugins/footnote.d.ts +2 -0
  397. package/dist/markdown/plugins/footnote.js +89 -0
  398. package/dist/markdown/plugins/katexDir.d.ts +1 -0
  399. package/dist/markdown/plugins/katexDir.js +15 -0
  400. package/dist/markdown/rehype/fadeIn.d.ts +2 -0
  401. package/dist/markdown/rehype/fadeIn.js +43 -0
  402. package/dist/markdown/type.d.ts +46 -0
  403. package/dist/markdown/type.js +1 -0
  404. package/dist/markdown/utils.d.ts +22 -0
  405. package/dist/markdown/utils.js +125 -0
  406. package/dist/provider/CustomCardsProvider.d.ts +15 -0
  407. package/dist/provider/CustomCardsProvider.js +18 -0
  408. package/dist/provider/GlobalProvider.d.ts +5 -0
  409. package/dist/provider/GlobalProvider.js +11 -0
  410. package/dist/provider/index.d.ts +8 -0
  411. package/dist/provider/index.js +20 -0
  412. package/dist/provider/types.d.ts +8 -0
  413. package/dist/provider/types.js +1 -0
  414. package/dist/sender/SenderHeader.d.ts +19 -0
  415. package/dist/sender/SenderHeader.js +79 -0
  416. package/dist/sender/StopLoading.d.ts +5 -0
  417. package/dist/sender/StopLoading.js +20 -0
  418. package/dist/sender/components/ActionButton.d.ts +22 -0
  419. package/dist/sender/components/ActionButton.js +39 -0
  420. package/dist/sender/components/ClearButton.d.ts +4 -0
  421. package/dist/sender/components/ClearButton.js +13 -0
  422. package/dist/sender/components/LoadingButton.d.ts +4 -0
  423. package/dist/sender/components/LoadingButton.js +22 -0
  424. package/dist/sender/components/SendButton.d.ts +4 -0
  425. package/dist/sender/components/SendButton.js +14 -0
  426. package/dist/sender/components/SpeechButton/RecordingIcon.d.ts +5 -0
  427. package/dist/sender/components/SpeechButton/RecordingIcon.js +49 -0
  428. package/dist/sender/components/SpeechButton/index.d.ts +4 -0
  429. package/dist/sender/components/SpeechButton/index.js +30 -0
  430. package/dist/sender/index.d.ts +61 -0
  431. package/dist/sender/index.js +307 -0
  432. package/dist/sender/style/header.d.ts +4 -0
  433. package/dist/sender/style/header.js +46 -0
  434. package/dist/sender/style/index.d.ts +10 -0
  435. package/dist/sender/style/index.js +123 -0
  436. package/dist/sender/useSpeech.d.ts +6 -0
  437. package/dist/sender/useSpeech.js +114 -0
  438. package/dist/stream/index.d.ts +34 -0
  439. package/dist/stream/index.en-US.md.bk +50 -0
  440. package/dist/stream/index.js +197 -0
  441. package/dist/stream/index.zh-CN.md.bk +51 -0
  442. package/dist/theme/components.d.ts +10 -0
  443. package/dist/theme/components.js +1 -0
  444. package/dist/theme/cssinjs-utils.d.ts +14 -0
  445. package/dist/theme/cssinjs-utils.js +1 -0
  446. package/dist/theme/genStyleUtils.d.ts +28 -0
  447. package/dist/theme/genStyleUtils.js +49 -0
  448. package/dist/theme/useToken.d.ts +18 -0
  449. package/dist/theme/useToken.js +110 -0
  450. package/dist/version/index.d.ts +2 -0
  451. package/dist/version/index.js +2 -0
  452. package/dist/voice-chat/Recorder/index.d.ts +26 -0
  453. package/dist/voice-chat/Recorder/index.js +168 -0
  454. package/dist/voice-chat/VoiceChatProvider/context.d.ts +22 -0
  455. package/dist/voice-chat/VoiceChatProvider/context.js +3 -0
  456. package/dist/voice-chat/VoiceChatProvider/hooks/useChatState.d.ts +1 -0
  457. package/dist/voice-chat/VoiceChatProvider/hooks/useChatState.js +5 -0
  458. package/dist/voice-chat/VoiceChatProvider/hooks/useMessages.d.ts +8 -0
  459. package/dist/voice-chat/VoiceChatProvider/hooks/useMessages.js +31 -0
  460. package/dist/voice-chat/VoiceChatProvider/hooks/useRecorder.d.ts +5 -0
  461. package/dist/voice-chat/VoiceChatProvider/hooks/useRecorder.js +48 -0
  462. package/dist/voice-chat/VoiceChatProvider/hooks/useVoiceChat.d.ts +4 -0
  463. package/dist/voice-chat/VoiceChatProvider/hooks/useVoiceChat.js +10 -0
  464. package/dist/voice-chat/VoiceChatProvider/index.d.ts +9 -0
  465. package/dist/voice-chat/VoiceChatProvider/index.js +55 -0
  466. package/dist/voice-chat/VoiceChatService/index.d.ts +34 -0
  467. package/dist/voice-chat/VoiceChatService/index.js +209 -0
  468. package/dist/voice-chat/index.d.ts +2 -0
  469. package/dist/voice-chat/index.js +2 -0
  470. package/dist/voice-chat/types/index.d.ts +12 -0
  471. package/dist/voice-chat/types/index.js +4 -0
  472. package/dist/welcome/icon.d.ts +2 -0
  473. package/dist/welcome/icon.js +38 -0
  474. package/dist/welcome/index.d.ts +9 -0
  475. package/dist/welcome/index.js +57 -0
  476. package/package.json +117 -0
@@ -0,0 +1,1449 @@
1
+ "use strict";(self.webpackChunk_agentscope_ai_chat=self.webpackChunk_agentscope_ai_chat||[]).push([[8480],{93006:function(e,n){n.Z=`import { ChatAnywhere, ChatAnywhereRef, uuid, Stream, TMessage, createCard, DefaultCards, Welcome } from '@ali/spark-chat';
2
+ import { UploadFile, Button } from 'antd';
3
+ import React, { useCallback, useEffect, useRef } from 'react';
4
+
5
+ export default function Demo() {
6
+ const ref = useRef<ChatAnywhereRef>();
7
+
8
+ // @ts-ignore
9
+ window.ref = ref;
10
+
11
+ const onInput = useCallback(async (data: { query: string; fileList?: UploadFile<any>[] }) => {
12
+ const query = data.query;
13
+
14
+ ref.current.updateMessage({
15
+ id: uuid(),
16
+ cards: [{
17
+ code: 'Text',
18
+ data: {
19
+ content: query
20
+ }
21
+ }],
22
+ role: 'user',
23
+ msgStatus: 'finished',
24
+ });
25
+
26
+
27
+ setTimeout(() => {
28
+ ref.current.updateMessage({
29
+ id: uuid(),
30
+ cards: [{
31
+ code: 'Text',
32
+ data: {
33
+ content: \`answer for: \${query}\`,
34
+ }
35
+ }],
36
+ role: 'assistant',
37
+ msgStatus: 'finished',
38
+ });
39
+
40
+ }, 1000);
41
+
42
+ }, []);
43
+
44
+ const onStop = useCallback(async () => {
45
+ }, []);
46
+
47
+
48
+ return <ChatAnywhere
49
+ ref={ref}
50
+ cardConfig={{
51
+ Welcome: () => <h1>\u81EA\u5B9A\u4E49\u6B22\u8FCE\u5361\u7247</h1>
52
+ }}
53
+ uiConfig={{
54
+ quickInput: <>
55
+ <Button size="small" onClick={() => {
56
+ ref.current.updateMessage({
57
+ id: uuid(),
58
+ cards: [{
59
+ code: 'Text',
60
+ data: {
61
+ content: \`some text\`,
62
+ }
63
+ }],
64
+ role: 'assistant',
65
+ msgStatus: 'finished',
66
+ });
67
+ }}>text</Button>
68
+ <Button size="small" onClick={() => {
69
+ ref.current.updateMessage({
70
+ id: uuid(),
71
+ cards: [
72
+ {
73
+ code: 'Text',
74
+ data: {
75
+ content: 'what is citypop'
76
+ },
77
+
78
+ },
79
+ {
80
+ code: 'Images',
81
+ data: [
82
+ { url: 'https://gw.alicdn.com/imgextra/i4/O1CN01sjZ4Uu1erFDOC6IkA_!!6000000003924-2-tps-396-224.png', },
83
+ ],
84
+ }
85
+ ],
86
+ role: 'user',
87
+ msgStatus: 'finished',
88
+ });
89
+ }}>text with image</Button>
90
+ <Button size="small" onClick={() => {
91
+ ref.current.updateMessage({
92
+ id: uuid(),
93
+ cards: [
94
+ {
95
+ code: 'Text',
96
+ data: {
97
+ content: 'what is citypop'
98
+ },
99
+
100
+ },
101
+ {
102
+ code: 'Files',
103
+ data: [
104
+ { filename: 'citypop.pdf', bytes: 1024 },
105
+ { filename: 'citypop.pdf', bytes: 2048 },
106
+ ],
107
+ }
108
+ ],
109
+ role: 'user',
110
+ msgStatus: 'finished',
111
+ });
112
+ }}>text with file</Button>
113
+ <Button size="small" onClick={() => {
114
+ ref.current.updateMessage({
115
+ id: uuid(),
116
+ cards: [
117
+ {
118
+ code: 'Welcome',
119
+ data: {},
120
+ },
121
+ ],
122
+ role: 'assistant',
123
+ msgStatus: 'finished',
124
+ });
125
+ }}>custom card a</Button>
126
+ <Button size="small">custom card b</Button>
127
+ </>,
128
+ disclaimer: 'AI can also make mistakes, so please check carefully and use it with caution',
129
+ narrowScreen: true,
130
+ }}
131
+ onInput={{
132
+ onSubmit: onInput,
133
+ }}
134
+ onStop={onStop}
135
+ ></ChatAnywhere>;
136
+
137
+ }`},70822:function(e,n){n.Z=`import React from 'react';
138
+ import { createStyles } from 'antd-style';
139
+ import Chat from './Chat';
140
+
141
+ const useStyles = createStyles(({ css, token }) => ({
142
+ container: css\`
143
+ display: flex;
144
+ height: 100vh;
145
+ \`,
146
+
147
+ iframe: css\`
148
+ flex: 5;
149
+ height: 100%;
150
+ border: none;
151
+ display: block;
152
+ \`,
153
+
154
+ chat: css\`
155
+ flex: 3;
156
+ height: 100%;
157
+ border-left: 1px solid \${token.colorBorderSecondary};
158
+ \`,
159
+
160
+
161
+ }));
162
+
163
+ export default function () {
164
+ const { styles } = useStyles();
165
+
166
+ return <div className={styles.container}>
167
+ <iframe className={styles.iframe} src="https://market.m.taobao.com/app/liveme-console/agentscope-portal/index.html" />
168
+ <div className={styles.chat}>
169
+ <Chat />
170
+ </div>
171
+ </div>;
172
+
173
+ }`},18135:function(e,n){n.Z=`import { ChatAnywhere, ChatAnywhereRef, uuid, Stream, TMessage, createCard, DefaultCards, Welcome, useChatAnywhere } from '@ali/spark-chat';
174
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
175
+ import { Card, Flex, Statistic, UploadFile, Input } from 'antd';
176
+ import { CopyOutlined, GlobalOutlined, PaperClipOutlined, RedoOutlined } from '@ant-design/icons';
177
+ import Header from '../Header';
178
+ import sessionLocalStorage from '../sessionLocalStorage';
179
+ import compact from 'lodash/compact'
180
+ import { Button } from '@spark-ai/design';
181
+ import ReactDOM from 'react-dom';
182
+ import { useMount } from 'ahooks';
183
+ import { useDemoContext } from '../DemoContext';
184
+
185
+ export default function () {
186
+ const ref = useRef<ChatAnywhereRef>();
187
+ const { demoContext, getDemoContext, setDemoContext } = useDemoContext();
188
+ // @ts-ignore
189
+ window.ref = ref;
190
+
191
+ const currentQA = useRef<{
192
+ query?: TMessage,
193
+ answer?: TMessage,
194
+ abortController?: AbortController;
195
+ }>({});
196
+
197
+
198
+ useMount(() => {
199
+ ref.current.updateSession(
200
+ sessionLocalStorage.get()
201
+ );
202
+ })
203
+
204
+
205
+ const onFinish = useCallback((status: 'finished' | 'interrupted' = 'finished', usage?: any) => {
206
+ currentQA.current.answer.msgStatus = status;
207
+ currentQA.current.answer.cards = currentQA.current.answer.cards.map(item => {
208
+ if (item.code === 'Text') {
209
+ return createCard('Text', {
210
+ ...item.data,
211
+ msgStatus: status,
212
+ });
213
+ } else if (item.code === 'DeepThink') {
214
+ return createCard('DeepThink', {
215
+ ...item.data,
216
+ loading: false,
217
+ });
218
+ } else {
219
+ return item;
220
+ }
221
+ });
222
+
223
+ if (status === 'interrupted') {
224
+ currentQA.current.answer.cards.push(
225
+ createCard('Interrupted', {})
226
+ );
227
+ }
228
+
229
+ currentQA.current.answer.cards.push(
230
+ createCard('Footer', {
231
+ left: <DefaultCards.FooterActions data={[
232
+ {
233
+ icon: <RedoOutlined />, label: '\u91CD\u65B0\u751F\u6210', onClick: () => {
234
+ onRegenerate(currentQA.current.answer);
235
+ }
236
+ },
237
+ ]} />,
238
+ right: usage ? <DefaultCards.FooterCount data={[['\u8F93\u5165tokens', usage.prompt_tokens], ['\u8F93\u51FAtokens', usage.completion_tokens]]} ></DefaultCards.FooterCount> : null
239
+
240
+ })
241
+ )
242
+ ref.current.setLoading(false);
243
+ ReactDOM.flushSync(() => {
244
+ ref.current.updateMessage(currentQA.current.answer);
245
+ });
246
+
247
+ saveToLocalStorage();
248
+ }, [demoContext]);
249
+
250
+ const saveToLocalStorage = useCallback(async () => {
251
+ // \u5C06\u5F53\u524D\u7684\u6D88\u606F\u5217\u8868\u540C\u6B65\u5230\u5F53\u524D session \u4E2D
252
+ ReactDOM.flushSync(() => {
253
+ ref.current.updateSessionMessages(ref.current.getMessages());
254
+ });
255
+
256
+ sessionLocalStorage.set(ref.current.getSession());
257
+ }, [demoContext]);
258
+
259
+ const chat = useCallback(async (messages: TMessage[]) => {
260
+
261
+ currentQA.current.answer = {
262
+ id: uuid(),
263
+ cards: [],
264
+ content: '',
265
+ role: 'assistant',
266
+ msgStatus: 'generating',
267
+ }
268
+
269
+ ref.current.updateMessage(currentQA.current.answer);
270
+
271
+ currentQA.current.abortController = new AbortController();
272
+
273
+ const requestMessages = messages.map(msg => {
274
+ return {
275
+ ...msg,
276
+ content: msg.content || (msg.cards || []).reduce((p, c) => { return p + (c.code === 'Text' ? c.data.content : '') }, '')
277
+ };
278
+ });
279
+
280
+
281
+ const response = await fetch('https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions', {
282
+ method: 'POST',
283
+ headers: {
284
+ 'Content-Type': 'application/json',
285
+ 'Authorization': \`Bearer sk-9c2fde3cee7d4edb8825d18f4f0fc0a9\`
286
+ },
287
+ body: JSON.stringify({
288
+ model: getDemoContext().model,
289
+ enable_thinking: getDemoContext().enable_thinking,
290
+ messages: requestMessages,
291
+ stream: true,
292
+ stream_options: {
293
+ include_usage: true,
294
+
295
+ },
296
+ }),
297
+ signal: currentQA.current.abortController.signal
298
+ });
299
+
300
+
301
+ if (response.status !== 200) {
302
+
303
+
304
+ return
305
+ }
306
+
307
+
308
+ let content = '';
309
+ let reasoning_content = '';
310
+ for await (const chunk of Stream({
311
+ readableStream: response.body,
312
+ }, {
313
+ openaiCompatible: true,
314
+ })) {
315
+
316
+ if (currentQA.current.answer.msgStatus === 'interrupted') {
317
+ debugger;
318
+ currentQA.current.abortController.abort();
319
+ break;
320
+ }
321
+
322
+ if (chunk.data === '[DONE]') {
323
+ onFinish('finished')
324
+ break;
325
+ }
326
+
327
+ const data = JSON.parse(chunk.data);
328
+ if (data.usage) {
329
+ onFinish('finished', data.usage);
330
+ break;
331
+ }
332
+
333
+ content += data.choices[0]?.delta.content || '';
334
+ reasoning_content += data.choices[0]?.delta.reasoning_content || '';
335
+
336
+ currentQA.current.answer.cards = compact([
337
+ reasoning_content && createCard('DeepThink', {
338
+ content: reasoning_content,
339
+ loading: !content,
340
+ }),
341
+ content && createCard('Text', {
342
+ content: content,
343
+ typing: true,
344
+ msgStatus: 'generating'
345
+ })
346
+ ])
347
+
348
+
349
+ ref.current.updateMessage(currentQA.current.answer);
350
+ }
351
+ }, [demoContext]);
352
+
353
+ const onInput = useCallback(async (data: { query: string; fileList?: UploadFile[][] }) => {
354
+ if (!getDemoContext().apikey) {
355
+ document.dispatchEvent(new CustomEvent('settingOpen'));
356
+ return;
357
+ }
358
+
359
+ clearFooter();
360
+ currentQA.current.answer = undefined;
361
+ currentQA.current.query = {
362
+ id: uuid(),
363
+ cards: [],
364
+ content: data.query,
365
+ role: 'user',
366
+ msgStatus: 'finished',
367
+ };
368
+
369
+ if (data.fileList?.length) {
370
+ const images = [];
371
+ const files = [];
372
+ // @ts-ignore
373
+ const allFileList = data.fileList.reduce((p, c) => [...p, ...c], [])
374
+ allFileList.forEach(file => {
375
+ if (file.type.startsWith('image')) {
376
+ images.push(file)
377
+ } else {
378
+ files.push(file)
379
+ }
380
+ })
381
+
382
+ if (images.length) {
383
+ currentQA.current.query.cards.push(createCard('Images', images.map(item => {
384
+ return item.response
385
+ })))
386
+ }
387
+
388
+ if (files.length) {
389
+ currentQA.current.query.cards.push(
390
+ createCard('Files', files.map(item => {
391
+ return {
392
+ filename: item.name,
393
+ bytes: item.size
394
+ }
395
+ }))
396
+ )
397
+ }
398
+ }
399
+
400
+ ref.current.setLoading(true);
401
+
402
+
403
+ ReactDOM.flushSync(() => {
404
+ ref.current.updateMessage(currentQA.current.query);
405
+ });
406
+
407
+ ref.current.scrollToBottom();
408
+ chat(ref.current.getMessages());
409
+ }, [demoContext]);
410
+
411
+ const onStop = useCallback(() => {
412
+ onFinish('interrupted');
413
+ }, [demoContext]);
414
+
415
+ const clearFooter = useCallback(() => {
416
+ try {
417
+ currentQA.current.answer.cards = currentQA.current.answer.cards.filter(item => item.code !== 'Footer');
418
+ ref.current.updateMessage(currentQA.current.answer);
419
+ } catch (error) {
420
+ }
421
+ }, [demoContext]);
422
+
423
+ const onRegenerate = useCallback((msg: Partial<TMessage>) => {
424
+ ReactDOM.flushSync(() => {
425
+ ref.current.removeMessage(msg);
426
+ });
427
+ const messages = ref.current.getMessages();
428
+ chat(messages);
429
+ }, [demoContext]);
430
+
431
+ const enable_thinking = demoContext.enable_thinking;
432
+
433
+ return <div style={{ height: '100vh' }}>
434
+ <ChatAnywhere
435
+ cardConfig={{ MyCard }}
436
+ uiConfig={{
437
+ welcome: <Welcome
438
+ style={{ marginTop: '35vh' }}
439
+ title="Nice to meet you!"
440
+ desc={"How can I help you today?"}
441
+ />,
442
+ disclaimer: 'AI can also make mistakes, so please check and use it carefully',
443
+ header: <Header />,
444
+ logo: <div style={{ fontFamily: 'Montserrat', fontWeight: 'bold' }}>Spark Chat</div>,
445
+ quickInput: <>
446
+ <Button size="small" onClick={() => {
447
+ ReactDOM.flushSync(() => {
448
+ ref.current.updateMessage({
449
+ id: uuid(),
450
+ cards: [
451
+ {
452
+ code: 'MyCard',
453
+ data: [
454
+ ['MyCard', 10000]
455
+ ],
456
+ },
457
+ ],
458
+ role: 'assistant',
459
+ msgStatus: 'finished',
460
+ })
461
+
462
+ })
463
+ ref.current.scrollToBottom();
464
+ }}>quickInput</Button>
465
+ <Button size="small">test case A</Button>
466
+ <Button size="small">test case B</Button>
467
+ </>
468
+ }}
469
+ ref={ref}
470
+ onInput={{
471
+ morePrefixActions: <>
472
+ {
473
+ enable_thinking !== undefined ?
474
+ <Button type="text" color={enable_thinking ? 'primary' : 'default'} variant={enable_thinking ? 'filled' : 'text'} icon={<GlobalOutlined />} style={{ padding: '0 6px', gap: 6 }} onClick={() => setDemoContext({ enable_thinking: !enable_thinking })}>DeepThink</Button>
475
+ : null
476
+ }
477
+ </>,
478
+ onSubmit: onInput,
479
+ maxLength: 100000,
480
+ beforeSubmit: () => Promise.resolve(true),
481
+ zoomable: true,
482
+ }}
483
+ onStop={onStop}
484
+ onRegenerate={onRegenerate}
485
+ onSessionKeyChange={(currentSessionKey) => {
486
+ currentQA.current.answer = undefined;
487
+ currentQA.current.query = undefined;
488
+ sessionLocalStorage.set({ currentSessionKey });
489
+ }}
490
+ onUpload={[{
491
+ multiple: false,
492
+ icon: <PaperClipOutlined />,
493
+ customRequest(options) {
494
+ options.onSuccess({
495
+ url: URL.createObjectURL(options.file as Blob)
496
+ });
497
+ }
498
+ }, {
499
+ multiple: false,
500
+ icon: <CopyOutlined />,
501
+ customRequest(options) {
502
+ options.onError(new Error('\u4E0A\u4F20\u5931\u8D25'));
503
+ }
504
+ }]}
505
+ ></ChatAnywhere>
506
+ </div>
507
+ }
508
+
509
+
510
+ function MyCard(props) {
511
+ const onInput = useChatAnywhere(v => v.onInput);
512
+
513
+ const [v, sv] = useState('');
514
+ return <Card title="my card" size="small">
515
+ <Flex gap={32}>
516
+ {props.data.map((item) => {
517
+ return <Statistic title={item[0]} value={item[1]} key={item[0]} />
518
+ })}
519
+ </Flex>
520
+ <br />
521
+ <Flex gap={8}>
522
+ <Input placeholder="\u8BF7\u8F93\u5165" onChange={e => sv(e.target.value)} /> <Button onClick={() => {
523
+ onInput.onSubmit({ query: v });
524
+ }}>\u63D0\u4EA4</Button>
525
+ </Flex>
526
+ </Card>;
527
+ }`},97763:function(e,n){n.Z=`import { useSetState } from 'ahooks';
528
+ import { SetState } from 'ahooks/lib/useSetState';
529
+ import React, { useState } from 'react';
530
+ import { useGetState } from 'ahooks';
531
+
532
+ type TContext = {
533
+ model: string
534
+ apikey: string
535
+ theme: 'purple' | 'carbon' | string
536
+ enable_thinking?: boolean;
537
+ }
538
+
539
+ export const DemoContext = React.createContext<{
540
+ demoContext: TContext,
541
+ setDemoContext: SetState<TContext>,
542
+ getDemoContext: () => TContext
543
+ }>(undefined);
544
+
545
+ export const DemoContextProvider = function (props: { children: React.ReactNode }) {
546
+ const [demoContext, setDemoContext, getDemoContext] = useGetState<TContext>({
547
+ model: 'qwq-plus',
548
+ apikey: localStorage.getItem('apikey') || '',
549
+ theme: localStorage.getItem('theme') || 'carbon',
550
+ enable_thinking: undefined,
551
+ });
552
+
553
+
554
+ return <DemoContext.Provider value={{
555
+ demoContext, getDemoContext, setDemoContext: data => {
556
+ return setDemoContext((state) => {
557
+ const nextState = {
558
+ ...state,
559
+ ...data,
560
+ }
561
+
562
+ if (nextState.model === 'qwen3-32b' && nextState.enable_thinking === undefined) {
563
+ nextState.enable_thinking = true
564
+ }
565
+
566
+ if (nextState.model !== 'qwen3-32b') {
567
+ nextState.enable_thinking = undefined;
568
+ }
569
+
570
+ localStorage.setItem('apikey', nextState.apikey);
571
+ localStorage.setItem('theme', nextState.theme);
572
+ return nextState
573
+ });
574
+ }
575
+ }}>
576
+ {props.children}
577
+ </DemoContext.Provider>
578
+ };
579
+
580
+
581
+ export const useDemoContext = function () {
582
+ return React.useContext(DemoContext);
583
+ };
584
+
585
+
586
+ `},60097:function(e,n){n.Z=`import React from "react";
587
+ // @ts-ignore
588
+ import styles from './index.module.less';
589
+ import { Dropdown, MenuProps, Space, Typography, Button } from 'antd';
590
+ import { DownOutlined } from "@ant-design/icons";
591
+ import { useDemoContext } from '../DemoContext';
592
+
593
+ const items = [
594
+ {
595
+ key: 'qwen-turbo',
596
+ label: <Model name="Qwen-Turbo" />
597
+ },
598
+ {
599
+ key: 'qwen-max',
600
+ label: <Model name="Qwen-Max" />
601
+ },
602
+ {
603
+ key: 'qwq-plus',
604
+ label: <Model name="Qwen-QwQ-Plus" />
605
+ },
606
+ {
607
+ key: 'qwen3-32b',
608
+ label: <Model name="Qwen3-32B" />
609
+ },
610
+ ];
611
+
612
+ function Model(props: {
613
+ name?: string;
614
+ size?: number;
615
+ arrow?: boolean
616
+ }) {
617
+ const { name = '', size = 12, arrow = false } = props;
618
+ return <div className={styles.model}>
619
+ <img src="https://img.alicdn.com/imgextra/i4/O1CN01SdyYTH1Kfz6skC36o_!!6000000001192-2-tps-96-96.png" className={styles.modelLogo} />
620
+ <div className={styles.modelName} style={{ fontSize: size }} >{name}</div>
621
+ {
622
+ arrow && <DownOutlined />
623
+ }
624
+ </div>
625
+ }
626
+
627
+ export default function () {
628
+ const { demoContext, setDemoContext } = useDemoContext();
629
+
630
+ const current = items.find(item => item.key === demoContext.model);
631
+
632
+ return <Dropdown
633
+ menu={{
634
+ items,
635
+ selectable: true,
636
+ onSelect: ({ key }) => {
637
+ setDemoContext({
638
+ model: key,
639
+ });
640
+ }
641
+ }}
642
+ >
643
+ <Button type="text" style={{ padding: '0 6px' }}>
644
+ {current?.label ? React.cloneElement(current.label, { size: 16, arrow: true }) : null}
645
+ </Button>
646
+ </Dropdown>
647
+ }`},73381:function(e,n){n.Z=`import React, { useEffect, useState } from "react";
648
+ import { Drawer, Button, Form, Input } from '@spark-ai/design';
649
+ import { SettingOutlined } from "@ant-design/icons";
650
+ import { ColorPicker, Flex, Radio, Switch, theme } from "antd";
651
+ import { useDemoContext } from "../DemoContext";
652
+ import { usePrefersColor } from "dumi";
653
+
654
+
655
+ export default function () {
656
+ const [form] = Form.useForm();
657
+ const [open, setOpen] = useState(false);
658
+ const { getDemoContext, setDemoContext } = useDemoContext();
659
+ const [
660
+ color,
661
+ prefersColor,
662
+ setPrefersColor,
663
+ ] = usePrefersColor();
664
+
665
+ useEffect(() => {
666
+ const settingOpen = () => setOpen(true);
667
+ document.addEventListener('settingOpen', settingOpen);
668
+ return () => {
669
+ document.removeEventListener('settingOpen', settingOpen);
670
+ }
671
+ }, [])
672
+
673
+
674
+
675
+ return <>
676
+ <Button type="text" icon={<SettingOutlined />} onClick={() => setOpen(true)}>
677
+ </Button>
678
+
679
+ <Drawer title="Setting"
680
+
681
+ afterOpenChange={() => {
682
+ form.setFieldsValue({
683
+ apikey: getDemoContext().apikey,
684
+ theme: getDemoContext().theme,
685
+ darkMode: color === 'dark',
686
+ })
687
+ }}
688
+
689
+ onClose={() => setOpen(false)} open={open} footer={<Button type="primary" onClick={async () => {
690
+ const values = await form.validateFields();
691
+ setPrefersColor(!!values.darkMode ? 'dark' : 'light');
692
+ setDemoContext({
693
+ apikey: values.apikey,
694
+ theme: values.theme,
695
+ })
696
+ setOpen(false);
697
+ }}>Save</Button>}>
698
+ <Form
699
+ form={form}
700
+ >
701
+ <Form.Item name="apikey" label="API Key" rules={[{ required: true }]}>
702
+ <Input />
703
+ </Form.Item>
704
+
705
+
706
+ <Form.Item name="theme" label="Theme" rules={[{ required: true }]}>
707
+ {/* @ts-ignore */}
708
+ <ThemeInput />
709
+ </Form.Item>
710
+
711
+
712
+ <Form.Item name="darkMode" label="Dark Mode" rules={[{ required: true }]}>
713
+ <Switch />
714
+ </Form.Item>
715
+ </Form>
716
+ </Drawer>
717
+ </>
718
+ }
719
+
720
+
721
+ function ThemeInput({ value, onChange }) {
722
+ return <Flex gap={8} align="center">
723
+ <Radio.Group options={[
724
+ { label: 'Carbon', value: 'carbon' },
725
+ { label: 'Purple', value: 'purple' },
726
+ ]} value={value} onChange={e => onChange(e.target.value)} />
727
+ <ColorPicker value={value} onChange={e => {
728
+ return onChange(e.toCssString());
729
+ }} /></Flex>
730
+ }`},36416:function(e,n){n.Z=`@import '../../../../index.less';
731
+
732
+ .header {
733
+ height: 100%;
734
+ display: flex;
735
+ align-items: center;
736
+ justify-content: space-between;
737
+ padding: 0 12px 0 12px;
738
+ width: 100%;
739
+ }
740
+
741
+ .model {
742
+ height: 20px;
743
+ display: flex;
744
+ align-items: center;
745
+ gap: 8px;
746
+
747
+ :global {
748
+ .anticon-down {
749
+ transform: scaleY(0.75);
750
+ }
751
+ }
752
+
753
+ .modelLogo {
754
+ width: 20px;
755
+ height: 20px;
756
+ background-color: e('var(--@{ant-prefix}-color-bg-base)');
757
+ border-radius: 6px;
758
+ }
759
+
760
+ .modelName {
761
+ font-weight: 500;
762
+ line-height: 20px;
763
+ color: e('var(--@{ant-prefix}-color-text)');
764
+ }
765
+ }
766
+ `},97626:function(e,n){n.Z=`import React from "react";
767
+ // @ts-ignore
768
+ import styles from './index.module.less';
769
+ import ModelSelect from "./ModelSelect";
770
+ import Setting from "./Setting";
771
+
772
+ export default function () {
773
+ return <div className={styles.header}>
774
+ <ModelSelect />
775
+ <div style={{ flex: 1 }} />
776
+ <Setting />
777
+ </div>
778
+ }`},90013:function(e,n){n.Z=`import React from 'react';
779
+ import { DemoContextProvider } from './DemoContext';
780
+ import Chat from './Chat';
781
+ import './index.less';
782
+
783
+ export default function () {
784
+ return <div style={{ height: '100vh' }} className='chat-anywhere-demo'>
785
+ <DemoContextProvider>
786
+ <Chat />
787
+ </DemoContextProvider>
788
+ </div>
789
+ }
790
+
791
+ `},4752:function(e,n){n.Z=`.chat-anywhere-demo {
792
+ .spc-chat-anywhere-chat-welcome {
793
+ height: auto;
794
+ }
795
+ }`},80142:function(e,n){n.Z=`const sessionLocalStorage = {
796
+ get() {
797
+ const localStorageDataString = localStorage.getItem(
798
+ 'chat-anywhere-session',
799
+ );
800
+
801
+ if (localStorageDataString) {
802
+ return JSON.parse(localStorageDataString);
803
+ } else {
804
+ return {
805
+ sessionList: [
806
+ {
807
+ label: Date.now().toString(),
808
+ key: '9ed1150f-6046-4917-a124-6e85ba1ea933',
809
+ messages: [[]],
810
+ },
811
+ ],
812
+ currentSessionKey: '9ed1150f-6046-4917-a124-6e85ba1ea933',
813
+ currentRegenerateIndex: 0,
814
+ };
815
+ }
816
+ },
817
+ set(data) {
818
+ const beforeData = sessionLocalStorage.get() || {};
819
+
820
+ localStorage.setItem(
821
+ 'chat-anywhere-session',
822
+ JSON.stringify({
823
+ ...beforeData,
824
+ ...data,
825
+ }),
826
+ );
827
+ },
828
+ };
829
+
830
+ export default sessionLocalStorage;
831
+ `},97318:function(e,n){n.Z=`import React, { useCallback } from 'react';
832
+ import { useCopilotChat } from "@copilotkit/react-core";
833
+ import { Sender, Bubble, CustomCardsProvider } from '@ali/spark-chat';
834
+ import { TMessage } from '@ali/spark-chat';
835
+ import { CodeBlock } from '@spark-ai/design';
836
+ import Input from './Input';
837
+
838
+ export default function Chat() {
839
+ const context = useCopilotChat();
840
+
841
+ const messages = context.visibleMessages.map((message) => {
842
+
843
+ if (message.type === 'TextMessage' && message.role === "user") {
844
+ return {
845
+ role: 'user',
846
+ content: message.content,
847
+ id: message.id,
848
+ }
849
+ }
850
+
851
+ if (message.type === 'TextMessage' && message.role === "assistant") {
852
+ return {
853
+ role: 'assistant',
854
+ typing: true,
855
+ msgStatus: message.status.code === 'Pending' ? 'generating' : void 0,
856
+ content: message.content,
857
+ id: message.id,
858
+ }
859
+ }
860
+
861
+ return {
862
+ role: 'assistant',
863
+ cards: [{
864
+ code: 'Code',
865
+ data: message,
866
+ }],
867
+ id: message.id,
868
+ }
869
+
870
+ }).filter(i => !!i);
871
+
872
+
873
+
874
+ return (
875
+ <>
876
+ <CustomCardsProvider cardConfig={{ Code }}>
877
+ <Bubble.List
878
+ style={{ height: 0, flex: 1, }}
879
+ items={messages as TMessage[]}
880
+ />
881
+ </CustomCardsProvider>
882
+ <Input />
883
+ </>
884
+ );
885
+ }
886
+
887
+
888
+ function Code(props) {
889
+ return <div style={{ width: '80%', border: '1px solid #ccc' }}>
890
+ <CodeBlock language="json" value={JSON.stringify(props.data)} />
891
+ </div>
892
+ }`},58658:function(e,n){n.Z=`import React from 'react';
893
+ import { Sender, Bubble, CustomCardsProvider, TMessage } from '@ali/spark-chat';
894
+ import { useCopilotChat } from "@copilotkit/react-core";
895
+ import { Role, TextMessage } from '@copilotkit/runtime-client-gql';
896
+
897
+
898
+ export default function () {
899
+ const [content, setContent] = React.useState('');
900
+ const context = useCopilotChat();
901
+
902
+ return <div>
903
+ <Sender
904
+ value={content}
905
+ loading={context.isLoading}
906
+ onChange={setContent}
907
+ onSubmit={async () => {
908
+ context.appendMessage(new TextMessage({
909
+ content: content,
910
+ role: Role.User,
911
+ }))
912
+ setContent('');
913
+ }} />
914
+ </div>
915
+ }`},71235:function(e,n){n.Z=`import { Button, Checkbox } from "antd";
916
+ import { useTasks } from "./hook";
917
+ import { TaskStatus, type Task } from "./hook";
918
+ import React from 'react';
919
+ import { DeleteOutlined } from "@ant-design/icons";
920
+
921
+ export function Task({ task: { id, title, status } }: { task: Task }) {
922
+ const { setTaskStatus, deleteTask } = useTasks();
923
+
924
+ return (
925
+ <div
926
+ style={{
927
+ display: "flex",
928
+ alignItems: "center",
929
+ justifyContent: "space-between",
930
+ flex: 1
931
+ }}
932
+ >
933
+ <Checkbox checked={status === TaskStatus.done} onChange={() => {
934
+ setTaskStatus(id, status === TaskStatus.done ? TaskStatus.todo : TaskStatus.done)
935
+ }}>
936
+ <label
937
+ >
938
+ {title}
939
+ </label>
940
+ </Checkbox>
941
+ <Button onClick={() => deleteTask(id)} icon={<DeleteOutlined />}>
942
+ </Button>
943
+ </div>
944
+ );
945
+ }
946
+ `},36323:function(e,n){n.Z=`import React from 'react';
947
+ import { Task } from "./Task";
948
+ import { useTasks } from "./hook";
949
+ import { List } from 'antd';
950
+
951
+ export function TasksList() {
952
+ const { tasks } = useTasks();
953
+ return <List
954
+ style={{ margin: 16 }}
955
+ rowKey="id"
956
+ header={<div>AI TODO MVC</div>}
957
+ bordered
958
+ dataSource={tasks}
959
+ renderItem={(item) => {
960
+ return (
961
+ <List.Item>
962
+ <Task task={item} />
963
+ </List.Item>
964
+ )
965
+ }}
966
+ />
967
+
968
+ }
969
+ `},60793:function(e,n){n.Z=`import { useCopilotAction, useCopilotReadable } from "@copilotkit/react-core";
970
+ import { createContext, useContext, useState, ReactNode } from "react";
971
+ import React from 'react';
972
+
973
+ export type Task = {
974
+ id: number;
975
+ title: string;
976
+ status: TaskStatus;
977
+ };
978
+
979
+ export enum TaskStatus {
980
+ todo = "todo",
981
+ done = "done",
982
+ }
983
+
984
+
985
+ const defaultTasks: Task[] = [
986
+ {
987
+ id: 1,
988
+ title: "Complete project proposal",
989
+ status: TaskStatus.done,
990
+ },
991
+ {
992
+ id: 2,
993
+ title: "Review design mockups",
994
+ status: TaskStatus.done,
995
+ },
996
+ {
997
+ id: 3,
998
+ title: "Prepare presentation slides",
999
+ status: TaskStatus.todo,
1000
+ },
1001
+ {
1002
+ id: 4,
1003
+ title: "Send meeting notes email",
1004
+ status: TaskStatus.todo,
1005
+ },
1006
+ {
1007
+ id: 5,
1008
+ title: "Review Uli's pull request",
1009
+ status: TaskStatus.todo,
1010
+ },
1011
+ ];
1012
+
1013
+ let nextId = defaultTasks.length + 1;
1014
+
1015
+ type TasksContextType = {
1016
+ tasks: Task[];
1017
+ addTask: (title: string) => void;
1018
+ setTaskStatus: (id: number, status: TaskStatus) => void;
1019
+ deleteTask: (id: number) => void;
1020
+ };
1021
+
1022
+ const TasksContext = createContext<TasksContextType | undefined>(undefined);
1023
+
1024
+ export const TasksProvider = ({ children }: { children: ReactNode }) => {
1025
+ const [tasks, setTasks] = useState<Task[]>(defaultTasks);
1026
+
1027
+ useCopilotReadable({
1028
+ description: "The state of the todo list",
1029
+ value: JSON.stringify(tasks),
1030
+ });
1031
+
1032
+ useCopilotAction({
1033
+ name: "addTask",
1034
+ description: "Adds a task to the todo list",
1035
+ parameters: [
1036
+ {
1037
+ name: "title",
1038
+ type: "string",
1039
+ description: "The title of the task",
1040
+ required: true,
1041
+ },
1042
+ ],
1043
+ handler: ({ title }) => {
1044
+ addTask(title);
1045
+ }
1046
+ });
1047
+
1048
+ useCopilotAction({
1049
+ name: "deleteTask",
1050
+ description: "Deletes a task from the todo list",
1051
+ parameters: [
1052
+ {
1053
+ name: "id",
1054
+ type: "number",
1055
+ description: "The id of the task",
1056
+ required: true,
1057
+ },
1058
+ ],
1059
+ handler: ({ id }) => {
1060
+ deleteTask(id);
1061
+ }
1062
+ });
1063
+
1064
+ useCopilotAction({
1065
+ name: "setTaskStatus",
1066
+ description: "Sets the status of a task",
1067
+ parameters: [
1068
+ {
1069
+ name: "id",
1070
+ type: "number",
1071
+ description: "The id of the task",
1072
+ required: true,
1073
+ },
1074
+ {
1075
+ name: "status",
1076
+ type: "string",
1077
+ description: "The status of the task",
1078
+ enum: Object.values(TaskStatus),
1079
+ required: true,
1080
+ },
1081
+ ],
1082
+ handler: ({ id, status }) => {
1083
+ setTaskStatus(id, status);
1084
+ }
1085
+ });
1086
+
1087
+ const addTask = (title: string) => {
1088
+ setTasks([...tasks, { id: nextId++, title, status: TaskStatus.todo }]);
1089
+ };
1090
+
1091
+ const setTaskStatus = (id: number, status: TaskStatus) => {
1092
+ setTasks(
1093
+ tasks.map((task) =>
1094
+ task.id === id ? { ...task, status } : task
1095
+ )
1096
+ );
1097
+ };
1098
+
1099
+ const deleteTask = (id: number) => {
1100
+ setTasks(tasks.filter((task) => task.id !== id));
1101
+ };
1102
+
1103
+ return (
1104
+ <TasksContext.Provider value={{ tasks, addTask, setTaskStatus, deleteTask }}>
1105
+ {children}
1106
+ </TasksContext.Provider>
1107
+ );
1108
+ };
1109
+
1110
+ export const useTasks = () => {
1111
+ const context = useContext(TasksContext);
1112
+ if (context === undefined) {
1113
+ throw new Error("useTasks must be used within a TasksProvider");
1114
+ }
1115
+ return context;
1116
+ };
1117
+ `},30513:function(e,n){n.Z=`import React from 'react';
1118
+ import { TasksList } from './TasksList';
1119
+ import { TasksProvider } from './hook';
1120
+ import { CopilotKit } from "@copilotkit/react-core";
1121
+ import { createStyles } from 'antd-style';
1122
+ import Chat from './Chat';
1123
+
1124
+ const useStyles = createStyles(({ css, token }) => ({
1125
+ container: css\`
1126
+ display: flex;
1127
+ height: 100%;
1128
+ \`,
1129
+
1130
+ left: css\`
1131
+ flex: 1;
1132
+ \`,
1133
+ right: css\`
1134
+ flex: 1;
1135
+ display: flex;
1136
+ flex-direction: column;
1137
+ border-left: 1px solid \${token.colorBorderSecondary};
1138
+ \`
1139
+ }));
1140
+
1141
+
1142
+ export default function () {
1143
+ const { styles } = useStyles();
1144
+
1145
+ return <CopilotKit runtimeUrl="https://func-jfa-zedphfubal.cn-hangzhou.fcapp.run/ag-ui"><div className={styles.container}>
1146
+
1147
+ <div className={styles.left}>
1148
+ <TasksProvider>
1149
+ <TasksList />
1150
+ </TasksProvider>
1151
+ </div>
1152
+
1153
+ <div className={styles.right}>
1154
+ <Chat />
1155
+ </div>
1156
+ </div>
1157
+ </CopilotKit>
1158
+
1159
+ }`},57373:function(e,n){n.Z=`import React, { useCallback } from 'react';
1160
+ import { Bubble, TMessage, SparkChatProvider } from '@ali/spark-chat'
1161
+ import { Card, Carousel, Flex, Statistic } from 'antd';
1162
+
1163
+ const contentStyle: React.CSSProperties = {
1164
+ margin: 0,
1165
+ height: '160px',
1166
+ color: '#fff',
1167
+ lineHeight: '160px',
1168
+ textAlign: 'center',
1169
+ background: '#364d79',
1170
+ };
1171
+
1172
+ function MyCard(props) {
1173
+ return <Card title="my card" size="small">
1174
+ <Flex gap={32}>
1175
+ {props.data.map((item) => {
1176
+ return <Statistic title={item[0]} value={item[1]} />
1177
+ })}
1178
+ </Flex>
1179
+ </Card>;
1180
+ }
1181
+
1182
+ export default function Custom() {
1183
+ const getRoles = useCallback((bubble: any) => {
1184
+ const message = bubble as TMessage;
1185
+ const roleConfig: any = {};
1186
+ if (message.role === 'assistant') {
1187
+ roleConfig.placement = 'start';
1188
+ }
1189
+
1190
+ if (message.role === 'user') roleConfig.placement = 'end';
1191
+ return roleConfig;
1192
+ }, []);
1193
+
1194
+ const messages = [
1195
+ {
1196
+ role: 'user',
1197
+ content: '\u4F60\u662F\u8C01',
1198
+ id: '1',
1199
+ },
1200
+ {
1201
+ role: 'assistant',
1202
+ content: '\u6211\u662F\u901A\u4E49\u5343\u95EE\uFF0C\u963F\u91CC\u5DF4\u5DF4\u96C6\u56E2\u65D7\u4E0B\u7684\u8D85\u5927\u89C4\u6A21\u8BED\u8A00\u6A21\u578B\u3002\u6211\u7684\u4E2D\u6587\u540D\u662F\u901A\u4E49\u5343\u95EE\uFF0C\u82F1\u6587\u540D\u662FQwen\u3002\u6211\u80FD\u591F\u5E2E\u52A9\u60A8\u56DE\u7B54\u95EE\u9898\u3001\u64B0\u5199\u6587\u7AE0\u3001\u7F16\u5199\u4EE3\u7801\u3001\u8FDB\u884C\u903B\u8F91\u63A8\u7406\u3001\u8868\u8FBE\u89C2\u70B9\u3001\u73A9\u6E38\u620F\u7B49\u3002\u5982\u679C\u60A8\u6709\u4EFB\u4F55\u95EE\u9898\u6216\u9700\u8981\u5E2E\u52A9\uFF0C\u6B22\u8FCE\u968F\u65F6\u544A\u8BC9\u6211\uFF01',
1203
+ id: '2',
1204
+ },
1205
+ {
1206
+ role: 'user',
1207
+ content: 'what is citypop',
1208
+ id: '3',
1209
+ },
1210
+ {
1211
+ role: 'assistant',
1212
+ content: \`city pop, short for city pop, is a genre of music that originated in japan during the late 1970s and early 1980s. it blends elements of jazz, folk, easy listening, and aor (adult oriented rock) with a distinctly urban feel. the term "city pop" often evokes images of the sophisticated, stylish, and sometimes nostalgic lifestyle of tokyo and other major japanese cities during this period.
1213
+ city pop is characterized by its smooth melodies, mellow rhythms, and often dreamy or introspective lyrics. common themes include city life, summer vibes, nature, and romantic encounters. the music is frequently associated with a particular aesthetic that reflects the fashion, design, and cultural trends of urban japan in the 1980s.
1214
+ some notable city pop artists include mariya takeuchi, known for her iconic song " plastic love," and joe hisaishi, a composer famous for his work on studio ghibli films, though he is not strictly considered a city pop artist.
1215
+ today, city pop has experienced a resurgence in popularity, particularly among younger generations who appreciate its unique sound and the nostalgic value it holds.\`,
1216
+ id: '4',
1217
+ },
1218
+ {
1219
+ role: 'user',
1220
+ content: '\u4F60\u662F\u8C01',
1221
+ id: '5',
1222
+ },
1223
+ {
1224
+ role: 'assistant',
1225
+ content: '\u6211\u662F\u901A\u4E49\u5343\u95EE\uFF08Qwen\uFF09\uFF0C\u963F\u91CC\u5DF4\u5DF4\u96C6\u56E2\u65D7\u4E0B\u7684\u8D85\u5927\u89C4\u6A21\u8BED\u8A00\u6A21\u578B\u3002\u6211\u7684\u4E2D\u6587\u540D\u662F\u901A\u4E49\u5343\u95EE\uFF0C\u82F1\u6587\u540D\u662FQwen\u3002\u6211\u80FD\u591F\u5E2E\u52A9\u60A8\u56DE\u7B54\u95EE\u9898\u3001\u64B0\u5199\u6587\u7AE0\u3001\u7F16\u5199\u4EE3\u7801\u3001\u8FDB\u884C\u903B\u8F91\u63A8\u7406\u3001\u8868\u8FBE\u89C2\u70B9\u3001\u73A9\u6E38\u620F\u7B49\u3002\u5982\u679C\u60A8\u6709\u4EFB\u4F55\u95EE\u9898\u6216\u9700\u8981\u5E2E\u52A9\uFF0C\u6B22\u8FCE\u968F\u65F6\u544A\u8BC9\u6211\uFF01',
1226
+ id: '6',
1227
+ },
1228
+ {
1229
+ role: 'user',
1230
+ cards: [
1231
+ {
1232
+ code: 'Text',
1233
+ data: {
1234
+ content: 'what is citypop'
1235
+ },
1236
+ }
1237
+ ],
1238
+ id: '7',
1239
+ },
1240
+ {
1241
+ role: 'assistant',
1242
+ cards: [
1243
+ {
1244
+ code: 'Text',
1245
+ data: {
1246
+ content: \`city pop, short for city pop, is a genre of music that originated in japan during the late 1970s and early 1980s. it blends elements of jazz, folk, easy listening, and aor (adult oriented rock) with a distinctly urban feel. the term "city pop" often evokes images of the sophisticated, stylish, and sometimes nostalgic lifestyle of tokyo and other major japanese cities during this period.
1247
+ city pop is characterized by its smooth melodies, mellow rhythms, and often dreamy or introspective lyrics. common themes include city life, summer vibes, nature, and romantic encounters. the music is frequently associated with a particular aesthetic that reflects the fashion, design, and cultural trends of urban japan in the 1980s.
1248
+ some notable city pop artists include mariya takeuchi, known for her iconic song " plastic love," and joe hisaishi, a composer famous for his work on studio ghibli films, though he is not strictly considered a city pop artist.
1249
+ today, city pop has experienced a resurgence in popularity, particularly among younger generations who appreciate its unique sound and the nostalgic value it holds.\`,
1250
+ }
1251
+ },
1252
+ {
1253
+ code: 'MyCard',
1254
+ data: [['Active Users', 112893], ['Account Balance (CNY)', 112893]],
1255
+ },
1256
+ {
1257
+ code: 'Foo',
1258
+ component: () => <Card size="small" title="card with inline component">
1259
+ <Carousel >
1260
+ <div>
1261
+ <h3 style={contentStyle}>1</h3>
1262
+ </div>
1263
+ <div>
1264
+ <h3 style={contentStyle}>2</h3>
1265
+ </div>
1266
+ <div>
1267
+ <h3 style={contentStyle}>3</h3>
1268
+ </div>
1269
+ <div>
1270
+ <h3 style={contentStyle}>4</h3>
1271
+ </div>
1272
+ </Carousel>
1273
+ </Card>
1274
+ },
1275
+ {
1276
+ code: 'Bar',
1277
+ component: <h1>Bar</h1>
1278
+ }
1279
+ ],
1280
+ id: '8',
1281
+ },
1282
+ ]
1283
+
1284
+
1285
+ return (
1286
+ <SparkChatProvider
1287
+ cardConfig={{ MyCard }}>
1288
+ <Bubble.List
1289
+ style={{ height: 400 }}
1290
+ roles={getRoles}
1291
+ items={messages}
1292
+ />
1293
+ </SparkChatProvider>
1294
+ );
1295
+ }
1296
+
1297
+ `},63399:function(e,n){n.Z=`import { Bubble } from '@ali/spark-chat';
1298
+ import React from 'react';
1299
+
1300
+ export default function () {
1301
+ return <Bubble
1302
+
1303
+ cards={[
1304
+
1305
+ {
1306
+ code: 'Files',
1307
+ data: [
1308
+ { filename: 'citypop.pdf', bytes: 1024 },
1309
+ { filename: 'citypop.pdf', bytes: 2048 },
1310
+ ],
1311
+ },
1312
+ ]} />
1313
+ }`},53679:function(e,n){n.Z=`import { Bubble, DefaultCards } from '@ali/spark-chat';
1314
+ import { CopyOutlined, DislikeOutlined, LikeOutlined, RedoOutlined } from '@ant-design/icons';
1315
+ import React from 'react';
1316
+
1317
+ export default function () {
1318
+ return <Bubble
1319
+
1320
+ cards={[
1321
+
1322
+ {
1323
+ code: 'Footer',
1324
+ data: {
1325
+ left: <DefaultCards.FooterActions data={[
1326
+
1327
+ {
1328
+ icon: <CopyOutlined />, onClick: () => {
1329
+ }
1330
+ },
1331
+ {
1332
+ icon: <LikeOutlined />, onClick: () => {
1333
+ }
1334
+ },
1335
+ {
1336
+ icon: <DislikeOutlined />, onClick: () => {
1337
+ }
1338
+ },
1339
+
1340
+ {
1341
+ icon: <RedoOutlined />, onClick: () => {
1342
+ }
1343
+ },
1344
+ ]} />,
1345
+ right: <DefaultCards.FooterCount data={[
1346
+ ['Words', 99],
1347
+ ['Input tokens', 200],
1348
+ ['Output tokens', 300],
1349
+ ]} />
1350
+
1351
+ }
1352
+ },
1353
+ ]} />
1354
+ }`},56391:function(e,n){n.Z=`import React from 'react';
1355
+ import { Bubble } from '@ali/spark-chat';
1356
+ const App = () => <Bubble cards={[
1357
+ {
1358
+ code: 'Images',
1359
+ data: [
1360
+ { url: 'https://gw.alicdn.com/imgextra/i4/O1CN01sjZ4Uu1erFDOC6IkA_!!6000000003924-2-tps-396-224.png', },
1361
+ ],
1362
+ },
1363
+ ]} />;
1364
+
1365
+ export default App;
1366
+ `},48481:function(e,n){n.Z=`import React from 'react';
1367
+ import { Bubble } from '@ali/spark-chat';
1368
+
1369
+ const content = \`city pop, short for city pop, is a genre of music that originated in japan during the late 1970s and early 1980s. it blends elements of jazz, folk, easy listening, and aor (adult oriented rock) with a distinctly urban feel. the term "city pop" often evokes images of the sophisticated, stylish, and sometimes nostalgic lifestyle of tokyo and other major japanese cities during this period.
1370
+ city pop is characterized by its smooth melodies, mellow rhythms, and often dreamy or introspective lyrics. common themes include city life, summer vibes, nature, and romantic encounters. the music is frequently associated with a particular aesthetic that reflects the fashion, design, and cultural trends of urban japan in the 1980s.
1371
+ some notable city pop artists include mariya takeuchi, known for her iconic song " plastic love," and joe hisaishi, a composer famous for his work on studio ghibli films, though he is not strictly considered a city pop artist.
1372
+ today, city pop has experienced a resurgence in popularity, particularly among younger generations who appreciate its unique sound and the nostalgic value it holds.\`
1373
+ const App = () => <Bubble cards={[
1374
+ {
1375
+ code: 'Text',
1376
+ data: {
1377
+ content
1378
+ },
1379
+ },
1380
+ ]} />;
1381
+
1382
+ export default App;
1383
+ `},26873:function(e,n){n.Z=`import React, { useCallback } from 'react';
1384
+ import { VoiceChatProvider, useVoiceChat } from '@ali/spark-chat';
1385
+ import { Sender, Bubble, CustomCardsProvider } from '@ali/spark-chat';
1386
+ import { IconButton } from '@spark-ai/design';
1387
+ import { AudioMutedOutlined, AudioOutlined, PhoneOutlined } from '@ant-design/icons';
1388
+
1389
+ export default () => {
1390
+ return <VoiceChatProvider>
1391
+ <App />
1392
+ </VoiceChatProvider>
1393
+ };
1394
+
1395
+
1396
+ function App() {
1397
+ const context = useVoiceChat();
1398
+ const getRoles = useCallback((bubble: any) => {
1399
+ const message = bubble as TMessage;
1400
+ const roleConfig: any = {};
1401
+ if (message.role === 'assistant') {
1402
+ roleConfig.placement = 'start';
1403
+ }
1404
+
1405
+ if (message.role === 'user') roleConfig.placement = 'end';
1406
+ return roleConfig;
1407
+ }, []);
1408
+
1409
+ const wsConnected = context.voiceChatContext.wsConnected;
1410
+
1411
+
1412
+ return <div style={{
1413
+ height: '100vh',
1414
+ display: 'flex',
1415
+ flexDirection: 'column',
1416
+ }}>
1417
+
1418
+ <Bubble.List
1419
+ roles={getRoles}
1420
+ style={{ height: 0, flex: 1, padding: 16 }}
1421
+ items={context.voiceChatContext.messages}
1422
+ />
1423
+
1424
+ <div style={{ display: 'flex', justifyContent: 'center', flexDirection: 'column', alignItems: 'center', padding: 32 }}>
1425
+
1426
+ <div className='tts' style={{ width: 165, height: 45, marginBottom: 32 }} >
1427
+
1428
+ </div>
1429
+
1430
+
1431
+ <IconButton
1432
+ type="primary"
1433
+ danger={wsConnected}
1434
+ onClick={() => {
1435
+ if (wsConnected) {
1436
+ context.recorderContext.recorderRef.current.stop();
1437
+ } else {
1438
+ context.recorderContext.recorderRef.current.start();
1439
+ }
1440
+ }}
1441
+ shape="circle" icon={
1442
+ wsConnected ? <AudioMutedOutlined /> :
1443
+ <PhoneOutlined />
1444
+ } size="large"
1445
+ />
1446
+
1447
+ </div>
1448
+ </div>;
1449
+ }`}}]);