@docyrus/ui-pro-ai-assistant 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +68 -60
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -32006,6 +32006,7 @@ var DocyAssistant = ({
|
|
|
32006
32006
|
const authTokenRef = useRef("");
|
|
32007
32007
|
const messageOptionsRef = useRef(null);
|
|
32008
32008
|
const initialPromptSentRef = useRef(false);
|
|
32009
|
+
const isSendingRef = useRef(false);
|
|
32009
32010
|
const clientToolMap = useMemo(() => buildClientToolMap(clientTools), [clientTools]);
|
|
32010
32011
|
const clientToolDefs = useMemo(() => serializeClientTools(clientTools), [clientTools]);
|
|
32011
32012
|
const clientToolMapRef = useRef(clientToolMap);
|
|
@@ -32282,75 +32283,82 @@ var DocyAssistant = ({
|
|
|
32282
32283
|
};
|
|
32283
32284
|
const handleSendMessage = async (e, options3, overrideText) => {
|
|
32284
32285
|
e?.preventDefault();
|
|
32286
|
+
if (isSendingRef.current) return;
|
|
32287
|
+
if (status === "submitted" || status === "streaming") return;
|
|
32285
32288
|
const messageText = (overrideText ?? input).trim();
|
|
32286
32289
|
if (!messageText) return;
|
|
32290
|
+
isSendingRef.current = true;
|
|
32291
|
+
setInput("");
|
|
32287
32292
|
setShowWelcome(false);
|
|
32288
|
-
|
|
32289
|
-
|
|
32290
|
-
|
|
32291
|
-
|
|
32292
|
-
|
|
32293
|
-
|
|
32294
|
-
|
|
32295
|
-
|
|
32296
|
-
|
|
32297
|
-
|
|
32298
|
-
|
|
32299
|
-
|
|
32300
|
-
|
|
32301
|
-
|
|
32302
|
-
|
|
32303
|
-
|
|
32304
|
-
|
|
32305
|
-
|
|
32306
|
-
|
|
32307
|
-
|
|
32308
|
-
|
|
32309
|
-
|
|
32310
|
-
|
|
32311
|
-
|
|
32312
|
-
|
|
32313
|
-
|
|
32314
|
-
|
|
32293
|
+
try {
|
|
32294
|
+
messageOptionsRef.current = options3;
|
|
32295
|
+
let currentThreadId = selectedSessionIdRef.current;
|
|
32296
|
+
if (!currentThreadId) {
|
|
32297
|
+
const subject = messageText.substring(0, 100);
|
|
32298
|
+
const newThread = await createThread(apiClient, {
|
|
32299
|
+
subject,
|
|
32300
|
+
body_text: messageText,
|
|
32301
|
+
sender_name: userDisplayName,
|
|
32302
|
+
deploymentId,
|
|
32303
|
+
tenantAiAgentId: activeAgentId,
|
|
32304
|
+
projectId: projectState.projectContext?.id
|
|
32305
|
+
});
|
|
32306
|
+
if (newThread) {
|
|
32307
|
+
currentThreadId = newThread.id;
|
|
32308
|
+
sessionActions.selectSessionId(currentThreadId);
|
|
32309
|
+
selectedSessionIdRef.current = currentThreadId;
|
|
32310
|
+
const session = {
|
|
32311
|
+
id: newThread.id,
|
|
32312
|
+
title: newThread.subject || subject,
|
|
32313
|
+
messages: [],
|
|
32314
|
+
createdAt: new Date(newThread.created_on || /* @__PURE__ */ new Date()),
|
|
32315
|
+
updatedAt: new Date(newThread.last_modified_on || /* @__PURE__ */ new Date())
|
|
32316
|
+
};
|
|
32317
|
+
sessionActions.addSession(session);
|
|
32318
|
+
fetchThreads();
|
|
32319
|
+
if (projectState.projectContext?.id) {
|
|
32320
|
+
fetchProjectThreads2(projectState.projectContext.id);
|
|
32321
|
+
}
|
|
32322
|
+
} else {
|
|
32323
|
+
return;
|
|
32315
32324
|
}
|
|
32316
|
-
} else {
|
|
32317
|
-
return;
|
|
32318
32325
|
}
|
|
32319
|
-
|
|
32320
|
-
|
|
32321
|
-
|
|
32322
|
-
|
|
32323
|
-
|
|
32324
|
-
|
|
32325
|
-
|
|
32326
|
-
|
|
32327
|
-
|
|
32328
|
-
|
|
32329
|
-
|
|
32330
|
-
|
|
32326
|
+
onMessageSend?.(messageText);
|
|
32327
|
+
const rawFiles = options3?.files || [];
|
|
32328
|
+
const filePaths = [];
|
|
32329
|
+
if (rawFiles.length > 0 && currentThreadId) {
|
|
32330
|
+
for (const rawFile of rawFiles) {
|
|
32331
|
+
try {
|
|
32332
|
+
const file = dataUrlToFile(rawFile.url, rawFile.filename);
|
|
32333
|
+
const path = await uploadThreadFile(apiClient, currentThreadId, file);
|
|
32334
|
+
if (path) {
|
|
32335
|
+
filePaths.push(path);
|
|
32336
|
+
}
|
|
32337
|
+
} catch (error) {
|
|
32338
|
+
console.error("[FILE_UPLOAD] Error:", error);
|
|
32331
32339
|
}
|
|
32332
|
-
} catch (error) {
|
|
32333
|
-
console.error("[FILE_UPLOAD] Error:", error);
|
|
32334
32340
|
}
|
|
32335
32341
|
}
|
|
32342
|
+
messageOptionsRef.current = {
|
|
32343
|
+
...options3,
|
|
32344
|
+
filePaths: filePaths.length > 0 ? filePaths : void 0
|
|
32345
|
+
};
|
|
32346
|
+
await sendMessage({
|
|
32347
|
+
text: messageText,
|
|
32348
|
+
metadata: {
|
|
32349
|
+
modelId: options3?.modelId,
|
|
32350
|
+
supportMultipleModels: options3?.supportMultipleModels,
|
|
32351
|
+
supportFiles: options3?.supportFiles,
|
|
32352
|
+
supportWebSearch: options3?.supportWebSearch,
|
|
32353
|
+
supportDeepResearch: options3?.supportDeepResearch,
|
|
32354
|
+
supportDocumentSearch: options3?.supportDocumentSearch,
|
|
32355
|
+
supportThinking: options3?.supportThinking,
|
|
32356
|
+
supportWorkCanvas: options3?.supportWorkCanvas
|
|
32357
|
+
}
|
|
32358
|
+
});
|
|
32359
|
+
} finally {
|
|
32360
|
+
isSendingRef.current = false;
|
|
32336
32361
|
}
|
|
32337
|
-
messageOptionsRef.current = {
|
|
32338
|
-
...options3,
|
|
32339
|
-
filePaths: filePaths.length > 0 ? filePaths : void 0
|
|
32340
|
-
};
|
|
32341
|
-
await sendMessage({
|
|
32342
|
-
text: messageText,
|
|
32343
|
-
metadata: {
|
|
32344
|
-
modelId: options3?.modelId,
|
|
32345
|
-
supportMultipleModels: options3?.supportMultipleModels,
|
|
32346
|
-
supportFiles: options3?.supportFiles,
|
|
32347
|
-
supportWebSearch: options3?.supportWebSearch,
|
|
32348
|
-
supportDeepResearch: options3?.supportDeepResearch,
|
|
32349
|
-
supportDocumentSearch: options3?.supportDocumentSearch,
|
|
32350
|
-
supportThinking: options3?.supportThinking,
|
|
32351
|
-
supportWorkCanvas: options3?.supportWorkCanvas
|
|
32352
|
-
}
|
|
32353
|
-
});
|
|
32354
32362
|
};
|
|
32355
32363
|
useEffect(() => {
|
|
32356
32364
|
if (!initialPrompt || initialPromptSentRef.current) return;
|