@myun/gimi-chat 0.1.3 → 0.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.
@@ -36,7 +36,6 @@ export default Node.create({
36
36
  renderHTML: function renderHTML(_ref) {
37
37
  var node = _ref.node,
38
38
  HTMLAttributes = _ref.HTMLAttributes;
39
- console.log('HTMLAttributes', node, HTMLAttributes);
40
39
  return ['title-slot', mergeAttributes(HTMLAttributes)];
41
40
  },
42
41
  addNodeView: function addNodeView() {
@@ -7,6 +7,7 @@ export interface ChatInputRef {
7
7
  }
8
8
  interface IAIInputProps {
9
9
  placeholder?: string;
10
+ platform?: string;
10
11
  defaultPrompt?: string;
11
12
  disabled?: boolean;
12
13
  onBeforeSend?: (text: string) => void;
@@ -226,7 +226,8 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
226
226
  content: '新对话',
227
227
  conversationType: agentObjRef.current.conversationType,
228
228
  botId: agentObjRef.current.botId,
229
- isSystemAuto: 1
229
+ isSystemAuto: 1,
230
+ preview: props.platform === 'preview' ? 1 : 0
230
231
  };
231
232
  _context.prev = 13;
232
233
  _context.next = 16;
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2
2
  import React from 'react';
3
3
  import { store } from "../../store";
4
4
  import { useAppDispatch, useAppSelector } from "../../store/hooks";
5
- import { setBaseUrl, setToken, setPlatform, setConversationId, setAgentDetail, setBussinessParams } from "../../store/slices/gimiMenuSlice";
5
+ import { setBaseUrl, setToken, setPlatform, setConversationId, setAgentDetail, setBussinessParams, setMessageList } from "../../store/slices/gimiMenuSlice";
6
6
  import useCommonChatAPI from "../../hooks/useCommonChatAPI";
7
7
  import { replaceBraces } from "../../utils/tools";
8
8
  import styles from "./index.module.css";
@@ -49,6 +49,7 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
49
49
  var dispatch = useAppDispatch();
50
50
  var containerRef = React.useRef(null);
51
51
  var chatInputRef = React.useRef(null);
52
+ var resetKeyRef = React.useRef('');
52
53
  var messageList = useAppSelector(function (state) {
53
54
  return state.gimiMenu.messageList;
54
55
  });
@@ -71,7 +72,7 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
71
72
  playTTSByText = _useChatVoice.playTTSByText,
72
73
  stopTTSByText = _useChatVoice.stopTTSByText,
73
74
  isPlaying = _useChatVoice.isPlaying;
74
- var _useCommonChatAPI = useCommonChatAPI(containerRef, businessType, stopTTSByText, isPlaying, agentId, (_props$chatInputConfi2 = props.chatInputConfig) === null || _props$chatInputConfi2 === void 0 ? void 0 : _props$chatInputConfi2.onConversationCreated, (_props$chatInputConfi3 = props.chatInputConfig) === null || _props$chatInputConfi3 === void 0 ? void 0 : _props$chatInputConfi3.onSendEnd),
75
+ var _useCommonChatAPI = useCommonChatAPI(containerRef, platform, stopTTSByText, isPlaying, agentId, (_props$chatInputConfi2 = props.chatInputConfig) === null || _props$chatInputConfi2 === void 0 ? void 0 : _props$chatInputConfi2.onConversationCreated, (_props$chatInputConfi3 = props.chatInputConfig) === null || _props$chatInputConfi3 === void 0 ? void 0 : _props$chatInputConfi3.onSendEnd),
75
76
  headerValue = _useCommonChatAPI.headerValue,
76
77
  msgLoading = _useCommonChatAPI.msgLoading,
77
78
  onSucessExcel = _useCommonChatAPI.onSucessExcel,
@@ -119,6 +120,17 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
119
120
  bussinessParams: bussinessParams || {}
120
121
  }));
121
122
  }, [baseUrl, token, agentDetail, platform, conversationId, bussinessParams]);
123
+ React.useEffect(function () {
124
+ if (props.resetkey !== resetKeyRef.current) {
125
+ resetKeyRef.current = props.resetkey || '';
126
+ dispatch(setConversationId({
127
+ conversationId: null
128
+ }));
129
+ dispatch(setMessageList({
130
+ messageList: []
131
+ }));
132
+ }
133
+ }, [props.resetkey]);
122
134
  React.useEffect(function () {
123
135
  if (bussinessParams !== null && bussinessParams !== void 0 && bussinessParams.QUESTION_ID && bussinessParams !== null && bussinessParams !== void 0 && bussinessParams.ANSWER_ID && businessType === 'correction' && storedBaseUrl && storedToken) {
124
136
  startAICorrection(bussinessParams.ANSWER_ID, bussinessParams.QUESTION_ID);
@@ -200,6 +212,7 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
200
212
  }, chatInputConfig, {
201
213
  onSend: handleInputSend,
202
214
  disabled: disableSend || isMoreLoading,
215
+ placeholder: (agentObj === null || agentObj === void 0 ? void 0 : agentObj.inputPrompt) || '',
203
216
  defaultPrompt: messageList.length > 0 ? '' : (agentObj === null || agentObj === void 0 ? void 0 : agentObj.defaultPrompt) || '',
204
217
  titleSlot: messageList.length > 0 ? '' : (agentObj === null || agentObj === void 0 ? void 0 : agentObj.agentName) || '',
205
218
  showDefaultPrompt: messageList.length === 0
@@ -212,7 +225,8 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
212
225
  asrText: asrText,
213
226
  shortAsrClick: shortAsrClick,
214
227
  disableVoiceCommunication: disableVoiceCommunication,
215
- onHistoryReload: onHistoryReload
228
+ onHistoryReload: onHistoryReload,
229
+ platform: platform
216
230
  }, props.chatInputConfig)), showPrologue && messageList.length === 0 && !isMoreLoading && quickQuestionListPosition === 'bottom' && /*#__PURE__*/React.createElement(PresetAgentContent, {
217
231
  prologue: '',
218
232
  questionList: (agentObj === null || agentObj === void 0 ? void 0 : agentObj.questionList) || [],
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IChatMessageItem } from "../interfaces/chatMessage";
3
- declare const useCommonChatAPI: (containerRef: React.RefObject<HTMLDivElement>, businessType: string, stopTTSByText?: () => void, isPlaying?: boolean, agentId?: number, onConversationCreated?: ((conversationId: number) => void) | undefined, onSendEnd?: ((message: IChatMessageItem) => void) | undefined) => {
3
+ declare const useCommonChatAPI: (containerRef: React.RefObject<HTMLDivElement>, platform: string, stopTTSByText?: () => void, isPlaying?: boolean, agentId?: number, onConversationCreated?: ((conversationId: number) => void) | undefined, onSendEnd?: ((message: IChatMessageItem) => void) | undefined) => {
4
4
  headerValue: string;
5
5
  getHeaderValue: (conversationId: number) => Promise<void>;
6
6
  msgLoading: boolean;
@@ -32,7 +32,7 @@ import { useChatRecommend } from "./useChatRecommend";
32
32
  import { set, cloneDeep } from 'lodash';
33
33
  import { FileStatus } from "../interfaces/fileInterface";
34
34
  import useChatHistory from "./useChatHistory";
35
- var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, stopTTSByText, isPlaying, agentId, onConversationCreated, onSendEnd) {
35
+ var useCommonChatAPI = function useCommonChatAPI(containerRef, platform, stopTTSByText, isPlaying, agentId, onConversationCreated, onSendEnd) {
36
36
  var _useApi = useApi(),
37
37
  getMessageTitle = _useApi.getMessageTitle,
38
38
  stopStreamOut = _useApi.stopStreamOut,
@@ -383,7 +383,7 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
383
383
  },
384
384
  onComplete: function onComplete(response, type) {
385
385
  if (type === 'end' || type === 'COMPLETED') {
386
- if (businessType === 'correction') {
386
+ if (platform === 'correction') {
387
387
  fullResponse = "<correction>".concat(fullResponse, "</correction>");
388
388
  }
389
389
  _onComplete(fullResponse, type, reasoningResponse);
@@ -975,7 +975,8 @@ var useCommonChatAPI = function useCommonChatAPI(containerRef, businessType, sto
975
975
  params = _objectSpread({
976
976
  content: value,
977
977
  conversationType: agentObjRef.current.conversationType,
978
- botId: agentObjRef.current.botId
978
+ botId: agentObjRef.current.botId,
979
+ preview: platform === 'preview' ? 1 : 0
979
980
  }, currentBussinessParams);
980
981
  isNewConversationRef.current = true;
981
982
  _context14.prev = 5;
@@ -113,6 +113,7 @@ export interface CommonChatProps {
113
113
  }
114
114
  conversationId?: number;
115
115
  messageConfig?: MessageConfig;
116
+ resetkey?: string;
116
117
  }
117
118
 
118
119
  export interface MessageConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myun/gimi-chat",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "ISC",