@myun/gimi-chat 0.9.64 → 0.9.65
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.d.ts +0 -6
- package/dist/apis/useApi.js +1 -45
- package/dist/components/ai-chat-dialogue/index copy.js +1 -1
- package/dist/components/ai-chat-dialogue/index.js +2 -4
- package/dist/components/answer-item/index.d.ts +1 -2
- package/dist/components/answer-item/index.js +8 -179
- package/dist/components/answer-item/index.module.css +0 -35
- package/dist/components/ask-card/index.d.ts +1 -1
- package/dist/components/chat-input/extension/index.d.ts +0 -1
- package/dist/components/chat-input/extension/index.js +1 -2
- package/dist/components/chat-input/index.js +24 -145
- package/dist/components/chat-input/index.module.css +0 -6
- package/dist/components/file-card/index.js +1 -2
- package/dist/components/file-card/index.module.css +0 -1
- package/dist/components/knowledge-trace/KnowledgeIconComponent.js +1 -6
- package/dist/components/knowledge-trace/tryWatch.js +2 -2
- package/dist/components/message-list/index.js +3 -15
- package/dist/components/message-list/index.module.css +0 -3
- package/dist/components/templates/CommonChat.js +1 -3
- package/dist/hooks/useChatActions.d.ts +1 -2
- package/dist/hooks/useChatActions.js +12 -52
- package/dist/hooks/useChatStream.d.ts +1 -6
- package/dist/hooks/useChatStream.js +5 -97
- package/dist/hooks/useCommonChatAPI.d.ts +1 -1
- package/dist/hooks/useCommonChatAPI.js +58 -212
- package/dist/i18n/locales/en-US.d.ts +0 -7
- package/dist/i18n/locales/en-US.js +1 -8
- package/dist/i18n/locales/zh-CN.d.ts +0 -7
- package/dist/i18n/locales/zh-CN.js +1 -8
- package/dist/interfaces/chatMessage.d.ts +0 -40
- package/dist/umd/index.min.js +1 -1
- package/dist/utils/tools.d.ts +0 -7
- package/dist/utils/tools.js +1 -38
- package/package.json +2 -4
- package/dist/components/answer-item/component/artifacts/index.d.ts +0 -13
- package/dist/components/answer-item/component/artifacts/index.js +0 -52
- package/dist/components/answer-item/component/artifacts/index.module.css +0 -24
- package/dist/components/answer-item/component/tool-list/index.d.ts +0 -7
- package/dist/components/answer-item/component/tool-list/index.js +0 -117
- package/dist/components/answer-item/component/tool-list/index.module.css +0 -97
- package/dist/components/chat-input/extension/skill/MentionList.d.ts +0 -31
- package/dist/components/chat-input/extension/skill/MentionList.js +0 -199
- package/dist/components/chat-input/extension/skill/ReferSlot.d.ts +0 -3
- package/dist/components/chat-input/extension/skill/ReferSlot.js +0 -100
- package/dist/components/chat-input/extension/skill/data.d.ts +0 -10
- package/dist/components/chat-input/extension/skill/data.js +0 -49
- package/dist/components/chat-input/extension/skill/index.d.ts +0 -7
- package/dist/components/chat-input/extension/skill/index.js +0 -5
- package/dist/components/chat-input/extension/skill/index.less +0 -117
- package/dist/components/chat-input/extension/skill/suggestion.d.ts +0 -16
- package/dist/components/chat-input/extension/skill/suggestion.js +0 -206
- package/dist/components/message-list/skill-tag/index.d.ts +0 -5
- package/dist/components/message-list/skill-tag/index.js +0 -23
- package/dist/components/message-list/skill-tag/index.module.css +0 -22
|
@@ -15,76 +15,6 @@ import { useLastEventId } from "./useLastEventId";
|
|
|
15
15
|
import { useAppSelector, useAppDispatch } from "../store/hooks";
|
|
16
16
|
import { setIsMsgRecieving } from "../store/slices/gimiMenuSlice";
|
|
17
17
|
import { getTimeZone } from "../utils/tools";
|
|
18
|
-
|
|
19
|
-
// 需要展示为工具调用的模块类型
|
|
20
|
-
export var TOOL_MODULE_TYPES = ['tool_invocation', 'tool_result', "thinking"
|
|
21
|
-
// 'start', 'llm', 'knowledge', 'video', 'image-text',
|
|
22
|
-
// 'input', 'if-select', 'intent', 'talk', 'text',
|
|
23
|
-
// 'video-caption', 'summary', 'loop', 'skillBase',
|
|
24
|
-
// 'break', 'http', 'esKnowledge', 'mcp'
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
// 所有需要进入处理流程的模块类型(包括工具类型 + 特殊处理类型)
|
|
28
|
-
var PROCESSABLE_MODULE_TYPES = [].concat(TOOL_MODULE_TYPES, ['end', 'ask', 'skill', 'tool_call', 'artifact', 'user_confirm', 'COMPLETED']);
|
|
29
|
-
|
|
30
|
-
// 模块类型到工具名称的映射
|
|
31
|
-
export var MODULE_TYPE_NAMES = {
|
|
32
|
-
'start': '开始节点',
|
|
33
|
-
'end': '结束节点',
|
|
34
|
-
'llm': '模型节点',
|
|
35
|
-
'knowledge': '知识库节点',
|
|
36
|
-
'video': '视频节点',
|
|
37
|
-
'image-text': '图文节点',
|
|
38
|
-
'input': '输入节点',
|
|
39
|
-
'if-select': '选择节点',
|
|
40
|
-
'intent': '意图识别节点',
|
|
41
|
-
'talk': '讨论节点',
|
|
42
|
-
'ask': '问答节点',
|
|
43
|
-
'text': '文本处理节点',
|
|
44
|
-
'video-caption': '视频字幕节点',
|
|
45
|
-
'summary': '章节总结节点',
|
|
46
|
-
'loop': '循环节点',
|
|
47
|
-
'skill': '技能节点',
|
|
48
|
-
'skillBase': '通用技能节点',
|
|
49
|
-
'break': '终止循环节点',
|
|
50
|
-
'http': 'HTTP节点',
|
|
51
|
-
'esKnowledge': '知识库节点',
|
|
52
|
-
'mcp': 'MCP节点'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// 根据 moduleType 和 status 生成 toolName
|
|
56
|
-
export var getToolNameByStatus = function getToolNameByStatus(moduleType, status) {
|
|
57
|
-
// thinking 类型定制文案
|
|
58
|
-
if (moduleType === 'thinking') {
|
|
59
|
-
if (status === 'STARTED') {
|
|
60
|
-
return '开始分析问题';
|
|
61
|
-
} else if (status === 'RUNNING') {
|
|
62
|
-
return '正在分析问题';
|
|
63
|
-
} else if (status === 'COMPLETED') {
|
|
64
|
-
return '已完成分析';
|
|
65
|
-
}
|
|
66
|
-
return '深度思考';
|
|
67
|
-
}
|
|
68
|
-
var baseName = MODULE_TYPE_NAMES[moduleType] || moduleType;
|
|
69
|
-
if (!status) {
|
|
70
|
-
return baseName;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 根据状态生成描述
|
|
74
|
-
if (status === 'STARTED') {
|
|
75
|
-
return "\u5F00\u59CB\u8FD0\u884C".concat(baseName);
|
|
76
|
-
} else if (status === 'COMPLETED') {
|
|
77
|
-
return "".concat(baseName, "\u8FD0\u884C\u5B8C\u6210");
|
|
78
|
-
} else if (status === 'RUNNING') {
|
|
79
|
-
return "".concat(baseName, "\u8FD0\u884C\u4E2D");
|
|
80
|
-
} else if (status === 'PENDING') {
|
|
81
|
-
return "".concat(baseName, "\u7B49\u5F85\u4E2D");
|
|
82
|
-
} else if (status === 'FAILED') {
|
|
83
|
-
return "".concat(baseName, "\u8FD0\u884C\u5931\u8D25");
|
|
84
|
-
} else {
|
|
85
|
-
return baseName;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
18
|
/**
|
|
89
19
|
* 处理流式聊天逻辑
|
|
90
20
|
*/
|
|
@@ -135,8 +65,6 @@ export var useChatStream = function useChatStream(platform) {
|
|
|
135
65
|
onComplete,
|
|
136
66
|
onErrorComplete,
|
|
137
67
|
onMCPToolsStream,
|
|
138
|
-
onToolStream,
|
|
139
|
-
onArtifactStream,
|
|
140
68
|
signal,
|
|
141
69
|
currentLastEventId,
|
|
142
70
|
url,
|
|
@@ -150,7 +78,7 @@ export var useChatStream = function useChatStream(platform) {
|
|
|
150
78
|
callbacks = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
151
79
|
method = _args.length > 3 ? _args[3] : undefined;
|
|
152
80
|
requestUrl = _args.length > 4 ? _args[4] : undefined;
|
|
153
|
-
onSseOpen = callbacks.onSseOpen, onDataReceived = callbacks.onDataReceived, onComplete = callbacks.onComplete, onErrorComplete = callbacks.onErrorComplete, onMCPToolsStream = callbacks.onMCPToolsStream
|
|
81
|
+
onSseOpen = callbacks.onSseOpen, onDataReceived = callbacks.onDataReceived, onComplete = callbacks.onComplete, onErrorComplete = callbacks.onErrorComplete, onMCPToolsStream = callbacks.onMCPToolsStream; // 中止之前的请求
|
|
154
82
|
if (esAbortRef.current) {
|
|
155
83
|
esAbortRef.current.abort();
|
|
156
84
|
}
|
|
@@ -214,8 +142,7 @@ export var useChatStream = function useChatStream(platform) {
|
|
|
214
142
|
if (messageId && event.id) {
|
|
215
143
|
saveLastEventId(messageId, event.id);
|
|
216
144
|
}
|
|
217
|
-
if (data.status === 0 && data.result &&
|
|
218
|
-
console.log('dataObj-----', _dataObj);
|
|
145
|
+
if (data.status === 0 && data.result && ['end', 'ask', 'skill', 'tool_call', 'COMPLETED'].includes(_dataObj.moduleType) && !_dataObj.ERROR) {
|
|
219
146
|
if (_dataObj.status === 'RUNNING' && _dataObj.moduleType === 'end') {
|
|
220
147
|
if (_dataObj.content && !_dataObj.reasoningContent) {
|
|
221
148
|
fullResponse += _dataObj.content;
|
|
@@ -228,33 +155,15 @@ export var useChatStream = function useChatStream(platform) {
|
|
|
228
155
|
if (_dataObj.moduleType === 'tool_call') {
|
|
229
156
|
onMCPToolsStream === null || onMCPToolsStream === void 0 || onMCPToolsStream(_dataObj);
|
|
230
157
|
}
|
|
231
|
-
|
|
232
|
-
// 工具调用
|
|
233
|
-
if (TOOL_MODULE_TYPES.includes(_dataObj.moduleType) && !["execute", "notifyWorkflowStart"].includes(_dataObj.name)) {
|
|
234
|
-
// console.log('dataObj',dataObj);
|
|
235
|
-
onToolStream === null || onToolStream === void 0 || onToolStream(_dataObj);
|
|
236
|
-
}
|
|
237
|
-
// 生成产物
|
|
238
|
-
if (_dataObj.moduleType === 'artifact' && _dataObj.status === 'COMPLETED') {
|
|
239
|
-
onArtifactStream === null || onArtifactStream === void 0 || onArtifactStream(_dataObj);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// 问答确认
|
|
243
158
|
if ((_dataObj.moduleType === 'ask' || _dataObj.moduleType === 'skill') && _dataObj.status === 'PENDING') {
|
|
244
159
|
onComplete === null || onComplete === void 0 || onComplete(_dataObj, _dataObj.moduleType);
|
|
245
160
|
return;
|
|
246
161
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
onComplete === null || onComplete === void 0 || onComplete(
|
|
162
|
+
if (_dataObj.status === 'COMPLETED' && _dataObj.moduleType === 'end' || _dataObj.moduleType === 'COMPLETED') {
|
|
163
|
+
removeLastEventId(messageId);
|
|
164
|
+
onComplete === null || onComplete === void 0 || onComplete(fullResponse, _dataObj.moduleType, reasoningResponse);
|
|
250
165
|
return;
|
|
251
166
|
}
|
|
252
|
-
} else if (_dataObj.moduleType === 'agent' && _dataObj.status === 'STARTED') {
|
|
253
|
-
onToolStream === null || onToolStream === void 0 || onToolStream(_dataObj);
|
|
254
|
-
} else if (_dataObj.moduleType === 'agent' && _dataObj.status === 'COMPLETED' || _dataObj.type === 'WORKFLOW_COMPLETED') {
|
|
255
|
-
removeLastEventId(messageId);
|
|
256
|
-
onComplete === null || onComplete === void 0 || onComplete(fullResponse, 'end', reasoningResponse, _dataObj);
|
|
257
|
-
return;
|
|
258
167
|
} else if (_dataObj.ERROR || _dataObj.moduleType === 'FAILED') {
|
|
259
168
|
var isRefresh = parseInt(_dataObj.status, 10) === 10002026;
|
|
260
169
|
if (isRefresh) {
|
|
@@ -298,7 +207,6 @@ export var useChatStream = function useChatStream(platform) {
|
|
|
298
207
|
dispatch(setIsMsgRecieving({
|
|
299
208
|
isMsgRecieving: false
|
|
300
209
|
}));
|
|
301
|
-
esAbortRef.current = null; // 清空,避免残留
|
|
302
210
|
console.log('流式结束');
|
|
303
211
|
}
|
|
304
212
|
}));
|
|
@@ -33,7 +33,7 @@ declare const useCommonChatAPI: (props: IHookProps) => {
|
|
|
33
33
|
getContentMessageList: (pageIndex?: number, curPageSize?: number) => Promise<void>;
|
|
34
34
|
hasMore: React.MutableRefObject<boolean>;
|
|
35
35
|
loadMore: () => void;
|
|
36
|
-
handleSend: (val: string, agent?: any, isSystemAuto?: boolean, conversationId?: number
|
|
36
|
+
handleSend: (val: string, agent?: any, isSystemAuto?: boolean, conversationId?: number) => Promise<void>;
|
|
37
37
|
scrollBottomForce: (animate?: boolean | undefined) => void;
|
|
38
38
|
showBackBottom: boolean;
|
|
39
39
|
isScrolling: boolean;
|