@touchvue/chat 1.0.0-beta.41 → 1.0.0-beta.43
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/es/package.json.css +1 -1
- package/es/package.json.mjs +1 -1
- package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/AiRobot/letter.vue.mjs +1 -1
- package/es/packages/components/touchchat/component/AiRobot/letter.vue2.mjs +15 -3
- package/es/packages/components/touchchat/component/AiRobot/letter.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/FileContent.vue2.mjs +3 -3
- package/es/packages/components/touchchat/component/FileContent.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/FileView.vue2.mjs +2 -2
- package/es/packages/components/touchchat/component/FileView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/HelloChat.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/ImageFile.vue2.mjs +6 -6
- package/es/packages/components/touchchat/component/ImageFile.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/ImageView.vue2.mjs +1 -1
- package/es/packages/components/touchchat/component/ImageView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/LinkView.vue2.mjs +4 -4
- package/es/packages/components/touchchat/component/LinkView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/MarkLayer.vue2.mjs +1 -1
- package/es/packages/components/touchchat/component/MarkLayer.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/ModuleSelect.vue2.mjs +2 -2
- package/es/packages/components/touchchat/component/ModuleSelect.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/PDFFile.vue2.mjs +8 -8
- package/es/packages/components/touchchat/component/PDFFile.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/RealtimeVoice.vue2.mjs +1 -1
- package/es/packages/components/touchchat/component/RealtimeVoice.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/Screenshot.vue2.mjs +11 -2
- package/es/packages/components/touchchat/component/Screenshot.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/UploadView.vue2.mjs +10 -7
- package/es/packages/components/touchchat/component/UploadView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/component/VoiceView.vue2.mjs +1 -1
- package/es/packages/components/touchchat/component/VoiceView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/AgentsView.vue2.mjs +1 -1
- package/es/packages/components/touchchat/src/AiChat/AgentsView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/AiMessage.vue2.mjs +22 -22
- package/es/packages/components/touchchat/src/AiChat/AiMessage.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.mjs +145 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/types.mjs +18 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/types.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useChat.mjs +672 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useChat.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useCopy.mjs +55 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useCopy.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useMessageRender.mjs +155 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useMessageRender.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useSSE.mjs +352 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useSSE.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useScroll.mjs +74 -0
- package/es/packages/components/touchchat/src/AiChat/Chat/useScroll.mjs.map +1 -0
- package/es/packages/components/touchchat/src/AiChat/ChatInput.vue2.mjs +8 -7
- package/es/packages/components/touchchat/src/AiChat/ChatInput.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/HistoryList.vue2.mjs +1 -1
- package/es/packages/components/touchchat/src/AiChat/HistoryList.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.mjs +3 -3
- package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/MessageActions.vue2.mjs +11 -11
- package/es/packages/components/touchchat/src/AiChat/MessageActions.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue2.mjs +3 -3
- package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue2.mjs +33 -29
- package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/TouchChat.vue2.mjs +179 -1332
- package/es/packages/components/touchchat/src/AiChat/TouchChat.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue2.mjs +19 -6
- package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/AiChat/UserMessage.vue2.mjs +14 -14
- package/es/packages/components/touchchat/src/AiChat/UserMessage.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/src/index.vue2.mjs +3 -3
- package/es/packages/components/touchchat/src/index.vue2.mjs.map +1 -1
- package/es/packages/components/touchchat/utils/a2aService.mjs +3 -2
- package/es/packages/components/touchchat/utils/a2aService.mjs.map +1 -1
- package/es/packages/components/touchchat/utils/fetchStream.mjs +2 -1
- package/es/packages/components/touchchat/utils/fetchStream.mjs.map +1 -1
- package/es/packages/components/touchchat/utils/markdown.mjs +30 -12
- package/es/packages/components/touchchat/utils/markdown.mjs.map +1 -1
- package/lib/package.json.css +1 -1
- package/lib/package.json.js +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/letter.vue.js +1 -1
- package/lib/packages/components/touchchat/component/AiRobot/letter.vue2.js +15 -3
- package/lib/packages/components/touchchat/component/AiRobot/letter.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/FileContent.vue2.js +3 -3
- package/lib/packages/components/touchchat/component/FileContent.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/FileView.vue2.js +2 -2
- package/lib/packages/components/touchchat/component/FileView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/HelloChat.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/ImageFile.vue2.js +6 -6
- package/lib/packages/components/touchchat/component/ImageFile.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/ImageView.vue2.js +1 -1
- package/lib/packages/components/touchchat/component/ImageView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/LinkView.vue2.js +4 -4
- package/lib/packages/components/touchchat/component/LinkView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/MarkLayer.vue2.js +1 -1
- package/lib/packages/components/touchchat/component/MarkLayer.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/ModuleSelect.vue2.js +2 -2
- package/lib/packages/components/touchchat/component/ModuleSelect.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/PDFFile.vue2.js +8 -8
- package/lib/packages/components/touchchat/component/PDFFile.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/RealtimeVoice.vue2.js +1 -1
- package/lib/packages/components/touchchat/component/RealtimeVoice.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/Screenshot.vue2.js +11 -2
- package/lib/packages/components/touchchat/component/Screenshot.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/UploadView.vue2.js +10 -7
- package/lib/packages/components/touchchat/component/UploadView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/component/VoiceView.vue2.js +1 -1
- package/lib/packages/components/touchchat/component/VoiceView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue2.js +1 -1
- package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue2.js +22 -22
- package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.js +147 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/types.js +21 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/types.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useChat.js +674 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useChat.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useCopy.js +57 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useCopy.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useMessageRender.js +157 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useMessageRender.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useSSE.js +354 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useSSE.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useScroll.js +76 -0
- package/lib/packages/components/touchchat/src/AiChat/Chat/useScroll.js.map +1 -0
- package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue2.js +8 -7
- package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue2.js +1 -1
- package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.js +3 -3
- package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue2.js +11 -11
- package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue2.js +3 -3
- package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue2.js +49 -45
- package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue2.js +179 -1332
- package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue2.js +19 -6
- package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue2.js +14 -14
- package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/src/index.vue2.js +3 -3
- package/lib/packages/components/touchchat/src/index.vue2.js.map +1 -1
- package/lib/packages/components/touchchat/utils/a2aService.js +3 -2
- package/lib/packages/components/touchchat/utils/a2aService.js.map +1 -1
- package/lib/packages/components/touchchat/utils/fetchStream.js +2 -1
- package/lib/packages/components/touchchat/utils/fetchStream.js.map +1 -1
- package/lib/packages/components/touchchat/utils/markdown.js +30 -12
- package/lib/packages/components/touchchat/utils/markdown.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,11 +7,9 @@ var UserMessage = require('./UserMessage.vue.js');
|
|
|
7
7
|
var AiMessage = require('./AiMessage.vue.js');
|
|
8
8
|
var ChatInput = require('./ChatInput.vue.js');
|
|
9
9
|
var HelloChat = require('../../component/HelloChat.vue.js');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var tools = require('../../utils/tools.js');
|
|
14
|
-
var TouchChat = require('./Chat/TouchChat.js');
|
|
10
|
+
var types = require('./Chat/types.js');
|
|
11
|
+
var useChat = require('./Chat/useChat.js');
|
|
12
|
+
var useCopy = require('./Chat/useCopy.js');
|
|
15
13
|
|
|
16
14
|
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
17
15
|
__name: "TouchChat",
|
|
@@ -24,11 +22,9 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
24
22
|
emits: ["sendMessage", "toggleSidebar", "beforeSendMessage"],
|
|
25
23
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
26
24
|
const emit = __emit;
|
|
27
|
-
const scripts = vue.inject("scripts", []);
|
|
28
|
-
const activeScript = vue.ref(null);
|
|
29
|
-
const resultItem = vue.ref(null);
|
|
25
|
+
const scripts = vue.inject("scripts", vue.ref([]));
|
|
30
26
|
const unmatchText = vue.inject("unmatchText", "\u60A8\u7684\u6D88\u606F\u672A\u5339\u914D\u5230\u4EFB\u4F55\u5185\u5BB9");
|
|
31
|
-
const modules = vue.inject("modules", []);
|
|
27
|
+
const modules = vue.inject("modules", vue.ref([]));
|
|
32
28
|
const afterSend = vue.inject("afterSend", () => {
|
|
33
29
|
console.warn("\u672A\u63D0\u4F9BafterSend\u51FD\u6570");
|
|
34
30
|
});
|
|
@@ -45,746 +41,58 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
45
41
|
const stop = vue.inject("stop", () => {
|
|
46
42
|
console.warn("\u672A\u63D0\u4F9Bstop\u51FD\u6570");
|
|
47
43
|
});
|
|
44
|
+
const scriptsLength = vue.computed(() => {
|
|
45
|
+
var _a;
|
|
46
|
+
return ((_a = scripts.value) == null ? void 0 : _a.length) || 0;
|
|
47
|
+
});
|
|
48
48
|
const props = __props;
|
|
49
49
|
const chatContainer = vue.ref(null);
|
|
50
|
-
const htmlContentRef = vue.ref([]);
|
|
51
|
-
const thinkingContentRef = vue.ref([]);
|
|
52
|
-
const reasoningContentRef = vue.ref([]);
|
|
53
|
-
const isMounted = vue.ref(false);
|
|
54
|
-
const isChating = vue.ref(false);
|
|
55
|
-
const inputValue = vue.ref("");
|
|
56
|
-
const enableDeepThinking = vue.ref(false);
|
|
57
|
-
const chatList = vue.ref([]);
|
|
58
|
-
const renderQueue = vue.ref([]);
|
|
59
|
-
const isRendering = vue.ref(false);
|
|
60
|
-
const currIndex = vue.ref(0);
|
|
61
|
-
const fetchStream$1 = vue.ref(null);
|
|
62
|
-
const TouchChatRobot = vue.ref();
|
|
63
|
-
const isUnmounting = vue.ref(false);
|
|
64
|
-
const currentComponentName = vue.ref("");
|
|
65
|
-
const fileData = vue.ref([]);
|
|
66
|
-
const activeAgentsName = vue.ref("");
|
|
67
|
-
const moduleInfo = vue.ref(modules[0]);
|
|
68
50
|
const ChatInputRef = vue.ref(null);
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
createStandardMessage: (data) => {
|
|
117
|
-
var _a, _b, _c, _d, _e;
|
|
118
|
-
return {
|
|
119
|
-
// chatId: data.chatId || 'ai_' + crypto.randomUUID().replace(/-/gi, ''),
|
|
120
|
-
chatId: data.chatId || "ai_" + Math.random().toString(36).slice(2).padEnd(10, "0").slice(0, 10),
|
|
121
|
-
user: data.user || "ai",
|
|
122
|
-
type: data.type || "text",
|
|
123
|
-
content: data.content || "",
|
|
124
|
-
isChating: (_a = data.isChating) != null ? _a : false,
|
|
125
|
-
thinkContent: data.thinkContent || "",
|
|
126
|
-
reasoningContent: data.reasoningContent || "",
|
|
127
|
-
isLiked: (_b = data.isLiked) != null ? _b : false,
|
|
128
|
-
isDisliked: (_c = data.isDisliked) != null ? _c : false,
|
|
129
|
-
isEditing: (_d = data.isEditing) != null ? _d : false,
|
|
130
|
-
editContent: (_e = data.editContent) != null ? _e : ""
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
const update = (index, message) => {
|
|
135
|
-
chatList.value[index] = { ...chatList.value[index], ...message };
|
|
136
|
-
console.log("update", chatList.value[index]);
|
|
137
|
-
};
|
|
138
|
-
const markdownToHtml = (markdownContent) => {
|
|
139
|
-
var _a;
|
|
140
|
-
return ((_a = markdown.default) == null ? void 0 : _a.render(markdownContent, { isReasoning: false })) || "";
|
|
141
|
-
};
|
|
142
|
-
const updateModule = (info) => {
|
|
143
|
-
moduleInfo.value = info;
|
|
144
|
-
};
|
|
145
|
-
const handleAgentSelect = (item) => {
|
|
146
|
-
localStorage.setItem("activeAgentsName", item.name);
|
|
147
|
-
const aiMessage = item.intro;
|
|
148
|
-
messageUtils.updateMessage(0, {
|
|
149
|
-
content: "",
|
|
150
|
-
isChating: false
|
|
151
|
-
});
|
|
152
|
-
simulateStreamOutput(0, aiMessage);
|
|
153
|
-
};
|
|
154
|
-
const completeRendered = (chatId) => {
|
|
155
|
-
console.log("completeRendered", "\u6E32\u67D3\u5B8C\u6210", chatId);
|
|
156
|
-
if (currentMessageProcessor.value) {
|
|
157
|
-
currentMessageProcessor.value.handleMessageComplete(chatId);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
const toggleSidebarClick = (item, index) => {
|
|
161
|
-
emit("toggleSidebar", item, index);
|
|
162
|
-
};
|
|
163
|
-
const init = () => {
|
|
164
|
-
try {
|
|
165
|
-
if (Array.isArray(props.value) && props.value.length && !scripts.length) {
|
|
166
|
-
chatList.value = props.value.map((item) => ({
|
|
167
|
-
...item,
|
|
168
|
-
content: item.thinkContent ? item.content || "" : item.content || "",
|
|
169
|
-
thinkContent: item.thinkContent || ""
|
|
170
|
-
}));
|
|
171
|
-
vue.nextTick(() => {
|
|
172
|
-
requestAnimationFrame(() => {
|
|
173
|
-
if (activeAgentsName.value && chatList.value.length > 0 && chatList.value[0].user === "ai") {
|
|
174
|
-
const aiMessage = chatList.value[0];
|
|
175
|
-
messageUtils.updateMessage(0, {
|
|
176
|
-
content: "",
|
|
177
|
-
isChating: true
|
|
178
|
-
});
|
|
179
|
-
simulateStreamOutput(0, aiMessage.content);
|
|
180
|
-
} else {
|
|
181
|
-
chatList.value.forEach((item) => {
|
|
182
|
-
if (item.thinkContent) {
|
|
183
|
-
renderContent(item.thinkContent, "thinking");
|
|
184
|
-
}
|
|
185
|
-
if (item.reasoningContent) {
|
|
186
|
-
renderContent(item.reasoningContent, "reasoning");
|
|
187
|
-
}
|
|
188
|
-
if (item.content) {
|
|
189
|
-
renderContent(item.content, "main");
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
vue.nextTick(() => {
|
|
193
|
-
scrollToBottom();
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
} catch (error) {
|
|
200
|
-
console.error("\u521D\u59CB\u5316\u5931\u8D25:", error);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
const onScrollToBottom = () => {
|
|
204
|
-
bottom();
|
|
205
|
-
};
|
|
206
|
-
const throttledScrollToBottom = index.throttle(300, onScrollToBottom);
|
|
207
|
-
const handleScroll = () => {
|
|
208
|
-
if (!chatContainer.value)
|
|
209
|
-
return;
|
|
210
|
-
const { scrollTop, scrollHeight, clientHeight } = chatContainer.value;
|
|
211
|
-
if (scrollTop + clientHeight >= scrollHeight) {
|
|
212
|
-
throttledScrollToBottom();
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
const simulateStreamOutput = (aiIndex, msg, callback) => {
|
|
216
|
-
const message = typeof msg === "string" ? msg : msg.content;
|
|
217
|
-
const componentName = typeof msg === "string" ? "" : msg.needSequenceProcessing ? msg.needSequenceType : "";
|
|
218
|
-
const isNeedSequenceProcessing = typeof msg === "string" ? false : msg.needSequenceProcessing;
|
|
219
|
-
const fn = () => {
|
|
220
|
-
clearInterval(interval);
|
|
221
|
-
emit("sendMessage", [...chatList.value]);
|
|
222
|
-
if (componentName) {
|
|
223
|
-
chatList.value[aiIndex].componentName = componentName;
|
|
224
|
-
}
|
|
225
|
-
messageUtils.updateMessage(aiIndex, {
|
|
226
|
-
isChating: false
|
|
227
|
-
});
|
|
228
|
-
vue.nextTick(() => {
|
|
229
|
-
renderContent(message, "main", aiIndex);
|
|
230
|
-
vue.nextTick(() => {
|
|
231
|
-
scrollToBottom();
|
|
232
|
-
if (!isNeedSequenceProcessing && callback) {
|
|
233
|
-
callback();
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
let index = 0;
|
|
239
|
-
const interval = setInterval(() => {
|
|
240
|
-
if (index < message.length) {
|
|
241
|
-
const newContent = message;
|
|
242
|
-
messageUtils.updateMessage(aiIndex, {
|
|
243
|
-
content: newContent
|
|
244
|
-
});
|
|
245
|
-
vue.nextTick(() => {
|
|
246
|
-
renderContent(newContent, "main", aiIndex);
|
|
247
|
-
vue.nextTick(() => {
|
|
248
|
-
scrollToBottom();
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
index++;
|
|
252
|
-
} else {
|
|
253
|
-
fn();
|
|
254
|
-
}
|
|
255
|
-
}, 50);
|
|
256
|
-
};
|
|
257
|
-
const findMatchingScriptContent = (userInput) => {
|
|
258
|
-
if (!scripts || scripts.length === 0)
|
|
259
|
-
return null;
|
|
260
|
-
const agentName = activeAgentsName.value ? activeAgentsName.value : localStorage.getItem("activeAgentsName") || "";
|
|
261
|
-
if (agentName) {
|
|
262
|
-
const agentMatchedScripts = scripts.filter((script) => {
|
|
263
|
-
return script.content.some((item) => item.agents === agentName);
|
|
264
|
-
});
|
|
265
|
-
if (agentMatchedScripts.length > 0) {
|
|
266
|
-
const fileTypeItems = agentMatchedScripts.flatMap((script) => script.content.filter((item) => item.file));
|
|
267
|
-
const fileTypes = fileTypeItems.map((item) => item.file);
|
|
268
|
-
const isFileTypeMatched = fileData.value.some((file) => {
|
|
269
|
-
const nameArr = file.name.split(".");
|
|
270
|
-
const name = nameArr[nameArr.length - 1];
|
|
271
|
-
const isMatched = fileTypes.includes(name);
|
|
272
|
-
return isMatched;
|
|
273
|
-
});
|
|
274
|
-
let matchedScriptContentIndex = -1;
|
|
275
|
-
if (!activeScript.value && isFileTypeMatched) {
|
|
276
|
-
activeScript.value = agentMatchedScripts[0];
|
|
277
|
-
}
|
|
278
|
-
if (isFileTypeMatched) {
|
|
279
|
-
for (const script of agentMatchedScripts) {
|
|
280
|
-
for (let i = 0; i < script.content.length; i++) {
|
|
281
|
-
const item = script.content[i];
|
|
282
|
-
if (item.file) {
|
|
283
|
-
const nameArr = fileData.value.map((file) => {
|
|
284
|
-
const fileExtArr = file.name.split(".");
|
|
285
|
-
return fileExtArr[fileExtArr.length - 1];
|
|
286
|
-
});
|
|
287
|
-
if (nameArr.includes(item.file)) {
|
|
288
|
-
matchedScriptContentIndex = i;
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
if (matchedScriptContentIndex !== -1) {
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
const responses = [];
|
|
298
|
-
const matchContent = agentMatchedScripts[0].content;
|
|
299
|
-
for (let j = matchedScriptContentIndex + 1; j < matchContent.length; j++) {
|
|
300
|
-
const nextItem = matchContent[j];
|
|
301
|
-
if (nextItem.user === "i") {
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
if (nextItem.user === "ai") {
|
|
305
|
-
if (nextItem.data && nextItem.type) {
|
|
306
|
-
responses.push({
|
|
307
|
-
...nextItem,
|
|
308
|
-
// 标记需要先流式输出文字,再调用组件
|
|
309
|
-
needSequenceProcessing: true
|
|
310
|
-
});
|
|
311
|
-
} else {
|
|
312
|
-
responses.push(nextItem);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
const nextIndex = matchContent.findIndex((contentItem, index) => index > matchedScriptContentIndex && contentItem.user === "i");
|
|
317
|
-
return {
|
|
318
|
-
responses,
|
|
319
|
-
nextIndex: nextIndex === -1 ? matchContent.length : nextIndex
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
} else {
|
|
323
|
-
return {
|
|
324
|
-
responses: [
|
|
325
|
-
{
|
|
326
|
-
user: "ai",
|
|
327
|
-
data: unmatchText
|
|
328
|
-
}
|
|
329
|
-
],
|
|
330
|
-
nextIndex: -1
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (activeScript.value) {
|
|
335
|
-
const result = searchInScript(activeScript.value, userInput);
|
|
336
|
-
if (result) {
|
|
337
|
-
return result;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
for (const script of scripts) {
|
|
341
|
-
const result = searchInScript(script, userInput);
|
|
342
|
-
if (result) {
|
|
343
|
-
activeScript.value = script;
|
|
344
|
-
return result;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return null;
|
|
348
|
-
};
|
|
349
|
-
const searchInScript = (script, userInput) => {
|
|
350
|
-
for (let i = 0; i < script.content.length; i++) {
|
|
351
|
-
const item = script.content[i];
|
|
352
|
-
if (item.user === "i") {
|
|
353
|
-
const isDataMatch = item.data && userInput.includes(item.data);
|
|
354
|
-
let isSubDataMatch = false;
|
|
355
|
-
if (item.alias) {
|
|
356
|
-
if (Array.isArray(item.alias)) {
|
|
357
|
-
isSubDataMatch = item.alias.some((subItem) => subItem === userInput);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (isDataMatch || isSubDataMatch) {
|
|
361
|
-
const responses = [];
|
|
362
|
-
for (let j = i + 1; j < script.content.length; j++) {
|
|
363
|
-
const nextItem = script.content[j];
|
|
364
|
-
if (nextItem.user === "i") {
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
if (nextItem.user === "ai") {
|
|
368
|
-
if (nextItem.data && nextItem.type) {
|
|
369
|
-
responses.push({
|
|
370
|
-
...nextItem,
|
|
371
|
-
// 标记需要先流式输出文字,再调用组件
|
|
372
|
-
needSequenceProcessing: true
|
|
373
|
-
});
|
|
374
|
-
} else {
|
|
375
|
-
responses.push(nextItem);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
const nextIndex = script.content.findIndex((contentItem, index) => index > i && contentItem.user === "i");
|
|
380
|
-
return { responses, nextIndex: nextIndex === -1 ? script.content.length : nextIndex };
|
|
381
|
-
}
|
|
382
|
-
} else if (item.user === "ai") {
|
|
383
|
-
scripts.forEach((script2) => {
|
|
384
|
-
if (script2.content.length) {
|
|
385
|
-
const contents = script2.content;
|
|
386
|
-
contents.forEach((item2) => {
|
|
387
|
-
if (item2.agents) {
|
|
388
|
-
if (item2.agents === activeAgentsName.value) {
|
|
389
|
-
activeScript.value = script2;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return null;
|
|
398
|
-
};
|
|
399
|
-
vue.watch(
|
|
400
|
-
() => props.value,
|
|
401
|
-
(newVal, oldVal) => {
|
|
402
|
-
if (!Array.isArray(newVal))
|
|
403
|
-
return;
|
|
404
|
-
if (newVal.length && JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
|
|
405
|
-
chatList.value = newVal.map((item) => ({
|
|
406
|
-
...item,
|
|
407
|
-
content: item.thinkContent ? item.content || "" : item.content || "",
|
|
408
|
-
thinkContent: item.thinkContent || ""
|
|
409
|
-
}));
|
|
410
|
-
vue.nextTick(() => {
|
|
411
|
-
requestAnimationFrame(() => {
|
|
412
|
-
chatList.value.forEach((item) => {
|
|
413
|
-
if (item.thinkContent) {
|
|
414
|
-
renderContent(item.thinkContent, "thinking");
|
|
415
|
-
}
|
|
416
|
-
if (item.reasoningContent) {
|
|
417
|
-
renderContent(item.reasoningContent, "reasoning");
|
|
418
|
-
}
|
|
419
|
-
if (item.content) {
|
|
420
|
-
renderContent(item.content, "main");
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
vue.nextTick(() => {
|
|
424
|
-
scrollToBottom();
|
|
425
|
-
});
|
|
426
|
-
});
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
},
|
|
430
|
-
{ deep: true, immediate: true }
|
|
431
|
-
);
|
|
432
|
-
const openSSE = (userContent, insertIndex, type) => {
|
|
433
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
434
|
-
try {
|
|
435
|
-
if (isUnmounting.value)
|
|
436
|
-
return;
|
|
437
|
-
isChating.value = true;
|
|
438
|
-
const currentAiMessage = chatList.value.find((item) => item.isChating);
|
|
439
|
-
if (currentAiMessage) {
|
|
440
|
-
currentAiMessage.isShowLike = true;
|
|
441
|
-
currentAiMessage.isShowCopy = true;
|
|
442
|
-
currentAiMessage.componentName = currentComponentName.value;
|
|
443
|
-
}
|
|
444
|
-
const chatId = (currentAiMessage == null ? void 0 : currentAiMessage.chatId) || "ai_" + Math.random().toString(36).slice(2).padEnd(10, "0").slice(0, 10);
|
|
445
|
-
let aiContent = (currentAiMessage == null ? void 0 : currentAiMessage.content) || "";
|
|
446
|
-
let reasoningContent = (currentAiMessage == null ? void 0 : currentAiMessage.reasoningContent) || "";
|
|
447
|
-
let allAiContent = "";
|
|
448
|
-
if (!currentAiMessage) {
|
|
449
|
-
const chatItem = {
|
|
450
|
-
chatId,
|
|
451
|
-
user: "ai",
|
|
452
|
-
type: "text",
|
|
453
|
-
isChating: true,
|
|
454
|
-
content: "",
|
|
455
|
-
thinkContent: "",
|
|
456
|
-
reasoningContent: "",
|
|
457
|
-
thinkStatus: TouchChat.ThinkStatus.THINKING,
|
|
458
|
-
thinkStartTime: Date.now(),
|
|
459
|
-
isShowLike: true,
|
|
460
|
-
isShowCopy: true,
|
|
461
|
-
componentName: currentComponentName.value,
|
|
462
|
-
typeFlag: typeFlag.value
|
|
463
|
-
};
|
|
464
|
-
if (insertIndex !== void 0 && insertIndex <= chatList.value.length) {
|
|
465
|
-
chatList.value.splice(insertIndex, 0, chatItem);
|
|
466
|
-
} else {
|
|
467
|
-
chatList.value.push(chatItem);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
currIndex.value = insertIndex != null ? insertIndex : chatList.value.length - 1;
|
|
471
|
-
const BodyConfig = (_b = (_a = moduleInfo.value) == null ? void 0 : _a.config) == null ? void 0 : _b.body();
|
|
472
|
-
if (!inputValue.value && ((_c = BodyConfig == null ? void 0 : BodyConfig.messages) == null ? void 0 : _c.length)) {
|
|
473
|
-
BodyConfig.messages[0].content = userContent;
|
|
474
|
-
BodyConfig.model = enableDeepThinking.value ? "deepseek-reasoner" : "deepseek-v3";
|
|
475
|
-
}
|
|
476
|
-
fetchStream$1.value = new fetchStream.FetchStream({
|
|
477
|
-
url: ((_e = (_d = moduleInfo.value) == null ? void 0 : _d.config) == null ? void 0 : _e.action) ? moduleInfo.value.config.action : "https://api.apiyi.com/v1/chat/completions",
|
|
478
|
-
requestInit: {
|
|
479
|
-
headers: ((_g = (_f = moduleInfo.value) == null ? void 0 : _f.config) == null ? void 0 : _g.headers) ? new Headers(moduleInfo.value.config.headers()) : new Headers({
|
|
480
|
-
"Content-Type": "application/json",
|
|
481
|
-
Authorization: "Bearer sk-fe9MtODvds8wpzz05f3417Fe3e9641C1926e6fC588425dEd"
|
|
482
|
-
}),
|
|
483
|
-
// body: moduleInfo.value?.config?.body
|
|
484
|
-
// ? JSON.stringify(BodyConfig as Record<string, any>)
|
|
485
|
-
// : JSON.stringify({
|
|
486
|
-
// model: enableDeepThinking.value ? 'deepseek-reasoner' : 'deepseek-v3',
|
|
487
|
-
// messages: [
|
|
488
|
-
// {
|
|
489
|
-
// role: 'user',
|
|
490
|
-
// content: userContent
|
|
491
|
-
// }
|
|
492
|
-
// ],
|
|
493
|
-
// stream: true
|
|
494
|
-
// })
|
|
495
|
-
body: JSON.stringify(BodyConfig)
|
|
496
|
-
},
|
|
497
|
-
onmessage: (line) => {
|
|
498
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j;
|
|
499
|
-
if (isUnmounting.value)
|
|
500
|
-
return;
|
|
501
|
-
let dataString = "";
|
|
502
|
-
if (line.length) {
|
|
503
|
-
if (line.includes("data:")) {
|
|
504
|
-
const match = line.match(/\{[\s\S]*\}/);
|
|
505
|
-
dataString = match ? match[0] : "";
|
|
506
|
-
} else if (line.startsWith("{") && line.endsWith("}")) {
|
|
507
|
-
dataString = line;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
dataString = dataString.trim();
|
|
511
|
-
const respoKey = (_b2 = (_a2 = moduleInfo.value) == null ? void 0 : _a2.config) == null ? void 0 : _b2.respoKey();
|
|
512
|
-
if (dataString && (dataString.startsWith("{") && dataString.endsWith("}") || !(respoKey == null ? void 0 : respoKey.content))) {
|
|
513
|
-
try {
|
|
514
|
-
const result = !(respoKey == null ? void 0 : respoKey.content) && moduleInfo.value ? dataString : JSON.parse(dataString);
|
|
515
|
-
const newAiMessage = chatList.value[currIndex.value];
|
|
516
|
-
const deepseekFlag = ((_c2 = moduleInfo.value) == null ? void 0 : _c2.name) === "deepseek-v3";
|
|
517
|
-
if (deepseekFlag || !moduleInfo.value) {
|
|
518
|
-
if ((_f2 = (_e2 = (_d2 = result == null ? void 0 : result.choices) == null ? void 0 : _d2[0]) == null ? void 0 : _e2.delta) == null ? void 0 : _f2.content) {
|
|
519
|
-
aiContent += result.choices[0].delta.content;
|
|
520
|
-
if ((newAiMessage == null ? void 0 : newAiMessage.thinkStatus) === TouchChat.ThinkStatus.THINKING) {
|
|
521
|
-
newAiMessage.thinkStatus = TouchChat.ThinkStatus.COMPLETED;
|
|
522
|
-
newAiMessage.thinkTime = Date.now() - (newAiMessage.thinkStartTime || Date.now());
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
if ((_i = (_h = (_g2 = result == null ? void 0 : result.choices) == null ? void 0 : _g2[0]) == null ? void 0 : _h.delta) == null ? void 0 : _i.reasoning_content) {
|
|
526
|
-
reasoningContent += result.choices[0].delta.reasoning_content;
|
|
527
|
-
if (!(newAiMessage == null ? void 0 : newAiMessage.thinkStatus)) {
|
|
528
|
-
newAiMessage.thinkStatus = TouchChat.ThinkStatus.THINKING;
|
|
529
|
-
newAiMessage.thinkStartTime = Date.now();
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
allAiContent = reasoningContent + aiContent;
|
|
533
|
-
} else {
|
|
534
|
-
if (respoKey && result && result[respoKey.content] && (result[respoKey.category] === respoKey.contentCategory || !result[respoKey.category])) {
|
|
535
|
-
aiContent += result[respoKey.content];
|
|
536
|
-
}
|
|
537
|
-
if (result && result[respoKey.category] === "done") {
|
|
538
|
-
resultItem.value = result;
|
|
539
|
-
}
|
|
540
|
-
if (result && result[respoKey.category] === "error") {
|
|
541
|
-
const errorMessage = (_j = result[respoKey.all]) != null ? _j : "\u5F53\u524D\u7F51\u7EDC\u5F02\u5E38";
|
|
542
|
-
const currentAiMessage2 = chatList.value[currIndex.value];
|
|
543
|
-
if (currentAiMessage2.chatId) {
|
|
544
|
-
currentAiMessage2.content = `<div style="color: red; display: flex; align-items: center;"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
545
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.5 15.5C11.6421 15.5 15 12.1421 15 8C15 3.85786 11.6421 0.5 7.5 0.5C3.35786 0.5 0 3.85786 0 8C0 12.1421 3.35786 15.5 7.5 15.5ZM9.7539 4.9506L10.5494 5.7461L8.2951 8.0001L10.5494 10.2539L9.7539 11.0494L7.5001 8.7951L5.2461 11.0494L4.4506 10.2539L6.7051 8.0001L4.4506 5.7461L5.2461 4.9506L7.5001 7.2051L9.7539 4.9506Z" fill="#F93920"/>
|
|
546
|
-
</svg>${errorMessage}</div>`;
|
|
547
|
-
currentAiMessage2.isChating = false;
|
|
548
|
-
currentAiMessage2.componentName = "";
|
|
549
|
-
currentAiMessage2.isShowLike = false;
|
|
550
|
-
currentAiMessage2.isShowCopy = false;
|
|
551
|
-
currentAiMessage2.isError = true;
|
|
552
|
-
vue.nextTick(() => {
|
|
553
|
-
emit("sendMessage", [...chatList.value]);
|
|
554
|
-
});
|
|
555
|
-
afterSend(result);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
if (aiContent || reasoningContent) {
|
|
559
|
-
allAiContent = aiContent + reasoningContent;
|
|
560
|
-
}
|
|
561
|
-
if (respoKey && result && result[respoKey.all] && result[respoKey.category] === respoKey.allCategory) {
|
|
562
|
-
allAiContent = result[respoKey.all];
|
|
563
|
-
}
|
|
564
|
-
if (respoKey && result && typeof result === "string" && result !== "[DONE]") {
|
|
565
|
-
aiContent += result;
|
|
566
|
-
}
|
|
567
|
-
if (respoKey && result && typeof result === "string" && result === "[DONE]") {
|
|
568
|
-
const index = chatList.value.findIndex((ele) => ele.chatId === chatId);
|
|
569
|
-
if (index !== -1 && chatList.value[index]) {
|
|
570
|
-
isChating.value = false;
|
|
571
|
-
chatList.value[index].isChating = false;
|
|
572
|
-
emit("sendMessage", JSON.parse(JSON.stringify(chatList.value)));
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
if (chatList.value.some((ele) => ele.chatId === chatId)) {
|
|
577
|
-
enqueueRender({
|
|
578
|
-
mainContent: aiContent,
|
|
579
|
-
thinkContent: "",
|
|
580
|
-
reasoningContent
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
if (type === 1) {
|
|
584
|
-
vue.nextTick(() => {
|
|
585
|
-
renderContent(aiContent, "main");
|
|
586
|
-
renderContent(reasoningContent, "reasoning");
|
|
587
|
-
vue.nextTick(() => {
|
|
588
|
-
scrollToBottom();
|
|
589
|
-
});
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
} catch (error) {
|
|
593
|
-
console.error("\u89E3\u6790SSE\u6D88\u606F\u5931\u8D25:", error);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
},
|
|
597
|
-
ondone: () => {
|
|
598
|
-
vue.nextTick(() => {
|
|
599
|
-
isChating.value = false;
|
|
600
|
-
if (isUnmounting.value || !isMounted.value)
|
|
601
|
-
return;
|
|
602
|
-
const index = chatList.value.findIndex((ele) => ele.chatId === chatId);
|
|
603
|
-
if (index !== -1 && chatList.value[index]) {
|
|
604
|
-
chatList.value[index].isChating = false;
|
|
605
|
-
chatList.value[index].componentName = currentComponentName.value;
|
|
606
|
-
chatList.value[index].html = markdownToHtml(allAiContent);
|
|
607
|
-
if (allAiContent) {
|
|
608
|
-
if (resultItem.value) {
|
|
609
|
-
resultItem.value.allAiContent = allAiContent;
|
|
610
|
-
afterSend(resultItem.value);
|
|
611
|
-
} else {
|
|
612
|
-
afterSend({ allAiContent });
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
const waitForRenderComplete = () => {
|
|
616
|
-
if (renderQueue.value.length === 0 && !isRendering.value) {
|
|
617
|
-
if (chatList.value.length > 0) {
|
|
618
|
-
emit("sendMessage", JSON.parse(JSON.stringify(chatList.value)));
|
|
619
|
-
}
|
|
620
|
-
} else {
|
|
621
|
-
requestAnimationFrame(waitForRenderComplete);
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
waitForRenderComplete();
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
},
|
|
628
|
-
onabort: () => {
|
|
629
|
-
handleAbort();
|
|
630
|
-
},
|
|
631
|
-
onerror: (response) => {
|
|
632
|
-
handleError(response);
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
} catch (error) {
|
|
636
|
-
console.error("OpenSSE\u9519\u8BEF:", error);
|
|
637
|
-
isChating.value = false;
|
|
638
|
-
chatList.value[currIndex.value].content = `<div style="color: red; display: flex; align-items: center;"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
639
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.5 15.5C11.6421 15.5 15 12.1421 15 8C15 3.85786 11.6421 0.5 7.5 0.5C3.35786 0.5 0 3.85786 0 8C0 12.1421 3.35786 15.5 7.5 15.5ZM9.7539 4.9506L10.5494 5.7461L8.2951 8.0001L10.5494 10.2539L9.7539 11.0494L7.5001 8.7951L5.2461 11.0494L4.4506 10.2539L6.7051 8.0001L4.4506 5.7461L5.2461 4.9506L7.5001 7.2051L9.7539 4.9506Z" fill="#F93920"/>
|
|
640
|
-
</svg>${"\u8BF7\u6C42\u5931\u8D25"}</div>`;
|
|
641
|
-
chatList.value[currIndex.value].isChating = false;
|
|
642
|
-
chatList.value[currIndex.value].isShowCopy = false;
|
|
643
|
-
chatList.value[currIndex.value].isShowLike = false;
|
|
644
|
-
tools.showToast("\u8BF7\u6C42\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5", "error", 3e3);
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
const handleAbort = () => {
|
|
648
|
-
isChating.value = false;
|
|
649
|
-
if (isUnmounting.value)
|
|
650
|
-
return;
|
|
651
|
-
const currentAiMessage = chatList.value[currIndex.value];
|
|
652
|
-
stop(chatList.value[currIndex.value], currIndex.value);
|
|
653
|
-
const hasContent = currentAiMessage && (currentAiMessage.content || currentAiMessage.thinkContent || currentAiMessage.reasoningContent);
|
|
654
|
-
if (currentAiMessage) {
|
|
655
|
-
if (currentAiMessage.thinkStatus === TouchChat.ThinkStatus.THINKING) {
|
|
656
|
-
currentAiMessage.thinkStatus = TouchChat.ThinkStatus.STOPPED;
|
|
657
|
-
currentAiMessage.thinkTime = Date.now() - (currentAiMessage.thinkStartTime || Date.now());
|
|
658
|
-
}
|
|
659
|
-
if (!hasContent) {
|
|
660
|
-
const userMessageIndex = currIndex.value - 1;
|
|
661
|
-
if (userMessageIndex >= 0 && chatList.value[userMessageIndex].user === "u") {
|
|
662
|
-
chatList.value.splice(currIndex.value, 1);
|
|
663
|
-
chatList.value.splice(userMessageIndex, 1);
|
|
664
|
-
} else {
|
|
665
|
-
chatList.value.splice(currIndex.value, 1);
|
|
666
|
-
}
|
|
667
|
-
} else {
|
|
668
|
-
const updatedAiMessage = {
|
|
669
|
-
...currentAiMessage,
|
|
670
|
-
isChating: false,
|
|
671
|
-
content: currentAiMessage.content ? currentAiMessage.content + "..." : "",
|
|
672
|
-
thinkContent: currentAiMessage.thinkContent ? currentAiMessage.thinkContent + "..." : void 0,
|
|
673
|
-
reasoningContent: currentAiMessage.reasoningContent ? currentAiMessage.reasoningContent + "..." : void 0,
|
|
674
|
-
thinkStatus: currentAiMessage.thinkStatus,
|
|
675
|
-
stop: true
|
|
676
|
-
};
|
|
677
|
-
chatList.value.splice(currIndex.value, 1, updatedAiMessage);
|
|
678
|
-
vue.nextTick(() => {
|
|
679
|
-
renderContent(updatedAiMessage.thinkContent || "", "thinking");
|
|
680
|
-
renderContent(updatedAiMessage.reasoningContent || "", "reasoning");
|
|
681
|
-
renderContent(updatedAiMessage.content || "", "main");
|
|
682
|
-
emit("sendMessage", [...chatList.value]);
|
|
683
|
-
});
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
if (chatList.value.length > 0) {
|
|
688
|
-
emit("sendMessage", [...chatList.value]);
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
const handleError = (response) => {
|
|
692
|
-
if (isUnmounting.value)
|
|
693
|
-
return;
|
|
694
|
-
isChating.value = false;
|
|
695
|
-
let errorMessage = "\u672A\u77E5\u9519\u8BEF";
|
|
696
|
-
if (response instanceof Error) {
|
|
697
|
-
console.error("API\u8BF7\u6C42\u9519\u8BEF:", response);
|
|
698
|
-
errorMessage = response.message;
|
|
699
|
-
} else if (response instanceof Response) {
|
|
700
|
-
console.error("API\u8BF7\u6C42\u9519\u8BEF, \u54CD\u5E94\u72B6\u6001:", response.status, response.statusText);
|
|
701
|
-
errorMessage = `\u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`;
|
|
702
|
-
}
|
|
703
|
-
const currentAiMessage = chatList.value[currIndex.value];
|
|
704
|
-
if (currentAiMessage) {
|
|
705
|
-
currentAiMessage.content = `<div style="color: red; display: flex; align-items: center;"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
706
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.5 15.5C11.6421 15.5 15 12.1421 15 8C15 3.85786 11.6421 0.5 7.5 0.5C3.35786 0.5 0 3.85786 0 8C0 12.1421 3.35786 15.5 7.5 15.5ZM9.7539 4.9506L10.5494 5.7461L8.2951 8.0001L10.5494 10.2539L9.7539 11.0494L7.5001 8.7951L5.2461 11.0494L4.4506 10.2539L6.7051 8.0001L4.4506 5.7461L5.2461 4.9506L7.5001 7.2051L9.7539 4.9506Z" fill="#F93920"/>
|
|
707
|
-
</svg>${errorMessage}</div>`;
|
|
708
|
-
currentAiMessage.isChating = false;
|
|
709
|
-
currentAiMessage.componentName = "";
|
|
710
|
-
currentAiMessage.isShowLike = false;
|
|
711
|
-
currentAiMessage.isShowCopy = false;
|
|
712
|
-
currentAiMessage.isError = true;
|
|
713
|
-
vue.nextTick(() => {
|
|
714
|
-
renderContent(currentAiMessage.content || "", "main");
|
|
715
|
-
emit("sendMessage", [...chatList.value]);
|
|
716
|
-
});
|
|
717
|
-
} else {
|
|
718
|
-
tools.showToast(errorMessage, "error", 3e3);
|
|
719
|
-
emit("sendMessage", [...chatList.value]);
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
const enqueueRender = (data) => {
|
|
723
|
-
if (isUnmounting.value || !isMounted.value)
|
|
724
|
-
return;
|
|
725
|
-
if (currIndex.value < 0 || currIndex.value >= chatList.value.length)
|
|
726
|
-
return;
|
|
727
|
-
renderQueue.value.push(data);
|
|
728
|
-
if (!isRendering.value) {
|
|
729
|
-
isRendering.value = true;
|
|
730
|
-
processRenderQueue();
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
const processRenderQueue = () => {
|
|
734
|
-
if (isUnmounting.value || !isMounted.value) {
|
|
735
|
-
renderQueue.value = [];
|
|
736
|
-
isRendering.value = false;
|
|
737
|
-
return;
|
|
738
|
-
}
|
|
739
|
-
if (renderQueue.value.length === 0) {
|
|
740
|
-
isRendering.value = false;
|
|
741
|
-
return;
|
|
742
|
-
}
|
|
743
|
-
requestAnimationFrame(() => {
|
|
744
|
-
const data = renderQueue.value.shift();
|
|
745
|
-
if (data) {
|
|
746
|
-
formatMarkdown(data);
|
|
747
|
-
}
|
|
748
|
-
processRenderQueue();
|
|
749
|
-
});
|
|
750
|
-
};
|
|
751
|
-
const formatMarkdown = (data) => {
|
|
752
|
-
if (!isMounted.value)
|
|
753
|
-
return;
|
|
754
|
-
if (currIndex.value < 0 || currIndex.value >= chatList.value.length)
|
|
755
|
-
return;
|
|
756
|
-
const currentItem = chatList.value[currIndex.value];
|
|
757
|
-
if (!currentItem.isError) {
|
|
758
|
-
currentItem.thinkContent = data.thinkContent;
|
|
759
|
-
currentItem.content = data.mainContent;
|
|
760
|
-
currentItem.reasoningContent = data.reasoningContent;
|
|
761
|
-
}
|
|
762
|
-
vue.nextTick(() => {
|
|
763
|
-
const thinkingContainer = thinkingContentRef.value[currIndex.value];
|
|
764
|
-
if (thinkingContainer) {
|
|
765
|
-
if (data.thinkContent && !currentItem.isError) {
|
|
766
|
-
renderContent(data.thinkContent, "thinking");
|
|
767
|
-
thinkingContainer.style.display = "block";
|
|
768
|
-
thinkingContainer.style.visibility = "visible";
|
|
769
|
-
} else {
|
|
770
|
-
thinkingContainer.style.display = "none";
|
|
771
|
-
thinkingContainer.style.visibility = "hidden";
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
const reasoningContainer = reasoningContentRef.value[currIndex.value];
|
|
775
|
-
if (reasoningContainer) {
|
|
776
|
-
if (data.reasoningContent && !currentItem.isError) {
|
|
777
|
-
renderContent(data.reasoningContent, "reasoning");
|
|
778
|
-
reasoningContainer.style.display = "block";
|
|
779
|
-
reasoningContainer.style.visibility = "visible";
|
|
780
|
-
} else {
|
|
781
|
-
reasoningContainer.style.display = "none";
|
|
782
|
-
reasoningContainer.style.visibility = "hidden";
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
renderContent(currentItem.isError ? currentItem.content : data.mainContent, "main");
|
|
786
|
-
});
|
|
787
|
-
};
|
|
51
|
+
const {
|
|
52
|
+
chatList,
|
|
53
|
+
isChating,
|
|
54
|
+
inputValue,
|
|
55
|
+
enableDeepThinking,
|
|
56
|
+
activeAgentsName,
|
|
57
|
+
init,
|
|
58
|
+
sendMessage,
|
|
59
|
+
handleBeforeSend,
|
|
60
|
+
handleSend,
|
|
61
|
+
handleStop,
|
|
62
|
+
handleMessageAction,
|
|
63
|
+
saveEdit,
|
|
64
|
+
cancelEdit,
|
|
65
|
+
completeRendered,
|
|
66
|
+
handleAgentSelect,
|
|
67
|
+
update,
|
|
68
|
+
updateModule,
|
|
69
|
+
handleDragEnter,
|
|
70
|
+
handleDragLeave,
|
|
71
|
+
handleDrop,
|
|
72
|
+
handleScroll,
|
|
73
|
+
onMounted: chatOnMounted,
|
|
74
|
+
onBeforeUnmount: chatOnBeforeUnmount
|
|
75
|
+
} = useChat.useChat({
|
|
76
|
+
props,
|
|
77
|
+
emit,
|
|
78
|
+
scripts: scripts.value,
|
|
79
|
+
unmatchText,
|
|
80
|
+
modules: modules.value,
|
|
81
|
+
afterSend,
|
|
82
|
+
sendMessageInject,
|
|
83
|
+
beforeSend,
|
|
84
|
+
bottom,
|
|
85
|
+
stop,
|
|
86
|
+
chatContainer,
|
|
87
|
+
chatInputRef: ChatInputRef
|
|
88
|
+
});
|
|
89
|
+
const { copyWithFeedback } = useCopy.useCopy();
|
|
90
|
+
const modelChangeExternal = vue.inject("modelChange", () => {
|
|
91
|
+
});
|
|
92
|
+
vue.provide("modelChange", (item, index) => {
|
|
93
|
+
modelChangeExternal(item, index);
|
|
94
|
+
updateModule(item);
|
|
95
|
+
});
|
|
788
96
|
const attachCopyButtons = (container) => {
|
|
789
97
|
const codeBlocks = container.querySelectorAll("pre code");
|
|
790
98
|
codeBlocks.forEach((codeBlock) => {
|
|
@@ -794,403 +102,23 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
794
102
|
copyBtn.className = "touchchat-code-copy";
|
|
795
103
|
copyBtn.addEventListener("click", () => {
|
|
796
104
|
const code = codeBlock.textContent || "";
|
|
797
|
-
|
|
798
|
-
tools.showToast("\u590D\u5236\u6210\u529F", "info", 2e3);
|
|
799
|
-
copyBtn.textContent = "\u5DF2\u590D\u5236";
|
|
800
|
-
setTimeout(() => {
|
|
801
|
-
copyBtn.textContent = "";
|
|
802
|
-
}, 2e3);
|
|
803
|
-
}).catch((err) => {
|
|
804
|
-
console.error("\u590D\u5236\u5931\u8D25:", err);
|
|
805
|
-
tools.showToast("\u590D\u5236\u5931\u8D25", "error", 2e3);
|
|
806
|
-
});
|
|
105
|
+
copyWithFeedback(code, copyBtn, "", "\u5DF2\u590D\u5236", 2e3);
|
|
807
106
|
});
|
|
808
107
|
pre.style.position = "relative";
|
|
809
108
|
pre.appendChild(copyBtn);
|
|
810
109
|
}
|
|
811
110
|
});
|
|
812
111
|
};
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
if (renderIndex < 0 || renderIndex >= chatList.value.length)
|
|
816
|
-
return;
|
|
817
|
-
const refArrays = {
|
|
818
|
-
main: htmlContentRef,
|
|
819
|
-
thinking: thinkingContentRef,
|
|
820
|
-
reasoning: reasoningContentRef
|
|
821
|
-
};
|
|
822
|
-
const processors = {
|
|
823
|
-
main: (content2) => {
|
|
824
|
-
var _a;
|
|
825
|
-
return ((_a = markdown.default) == null ? void 0 : _a.render(content2, { isReasoning: false })) || "";
|
|
826
|
-
},
|
|
827
|
-
thinking: (content2) => {
|
|
828
|
-
var _a;
|
|
829
|
-
return ((_a = markdown.default) == null ? void 0 : _a.render(content2, { isReasoning: false })) || "";
|
|
830
|
-
},
|
|
831
|
-
reasoning: (content2) => {
|
|
832
|
-
var _a;
|
|
833
|
-
return ((_a = markdown.default) == null ? void 0 : _a.render(content2, { isReasoning: false })) || "";
|
|
834
|
-
}
|
|
835
|
-
};
|
|
836
|
-
const container = refArrays[type].value[renderIndex];
|
|
837
|
-
if (!container)
|
|
838
|
-
return;
|
|
839
|
-
container.innerHTML = processors[type](content || "");
|
|
840
|
-
attachCopyButtons(container);
|
|
841
|
-
};
|
|
842
|
-
const sendMessage = (content, fileList, auto, type) => {
|
|
843
|
-
inputValue.value = content || "";
|
|
844
|
-
handleBeforeSend(content, fileList, auto, type);
|
|
845
|
-
};
|
|
846
|
-
const handleBeforeSend = (content, fileList, auto, type) => {
|
|
847
|
-
fileData.value = fileList || [];
|
|
848
|
-
if (beforeSend) {
|
|
849
|
-
const fn = beforeSend();
|
|
850
|
-
if (fn && typeof fn.then === "function") {
|
|
851
|
-
Promise.resolve(fn).then((res) => {
|
|
852
|
-
if (res.result) {
|
|
853
|
-
currentComponentName.value = res.componentName || "";
|
|
854
|
-
handleSend(content, fileList, auto, type);
|
|
855
|
-
}
|
|
856
|
-
}).catch((error) => {
|
|
857
|
-
console.log(error);
|
|
858
|
-
});
|
|
859
|
-
} else {
|
|
860
|
-
if (fn.result) {
|
|
861
|
-
currentComponentName.value = fn.componentName || "";
|
|
862
|
-
handleSend(content, fileList, auto, type);
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
};
|
|
867
|
-
const handleSend = (content, fileList, auto, type) => {
|
|
868
|
-
emit("beforeSendMessage");
|
|
869
|
-
sendMessageInject(inputValue.value, fileData.value);
|
|
870
|
-
typeFlag.value = type || "";
|
|
871
|
-
if (scripts && Array.isArray(scripts) && scripts.length > 0) {
|
|
872
|
-
const userInput = content ? content.replace(/\n/g, "") : inputValue.value.replace(/\n/g, "").trim();
|
|
873
|
-
if (!userInput && !(fileList == null ? void 0 : fileList.length) && auto)
|
|
874
|
-
return;
|
|
875
|
-
const userChatId = `user_${Date.now()}`;
|
|
876
|
-
const userMessage = {
|
|
877
|
-
chatId: userChatId,
|
|
878
|
-
user: "u",
|
|
879
|
-
type: "text",
|
|
880
|
-
content: userInput,
|
|
881
|
-
isShowLike: false,
|
|
882
|
-
isShowCopy: true,
|
|
883
|
-
files: fileList || [],
|
|
884
|
-
typeFlag: type,
|
|
885
|
-
auto: auto || false
|
|
886
|
-
};
|
|
887
|
-
chatList.value.push(userMessage);
|
|
888
|
-
emit("sendMessage", [...chatList.value]);
|
|
889
|
-
vue.nextTick(() => {
|
|
890
|
-
renderContent(userMessage.content, "main", chatList.value.length - 1);
|
|
891
|
-
vue.nextTick(() => {
|
|
892
|
-
scrollToBottom();
|
|
893
|
-
});
|
|
894
|
-
});
|
|
895
|
-
const result = findMatchingScriptContent(userInput);
|
|
896
|
-
if (result && result.responses.length > 0) {
|
|
897
|
-
const newAiMessages = [];
|
|
898
|
-
result.responses.forEach((response, idx) => {
|
|
899
|
-
const pauseMarker = Array.isArray(response.data) ? "\u200B".repeat(20) : "";
|
|
900
|
-
const content2 = Array.isArray(response.data) ? response.data.join(pauseMarker) : response.data;
|
|
901
|
-
const aiChatId = `ai_${Date.now()}_${idx}`;
|
|
902
|
-
const aiMessage = {
|
|
903
|
-
chatId: aiChatId,
|
|
904
|
-
user: "ai",
|
|
905
|
-
type: "text",
|
|
906
|
-
content: content2 || "",
|
|
907
|
-
// componentName: response.needSequenceProcessing ? '' : response.type || '',
|
|
908
|
-
componentName: response.type || "",
|
|
909
|
-
isShowLike: true,
|
|
910
|
-
isShowCopy: true,
|
|
911
|
-
needSequenceType: response.type || "",
|
|
912
|
-
needSequenceProcessing: response.needSequenceProcessing || false,
|
|
913
|
-
typeFlag: type
|
|
914
|
-
};
|
|
915
|
-
newAiMessages.push(aiMessage);
|
|
916
|
-
});
|
|
917
|
-
let messageQueue = [...newAiMessages];
|
|
918
|
-
let isProcessing = false;
|
|
919
|
-
let currentMessage = null;
|
|
920
|
-
const processNextMessage = () => {
|
|
921
|
-
if (messageQueue.length > 0 && !isProcessing) {
|
|
922
|
-
isProcessing = true;
|
|
923
|
-
const nextMessage = messageQueue.shift();
|
|
924
|
-
if (nextMessage) {
|
|
925
|
-
currentMessage = nextMessage;
|
|
926
|
-
console.log("\u5F00\u59CB\u5904\u7406\u6D88\u606F:", currentMessage.chatId);
|
|
927
|
-
chatList.value.push(currentMessage);
|
|
928
|
-
emit("sendMessage", [...chatList.value]);
|
|
929
|
-
const msgIndex = chatList.value.length - 1;
|
|
930
|
-
vue.nextTick(() => {
|
|
931
|
-
renderContent((currentMessage == null ? void 0 : currentMessage.content) || "", "main", msgIndex);
|
|
932
|
-
vue.nextTick(() => {
|
|
933
|
-
scrollToBottom();
|
|
934
|
-
if (currentMessage) {
|
|
935
|
-
const messageToProcess = {
|
|
936
|
-
...currentMessage,
|
|
937
|
-
needSequenceProcessing: true
|
|
938
|
-
};
|
|
939
|
-
simulateStreamOutput(msgIndex, messageToProcess);
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
const handleMessageComplete = (chatId) => {
|
|
947
|
-
if (currentMessage && currentMessage.chatId === chatId) {
|
|
948
|
-
console.log("\u5E8F\u5217\u6D88\u606F\u5904\u7406\u5B8C\u6210\uFF0C\u5904\u7406\u4E0B\u4E00\u6761:", chatId);
|
|
949
|
-
currentMessage = null;
|
|
950
|
-
isProcessing = false;
|
|
951
|
-
processNextMessage();
|
|
952
|
-
}
|
|
953
|
-
};
|
|
954
|
-
const processorObj = {
|
|
955
|
-
messageQueue,
|
|
956
|
-
isProcessing,
|
|
957
|
-
currentMessage,
|
|
958
|
-
processNextMessage,
|
|
959
|
-
handleMessageComplete
|
|
960
|
-
};
|
|
961
|
-
currentMessageProcessor.value = processorObj;
|
|
962
|
-
processNextMessage();
|
|
963
|
-
} else {
|
|
964
|
-
const defaultAiChatId = `ai_${Date.now()}`;
|
|
965
|
-
const defaultAiMessage = {
|
|
966
|
-
chatId: defaultAiChatId,
|
|
967
|
-
user: "ai",
|
|
968
|
-
type: "text",
|
|
969
|
-
content: unmatchText,
|
|
970
|
-
isShowLike: true,
|
|
971
|
-
isShowCopy: true
|
|
972
|
-
};
|
|
973
|
-
chatList.value.push(defaultAiMessage);
|
|
974
|
-
emit("sendMessage", [...chatList.value]);
|
|
975
|
-
vue.nextTick(() => {
|
|
976
|
-
const msgIndex = chatList.value.findIndex((item) => item.chatId === defaultAiChatId);
|
|
977
|
-
if (msgIndex !== -1) {
|
|
978
|
-
renderContent(defaultAiMessage.content, "main", msgIndex);
|
|
979
|
-
vue.nextTick(() => {
|
|
980
|
-
scrollToBottom();
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
|
-
});
|
|
984
|
-
}
|
|
985
|
-
inputValue.value = "";
|
|
986
|
-
} else {
|
|
987
|
-
if (content) {
|
|
988
|
-
inputValue.value = content;
|
|
989
|
-
}
|
|
990
|
-
if ((isChating.value || !inputValue.value.trim() && !(fileList == null ? void 0 : fileList.length)) && !auto)
|
|
991
|
-
return;
|
|
992
|
-
const userChatId = "user_" + Math.random().toString(36).slice(2).padEnd(10, "0").slice(0, 10);
|
|
993
|
-
const userMessage = {
|
|
994
|
-
chatId: userChatId,
|
|
995
|
-
user: "u",
|
|
996
|
-
type: "text",
|
|
997
|
-
content: inputValue.value,
|
|
998
|
-
files: fileList || []
|
|
999
|
-
};
|
|
1000
|
-
chatList.value.push(userMessage);
|
|
1001
|
-
const index = chatList.value.length - 1;
|
|
1002
|
-
vue.nextTick(() => {
|
|
1003
|
-
renderContent(userMessage.content, "main", index);
|
|
1004
|
-
scrollToBottom();
|
|
1005
|
-
});
|
|
1006
|
-
openSSE(inputValue.value, index + 1, 1);
|
|
1007
|
-
inputValue.value = "";
|
|
1008
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
const handleStop = () => {
|
|
1011
|
-
var _a, _b;
|
|
1012
|
-
(_a = fetchStream$1.value) == null ? void 0 : _a.abort();
|
|
1013
|
-
const aiIndex = chatList.value.findIndex((item) => item.isChating);
|
|
1014
|
-
if (aiIndex !== -1) {
|
|
1015
|
-
const currentAiMessage = chatList.value[aiIndex];
|
|
1016
|
-
if ((_b = currentAiMessage.content) == null ? void 0 : _b.trim()) {
|
|
1017
|
-
vue.nextTick(() => {
|
|
1018
|
-
chatList.value[aiIndex] = {
|
|
1019
|
-
...currentAiMessage,
|
|
1020
|
-
content: currentAiMessage.content + "...",
|
|
1021
|
-
isChating: false
|
|
1022
|
-
};
|
|
1023
|
-
renderContent(chatList.value[aiIndex].content, "main", aiIndex);
|
|
1024
|
-
emit("sendMessage", chatList.value);
|
|
1025
|
-
});
|
|
1026
|
-
} else {
|
|
1027
|
-
if (aiIndex > 0) {
|
|
1028
|
-
const userMessageIndex = aiIndex - 1;
|
|
1029
|
-
if (chatList.value[userMessageIndex].user === "u") {
|
|
1030
|
-
chatList.value.splice(userMessageIndex, 2);
|
|
1031
|
-
} else {
|
|
1032
|
-
chatList.value.splice(aiIndex, 1);
|
|
1033
|
-
}
|
|
1034
|
-
} else {
|
|
1035
|
-
chatList.value.splice(aiIndex, 1);
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
} else {
|
|
1039
|
-
const lastIndex = chatList.value.length - 1;
|
|
1040
|
-
if (lastIndex >= 0 && chatList.value[lastIndex].user === "u") {
|
|
1041
|
-
chatList.value.pop();
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
isChating.value = false;
|
|
1045
|
-
};
|
|
1046
|
-
const scrollObserver = vue.ref(null);
|
|
1047
|
-
const scrollToBottom = () => {
|
|
1048
|
-
if (!isMounted.value || isUnmounting.value || !chatContainer.value)
|
|
1049
|
-
return;
|
|
1050
|
-
vue.nextTick(() => {
|
|
1051
|
-
requestAnimationFrame(() => {
|
|
1052
|
-
const chatContainerEl = chatContainer.value;
|
|
1053
|
-
const lastMessage = chatContainerEl.querySelector(".touchchat-dialog-content > *:last-child");
|
|
1054
|
-
if (lastMessage) {
|
|
1055
|
-
const { height: messageHeight } = lastMessage.getBoundingClientRect();
|
|
1056
|
-
const containerHeight = chatContainerEl.clientHeight;
|
|
1057
|
-
const messageBottom = lastMessage.offsetTop + lastMessage.offsetHeight;
|
|
1058
|
-
if (messageHeight > containerHeight) {
|
|
1059
|
-
chatContainerEl.scrollTop = lastMessage.offsetTop;
|
|
1060
|
-
} else {
|
|
1061
|
-
chatContainerEl.scrollTop = messageBottom - containerHeight;
|
|
1062
|
-
}
|
|
1063
|
-
if (scrollObserver.value) {
|
|
1064
|
-
scrollObserver.value.disconnect();
|
|
1065
|
-
}
|
|
1066
|
-
scrollObserver.value = new MutationObserver(() => {
|
|
1067
|
-
const updatedMessageBottom = lastMessage.offsetTop + lastMessage.offsetHeight;
|
|
1068
|
-
chatContainerEl.scrollTop = Math.max(updatedMessageBottom - containerHeight, chatContainerEl.scrollTop);
|
|
1069
|
-
});
|
|
1070
|
-
scrollObserver.value.observe(lastMessage, {
|
|
1071
|
-
childList: true,
|
|
1072
|
-
subtree: true,
|
|
1073
|
-
characterData: true,
|
|
1074
|
-
attributes: true,
|
|
1075
|
-
// 新增监听属性变化(如高度)
|
|
1076
|
-
attributeFilter: ["style", "class"]
|
|
1077
|
-
// 只监听样式相关属性
|
|
1078
|
-
});
|
|
1079
|
-
} else {
|
|
1080
|
-
chatContainerEl.scrollTo({
|
|
1081
|
-
top: chatContainerEl.scrollHeight,
|
|
1082
|
-
behavior: "smooth"
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
});
|
|
1086
|
-
});
|
|
1087
|
-
};
|
|
1088
|
-
const handleMessageAction = (action, index) => {
|
|
1089
|
-
const message = chatList.value[index];
|
|
1090
|
-
if (!message)
|
|
1091
|
-
return;
|
|
1092
|
-
switch (action) {
|
|
1093
|
-
case TouchChat.MessageAction.COPY: {
|
|
1094
|
-
const textContent = message.content;
|
|
1095
|
-
navigator.clipboard.writeText(textContent).then(() => {
|
|
1096
|
-
tools.showToast("\u590D\u5236\u6210\u529F", "info");
|
|
1097
|
-
}).catch((err) => {
|
|
1098
|
-
console.error("\u590D\u5236\u5931\u8D25:", err);
|
|
1099
|
-
tools.showToast("\u590D\u5236\u5931\u8D25", "error");
|
|
1100
|
-
});
|
|
1101
|
-
break;
|
|
1102
|
-
}
|
|
1103
|
-
case TouchChat.MessageAction.EDIT:
|
|
1104
|
-
message.isEditing = true;
|
|
1105
|
-
message.editContent = message.content;
|
|
1106
|
-
break;
|
|
1107
|
-
case TouchChat.MessageAction.DELETE:
|
|
1108
|
-
messageUtils.deleteMessageChain(index);
|
|
1109
|
-
emit("sendMessage", chatList.value);
|
|
1110
|
-
break;
|
|
1111
|
-
case TouchChat.MessageAction.RETRY: {
|
|
1112
|
-
const aiMessage = chatList.value[index];
|
|
1113
|
-
const userMessageIndex = index - 1;
|
|
1114
|
-
const userMessage = chatList.value[userMessageIndex];
|
|
1115
|
-
if (userMessage && userMessage.user === "u") {
|
|
1116
|
-
const updatedAiMessage = {
|
|
1117
|
-
...aiMessage,
|
|
1118
|
-
content: "",
|
|
1119
|
-
thinkContent: "",
|
|
1120
|
-
reasoningContent: "",
|
|
1121
|
-
isLiked: false,
|
|
1122
|
-
isDisliked: false,
|
|
1123
|
-
isChating: true,
|
|
1124
|
-
chatId: aiMessage.chatId,
|
|
1125
|
-
user: aiMessage.user,
|
|
1126
|
-
type: aiMessage.type,
|
|
1127
|
-
thinkStatus: TouchChat.ThinkStatus.COMPLETED,
|
|
1128
|
-
thinkStartTime: 0,
|
|
1129
|
-
thinkEndTime: 0
|
|
1130
|
-
};
|
|
1131
|
-
chatList.value.splice(index, 1, updatedAiMessage);
|
|
1132
|
-
vue.nextTick(() => {
|
|
1133
|
-
if (htmlContentRef.value[index])
|
|
1134
|
-
htmlContentRef.value[index].innerHTML = "";
|
|
1135
|
-
if (thinkingContentRef.value[index])
|
|
1136
|
-
thinkingContentRef.value[index].innerHTML = "";
|
|
1137
|
-
if (reasoningContentRef.value[index])
|
|
1138
|
-
reasoningContentRef.value[index].innerHTML = "";
|
|
1139
|
-
setTimeout(() => {
|
|
1140
|
-
openSSE(userMessage.content || "", index, 2);
|
|
1141
|
-
}, 50);
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
break;
|
|
1145
|
-
}
|
|
1146
|
-
case TouchChat.MessageAction.LIKE:
|
|
1147
|
-
messageUtils.updateMessage(index, {
|
|
1148
|
-
isLiked: true,
|
|
1149
|
-
isDisliked: false
|
|
1150
|
-
});
|
|
1151
|
-
break;
|
|
1152
|
-
case TouchChat.MessageAction.DISLIKE:
|
|
1153
|
-
messageUtils.updateMessage(index, {
|
|
1154
|
-
isLiked: false,
|
|
1155
|
-
isDisliked: true
|
|
1156
|
-
});
|
|
1157
|
-
break;
|
|
1158
|
-
}
|
|
112
|
+
const toggleSidebarClick = (item, index) => {
|
|
113
|
+
emit("toggleSidebar", item, index);
|
|
1159
114
|
};
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
return;
|
|
1164
|
-
chatList.value[index] = {
|
|
1165
|
-
...message,
|
|
1166
|
-
content: newContent,
|
|
1167
|
-
isEditing: false,
|
|
1168
|
-
editContent: void 0
|
|
1169
|
-
};
|
|
1170
|
-
vue.nextTick(() => {
|
|
1171
|
-
renderContent(message.content, "main", index);
|
|
1172
|
-
});
|
|
1173
|
-
if (index + 1 < chatList.value.length && chatList.value[index + 1].user === "ai") {
|
|
1174
|
-
chatList.value.splice(index + 1, 1);
|
|
115
|
+
const itemUploadFile = (_item, index) => {
|
|
116
|
+
if (ChatInputRef.value) {
|
|
117
|
+
ChatInputRef.value.itemUploadFile(index, "drop");
|
|
1175
118
|
}
|
|
1176
|
-
openSSE(newContent, index + 1);
|
|
1177
|
-
emit("sendMessage", chatList.value);
|
|
1178
|
-
};
|
|
1179
|
-
const cancelEdit = (index) => {
|
|
1180
|
-
const message = chatList.value[index];
|
|
1181
|
-
if (!message)
|
|
1182
|
-
return;
|
|
1183
|
-
message.isEditing = false;
|
|
1184
|
-
message.editContent = "";
|
|
1185
|
-
vue.nextTick(() => {
|
|
1186
|
-
renderContent(message.content, "main", index);
|
|
1187
|
-
});
|
|
1188
119
|
};
|
|
1189
|
-
vue.onMounted(
|
|
1190
|
-
|
|
1191
|
-
init();
|
|
1192
|
-
}
|
|
1193
|
-
isMounted.value = true;
|
|
120
|
+
vue.onMounted(() => {
|
|
121
|
+
chatOnMounted();
|
|
1194
122
|
vue.watch(
|
|
1195
123
|
() => scripts,
|
|
1196
124
|
() => {
|
|
@@ -1200,84 +128,8 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
1200
128
|
);
|
|
1201
129
|
});
|
|
1202
130
|
vue.onBeforeUnmount(() => {
|
|
1203
|
-
|
|
1204
|
-
isUnmounting.value = true;
|
|
1205
|
-
if (fetchStream$1.value) {
|
|
1206
|
-
fetchStream$1.value.abort();
|
|
1207
|
-
fetchStream$1.value = null;
|
|
1208
|
-
}
|
|
1209
|
-
if (TouchChatRobot.value) {
|
|
1210
|
-
TouchChatRobot.value.close();
|
|
1211
|
-
TouchChatRobot.value = void 0;
|
|
1212
|
-
}
|
|
1213
|
-
isMounted.value = false;
|
|
1214
|
-
renderQueue.value = [];
|
|
1215
|
-
htmlContentRef.value = [];
|
|
1216
|
-
thinkingContentRef.value = [];
|
|
1217
|
-
reasoningContentRef.value = [];
|
|
1218
|
-
}
|
|
1219
|
-
if (scrollObserver.value) {
|
|
1220
|
-
scrollObserver.value.disconnect();
|
|
1221
|
-
scrollObserver.value = null;
|
|
1222
|
-
}
|
|
131
|
+
chatOnBeforeUnmount();
|
|
1223
132
|
});
|
|
1224
|
-
const handleDragEnter = () => {
|
|
1225
|
-
if (ChatInputRef.value) {
|
|
1226
|
-
ChatInputRef.value.openMarkLayer();
|
|
1227
|
-
}
|
|
1228
|
-
isDragging.value = true;
|
|
1229
|
-
};
|
|
1230
|
-
const handleDragLeave = (e) => {
|
|
1231
|
-
const rect = e.target.getBoundingClientRect();
|
|
1232
|
-
if (e.clientX < rect.left || e.clientX > rect.right || e.clientY < rect.top || e.clientY > rect.bottom) {
|
|
1233
|
-
isDragging.value = false;
|
|
1234
|
-
}
|
|
1235
|
-
};
|
|
1236
|
-
const handleDrop = async (e) => {
|
|
1237
|
-
var _a;
|
|
1238
|
-
isDragging.value = false;
|
|
1239
|
-
const files = (_a = e.dataTransfer) == null ? void 0 : _a.files;
|
|
1240
|
-
if (files && files.length > 0) {
|
|
1241
|
-
const fileList = await Promise.all(
|
|
1242
|
-
Array.from(files).map(async (file) => {
|
|
1243
|
-
let base64 = "";
|
|
1244
|
-
if (file.type.startsWith("image/")) {
|
|
1245
|
-
base64 = await new Promise((resolve) => {
|
|
1246
|
-
const reader = new FileReader();
|
|
1247
|
-
reader.onload = (e2) => {
|
|
1248
|
-
var _a2;
|
|
1249
|
-
resolve((_a2 = e2.target) == null ? void 0 : _a2.result);
|
|
1250
|
-
};
|
|
1251
|
-
reader.readAsDataURL(file);
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1254
|
-
return {
|
|
1255
|
-
// id: crypto.randomUUID().replace(/-/gi, ''),
|
|
1256
|
-
id: Math.random().toString(36).slice(2).padEnd(10, "0").slice(0, 10),
|
|
1257
|
-
file,
|
|
1258
|
-
name: file.name,
|
|
1259
|
-
fileType: file.type,
|
|
1260
|
-
fileSize: file.size,
|
|
1261
|
-
lastModified: file.lastModified,
|
|
1262
|
-
preview: URL.createObjectURL(file),
|
|
1263
|
-
base64
|
|
1264
|
-
};
|
|
1265
|
-
})
|
|
1266
|
-
);
|
|
1267
|
-
if (ChatInputRef.value) {
|
|
1268
|
-
ChatInputRef.value.handlePaste(fileList, "drop");
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
if (ChatInputRef.value) {
|
|
1272
|
-
ChatInputRef.value.colseMarkLayer();
|
|
1273
|
-
}
|
|
1274
|
-
};
|
|
1275
|
-
const itemUploadFile = (item, index) => {
|
|
1276
|
-
console.log("itemUploadFile", item, index);
|
|
1277
|
-
if (ChatInputRef.value) {
|
|
1278
|
-
ChatInputRef.value.itemUploadFile(index, "drop");
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
133
|
vue.provide("touchchat", {
|
|
1282
134
|
send: sendMessage,
|
|
1283
135
|
retry: handleMessageAction
|
|
@@ -1288,7 +140,7 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
1288
140
|
},
|
|
1289
141
|
handleAgentSelect,
|
|
1290
142
|
retry: (index) => {
|
|
1291
|
-
handleMessageAction(
|
|
143
|
+
handleMessageAction(types.MessageAction.RETRY, index);
|
|
1292
144
|
},
|
|
1293
145
|
update
|
|
1294
146
|
});
|
|
@@ -1297,118 +149,112 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
1297
149
|
class: "touchchat-main",
|
|
1298
150
|
onDragover: vue.withModifiers(() => {
|
|
1299
151
|
}, ["prevent"]),
|
|
1300
|
-
onDragenter: vue.withModifiers(handleDragEnter, ["prevent"]),
|
|
1301
|
-
onDragleave: handleDragLeave,
|
|
1302
|
-
onDrop: vue.withModifiers(handleDrop, ["prevent"])
|
|
152
|
+
onDragenter: vue.withModifiers(vue.unref(handleDragEnter), ["prevent"]),
|
|
153
|
+
onDragleave: vue.unref(handleDragLeave),
|
|
154
|
+
onDrop: vue.withModifiers(vue.unref(handleDrop), ["prevent"])
|
|
1303
155
|
}, [
|
|
1304
|
-
vue.createElementVNode(
|
|
1305
|
-
"
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
}, [
|
|
1318
|
-
vue.renderSlot(_ctx.$slots, "welcome", {}, () => [
|
|
1319
|
-
vue.createVNode(HelloChat.default, { onSendMessage: sendMessage })
|
|
1320
|
-
])
|
|
1321
|
-
])) : vue.createCommentVNode("v-if", true),
|
|
1322
|
-
vue.createElementVNode("div", { class: "touchchat-dialog-content" }, [
|
|
1323
|
-
(vue.openBlock(true), vue.createElementBlock(
|
|
1324
|
-
vue.Fragment,
|
|
1325
|
-
null,
|
|
1326
|
-
vue.renderList(chatList.value, (item, index) => {
|
|
1327
|
-
return vue.openBlock(), vue.createElementBlock(
|
|
1328
|
-
vue.Fragment,
|
|
1329
|
-
{
|
|
1330
|
-
key: item.chatId
|
|
1331
|
-
},
|
|
1332
|
-
[
|
|
1333
|
-
item.user === "u" ? (vue.openBlock(), vue.createBlock(UserMessage.default, {
|
|
1334
|
-
key: 0,
|
|
1335
|
-
item,
|
|
1336
|
-
index,
|
|
1337
|
-
onUserMessageFileList: itemUploadFile,
|
|
1338
|
-
onCopy: ($event) => handleMessageAction(vue.unref(TouchChat.MessageAction).COPY, index),
|
|
1339
|
-
onEdit: ($event) => handleMessageAction(vue.unref(TouchChat.MessageAction).EDIT, index),
|
|
1340
|
-
onDelete: ($event) => handleMessageAction(vue.unref(TouchChat.MessageAction).DELETE, index),
|
|
1341
|
-
onSaveEdit: saveEdit,
|
|
1342
|
-
onCancelEdit: ($event) => cancelEdit(index)
|
|
1343
|
-
}, {
|
|
1344
|
-
userAvatar: vue.withCtx(() => [
|
|
1345
|
-
vue.renderSlot(_ctx.$slots, "userAvatar")
|
|
1346
|
-
]),
|
|
1347
|
-
fn: vue.withCtx(() => [
|
|
1348
|
-
vue.renderSlot(_ctx.$slots, "fn", {
|
|
1349
|
-
item,
|
|
1350
|
-
index
|
|
1351
|
-
})
|
|
1352
|
-
]),
|
|
1353
|
-
_: 2
|
|
1354
|
-
/* DYNAMIC */
|
|
1355
|
-
}, 1032, ["item", "index", "onCopy", "onEdit", "onDelete", "onCancelEdit"])) : (vue.openBlock(), vue.createBlock(AiMessage.default, {
|
|
1356
|
-
key: 1,
|
|
1357
|
-
item,
|
|
1358
|
-
index,
|
|
1359
|
-
"enable-deep-thinking": enableDeepThinking.value,
|
|
1360
|
-
"has-retry": activeAgentsName.value || vue.unref(scripts).length > 0 ? false : true,
|
|
1361
|
-
onCopy: ($event) => handleMessageAction(vue.unref(TouchChat.MessageAction).COPY, index),
|
|
1362
|
-
onRetry: ($event) => handleMessageAction(vue.unref(TouchChat.MessageAction).RETRY, index),
|
|
1363
|
-
onLike: ($event) => handleMessageAction(vue.unref(TouchChat.MessageAction).LIKE, index),
|
|
1364
|
-
onDislike: ($event) => handleMessageAction(vue.unref(TouchChat.MessageAction).DISLIKE, index),
|
|
1365
|
-
onContentRendered: attachCopyButtons,
|
|
1366
|
-
onCompleteRendered: (chatId) => completeRendered(chatId),
|
|
1367
|
-
onToggleSidebar: toggleSidebarClick
|
|
1368
|
-
}, {
|
|
1369
|
-
aimsg: vue.withCtx(() => [
|
|
1370
|
-
vue.renderSlot(_ctx.$slots, "aimsg", {
|
|
1371
|
-
item,
|
|
1372
|
-
index
|
|
1373
|
-
})
|
|
1374
|
-
]),
|
|
1375
|
-
msg: vue.withCtx(() => [
|
|
1376
|
-
vue.renderSlot(_ctx.$slots, "msg", {
|
|
1377
|
-
item,
|
|
1378
|
-
index
|
|
1379
|
-
})
|
|
1380
|
-
]),
|
|
1381
|
-
aiAvatar: vue.withCtx(() => [
|
|
1382
|
-
vue.renderSlot(_ctx.$slots, "aiAvatar")
|
|
1383
|
-
]),
|
|
1384
|
-
fn: vue.withCtx(() => [
|
|
1385
|
-
vue.renderSlot(_ctx.$slots, "fn", {
|
|
1386
|
-
item,
|
|
1387
|
-
index
|
|
1388
|
-
})
|
|
1389
|
-
]),
|
|
1390
|
-
extendsFn: vue.withCtx(() => [
|
|
1391
|
-
vue.renderSlot(_ctx.$slots, "extendsFn", {
|
|
1392
|
-
item,
|
|
1393
|
-
index
|
|
1394
|
-
})
|
|
1395
|
-
]),
|
|
1396
|
-
_: 2
|
|
1397
|
-
/* DYNAMIC */
|
|
1398
|
-
}, 1032, ["item", "index", "enable-deep-thinking", "has-retry", "onCopy", "onRetry", "onLike", "onDislike", "onCompleteRendered"]))
|
|
1399
|
-
],
|
|
1400
|
-
64
|
|
1401
|
-
/* STABLE_FRAGMENT */
|
|
1402
|
-
);
|
|
1403
|
-
}),
|
|
1404
|
-
128
|
|
1405
|
-
/* KEYED_FRAGMENT */
|
|
1406
|
-
))
|
|
156
|
+
vue.createElementVNode("div", {
|
|
157
|
+
ref_key: "chatContainer",
|
|
158
|
+
ref: chatContainer,
|
|
159
|
+
class: "touchchat-dialog",
|
|
160
|
+
onScroll: vue.unref(handleScroll)
|
|
161
|
+
}, [
|
|
162
|
+
vue.renderSlot(_ctx.$slots, "top"),
|
|
163
|
+
vue.unref(chatList).length === 0 ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
164
|
+
key: 0,
|
|
165
|
+
class: "touchchat-welcome"
|
|
166
|
+
}, [
|
|
167
|
+
vue.renderSlot(_ctx.$slots, "welcome", {}, () => [
|
|
168
|
+
vue.createVNode(HelloChat.default, { onSendMessage: vue.unref(sendMessage) }, null, 8, ["onSendMessage"])
|
|
1407
169
|
])
|
|
1408
|
-
],
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
170
|
+
])) : vue.createCommentVNode("v-if", true),
|
|
171
|
+
vue.createElementVNode("div", { class: "touchchat-dialog-content" }, [
|
|
172
|
+
(vue.openBlock(true), vue.createElementBlock(
|
|
173
|
+
vue.Fragment,
|
|
174
|
+
null,
|
|
175
|
+
vue.renderList(vue.unref(chatList), (item, index) => {
|
|
176
|
+
return vue.openBlock(), vue.createElementBlock(
|
|
177
|
+
vue.Fragment,
|
|
178
|
+
{
|
|
179
|
+
key: item.chatId
|
|
180
|
+
},
|
|
181
|
+
[
|
|
182
|
+
item.user === "u" ? (vue.openBlock(), vue.createBlock(UserMessage.default, {
|
|
183
|
+
key: 0,
|
|
184
|
+
item,
|
|
185
|
+
index,
|
|
186
|
+
onUserMessageFileList: itemUploadFile,
|
|
187
|
+
onCopy: ($event) => vue.unref(handleMessageAction)(vue.unref(types.MessageAction).COPY, index),
|
|
188
|
+
onEdit: ($event) => vue.unref(handleMessageAction)(vue.unref(types.MessageAction).EDIT, index),
|
|
189
|
+
onDelete: ($event) => vue.unref(handleMessageAction)(vue.unref(types.MessageAction).DELETE, index),
|
|
190
|
+
onSaveEdit: vue.unref(saveEdit),
|
|
191
|
+
onCancelEdit: ($event) => vue.unref(cancelEdit)(index)
|
|
192
|
+
}, {
|
|
193
|
+
userAvatar: vue.withCtx(() => [
|
|
194
|
+
vue.renderSlot(_ctx.$slots, "userAvatar")
|
|
195
|
+
]),
|
|
196
|
+
fn: vue.withCtx(() => [
|
|
197
|
+
vue.renderSlot(_ctx.$slots, "fn", {
|
|
198
|
+
item,
|
|
199
|
+
index
|
|
200
|
+
})
|
|
201
|
+
]),
|
|
202
|
+
_: 2
|
|
203
|
+
/* DYNAMIC */
|
|
204
|
+
}, 1032, ["item", "index", "onCopy", "onEdit", "onDelete", "onSaveEdit", "onCancelEdit"])) : (vue.openBlock(), vue.createBlock(AiMessage.default, {
|
|
205
|
+
key: 1,
|
|
206
|
+
item,
|
|
207
|
+
index,
|
|
208
|
+
"enable-deep-thinking": vue.unref(enableDeepThinking),
|
|
209
|
+
"has-retry": vue.unref(activeAgentsName) || scriptsLength.value > 0 ? false : true,
|
|
210
|
+
onCopy: ($event) => vue.unref(handleMessageAction)(vue.unref(types.MessageAction).COPY, index),
|
|
211
|
+
onRetry: ($event) => vue.unref(handleMessageAction)(vue.unref(types.MessageAction).RETRY, index),
|
|
212
|
+
onLike: ($event) => vue.unref(handleMessageAction)(vue.unref(types.MessageAction).LIKE, index),
|
|
213
|
+
onDislike: ($event) => vue.unref(handleMessageAction)(vue.unref(types.MessageAction).DISLIKE, index),
|
|
214
|
+
onContentRendered: attachCopyButtons,
|
|
215
|
+
onCompleteRendered: vue.unref(completeRendered),
|
|
216
|
+
onToggleSidebar: toggleSidebarClick
|
|
217
|
+
}, {
|
|
218
|
+
aimsg: vue.withCtx(() => [
|
|
219
|
+
vue.renderSlot(_ctx.$slots, "aimsg", {
|
|
220
|
+
item,
|
|
221
|
+
index
|
|
222
|
+
})
|
|
223
|
+
]),
|
|
224
|
+
msg: vue.withCtx(() => [
|
|
225
|
+
vue.renderSlot(_ctx.$slots, "msg", {
|
|
226
|
+
item,
|
|
227
|
+
index
|
|
228
|
+
})
|
|
229
|
+
]),
|
|
230
|
+
aiAvatar: vue.withCtx(() => [
|
|
231
|
+
vue.renderSlot(_ctx.$slots, "aiAvatar")
|
|
232
|
+
]),
|
|
233
|
+
fn: vue.withCtx(() => [
|
|
234
|
+
vue.renderSlot(_ctx.$slots, "fn", {
|
|
235
|
+
item,
|
|
236
|
+
index
|
|
237
|
+
})
|
|
238
|
+
]),
|
|
239
|
+
extendsFn: vue.withCtx(() => [
|
|
240
|
+
vue.renderSlot(_ctx.$slots, "extendsFn", {
|
|
241
|
+
item,
|
|
242
|
+
index
|
|
243
|
+
})
|
|
244
|
+
]),
|
|
245
|
+
_: 2
|
|
246
|
+
/* DYNAMIC */
|
|
247
|
+
}, 1032, ["item", "index", "enable-deep-thinking", "has-retry", "onCopy", "onRetry", "onLike", "onDislike", "onCompleteRendered"]))
|
|
248
|
+
],
|
|
249
|
+
64
|
|
250
|
+
/* STABLE_FRAGMENT */
|
|
251
|
+
);
|
|
252
|
+
}),
|
|
253
|
+
128
|
|
254
|
+
/* KEYED_FRAGMENT */
|
|
255
|
+
))
|
|
256
|
+
])
|
|
257
|
+
], 40, ["onScroll"]),
|
|
1412
258
|
_ctx.$slots.shortcut ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
1413
259
|
key: 0,
|
|
1414
260
|
class: "touchchat-edit-shortcut"
|
|
@@ -1419,15 +265,16 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
1419
265
|
vue.createVNode(ChatInput.default, {
|
|
1420
266
|
ref_key: "ChatInputRef",
|
|
1421
267
|
ref: ChatInputRef,
|
|
1422
|
-
"input-value": inputValue
|
|
1423
|
-
"onUpdate:inputValue": ($event) => inputValue.value = $event,
|
|
1424
|
-
"enable-deep-thinking": enableDeepThinking
|
|
1425
|
-
"onUpdate:enableDeepThinking": ($event) => enableDeepThinking.value = $event,
|
|
1426
|
-
"is-chating": isChating
|
|
1427
|
-
onSend: handleBeforeSend,
|
|
1428
|
-
onStop: handleStop,
|
|
268
|
+
"input-value": vue.unref(inputValue),
|
|
269
|
+
"onUpdate:inputValue": ($event) => vue.isRef(inputValue) ? inputValue.value = $event : null,
|
|
270
|
+
"enable-deep-thinking": vue.unref(enableDeepThinking),
|
|
271
|
+
"onUpdate:enableDeepThinking": ($event) => vue.isRef(enableDeepThinking) ? enableDeepThinking.value = $event : null,
|
|
272
|
+
"is-chating": vue.unref(isChating),
|
|
273
|
+
onSend: vue.unref(handleBeforeSend),
|
|
274
|
+
onStop: vue.unref(handleStop),
|
|
1429
275
|
onToggleDeepThinking: (val) => enableDeepThinking.value = val,
|
|
1430
|
-
onModuleInfo:
|
|
276
|
+
onModuleInfo: (_info) => {
|
|
277
|
+
}
|
|
1431
278
|
}, {
|
|
1432
279
|
editTop: vue.withCtx(() => [
|
|
1433
280
|
vue.renderSlot(_ctx.$slots, "editTop")
|
|
@@ -1437,9 +284,9 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
1437
284
|
]),
|
|
1438
285
|
_: 3
|
|
1439
286
|
/* FORWARDED */
|
|
1440
|
-
}, 8, ["input-value", "onUpdate:inputValue", "enable-deep-thinking", "onUpdate:enableDeepThinking", "is-chating", "onToggleDeepThinking"])
|
|
287
|
+
}, 8, ["input-value", "onUpdate:inputValue", "enable-deep-thinking", "onUpdate:enableDeepThinking", "is-chating", "onSend", "onStop", "onToggleDeepThinking"])
|
|
1441
288
|
])
|
|
1442
|
-
], 40, ["onDragover"]);
|
|
289
|
+
], 40, ["onDragover", "onDragenter", "onDragleave", "onDrop"]);
|
|
1443
290
|
};
|
|
1444
291
|
}
|
|
1445
292
|
});
|