@myun/gimi-chat 0.9.21 → 0.9.23
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/apis/useApi.js +1 -1
- package/dist/components/ai-chat-dialogue/index copy.d.ts +16 -0
- package/dist/components/ai-chat-dialogue/index copy.js +1062 -0
- package/dist/components/ai-chat-dialogue/index.js +54 -49
- package/dist/components/ai-chat-dialogue/index.module copy.css +230 -0
- package/dist/components/ai-chat-dialogue/index.module.css +78 -136
- package/dist/components/chat-input/index.d.ts +4 -0
- package/dist/components/chat-input/index.js +176 -67
- package/dist/components/chat-input/index.module.css +60 -2
- package/dist/components/file-upload/index.js +120 -34
- package/dist/components/iconfont-com/index.js +1 -1
- package/dist/components/message-list/index.js +2 -1
- package/dist/components/templates/CommonChat.js +24 -5
- package/dist/components/templates/GimiChatComponent.js +4 -0
- package/dist/components/upload-list/CustomFile.d.ts +15 -0
- package/dist/components/upload-list/CustomFile.js +105 -0
- package/dist/components/upload-list/ImageFile.d.ts +18 -0
- package/dist/components/upload-list/ImageFile.js +68 -0
- package/dist/components/upload-list/customFile.module.css +122 -0
- package/dist/components/upload-list/imageFile.module.css +95 -0
- package/dist/components/upload-list/index.d.ts +4 -3
- package/dist/components/upload-list/index.js +95 -84
- package/dist/components/upload-list/index.module.css +68 -99
- package/dist/components/voice-bars/index.js +10 -9
- package/dist/components/voice-check-dialog/index.js +2 -1
- package/dist/components/voice-recording/index.d.ts +1 -1
- package/dist/components/voice-recording/index.js +2 -28
- package/dist/hooks/useChatMessage.d.ts +1 -1
- package/dist/hooks/useChatMessage.js +1 -1
- package/dist/hooks/useCommonChatAPI.js +13 -9
- package/dist/hooks/useFile.js +99 -7
- package/dist/i18n/locales/en-US.d.ts +9 -0
- package/dist/i18n/locales/en-US.js +10 -1
- package/dist/i18n/locales/zh-CN.d.ts +9 -0
- package/dist/i18n/locales/zh-CN.js +10 -1
- package/dist/types/chat.d.ts +2 -0
- package/dist/types/file.d.ts +2 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -3,12 +3,11 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
3
3
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
7
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
11
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
12
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
13
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -17,12 +16,11 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
17
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
17
|
import React, { useContext } from "react";
|
|
19
18
|
import { useTranslation } from 'react-i18next';
|
|
20
|
-
import { AIChatInput, Divider } from '@douyinfe/semi-ui';
|
|
19
|
+
import { AIChatInput, Divider, Popover } from '@douyinfe/semi-ui';
|
|
21
20
|
import { transformToInputSlots } from "../../utils/chatInputUtil";
|
|
22
21
|
import VoiceCheckDialog from "../voice-check-dialog";
|
|
23
22
|
import VoiceCommunication from "../chat-voice/VoiceCommunication";
|
|
24
23
|
import VoiceRecord from "../chat-voice/VoiceRecord";
|
|
25
|
-
import VoiceRecording from "../voice-recording";
|
|
26
24
|
// import deepThinkActive from "../../assets/image/deepthinkActive.png";
|
|
27
25
|
import { Tooltip } from "@douyinfe/semi-ui";
|
|
28
26
|
import styles from "./index.module.css";
|
|
@@ -39,6 +37,8 @@ import { Keydown, TitleSlot } from "./extension";
|
|
|
39
37
|
import QuotedContent from "../quoted-content";
|
|
40
38
|
import { ReferencesEdit } from "../reference-content";
|
|
41
39
|
import IconFontCom from "../iconfont-com";
|
|
40
|
+
import VoiceBars from "../voice-bars";
|
|
41
|
+
import classNames from 'classnames';
|
|
42
42
|
var extractText = function extractText() {
|
|
43
43
|
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
44
44
|
return content.map(function (item) {
|
|
@@ -95,14 +95,12 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
95
95
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
96
96
|
showChatCommunication = _React$useState2[0],
|
|
97
97
|
setShowChatCommunication = _React$useState2[1];
|
|
98
|
-
|
|
98
|
+
// const [inputWidth, setInputWidth] = React.useState(0);
|
|
99
|
+
|
|
100
|
+
var _React$useState3 = React.useState(false),
|
|
99
101
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var _React$useState5 = React.useState(false),
|
|
103
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
104
|
-
hasContent = _React$useState6[0],
|
|
105
|
-
setHasContent = _React$useState6[1];
|
|
102
|
+
hasContent = _React$useState4[0],
|
|
103
|
+
setHasContent = _React$useState4[1];
|
|
106
104
|
var _useContext = useContext(ChatContext),
|
|
107
105
|
apiService = _useContext.apiService;
|
|
108
106
|
var _ref = apiService,
|
|
@@ -149,29 +147,25 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
149
147
|
preInputValueRef.current = value;
|
|
150
148
|
(_props$onValueChange = props.onValueChange) === null || _props$onValueChange === void 0 || _props$onValueChange.call(props, value);
|
|
151
149
|
}, [props]);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return function () {
|
|
172
|
-
resizeObserver.disconnect();
|
|
173
|
-
};
|
|
174
|
-
}, []);
|
|
150
|
+
|
|
151
|
+
// React.useEffect(() => {
|
|
152
|
+
// const element = inputWrapRef.current;
|
|
153
|
+
// if (!element) return;
|
|
154
|
+
|
|
155
|
+
// const resizeObserver = new ResizeObserver((entries) => {
|
|
156
|
+
// for (const entry of entries) {
|
|
157
|
+
// const width = entry.contentRect.width;
|
|
158
|
+
// setInputWidth(width);
|
|
159
|
+
// }
|
|
160
|
+
// });
|
|
161
|
+
|
|
162
|
+
// resizeObserver.observe(element);
|
|
163
|
+
|
|
164
|
+
// return () => {
|
|
165
|
+
// resizeObserver.disconnect();
|
|
166
|
+
// };
|
|
167
|
+
// }, []);
|
|
168
|
+
|
|
175
169
|
var handleQuickInput = React.useCallback(function (value) {
|
|
176
170
|
var isReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
177
171
|
if (isReplace) {
|
|
@@ -188,8 +182,8 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
188
182
|
}
|
|
189
183
|
}, [props.asrText, props.isRecording, props.isVoiceGetting, handleQuickInput]);
|
|
190
184
|
var handleTip = function handleTip() {
|
|
191
|
-
if ((fileList === null || fileList === void 0 ? void 0 : fileList.length)
|
|
192
|
-
return Toast.info(t('chatInput.
|
|
185
|
+
if ((fileList === null || fileList === void 0 ? void 0 : fileList.length) >= 10) {
|
|
186
|
+
return Toast.info(t('chatInput.uploadLimitTen'));
|
|
193
187
|
}
|
|
194
188
|
return Toast.info(t('chatInput.flowUnsupported'));
|
|
195
189
|
};
|
|
@@ -197,8 +191,8 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
197
191
|
if (!props.enableFileUpload || (agentObj === null || agentObj === void 0 ? void 0 : agentObj.openUploadFile) === 0) {
|
|
198
192
|
return null;
|
|
199
193
|
}
|
|
200
|
-
var shouldDisableUploadFile = props.disabled || (fileList === null || fileList === void 0 ? void 0 : fileList.length)
|
|
201
|
-
return /*#__PURE__*/React.createElement(FileUpload, {
|
|
194
|
+
var shouldDisableUploadFile = props.disabled || (fileList === null || fileList === void 0 ? void 0 : fileList.length) >= 10 || isAskProcess;
|
|
195
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FileUpload, {
|
|
202
196
|
ref: uploadFileRef,
|
|
203
197
|
accept: props.accept,
|
|
204
198
|
disabled: shouldDisableUploadFile,
|
|
@@ -211,16 +205,78 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
211
205
|
style: {
|
|
212
206
|
cursor: 'not-allowed'
|
|
213
207
|
}
|
|
214
|
-
}, /*#__PURE__*/React.createElement(
|
|
215
|
-
|
|
216
|
-
|
|
208
|
+
}, /*#__PURE__*/React.createElement(IconFontCom, {
|
|
209
|
+
type: "icon-a-tianjia2",
|
|
210
|
+
size: 20
|
|
217
211
|
})) : /*#__PURE__*/React.createElement("div", {
|
|
218
212
|
className: styles.uploadIcon
|
|
213
|
+
}, /*#__PURE__*/React.createElement(IconFontCom, {
|
|
214
|
+
type: "icon-a-tianjia2",
|
|
215
|
+
size: 20
|
|
216
|
+
})))), /*#__PURE__*/React.createElement(Divider, {
|
|
217
|
+
layout: "vertical",
|
|
218
|
+
style: {
|
|
219
|
+
marginLeft: 8
|
|
220
|
+
}
|
|
221
|
+
}));
|
|
222
|
+
}, [props.enableFileUpload, props.accept, props.disabled, messageList, agentObj === null || agentObj === void 0 ? void 0 : agentObj.openUploadFile, fileList, isAskProcess]);
|
|
223
|
+
var AgentContainer = React.useMemo(function () {
|
|
224
|
+
var _props$agentList, _props$agentList2, _props$agentList3;
|
|
225
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
226
|
+
className: styles.agentContainer
|
|
227
|
+
}, (_props$agentList = props.agentList) === null || _props$agentList === void 0 ? void 0 : _props$agentList.slice(0, 3).map(function (item) {
|
|
228
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
229
|
+
className: classNames(styles.agentItem, _defineProperty({}, styles.active, item.agentId === (agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentId))),
|
|
230
|
+
key: item.agentId,
|
|
231
|
+
onClick: function onClick() {
|
|
232
|
+
var _props$onAgentChange;
|
|
233
|
+
return item.agentId && ((_props$onAgentChange = props.onAgentChange) === null || _props$onAgentChange === void 0 ? void 0 : _props$onAgentChange.call(props, item.agentId));
|
|
234
|
+
},
|
|
235
|
+
style: {
|
|
236
|
+
cursor: 'pointer'
|
|
237
|
+
}
|
|
238
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
239
|
+
src: item.agentIcon,
|
|
240
|
+
alt: ""
|
|
241
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
242
|
+
className: styles.agentName
|
|
243
|
+
}, item.agentName));
|
|
244
|
+
}), (props === null || props === void 0 ? void 0 : props.agentList) && ((_props$agentList2 = props.agentList) === null || _props$agentList2 === void 0 ? void 0 : _props$agentList2.length) > 3 && /*#__PURE__*/React.createElement(Popover, {
|
|
245
|
+
content: /*#__PURE__*/React.createElement("div", {
|
|
246
|
+
className: styles.agentPopover
|
|
247
|
+
}, (_props$agentList3 = props.agentList) === null || _props$agentList3 === void 0 || (_props$agentList3 = _props$agentList3.slice(3)) === null || _props$agentList3 === void 0 ? void 0 : _props$agentList3.map(function (item) {
|
|
248
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
249
|
+
className: classNames(styles.agentItem, _defineProperty({}, styles.active, item.agentId === (agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentId))),
|
|
250
|
+
key: item.agentId,
|
|
251
|
+
onClick: function onClick() {
|
|
252
|
+
var _props$onAgentChange2;
|
|
253
|
+
return item.agentId && ((_props$onAgentChange2 = props.onAgentChange) === null || _props$onAgentChange2 === void 0 ? void 0 : _props$onAgentChange2.call(props, item.agentId));
|
|
254
|
+
},
|
|
255
|
+
style: {
|
|
256
|
+
cursor: 'pointer'
|
|
257
|
+
}
|
|
258
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
259
|
+
src: item.agentIcon,
|
|
260
|
+
alt: ""
|
|
261
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
262
|
+
className: styles.agentName
|
|
263
|
+
}, item.agentName));
|
|
264
|
+
})),
|
|
265
|
+
position: "topLeft",
|
|
266
|
+
trigger: "click"
|
|
267
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
268
|
+
className: styles.agentItem,
|
|
269
|
+
key: "more",
|
|
270
|
+
style: {
|
|
271
|
+
cursor: 'pointer'
|
|
272
|
+
}
|
|
219
273
|
}, /*#__PURE__*/React.createElement("img", {
|
|
220
|
-
src:
|
|
274
|
+
src: "https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202606/08/5655a_20260608143804.png",
|
|
221
275
|
alt: ""
|
|
222
|
-
})
|
|
223
|
-
|
|
276
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
277
|
+
className: styles.agentName
|
|
278
|
+
}, t('chatInput.more')))));
|
|
279
|
+
}, [props.agentList, agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentId, t]);
|
|
224
280
|
var openChatCommunication = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
225
281
|
var params, res, _props$onConversation;
|
|
226
282
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -340,21 +396,46 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
340
396
|
});
|
|
341
397
|
}, [props.enableSourceQuote, props.initQuoteSource]);
|
|
342
398
|
var renderActionArea = React.useCallback(function (renderProps) {
|
|
399
|
+
var sendBtn = renderProps.menuItem;
|
|
400
|
+
|
|
401
|
+
// 判断是否有语音能力
|
|
402
|
+
var hasVoiceCapability = props.enableVoiceChat || props.enableVoiceRecord;
|
|
403
|
+
|
|
404
|
+
// 当没有内容、没有文件、没有引用、且有语音能力时显示语音工具,否则显示发送按钮
|
|
405
|
+
var hasReference = (quoteTeachModelList === null || quoteTeachModelList === void 0 ? void 0 : quoteTeachModelList.length) > 0 || (quoteProductList === null || quoteProductList === void 0 ? void 0 : quoteProductList.length) > 0;
|
|
406
|
+
var showVoiceTools = !isMsgRecieving && !hasContent && (!fileList || fileList.length === 0) && !hasReference && hasVoiceCapability;
|
|
343
407
|
return /*#__PURE__*/React.createElement("div", {
|
|
344
408
|
className: renderProps.className,
|
|
345
|
-
key: "action_area"
|
|
409
|
+
key: "action_area",
|
|
410
|
+
style: {
|
|
411
|
+
position: 'relative'
|
|
412
|
+
}
|
|
346
413
|
}, /*#__PURE__*/React.createElement("div", {
|
|
347
414
|
style: {
|
|
348
415
|
display: 'flex',
|
|
349
|
-
alignItems: 'center'
|
|
416
|
+
alignItems: 'center',
|
|
417
|
+
gap: 8
|
|
350
418
|
}
|
|
351
|
-
}, renderQuotedContent,
|
|
352
|
-
|
|
419
|
+
}, renderQuotedContent, props.isRecording ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
420
|
+
content: t('chatInput.stopVoiceInput')
|
|
421
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
353
422
|
style: {
|
|
354
|
-
|
|
423
|
+
width: 32,
|
|
424
|
+
height: 32,
|
|
425
|
+
borderRadius: 8,
|
|
426
|
+
backgroundColor: "#F2F3F7",
|
|
427
|
+
border: "#F2F3F7",
|
|
428
|
+
cursor: "pointer",
|
|
429
|
+
position: 'relative',
|
|
430
|
+
zIndex: 10
|
|
431
|
+
},
|
|
432
|
+
onClick: function onClick() {
|
|
433
|
+
return stopRecording(true);
|
|
355
434
|
}
|
|
356
|
-
}
|
|
357
|
-
|
|
435
|
+
}, /*#__PURE__*/React.createElement(VoiceBars, {
|
|
436
|
+
parentWidth: 32
|
|
437
|
+
}))) : showVoiceTools ? VoiceTools : sendBtn));
|
|
438
|
+
}, [VoiceTools, renderQuotedContent, props.renderSendButton, hasContent, fileList, quoteTeachModelList, quoteProductList, props.isRecording, stopRecording]);
|
|
358
439
|
var onMessageSend = React.useCallback(function (content) {
|
|
359
440
|
var _props$onSend;
|
|
360
441
|
var inputContents = content.inputContents || [];
|
|
@@ -362,29 +443,44 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
362
443
|
(_props$onSend = props.onSend) === null || _props$onSend === void 0 || _props$onSend.call(props, text);
|
|
363
444
|
}, [props]);
|
|
364
445
|
var renderConfigureArea = React.useCallback(function () {
|
|
365
|
-
return /*#__PURE__*/React.createElement(
|
|
446
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
447
|
+
className: styles.configureArea
|
|
448
|
+
}, UploadFileTool, /*#__PURE__*/React.createElement(Tooltip, {
|
|
366
449
|
trigger: 'click',
|
|
367
450
|
content: t('chatInput.deepThinkTip')
|
|
368
451
|
}, /*#__PURE__*/React.createElement("div", {
|
|
369
452
|
className: styles.deepthink
|
|
370
453
|
}, /*#__PURE__*/React.createElement(IconFontCom, {
|
|
371
454
|
type: "icon-moxing",
|
|
372
|
-
size: 14
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
455
|
+
size: 14
|
|
456
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
457
|
+
style: {
|
|
458
|
+
marginBottom: 2
|
|
459
|
+
}
|
|
460
|
+
}, t('chatInput.deepThinkModeAuto')), /*#__PURE__*/React.createElement(IconFontCom, {
|
|
461
|
+
type: "icon-a-jiantoucu2x",
|
|
462
|
+
size: 12,
|
|
463
|
+
extraStyle: {
|
|
464
|
+
marginLeft: 0
|
|
465
|
+
}
|
|
466
|
+
}))), AgentContainer);
|
|
467
|
+
}, [UploadFileTool]);
|
|
376
468
|
var stopSSe = function stopSSe() {
|
|
377
469
|
if (uploadFileRef.current) {
|
|
378
470
|
var _uploadFileRef$curren;
|
|
379
471
|
(_uploadFileRef$curren = uploadFileRef.current) === null || _uploadFileRef$curren === void 0 || _uploadFileRef$curren.abortUpload();
|
|
380
472
|
}
|
|
381
473
|
};
|
|
382
|
-
var handleDelFile = React.useCallback(function () {
|
|
474
|
+
var handleDelFile = React.useCallback(function (uid) {
|
|
383
475
|
stopSSe();
|
|
476
|
+
var currentFileList = fileList || [];
|
|
477
|
+
var newFileList = currentFileList.filter(function (file) {
|
|
478
|
+
return file.uid !== uid;
|
|
479
|
+
});
|
|
384
480
|
dispatch(setFileList({
|
|
385
|
-
fileList:
|
|
481
|
+
fileList: newFileList
|
|
386
482
|
}));
|
|
387
|
-
}, [dispatch]);
|
|
483
|
+
}, [dispatch, fileList]);
|
|
388
484
|
var handleReTry = React.useCallback(function (file) {
|
|
389
485
|
var currentFileList = fileList || [];
|
|
390
486
|
var _file = currentFileList.find(function (item) {
|
|
@@ -405,7 +501,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
405
501
|
className: styles.reference,
|
|
406
502
|
key: "reference"
|
|
407
503
|
}, !props.isRecording && (fileList === null || fileList === void 0 ? void 0 : fileList.length) > 0 && !disabledUploadFileList && /*#__PURE__*/React.createElement(UploadList, {
|
|
408
|
-
|
|
504
|
+
fileList: fileList,
|
|
409
505
|
handleReTry: handleReTry,
|
|
410
506
|
handleDelFile: handleDelFile
|
|
411
507
|
}), ((quoteTeachModelList === null || quoteTeachModelList === void 0 ? void 0 : quoteTeachModelList.length) > 0 || (quoteProductList === null || quoteProductList === void 0 ? void 0 : quoteProductList.length) > 0) && !props.isRecording && /*#__PURE__*/React.createElement("div", {
|
|
@@ -455,12 +551,25 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
455
551
|
var uniqueKey = "".concat(props.placeholder, "-").concat(defaultContent);
|
|
456
552
|
return /*#__PURE__*/React.createElement("div", {
|
|
457
553
|
className: styles.inputWrap,
|
|
458
|
-
ref: inputWrapRef
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
554
|
+
ref: inputWrapRef,
|
|
555
|
+
style: {
|
|
556
|
+
position: 'relative'
|
|
557
|
+
}
|
|
558
|
+
}, props.isRecording && /*#__PURE__*/React.createElement("div", {
|
|
559
|
+
style: {
|
|
560
|
+
position: 'absolute',
|
|
561
|
+
top: 0,
|
|
562
|
+
left: 0,
|
|
563
|
+
right: 0,
|
|
564
|
+
bottom: 0,
|
|
565
|
+
zIndex: 10,
|
|
566
|
+
display: 'flex',
|
|
567
|
+
alignItems: 'center',
|
|
568
|
+
justifyContent: 'center',
|
|
569
|
+
borderRadius: '8px',
|
|
570
|
+
pointerEvents: 'auto'
|
|
571
|
+
}
|
|
572
|
+
}), /*#__PURE__*/React.createElement(AIChatInput, _extends({
|
|
464
573
|
ref: inputRef
|
|
465
574
|
// 为了当 props 变化时,重新渲染 AIChatInput
|
|
466
575
|
,
|
|
@@ -17,8 +17,6 @@
|
|
|
17
17
|
align-items: center;
|
|
18
18
|
justify-content: center;
|
|
19
19
|
cursor: pointer;
|
|
20
|
-
color: var(--theme-primary, #4086ff);
|
|
21
|
-
background-color: var(--theme-primary-pale, #F0F8FF);
|
|
22
20
|
}
|
|
23
21
|
.deepthink span {
|
|
24
22
|
margin-left: 4px;
|
|
@@ -38,8 +36,15 @@
|
|
|
38
36
|
.uploadIcon {
|
|
39
37
|
width: 32px;
|
|
40
38
|
height: 32px;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
41
42
|
cursor: pointer;
|
|
42
43
|
}
|
|
44
|
+
.uploadIcon:hover {
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
background-color: #F2F3F7;
|
|
47
|
+
}
|
|
43
48
|
.uploadIcon img {
|
|
44
49
|
width: 100%;
|
|
45
50
|
height: 100%;
|
|
@@ -93,10 +98,63 @@
|
|
|
93
98
|
align-items: center;
|
|
94
99
|
padding-top: 5px;
|
|
95
100
|
}
|
|
101
|
+
.reference .fileListContainer {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-wrap: nowrap;
|
|
104
|
+
gap: 8px;
|
|
105
|
+
padding-top: 5px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.configureArea {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: flex-start;
|
|
112
|
+
}
|
|
96
113
|
|
|
97
114
|
:global .semi-aiChatInput-footer-action-send {
|
|
98
115
|
background-color: var(--theme-primary, #4086ff);
|
|
99
116
|
}
|
|
100
117
|
:global .semi-aiChatInput-footer-action-send-disabled {
|
|
101
118
|
background-color: rgba(46, 50, 56, 0.1294117647);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.agentContainer {
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: flex-start;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.agentItem {
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
padding: 6px 12px;
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
font-size: 13px;
|
|
133
|
+
}
|
|
134
|
+
.agentItem:hover {
|
|
135
|
+
border-radius: 8px;
|
|
136
|
+
background-color: #F2F3F7;
|
|
137
|
+
}
|
|
138
|
+
.agentItem.active {
|
|
139
|
+
border-radius: 8px;
|
|
140
|
+
background-color: var(--theme-primary-pale, #F0F8FF);
|
|
141
|
+
color: var(--theme-primary, #4086ff);
|
|
142
|
+
}
|
|
143
|
+
.agentItem img {
|
|
144
|
+
width: 16px;
|
|
145
|
+
height: 16px;
|
|
146
|
+
margin-right: 4px;
|
|
147
|
+
}
|
|
148
|
+
.agentItem .agentName {
|
|
149
|
+
max-width: 100px;
|
|
150
|
+
overflow: hidden;
|
|
151
|
+
text-overflow: ellipsis;
|
|
152
|
+
white-space: nowrap;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.agentPopover {
|
|
156
|
+
padding: 4px;
|
|
157
|
+
}
|
|
158
|
+
.agentPopover .agentItem {
|
|
159
|
+
padding: 6px 4px;
|
|
102
160
|
}
|