yt-chat-components 0.9.7 → 0.9.9-a

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.
@@ -19,8 +19,6 @@ H
19
19
  src/chatWidget/index.tsx,3/6/364385cedcce4c06de1901392ffeeac0caef0f3c
20
20
  =
21
21
 
22
- j
23
- :src/YtChatView/chatWidget/chatWindow/chatMessage/index.tsx,2/e/2e9f70bf32b414323ca1647e2b6f26e1533ee2fc
24
22
  e
25
23
  5src/YtChatView/chatWidget/chatWindow/index.module.css,d/7/d747cbed4201192dfa83a1a51345b020a050b647
26
24
  U
@@ -34,6 +32,4 @@ U
34
32
  A
35
33
  webpack.config.js,d/5/d5595158cc48f9bf3e51b06f6e6805a8fd2d6262
36
34
  S
37
- #src/chatWidget/chatWindow/index.tsx,6/c/6c024c1d0ad64656b9d4b0695ec3c49c0454addf
38
- =
39
-
35
+ #src/chatWidget/chatWindow/index.tsx,6/c/6c024c1d0ad64656b9d4b0695ec3c49c0454addf
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yt-chat-components",
3
- "version": "0.9.7",
3
+ "version": "0.9.9a",
4
4
  "main": "build/static/js/bundle.min.js",
5
5
  "module": "build/static/js/bundle.min.js",
6
6
  "types": "build/static/js/index.d.ts",
@@ -135,6 +135,7 @@ export default function ChatWindow({
135
135
  const {isTitleSideIcon, logoWidth, agentUrl} = baseConfig;
136
136
  const inputContainerRef = useRef(null);
137
137
  const [inputContainerHeight,setInputContainerHeight] = useState('50px')
138
+ const contentRef = useRef(nowAIContent);
138
139
 
139
140
  let voiceChunks = []; // 临时存储录制的语音片段
140
141
  // 滚动事件处理,选择文件时,文件内容超出显示框时,显示左右箭头
@@ -155,16 +156,21 @@ export default function ChatWindow({
155
156
 
156
157
  // 流式输出消息,实时显示(token为流式输出内容,end为结束输出,整体输出一次)
157
158
  const handleMessageContent = (event, data) => {
159
+ // console.error("event, data",event, data)
158
160
  if (event == 'add_message' && data['sender'] == 'Machine') {
159
161
  getHistoryList();
160
162
  } else if (event == 'token') {
161
- setNowAIContent((prevState) => prevState + data['chunk']);
163
+ setNowAIContent((prevState) => {
164
+ const newValue = prevState + data['chunk'];
165
+ contentRef.current = newValue
166
+ return newValue
167
+ });
162
168
  if (lastMessage.current) lastMessage.current.scrollIntoView({ behavior: 'smooth' });
163
- } else if (false && event == 'end') {// 移除end事件的响应
169
+ } else if (event == 'end') {
164
170
  const res = {
165
171
  data: data['result'],
166
172
  };
167
- if (
173
+ if (false&&
168
174
  res.data &&
169
175
  res.data.outputs &&
170
176
  Object.keys(res.data.outputs).length > 0 &&
@@ -217,6 +223,15 @@ export default function ChatWindow({
217
223
  });
218
224
  }
219
225
  }
226
+ const output = {
227
+ message:contentRef.current,
228
+ type:'text'
229
+ };
230
+ addMessage({
231
+ message: extractMessageFromOutput(output),
232
+ isSend: false,
233
+ rawInfo: output.message,
234
+ });
220
235
  setSendingMessage(false);
221
236
  }
222
237
  };
@@ -355,7 +355,7 @@ export class ToolDialog extends React.Component {
355
355
  // 单独组件情况
356
356
  if(isRefreshWords){
357
357
  this.getFlowInfo().then(currentFlow=>{
358
- const dropDownList = this.getDropDownList(currentFlow.welcome_words||[]);
358
+ const dropDownList = this.getDropDownList(currentFlow?.welcome_words||[]);
359
359
  this.setState({ dropDownList, currentFlow })
360
360
  })
361
361
  }
@@ -365,7 +365,7 @@ export class ToolDialog extends React.Component {
365
365
  }else{
366
366
  const currentScene = sceneData||this.state.sceneInfo;
367
367
  const currentFlow = currentScene.flows[0];
368
- const dropDownList = this.getDropDownList(currentFlow.welcome_words||[]);
368
+ const dropDownList = this.getDropDownList(currentFlow?.welcome_words||[]);
369
369
  if(!isEmpty(sceneData)){
370
370
  this.setState({ currentFlow, dropDownList })
371
371
  }else if(isEmpty(this.state.sceneInfo)){
@@ -400,7 +400,7 @@ export class ToolDialog extends React.Component {
400
400
  return;
401
401
  }
402
402
  this.setState({ sessionId: uuidv4() });
403
- this.setState({ dropDownList: this.getDropDownList(this.state.currentFlow.welcome_words||[]) })
403
+ this.setState({ dropDownList: this.getDropDownList(this.state.currentFlow?.welcome_words||[]) })
404
404
  }
405
405
 
406
406
  updateSessionId = (sessionId) => {
@@ -540,7 +540,7 @@ export class ToolDialog extends React.Component {
540
540
  this.setState({
541
541
  sessionId: uuidv4(),
542
542
  currentFlow: item,
543
- dropDownList: this.getDropDownList(item.welcome_words)
543
+ dropDownList: this.getDropDownList(item?.welcome_words||[])
544
544
  });
545
545
  this.getCurrentFlowHistory(item.id);
546
546
  }}>