@zero-library/chat-agent 2.4.0 → 2.4.1
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 +17 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.esm.js +17 -17
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -229,10 +229,6 @@ interface MessageSender {
|
|
|
229
229
|
interface ConversationMessage {
|
|
230
230
|
/** 会话ID */
|
|
231
231
|
conversationId: string;
|
|
232
|
-
/** 会话标题(WebSocket返回时可能包含) */
|
|
233
|
-
conversationTitle?: string;
|
|
234
|
-
/** 消息类型:WebSocket流式消息类型 */
|
|
235
|
-
type?: 'TEXT_MESSAGE_START' | 'STEP_STARTED' | 'TEXT_MESSAGE_CONTENT' | 'TEXT_MESSAGE_END' | 'RUN_ERROR' | 'TEXT_MESSAGE_CITATION';
|
|
236
232
|
/** 消息ID */
|
|
237
233
|
id: string;
|
|
238
234
|
/** 消息内容 */
|
|
@@ -245,14 +241,26 @@ interface ConversationMessage {
|
|
|
245
241
|
quoteMsg?: MessageQuoteMsg;
|
|
246
242
|
/** 透传参数 json字符串 */
|
|
247
243
|
params?: string;
|
|
248
|
-
/**
|
|
249
|
-
|
|
244
|
+
/** 消息体额外参数 */
|
|
245
|
+
msgExtra?: {
|
|
246
|
+
/** 大模型引用到的数据列表*/
|
|
247
|
+
citations?: any[];
|
|
248
|
+
/** 是否获取推荐问题 */
|
|
249
|
+
sug?: 0 | 1;
|
|
250
|
+
[key: string]: any;
|
|
251
|
+
};
|
|
250
252
|
/** 发送者信息 */
|
|
251
253
|
sender?: MessageSender;
|
|
252
254
|
/** 发送时间戳 */
|
|
253
255
|
sendTime: number;
|
|
254
256
|
/** 是否被打断标志 */
|
|
255
257
|
stopFlag?: boolean;
|
|
258
|
+
/** 会话标题(WebSocket返回时可能包含) */
|
|
259
|
+
conversationTitle?: string;
|
|
260
|
+
/** 消息类型:WebSocket流式消息类型
|
|
261
|
+
* @description TEXT_MESSAGE_CITATION 渲染需要的额外参数,历史问题不一定是引用数据
|
|
262
|
+
*/
|
|
263
|
+
type?: 'TEXT_MESSAGE_START' | 'STEP_STARTED' | 'TEXT_MESSAGE_CONTENT' | 'TEXT_MESSAGE_END' | 'RUN_ERROR' | 'TEXT_MESSAGE_CITATION';
|
|
256
264
|
/** 临时Content数据 用于存储step和error信息 */
|
|
257
265
|
tempContent?: string;
|
|
258
266
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -229,10 +229,6 @@ interface MessageSender {
|
|
|
229
229
|
interface ConversationMessage {
|
|
230
230
|
/** 会话ID */
|
|
231
231
|
conversationId: string;
|
|
232
|
-
/** 会话标题(WebSocket返回时可能包含) */
|
|
233
|
-
conversationTitle?: string;
|
|
234
|
-
/** 消息类型:WebSocket流式消息类型 */
|
|
235
|
-
type?: 'TEXT_MESSAGE_START' | 'STEP_STARTED' | 'TEXT_MESSAGE_CONTENT' | 'TEXT_MESSAGE_END' | 'RUN_ERROR' | 'TEXT_MESSAGE_CITATION';
|
|
236
232
|
/** 消息ID */
|
|
237
233
|
id: string;
|
|
238
234
|
/** 消息内容 */
|
|
@@ -245,14 +241,26 @@ interface ConversationMessage {
|
|
|
245
241
|
quoteMsg?: MessageQuoteMsg;
|
|
246
242
|
/** 透传参数 json字符串 */
|
|
247
243
|
params?: string;
|
|
248
|
-
/**
|
|
249
|
-
|
|
244
|
+
/** 消息体额外参数 */
|
|
245
|
+
msgExtra?: {
|
|
246
|
+
/** 大模型引用到的数据列表*/
|
|
247
|
+
citations?: any[];
|
|
248
|
+
/** 是否获取推荐问题 */
|
|
249
|
+
sug?: 0 | 1;
|
|
250
|
+
[key: string]: any;
|
|
251
|
+
};
|
|
250
252
|
/** 发送者信息 */
|
|
251
253
|
sender?: MessageSender;
|
|
252
254
|
/** 发送时间戳 */
|
|
253
255
|
sendTime: number;
|
|
254
256
|
/** 是否被打断标志 */
|
|
255
257
|
stopFlag?: boolean;
|
|
258
|
+
/** 会话标题(WebSocket返回时可能包含) */
|
|
259
|
+
conversationTitle?: string;
|
|
260
|
+
/** 消息类型:WebSocket流式消息类型
|
|
261
|
+
* @description TEXT_MESSAGE_CITATION 渲染需要的额外参数,历史问题不一定是引用数据
|
|
262
|
+
*/
|
|
263
|
+
type?: 'TEXT_MESSAGE_START' | 'STEP_STARTED' | 'TEXT_MESSAGE_CONTENT' | 'TEXT_MESSAGE_END' | 'RUN_ERROR' | 'TEXT_MESSAGE_CITATION';
|
|
256
264
|
/** 临时Content数据 用于存储step和error信息 */
|
|
257
265
|
tempContent?: string;
|
|
258
266
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -134,13 +134,9 @@ var init_IndexQuote = __esm({
|
|
|
134
134
|
IndexQuote_default = ({ data, loading, message: message2 }) => {
|
|
135
135
|
const [open, setOpen] = useState(false);
|
|
136
136
|
const citation = useMemo(() => {
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
citations = JSON.parse(message2.citations);
|
|
140
|
-
} catch (e) {
|
|
141
|
-
}
|
|
137
|
+
const citations = message2.msgExtra?.citations ?? [];
|
|
142
138
|
return citations?.find((item) => String(item.citationId) === String(data.citationId));
|
|
143
|
-
}, [data.citationId, message2.citations]);
|
|
139
|
+
}, [data.citationId, message2.msgExtra?.citations]);
|
|
144
140
|
const onClick = () => {
|
|
145
141
|
if (!citation?.citationUrl) return;
|
|
146
142
|
if (isExternal(citation.citationUrl)) {
|
|
@@ -420,7 +416,7 @@ var createChatService = (request) => {
|
|
|
420
416
|
return request.delete("/lolr/label/item", { id });
|
|
421
417
|
};
|
|
422
418
|
const labelsQuery = (params) => {
|
|
423
|
-
return request.
|
|
419
|
+
return request.post("/lolr/label", params);
|
|
424
420
|
};
|
|
425
421
|
const labelItemsQuery = (params) => {
|
|
426
422
|
return request.get("/lolr/label/item", params);
|
|
@@ -858,16 +854,17 @@ function createChatStore() {
|
|
|
858
854
|
conversation.messages[conversationId].questionList = [];
|
|
859
855
|
}
|
|
860
856
|
};
|
|
861
|
-
const getQuestionList = async (
|
|
857
|
+
const getQuestionList = async (message2) => {
|
|
858
|
+
if (message2?.msgExtra?.sug === 0) return;
|
|
862
859
|
if (receiver.active.feature?.prompts === false) return;
|
|
863
|
-
const messages = conversation.messages[conversationId]?.message;
|
|
860
|
+
const messages = conversation.messages[message2.conversationId]?.message;
|
|
864
861
|
if (!messages?.length) return;
|
|
865
862
|
let lastMessage = messages[messages.length - 1];
|
|
866
|
-
if (!lastMessage || lastMessage.sender.type !== 3 || lastMessage.id !==
|
|
867
|
-
const { data } = await config.services.request.messageSuggestedQuery(
|
|
863
|
+
if (!lastMessage || lastMessage.sender.type !== 3 || lastMessage.id !== message2.id) return;
|
|
864
|
+
const { data } = await config.services.request.messageSuggestedQuery(message2.id);
|
|
868
865
|
lastMessage = messages[messages.length - 1];
|
|
869
|
-
if (lastMessage.id !==
|
|
870
|
-
conversation.messages[conversationId].questionList = data;
|
|
866
|
+
if (lastMessage.id !== message2.id) return;
|
|
867
|
+
conversation.messages[message2.conversationId].questionList = data;
|
|
871
868
|
};
|
|
872
869
|
const getRecommendQuestions = async (conversationId) => {
|
|
873
870
|
if (conversationId === conversation.active.id && conversation.active.member.agent?.memberId && !conversation.messages[conversationId].message.length) {
|
|
@@ -1116,16 +1113,19 @@ function createChatStore() {
|
|
|
1116
1113
|
type: void 0
|
|
1117
1114
|
};
|
|
1118
1115
|
conversation.messages[msg.conversationId].loading = false;
|
|
1119
|
-
getQuestionList(
|
|
1116
|
+
getQuestionList(messages[idx]);
|
|
1120
1117
|
};
|
|
1121
|
-
const
|
|
1118
|
+
const extraMsgCallback = (msg) => {
|
|
1122
1119
|
const messages = conversation.messages[msg.conversationId]?.message;
|
|
1123
1120
|
const idx = findMsgIndex(msg.id, messages);
|
|
1124
1121
|
if (idx === -1) return;
|
|
1125
1122
|
conversation.messages[msg.conversationId].loading = true;
|
|
1126
1123
|
messages[idx] = {
|
|
1127
1124
|
...messages[idx],
|
|
1128
|
-
|
|
1125
|
+
msgExtra: {
|
|
1126
|
+
...messages[idx]?.msgExtra,
|
|
1127
|
+
...msg.msgExtra
|
|
1128
|
+
}
|
|
1129
1129
|
};
|
|
1130
1130
|
};
|
|
1131
1131
|
const errCallback = (msg) => {
|
|
@@ -1163,7 +1163,7 @@ function createChatStore() {
|
|
|
1163
1163
|
endCallback(newMessage.data);
|
|
1164
1164
|
break;
|
|
1165
1165
|
case "TEXT_MESSAGE_CITATION":
|
|
1166
|
-
|
|
1166
|
+
extraMsgCallback(newMessage.data);
|
|
1167
1167
|
break;
|
|
1168
1168
|
case "RUN_ERROR":
|
|
1169
1169
|
errCallback(newMessage.data);
|