@myun/gimi-chat 0.9.77 → 0.9.78
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.
|
@@ -8,7 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
8
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
-
import React, { useEffect, useMemo, useState } from "react";
|
|
11
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { MMarkdown } from '@myun/gimi-design';
|
|
13
13
|
import IconFont from "../../../iconfont-com";
|
|
14
14
|
import FileUpload from "../../../file-upload";
|
|
@@ -16,6 +16,8 @@ import styles from "./index.module.css";
|
|
|
16
16
|
import classNames from "classnames";
|
|
17
17
|
import { useTranslation } from "react-i18next";
|
|
18
18
|
import { useAppSelector } from "../../../../store/hooks";
|
|
19
|
+
import useScroll from "../../../../hooks/useScroll";
|
|
20
|
+
|
|
19
21
|
// 思考工具项组件
|
|
20
22
|
var ThinkingToolItem = function ThinkingToolItem(_ref) {
|
|
21
23
|
var item = _ref.item,
|
|
@@ -28,12 +30,22 @@ var ThinkingToolItem = function ThinkingToolItem(_ref) {
|
|
|
28
30
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
31
|
manual = _useState4[0],
|
|
30
32
|
setManual = _useState4[1]; // 用户是否手动操作过,手动后不再被状态覆盖
|
|
31
|
-
|
|
33
|
+
var contentRef = useRef(null);
|
|
34
|
+
var _useScroll = useScroll(contentRef),
|
|
35
|
+
_useScroll2 = _slicedToArray(_useScroll, 1),
|
|
36
|
+
throttledScrollToBottom = _useScroll2[0];
|
|
32
37
|
useEffect(function () {
|
|
33
38
|
if (!manual) {
|
|
34
39
|
setShowContent(item.status !== "COMPLETED");
|
|
35
40
|
}
|
|
36
41
|
}, [item.status, manual]);
|
|
42
|
+
|
|
43
|
+
// 内容更新 / 展开时滚动到底部
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
if (showContent) {
|
|
46
|
+
throttledScrollToBottom();
|
|
47
|
+
}
|
|
48
|
+
}, [item.content, showContent]);
|
|
37
49
|
var handleToggle = function handleToggle() {
|
|
38
50
|
setManual(true);
|
|
39
51
|
setShowContent(function (v) {
|
|
@@ -60,7 +72,8 @@ var ThinkingToolItem = function ThinkingToolItem(_ref) {
|
|
|
60
72
|
color: !showContent ? "var(--theme-neutral, #626262)" : "var(--theme-mediumNeutral, #B3B2B2)"
|
|
61
73
|
}
|
|
62
74
|
})), item.content && showContent && /*#__PURE__*/React.createElement("div", {
|
|
63
|
-
className: styles.toolItemContent
|
|
75
|
+
className: styles.toolItemContent,
|
|
76
|
+
ref: contentRef
|
|
64
77
|
}, /*#__PURE__*/React.createElement(MMarkdown, {
|
|
65
78
|
content: item.content,
|
|
66
79
|
customRender: customRender,
|
|
@@ -204,9 +204,9 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
204
204
|
return {
|
|
205
205
|
id: "thinking-".concat(item.id),
|
|
206
206
|
moduleType: 'thinking',
|
|
207
|
-
toolName: getToolNameByStatus('thinking', item.reasoningStatus === 1 ? 'RUNNING' : item.reasoningStatus === 2 ? 'COMPLETED' : '
|
|
207
|
+
toolName: getToolNameByStatus('thinking', item.reasoningStatus === 1 ? 'RUNNING' : item.reasoningStatus === 2 ? 'COMPLETED' : 'CANCELLED'),
|
|
208
208
|
content: item.reasoningContent,
|
|
209
|
-
status: item.reasoningStatus === 1 ? 'RUNNING' : item.reasoningStatus === 2 ? 'COMPLETED' : '
|
|
209
|
+
status: item.reasoningStatus === 1 ? 'RUNNING' : item.reasoningStatus === 2 ? 'COMPLETED' : 'CANCELLED'
|
|
210
210
|
};
|
|
211
211
|
}, [item.reasoningContent, item.reasoningStatus, item.vipLevel, item.id]);
|
|
212
212
|
|
|
@@ -199,8 +199,9 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
199
199
|
// 如果有正在进行的请求,复用该 Promise
|
|
200
200
|
if (thinkingCacheRef.current.agentId === agentId && thinkingCacheRef.current.promise) {
|
|
201
201
|
thinkingCacheRef.current.promise.then(function (result) {
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
var data = result || {};
|
|
203
|
+
setDeepThinkDisabled(data.thinking !== 1);
|
|
204
|
+
setDeepThinkActive(data.thinkingEnable === 1);
|
|
204
205
|
}).catch(function (e) {
|
|
205
206
|
console.error('[deepThink] getThinkingEffective error:', e);
|
|
206
207
|
setDeepThinkDisabled(false);
|