@gendive/chatllm 0.21.9 → 0.22.0
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.d.mts +11 -0
- package/dist/react/index.d.ts +11 -0
- package/dist/react/index.js +30 -5
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +30 -5
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -2184,6 +2184,16 @@ var convertAttachmentsToBase64 = async (attachments) => Promise.all(
|
|
|
2184
2184
|
size: att.size
|
|
2185
2185
|
}))
|
|
2186
2186
|
);
|
|
2187
|
+
var convertAttachmentsWithUploader = async (attachments, uploader) => Promise.all(
|
|
2188
|
+
attachments.map(async (att) => ({
|
|
2189
|
+
name: att.name,
|
|
2190
|
+
mimeType: att.mimeType,
|
|
2191
|
+
base64: "",
|
|
2192
|
+
url: await uploader(att.file),
|
|
2193
|
+
size: att.size,
|
|
2194
|
+
source: "uploader"
|
|
2195
|
+
}))
|
|
2196
|
+
);
|
|
2187
2197
|
var findPreviousResultImage = (messages) => {
|
|
2188
2198
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2189
2199
|
const msg = messages[i];
|
|
@@ -2245,6 +2255,8 @@ var useChatUI = (options) => {
|
|
|
2245
2255
|
// Image upload
|
|
2246
2256
|
onUploadImage,
|
|
2247
2257
|
onImageError,
|
|
2258
|
+
// File upload
|
|
2259
|
+
fileUploader,
|
|
2248
2260
|
// External storage options
|
|
2249
2261
|
useExternalStorage = false,
|
|
2250
2262
|
startWithNewSession = false,
|
|
@@ -2352,6 +2364,7 @@ var useChatUI = (options) => {
|
|
|
2352
2364
|
const onLoadModelsRef = useRef5(onLoadModels);
|
|
2353
2365
|
const onUploadImageRef = useRef5(onUploadImage);
|
|
2354
2366
|
const onImageErrorRef = useRef5(onImageError);
|
|
2367
|
+
const fileUploaderRef = useRef5(fileUploader);
|
|
2355
2368
|
const globalMemoryRef = useRef5(null);
|
|
2356
2369
|
useEffect4(() => {
|
|
2357
2370
|
onSendMessageRef.current = onSendMessage;
|
|
@@ -2373,6 +2386,7 @@ var useChatUI = (options) => {
|
|
|
2373
2386
|
onSessionContextChangeRef.current = onSessionContextChange;
|
|
2374
2387
|
onUploadImageRef.current = onUploadImage;
|
|
2375
2388
|
onImageErrorRef.current = onImageError;
|
|
2389
|
+
fileUploaderRef.current = fileUploader;
|
|
2376
2390
|
onLoadModelsRef.current = onLoadModels;
|
|
2377
2391
|
});
|
|
2378
2392
|
const abortControllersRef = useRef5(/* @__PURE__ */ new Map());
|
|
@@ -3560,7 +3574,7 @@ ${finalContent}`;
|
|
|
3560
3574
|
})
|
|
3561
3575
|
);
|
|
3562
3576
|
try {
|
|
3563
|
-
const filesToPass = skillConfig.autoConvertBase64 ? await convertAttachmentsToBase64(matchedFiles) : matchedFiles;
|
|
3577
|
+
const filesToPass = fileUploaderRef.current ? await convertAttachmentsWithUploader(matchedFiles, fileUploaderRef.current) : skillConfig.autoConvertBase64 ? await convertAttachmentsToBase64(matchedFiles) : matchedFiles;
|
|
3564
3578
|
const result = await skillConfig.execute({ files: filesToPass, userMessage: finalContent });
|
|
3565
3579
|
const attachResultType = result.metadata?.type || result.metadata?.resultType || "text";
|
|
3566
3580
|
const toolResultPart = {
|
|
@@ -3618,7 +3632,12 @@ ${finalContent}`;
|
|
|
3618
3632
|
const hasUserText = finalContent.trim().length > 0;
|
|
3619
3633
|
if (hasImageAttachments && hasUserText) {
|
|
3620
3634
|
const imageAttachments = currentAttachments.filter((a) => a.type === "image");
|
|
3621
|
-
|
|
3635
|
+
try {
|
|
3636
|
+
pendingAttachmentDataRef.current = fileUploaderRef.current ? await convertAttachmentsWithUploader(imageAttachments, fileUploaderRef.current) : await convertAttachmentsToBase64(imageAttachments);
|
|
3637
|
+
} catch (err) {
|
|
3638
|
+
console.error("[chatllm] pendingAttachment conversion failed:", err);
|
|
3639
|
+
pendingAttachmentDataRef.current = null;
|
|
3640
|
+
}
|
|
3622
3641
|
} else {
|
|
3623
3642
|
pendingAttachmentDataRef.current = null;
|
|
3624
3643
|
}
|
|
@@ -3766,7 +3785,9 @@ ${attachmentContext}
|
|
|
3766
3785
|
}
|
|
3767
3786
|
}
|
|
3768
3787
|
} else if (attachmentResults.length === 0 && pendingAttachmentDataRef.current !== null) {
|
|
3769
|
-
const isReferenceImage = pendingAttachmentDataRef.current.some(
|
|
3788
|
+
const isReferenceImage = pendingAttachmentDataRef.current.some(
|
|
3789
|
+
(d) => d.url && !d.base64 && d.source !== "uploader"
|
|
3790
|
+
);
|
|
3770
3791
|
if (isReferenceImage) {
|
|
3771
3792
|
chatMessages.push({
|
|
3772
3793
|
role: "user",
|
|
@@ -15077,7 +15098,9 @@ var ChatUIWithHook = ({
|
|
|
15077
15098
|
onAnalyzePatterns,
|
|
15078
15099
|
// Image upload
|
|
15079
15100
|
onUploadImage,
|
|
15080
|
-
onImageError
|
|
15101
|
+
onImageError,
|
|
15102
|
+
// File upload
|
|
15103
|
+
fileUploader
|
|
15081
15104
|
}) => {
|
|
15082
15105
|
const hookOptions = {
|
|
15083
15106
|
models,
|
|
@@ -15128,7 +15151,9 @@ var ChatUIWithHook = ({
|
|
|
15128
15151
|
onAnalyzePatterns,
|
|
15129
15152
|
// Image upload
|
|
15130
15153
|
onUploadImage,
|
|
15131
|
-
onImageError
|
|
15154
|
+
onImageError,
|
|
15155
|
+
// File upload
|
|
15156
|
+
fileUploader
|
|
15132
15157
|
};
|
|
15133
15158
|
const state = useChatUI(hookOptions);
|
|
15134
15159
|
return /* @__PURE__ */ jsx23(ImageErrorContext.Provider, { value: onImageError || null, children: /* @__PURE__ */ jsx23(
|