@gendive/chatllm 0.17.3 → 0.17.4
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/react/index.js +92 -38
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +92 -38
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -2360,6 +2360,39 @@ ${finalContent}`;
|
|
|
2360
2360
|
...isHidden && { hidden: true },
|
|
2361
2361
|
...userContentParts && { contentParts: userContentParts }
|
|
2362
2362
|
};
|
|
2363
|
+
const capturedSessionId = sessionId;
|
|
2364
|
+
const currentSession2 = sessions.find((s) => s.id === capturedSessionId);
|
|
2365
|
+
const existingMessages = currentSession2?.messages || [];
|
|
2366
|
+
const isFirstMessage = !existingMessages.length;
|
|
2367
|
+
const contextSummary = currentSession2?.compressionState?.contextSummary || currentSession2?.contextSummary;
|
|
2368
|
+
const summaryAfterIndex = currentSession2?.compressionState?.summaryAfterIndex || currentSession2?.summaryAfterIndex || 0;
|
|
2369
|
+
let compressionCount = currentSession2?.compressionState?.compressionCount || 0;
|
|
2370
|
+
const assistantMessageId = generateId3("msg");
|
|
2371
|
+
const assistantMessage = {
|
|
2372
|
+
id: assistantMessageId,
|
|
2373
|
+
role: "assistant",
|
|
2374
|
+
content: "",
|
|
2375
|
+
model: selectedModel,
|
|
2376
|
+
timestamp: Date.now()
|
|
2377
|
+
};
|
|
2378
|
+
setInput("");
|
|
2379
|
+
setQuotedText(null);
|
|
2380
|
+
setSelectedAction(null);
|
|
2381
|
+
setAttachments([]);
|
|
2382
|
+
setSessions(
|
|
2383
|
+
(prev) => prev.map((s) => {
|
|
2384
|
+
if (s.id === capturedSessionId) {
|
|
2385
|
+
const newMessages = [...s.messages, userMessage, assistantMessage];
|
|
2386
|
+
return {
|
|
2387
|
+
...s,
|
|
2388
|
+
messages: newMessages,
|
|
2389
|
+
title: s.messages.length === 0 ? generateTitle([userMessage]) : s.title,
|
|
2390
|
+
updatedAt: Date.now()
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
return s;
|
|
2394
|
+
})
|
|
2395
|
+
);
|
|
2363
2396
|
let attachmentResults = [];
|
|
2364
2397
|
if (currentAttachments.length > 0) {
|
|
2365
2398
|
const attachmentSkills = Object.entries(resolvedSkills).filter(
|
|
@@ -2378,10 +2411,29 @@ ${finalContent}`;
|
|
|
2378
2411
|
});
|
|
2379
2412
|
});
|
|
2380
2413
|
if (matchedFiles.length === 0) continue;
|
|
2414
|
+
setSessions(
|
|
2415
|
+
(prev) => prev.map((s) => {
|
|
2416
|
+
if (s.id !== capturedSessionId) return s;
|
|
2417
|
+
return {
|
|
2418
|
+
...s,
|
|
2419
|
+
messages: s.messages.map((m) => {
|
|
2420
|
+
if (m.id !== assistantMessageId) return m;
|
|
2421
|
+
return {
|
|
2422
|
+
...m,
|
|
2423
|
+
contentParts: [...m.contentParts || [], {
|
|
2424
|
+
type: "tool_loading",
|
|
2425
|
+
toolName: skillName,
|
|
2426
|
+
label: skillConfig.label
|
|
2427
|
+
}]
|
|
2428
|
+
};
|
|
2429
|
+
})
|
|
2430
|
+
};
|
|
2431
|
+
})
|
|
2432
|
+
);
|
|
2381
2433
|
try {
|
|
2382
2434
|
const filesToPass = skillConfig.autoConvertBase64 ? await convertAttachmentsToBase64(matchedFiles) : matchedFiles;
|
|
2383
2435
|
const result = await skillConfig.execute({ files: filesToPass, userMessage: finalContent });
|
|
2384
|
-
|
|
2436
|
+
const toolResultPart = {
|
|
2385
2437
|
type: "tool_result",
|
|
2386
2438
|
toolName: skillName,
|
|
2387
2439
|
label: skillConfig.label,
|
|
@@ -2392,9 +2444,44 @@ ${finalContent}`;
|
|
|
2392
2444
|
metadata: result.metadata,
|
|
2393
2445
|
sources: result.sources
|
|
2394
2446
|
}
|
|
2395
|
-
}
|
|
2447
|
+
};
|
|
2448
|
+
attachmentResults.push(toolResultPart);
|
|
2449
|
+
setSessions(
|
|
2450
|
+
(prev) => prev.map((s) => {
|
|
2451
|
+
if (s.id !== capturedSessionId) return s;
|
|
2452
|
+
return {
|
|
2453
|
+
...s,
|
|
2454
|
+
messages: s.messages.map((m) => {
|
|
2455
|
+
if (m.id !== assistantMessageId) return m;
|
|
2456
|
+
return {
|
|
2457
|
+
...m,
|
|
2458
|
+
contentParts: (m.contentParts || []).map(
|
|
2459
|
+
(p) => p.type === "tool_loading" && p.toolName === skillName ? toolResultPart : p
|
|
2460
|
+
)
|
|
2461
|
+
};
|
|
2462
|
+
})
|
|
2463
|
+
};
|
|
2464
|
+
})
|
|
2465
|
+
);
|
|
2396
2466
|
} catch (error) {
|
|
2397
2467
|
console.error(`[useChatUI] attachment skill ${skillName} failed:`, error);
|
|
2468
|
+
setSessions(
|
|
2469
|
+
(prev) => prev.map((s) => {
|
|
2470
|
+
if (s.id !== capturedSessionId) return s;
|
|
2471
|
+
return {
|
|
2472
|
+
...s,
|
|
2473
|
+
messages: s.messages.map((m) => {
|
|
2474
|
+
if (m.id !== assistantMessageId) return m;
|
|
2475
|
+
return {
|
|
2476
|
+
...m,
|
|
2477
|
+
contentParts: (m.contentParts || []).filter(
|
|
2478
|
+
(p) => !(p.type === "tool_loading" && p.toolName === skillName)
|
|
2479
|
+
)
|
|
2480
|
+
};
|
|
2481
|
+
})
|
|
2482
|
+
};
|
|
2483
|
+
})
|
|
2484
|
+
);
|
|
2398
2485
|
}
|
|
2399
2486
|
}
|
|
2400
2487
|
}
|
|
@@ -2412,40 +2499,6 @@ ${finalContent}`;
|
|
|
2412
2499
|
}
|
|
2413
2500
|
}
|
|
2414
2501
|
}
|
|
2415
|
-
const assistantMessageId = generateId3("msg");
|
|
2416
|
-
const assistantMessage = {
|
|
2417
|
-
id: assistantMessageId,
|
|
2418
|
-
role: "assistant",
|
|
2419
|
-
content: "",
|
|
2420
|
-
model: selectedModel,
|
|
2421
|
-
timestamp: Date.now(),
|
|
2422
|
-
...attachmentResults.length > 0 && { contentParts: attachmentResults }
|
|
2423
|
-
};
|
|
2424
|
-
setInput("");
|
|
2425
|
-
setQuotedText(null);
|
|
2426
|
-
setSelectedAction(null);
|
|
2427
|
-
setAttachments([]);
|
|
2428
|
-
const capturedSessionId = sessionId;
|
|
2429
|
-
const currentSession2 = sessions.find((s) => s.id === capturedSessionId);
|
|
2430
|
-
const existingMessages = currentSession2?.messages || [];
|
|
2431
|
-
const isFirstMessage = !existingMessages.length;
|
|
2432
|
-
const contextSummary = currentSession2?.compressionState?.contextSummary || currentSession2?.contextSummary;
|
|
2433
|
-
const summaryAfterIndex = currentSession2?.compressionState?.summaryAfterIndex || currentSession2?.summaryAfterIndex || 0;
|
|
2434
|
-
let compressionCount = currentSession2?.compressionState?.compressionCount || 0;
|
|
2435
|
-
setSessions(
|
|
2436
|
-
(prev) => prev.map((s) => {
|
|
2437
|
-
if (s.id === capturedSessionId) {
|
|
2438
|
-
const newMessages = [...s.messages, userMessage, assistantMessage];
|
|
2439
|
-
return {
|
|
2440
|
-
...s,
|
|
2441
|
-
messages: newMessages,
|
|
2442
|
-
title: s.messages.length === 0 ? generateTitle([userMessage]) : s.title,
|
|
2443
|
-
updatedAt: Date.now()
|
|
2444
|
-
};
|
|
2445
|
-
}
|
|
2446
|
-
return s;
|
|
2447
|
-
})
|
|
2448
|
-
);
|
|
2449
2502
|
if (isFirstMessage && generateTitleRef.current) {
|
|
2450
2503
|
Promise.resolve(generateTitleRef.current(finalContent)).then((generatedTitle) => {
|
|
2451
2504
|
if (generatedTitle && generatedTitle.trim()) {
|
|
@@ -8244,7 +8297,7 @@ var MessageBubble = ({
|
|
|
8244
8297
|
] })
|
|
8245
8298
|
] })
|
|
8246
8299
|
] }),
|
|
8247
|
-
message.contentParts?.length
|
|
8300
|
+
message.contentParts?.length && /* @__PURE__ */ jsx15("div", { style: { wordBreak: "break-word" }, children: /* @__PURE__ */ jsx15(
|
|
8248
8301
|
ContentPartRenderer,
|
|
8249
8302
|
{
|
|
8250
8303
|
parts: message.contentParts,
|
|
@@ -8252,7 +8305,8 @@ var MessageBubble = ({
|
|
|
8252
8305
|
showThinking,
|
|
8253
8306
|
thinkingDefaultOpen
|
|
8254
8307
|
}
|
|
8255
|
-
) })
|
|
8308
|
+
) }),
|
|
8309
|
+
displayContent ? /* @__PURE__ */ jsx15("div", { style: { wordBreak: "break-word" }, children: /* @__PURE__ */ jsx15(
|
|
8256
8310
|
MarkdownRenderer,
|
|
8257
8311
|
{
|
|
8258
8312
|
content: displayContent,
|