@icos-react/largemodel 1.0.28 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -968,6 +968,16 @@ interface MessageActionCallbacks {
968
968
  onCopy?: (content: string, messageId: string | number) => Promise<void> | void;
969
969
  onRefresh?: (messageId: string | number, userMessageContent: string) => Promise<void> | void;
970
970
  }
971
+ interface ChatDemoRef$1 {
972
+ sendMessage: (message: string, isCreateApp?: boolean, variable?: any) => Promise<void>;
973
+ sendMessageWithControl: (message: string, showUserMessage?: boolean, variable?: any, resetSession?: boolean) => Promise<void>;
974
+ setInputText: (text: string) => void;
975
+ /** 中止当前正在进行的 AI 流式请求 */
976
+ stopGeneration: () => void;
977
+ getMidVal: () => any;
978
+ getVariables: () => any;
979
+ updateVariables: (newVariables: any) => void;
980
+ }
971
981
  interface ChatXProps$1 {
972
982
  buttonImage?: string;
973
983
  userIcon?: string;
@@ -1104,11 +1114,6 @@ interface ChatXProps$1 {
1104
1114
  formatThinkingBarTitle?: (thinkingTimeMs: number) => string;
1105
1115
  }
1106
1116
 
1107
- interface ChatDemoRef$1 {
1108
- sendMessage: (message: string, isCreateApp?: boolean, variable?: any) => Promise<void>;
1109
- sendMessageWithControl: (message: string, showUserMessage?: boolean, variable?: any, resetSession?: boolean) => Promise<void>;
1110
- setInputText: (text: string) => void;
1111
- }
1112
1117
  declare const ChatDemo: React__default.ForwardRefExoticComponent<ChatXProps$1 & React__default.RefAttributes<ChatDemoRef$1>>;
1113
1118
 
1114
1119
  /**
package/dist/index.js CHANGED
@@ -587,6 +587,9 @@ BubbleList.displayName = "BubbleList";
587
587
  // src/core/BubbleList/StandardMessageRenderer.tsx
588
588
  var import_react4 = __toESM(require("react"));
589
589
  var import_react_markdown = __toESM(require("react-markdown"));
590
+ var import_remark_math = __toESM(require("remark-math"));
591
+ var import_rehype_katex = __toESM(require("rehype-katex"));
592
+ var import_katex_min = require("katex/dist/katex.min.css");
590
593
 
591
594
  // src/core/utils/index.ts
592
595
  var import_react3 = __toESM(require("react"));
@@ -661,6 +664,8 @@ var StandardMessageRenderer = ({ message, eventContent = {}, components, classNa
661
664
  import_react_markdown.default,
662
665
  {
663
666
  key: index,
667
+ remarkPlugins: [import_remark_math.default],
668
+ rehypePlugins: [import_rehype_katex.default],
664
669
  components: {
665
670
  p: ({ node, ...props }) => /* @__PURE__ */ import_react4.default.createElement("p", { style: { margin: "0.5em 0" }, ...props }),
666
671
  pre: ({ node, ...props }) => /* @__PURE__ */ import_react4.default.createElement(
@@ -4455,6 +4460,9 @@ init_apiHandler();
4455
4460
  var import_react20 = __toESM(require("react"));
4456
4461
  var import_react_markdown2 = __toESM(require("react-markdown"));
4457
4462
  var import_rehype_raw = __toESM(require("rehype-raw"));
4463
+ var import_remark_math2 = __toESM(require("remark-math"));
4464
+ var import_rehype_katex2 = __toESM(require("rehype-katex"));
4465
+ var import_katex_min2 = require("katex/dist/katex.min.css");
4458
4466
  var rightIcon = `data:image/svg+xml,${encodeURIComponent(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
4459
4467
  <path d="M8 15C11.866 15 15 11.866 15 8C15 4.134 11.866 1 8 1C4.134 1 1 4.134 1 8C1 11.866 4.134 15 8 15ZM11.82 6.21998L7.3 10.7399L4.35502 7.79497L5.34498 6.80503L7.3 8.76006L10.83 5.23002L11.82 6.21998Z" fill="#00FFFF"/>
4460
4468
  </svg>`)}`;
@@ -4672,7 +4680,7 @@ var ThinkingContent = ({
4672
4680
  style: customStyle?.thinkingContent,
4673
4681
  "data-custom-color": ""
4674
4682
  },
4675
- /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { components: markdownComponents, rehypePlugins: [import_rehype_raw.default] }, content)
4683
+ /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { components: markdownComponents, remarkPlugins: [import_remark_math2.default], rehypePlugins: [import_rehype_katex2.default, import_rehype_raw.default] }, content)
4676
4684
  ));
4677
4685
  };
4678
4686
  if (typeof window !== "undefined") {
@@ -4705,12 +4713,12 @@ var renderContentWithAnchors = (content, messageId, eventContent, styles) => {
4705
4713
  img: CustomImageComponent
4706
4714
  };
4707
4715
  if (!hasAnchors) {
4708
- return /* @__PURE__ */ import_react20.default.createElement("div", { className: styles.messageText }, /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { components: markdownComponents, rehypePlugins: [import_rehype_raw.default] }, content));
4716
+ return /* @__PURE__ */ import_react20.default.createElement("div", { className: styles.messageText }, /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { components: markdownComponents, remarkPlugins: [import_remark_math2.default], rehypePlugins: [import_rehype_katex2.default, import_rehype_raw.default] }, content));
4709
4717
  }
4710
4718
  const parts = parseContentWithAnchors2(content, messageId, eventContent || {});
4711
4719
  return /* @__PURE__ */ import_react20.default.createElement("div", { className: styles.messageText }, parts.map((part, index) => {
4712
4720
  if (typeof part === "string") {
4713
- return /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { key: index, components: markdownComponents, rehypePlugins: [import_rehype_raw.default] }, part);
4721
+ return /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { key: index, components: markdownComponents, remarkPlugins: [import_remark_math2.default], rehypePlugins: [import_rehype_katex2.default, import_rehype_raw.default] }, part);
4714
4722
  }
4715
4723
  return part;
4716
4724
  }));
@@ -4745,11 +4753,11 @@ function renderCustomTagStreamRoot(message, styles, customTagRenderers, eventCon
4745
4753
  return null;
4746
4754
  const hasAnchors = text.includes("[ANCHOR:");
4747
4755
  if (!hasAnchors) {
4748
- return /* @__PURE__ */ import_react20.default.createElement("div", { className: styles.messageText, key }, /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { components: markdownComponents, rehypePlugins: [import_rehype_raw.default] }, text));
4756
+ return /* @__PURE__ */ import_react20.default.createElement("div", { className: styles.messageText, key }, /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { components: markdownComponents, remarkPlugins: [import_remark_math2.default], rehypePlugins: [import_rehype_katex2.default, import_rehype_raw.default] }, text));
4749
4757
  }
4750
4758
  const parts = parseContentWithAnchors2(text, message.id, eventContent || {});
4751
4759
  return /* @__PURE__ */ import_react20.default.createElement("div", { className: styles.messageText, key }, parts.map(
4752
- (part, index) => typeof part === "string" ? /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { key: index, components: markdownComponents, rehypePlugins: [import_rehype_raw.default] }, part) : part
4760
+ (part, index) => typeof part === "string" ? /* @__PURE__ */ import_react20.default.createElement(import_react_markdown2.default, { key: index, components: markdownComponents, remarkPlugins: [import_remark_math2.default], rehypePlugins: [import_rehype_katex2.default, import_rehype_raw.default] }, part) : part
4753
4761
  ));
4754
4762
  };
4755
4763
  const renderSegmentNode = (segmentId) => {
@@ -6029,6 +6037,9 @@ var ChatDemo = (0, import_react21.forwardRef)(
6029
6037
  },
6030
6038
  updateVariables: (newVariables) => {
6031
6039
  setInternalVariables(newVariables);
6040
+ },
6041
+ stopGeneration: () => {
6042
+ handleStopResponse();
6032
6043
  }
6033
6044
  }),
6034
6045
  [sendMessage, sendMessageWithControl, midVal, internalVariables]
@@ -7303,6 +7314,14 @@ var ChatAssistant = (0, import_react23.forwardRef)(
7303
7314
  setContentEditableText(customInputElementRef.current, text, true);
7304
7315
  }, 0);
7305
7316
  }
7317
+ },
7318
+ stopGeneration: () => {
7319
+ chatDemoRef.current?.stopGeneration?.();
7320
+ },
7321
+ getMidVal: () => chatDemoRef.current?.getMidVal?.(),
7322
+ getVariables: () => chatDemoRef.current?.getVariables?.(),
7323
+ updateVariables: (newVariables) => {
7324
+ chatDemoRef.current?.updateVariables?.(newVariables);
7306
7325
  }
7307
7326
  }),
7308
7327
  [sendStatus, history]
@@ -8876,6 +8895,17 @@ var ChatButton = (0, import_react25.forwardRef)(
8876
8895
  internalRef.current.setInputText(text);
8877
8896
  }
8878
8897
  }, 100);
8898
+ },
8899
+ stopGeneration: () => {
8900
+ internalRef.current?.stopGeneration?.();
8901
+ },
8902
+ close: () => {
8903
+ setIsOpen(false);
8904
+ },
8905
+ getMidVal: () => internalRef.current?.getMidVal?.(),
8906
+ getVariables: () => internalRef.current?.getVariables?.(),
8907
+ updateVariables: (newVariables) => {
8908
+ internalRef.current?.updateVariables?.(newVariables);
8879
8909
  }
8880
8910
  }), [isOpen]);
8881
8911
  (0, import_react25.useEffect)(() => {
package/dist/index.mjs CHANGED
@@ -532,6 +532,9 @@ BubbleList.displayName = "BubbleList";
532
532
  // src/core/BubbleList/StandardMessageRenderer.tsx
533
533
  import React4 from "react";
534
534
  import ReactMarkdown from "react-markdown";
535
+ import remarkMath from "remark-math";
536
+ import rehypeKatex from "rehype-katex";
537
+ import "katex/dist/katex.min.css";
535
538
 
536
539
  // src/core/utils/index.ts
537
540
  import React3 from "react";
@@ -606,6 +609,8 @@ var StandardMessageRenderer = ({ message, eventContent = {}, components, classNa
606
609
  ReactMarkdown,
607
610
  {
608
611
  key: index,
612
+ remarkPlugins: [remarkMath],
613
+ rehypePlugins: [rehypeKatex],
609
614
  components: {
610
615
  p: ({ node, ...props }) => /* @__PURE__ */ React4.createElement("p", { style: { margin: "0.5em 0" }, ...props }),
611
616
  pre: ({ node, ...props }) => /* @__PURE__ */ React4.createElement(
@@ -4406,6 +4411,9 @@ init_apiHandler();
4406
4411
  import React10, { useEffect as useEffect8, useRef as useRef9, useState as useState8 } from "react";
4407
4412
  import ReactMarkdown2 from "react-markdown";
4408
4413
  import rehypeRaw from "rehype-raw";
4414
+ import remarkMath2 from "remark-math";
4415
+ import rehypeKatex2 from "rehype-katex";
4416
+ import "katex/dist/katex.min.css";
4409
4417
  var rightIcon = `data:image/svg+xml,${encodeURIComponent(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
4410
4418
  <path d="M8 15C11.866 15 15 11.866 15 8C15 4.134 11.866 1 8 1C4.134 1 1 4.134 1 8C1 11.866 4.134 15 8 15ZM11.82 6.21998L7.3 10.7399L4.35502 7.79497L5.34498 6.80503L7.3 8.76006L10.83 5.23002L11.82 6.21998Z" fill="#00FFFF"/>
4411
4419
  </svg>`)}`;
@@ -4623,7 +4631,7 @@ var ThinkingContent = ({
4623
4631
  style: customStyle?.thinkingContent,
4624
4632
  "data-custom-color": ""
4625
4633
  },
4626
- /* @__PURE__ */ React10.createElement(ReactMarkdown2, { components: markdownComponents, rehypePlugins: [rehypeRaw] }, content)
4634
+ /* @__PURE__ */ React10.createElement(ReactMarkdown2, { components: markdownComponents, remarkPlugins: [remarkMath2], rehypePlugins: [rehypeKatex2, rehypeRaw] }, content)
4627
4635
  ));
4628
4636
  };
4629
4637
  if (typeof window !== "undefined") {
@@ -4656,12 +4664,12 @@ var renderContentWithAnchors = (content, messageId, eventContent, styles) => {
4656
4664
  img: CustomImageComponent
4657
4665
  };
4658
4666
  if (!hasAnchors) {
4659
- return /* @__PURE__ */ React10.createElement("div", { className: styles.messageText }, /* @__PURE__ */ React10.createElement(ReactMarkdown2, { components: markdownComponents, rehypePlugins: [rehypeRaw] }, content));
4667
+ return /* @__PURE__ */ React10.createElement("div", { className: styles.messageText }, /* @__PURE__ */ React10.createElement(ReactMarkdown2, { components: markdownComponents, remarkPlugins: [remarkMath2], rehypePlugins: [rehypeKatex2, rehypeRaw] }, content));
4660
4668
  }
4661
4669
  const parts = parseContentWithAnchors2(content, messageId, eventContent || {});
4662
4670
  return /* @__PURE__ */ React10.createElement("div", { className: styles.messageText }, parts.map((part, index) => {
4663
4671
  if (typeof part === "string") {
4664
- return /* @__PURE__ */ React10.createElement(ReactMarkdown2, { key: index, components: markdownComponents, rehypePlugins: [rehypeRaw] }, part);
4672
+ return /* @__PURE__ */ React10.createElement(ReactMarkdown2, { key: index, components: markdownComponents, remarkPlugins: [remarkMath2], rehypePlugins: [rehypeKatex2, rehypeRaw] }, part);
4665
4673
  }
4666
4674
  return part;
4667
4675
  }));
@@ -4696,11 +4704,11 @@ function renderCustomTagStreamRoot(message, styles, customTagRenderers, eventCon
4696
4704
  return null;
4697
4705
  const hasAnchors = text.includes("[ANCHOR:");
4698
4706
  if (!hasAnchors) {
4699
- return /* @__PURE__ */ React10.createElement("div", { className: styles.messageText, key }, /* @__PURE__ */ React10.createElement(ReactMarkdown2, { components: markdownComponents, rehypePlugins: [rehypeRaw] }, text));
4707
+ return /* @__PURE__ */ React10.createElement("div", { className: styles.messageText, key }, /* @__PURE__ */ React10.createElement(ReactMarkdown2, { components: markdownComponents, remarkPlugins: [remarkMath2], rehypePlugins: [rehypeKatex2, rehypeRaw] }, text));
4700
4708
  }
4701
4709
  const parts = parseContentWithAnchors2(text, message.id, eventContent || {});
4702
4710
  return /* @__PURE__ */ React10.createElement("div", { className: styles.messageText, key }, parts.map(
4703
- (part, index) => typeof part === "string" ? /* @__PURE__ */ React10.createElement(ReactMarkdown2, { key: index, components: markdownComponents, rehypePlugins: [rehypeRaw] }, part) : part
4711
+ (part, index) => typeof part === "string" ? /* @__PURE__ */ React10.createElement(ReactMarkdown2, { key: index, components: markdownComponents, remarkPlugins: [remarkMath2], rehypePlugins: [rehypeKatex2, rehypeRaw] }, part) : part
4704
4712
  ));
4705
4713
  };
4706
4714
  const renderSegmentNode = (segmentId) => {
@@ -5980,6 +5988,9 @@ var ChatDemo = forwardRef5(
5980
5988
  },
5981
5989
  updateVariables: (newVariables) => {
5982
5990
  setInternalVariables(newVariables);
5991
+ },
5992
+ stopGeneration: () => {
5993
+ handleStopResponse();
5983
5994
  }
5984
5995
  }),
5985
5996
  [sendMessage, sendMessageWithControl, midVal, internalVariables]
@@ -7262,6 +7273,14 @@ var ChatAssistant = forwardRef6(
7262
7273
  setContentEditableText(customInputElementRef.current, text, true);
7263
7274
  }, 0);
7264
7275
  }
7276
+ },
7277
+ stopGeneration: () => {
7278
+ chatDemoRef.current?.stopGeneration?.();
7279
+ },
7280
+ getMidVal: () => chatDemoRef.current?.getMidVal?.(),
7281
+ getVariables: () => chatDemoRef.current?.getVariables?.(),
7282
+ updateVariables: (newVariables) => {
7283
+ chatDemoRef.current?.updateVariables?.(newVariables);
7265
7284
  }
7266
7285
  }),
7267
7286
  [sendStatus, history]
@@ -8842,6 +8861,17 @@ var ChatButton = forwardRef8(
8842
8861
  internalRef.current.setInputText(text);
8843
8862
  }
8844
8863
  }, 100);
8864
+ },
8865
+ stopGeneration: () => {
8866
+ internalRef.current?.stopGeneration?.();
8867
+ },
8868
+ close: () => {
8869
+ setIsOpen(false);
8870
+ },
8871
+ getMidVal: () => internalRef.current?.getMidVal?.(),
8872
+ getVariables: () => internalRef.current?.getVariables?.(),
8873
+ updateVariables: (newVariables) => {
8874
+ internalRef.current?.updateVariables?.(newVariables);
8845
8875
  }
8846
8876
  }), [isOpen]);
8847
8877
  useEffect13(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icos-react/largemodel",
3
3
  "displayName": "大模型组件",
4
- "version": "1.0.28",
4
+ "version": "1.0.30",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -39,9 +39,12 @@
39
39
  "@ant-design/x": "^1.0.0",
40
40
  "antd-style": "^3.7.1",
41
41
  "immer": "^10.1.1",
42
+ "katex": "^0.17.0",
42
43
  "ldrs": "^1.1.7",
43
44
  "react-markdown": "^10.1.0",
44
- "rehype-raw": "^7.0.0"
45
+ "rehype-katex": "^7.0.1",
46
+ "rehype-raw": "^7.0.0",
47
+ "remark-math": "^6.0.0"
45
48
  },
46
49
  "publishConfig": {
47
50
  "access": "public",