@zero-library/chat-agent 2.4.0 → 2.4.2

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.cjs.js CHANGED
@@ -142,13 +142,9 @@ var init_IndexQuote = __esm({
142
142
  IndexQuote_default = ({ data, loading, message: message2 }) => {
143
143
  const [open, setOpen] = react.useState(false);
144
144
  const citation = react.useMemo(() => {
145
- let citations = [];
146
- try {
147
- citations = JSON.parse(message2.citations);
148
- } catch (e) {
149
- }
145
+ const citations = message2.msgExtra?.citations ?? [];
150
146
  return citations?.find((item) => String(item.citationId) === String(data.citationId));
151
- }, [data.citationId, message2.citations]);
147
+ }, [data.citationId, message2.msgExtra?.citations]);
152
148
  const onClick = () => {
153
149
  if (!citation?.citationUrl) return;
154
150
  if (common.isExternal(citation.citationUrl)) {
@@ -428,7 +424,7 @@ var createChatService = (request) => {
428
424
  return request.delete("/lolr/label/item", { id });
429
425
  };
430
426
  const labelsQuery = (params) => {
431
- return request.get("/lolr/label", params);
427
+ return request.post("/lolr/label", params);
432
428
  };
433
429
  const labelItemsQuery = (params) => {
434
430
  return request.get("/lolr/label/item", params);
@@ -866,16 +862,17 @@ function createChatStore() {
866
862
  conversation.messages[conversationId].questionList = [];
867
863
  }
868
864
  };
869
- const getQuestionList = async (conversationId, messageId) => {
865
+ const getQuestionList = async (message2) => {
866
+ if (message2?.msgExtra?.sug === 0) return;
870
867
  if (receiver.active.feature?.prompts === false) return;
871
- const messages = conversation.messages[conversationId]?.message;
868
+ const messages = conversation.messages[message2.conversationId]?.message;
872
869
  if (!messages?.length) return;
873
870
  let lastMessage = messages[messages.length - 1];
874
- if (!lastMessage || lastMessage.sender.type !== 3 || lastMessage.id !== messageId) return;
875
- const { data } = await config.services.request.messageSuggestedQuery(messageId);
871
+ if (!lastMessage || lastMessage.sender.type !== 3 || lastMessage.id !== message2.id) return;
872
+ const { data } = await config.services.request.messageSuggestedQuery(message2.id);
876
873
  lastMessage = messages[messages.length - 1];
877
- if (lastMessage.id !== messageId) return;
878
- conversation.messages[conversationId].questionList = data;
874
+ if (lastMessage.id !== message2.id) return;
875
+ conversation.messages[message2.conversationId].questionList = data;
879
876
  };
880
877
  const getRecommendQuestions = async (conversationId) => {
881
878
  if (conversationId === conversation.active.id && conversation.active.member.agent?.memberId && !conversation.messages[conversationId].message.length) {
@@ -1124,16 +1121,19 @@ function createChatStore() {
1124
1121
  type: void 0
1125
1122
  };
1126
1123
  conversation.messages[msg.conversationId].loading = false;
1127
- getQuestionList(msg.conversationId, msg.id);
1124
+ getQuestionList(messages[idx]);
1128
1125
  };
1129
- const citationCallback = (msg) => {
1126
+ const extraMsgCallback = (msg) => {
1130
1127
  const messages = conversation.messages[msg.conversationId]?.message;
1131
1128
  const idx = findMsgIndex(msg.id, messages);
1132
1129
  if (idx === -1) return;
1133
1130
  conversation.messages[msg.conversationId].loading = true;
1134
1131
  messages[idx] = {
1135
1132
  ...messages[idx],
1136
- citations: msg.msgContent
1133
+ msgExtra: {
1134
+ ...messages[idx]?.msgExtra,
1135
+ ...msg.msgExtra
1136
+ }
1137
1137
  };
1138
1138
  };
1139
1139
  const errCallback = (msg) => {
@@ -1171,7 +1171,7 @@ function createChatStore() {
1171
1171
  endCallback(newMessage.data);
1172
1172
  break;
1173
1173
  case "TEXT_MESSAGE_CITATION":
1174
- citationCallback(newMessage.data);
1174
+ extraMsgCallback(newMessage.data);
1175
1175
  break;
1176
1176
  case "RUN_ERROR":
1177
1177
  errCallback(newMessage.data);