koishi-plugin-chatluna 1.3.2 → 1.3.3
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/lib/index.cjs +17 -8
- package/lib/index.mjs +17 -8
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -3494,27 +3494,36 @@ function apply26(ctx, config, chain) {
|
|
|
3494
3494
|
"img",
|
|
3495
3495
|
async (session, element, message, model) => {
|
|
3496
3496
|
const parsedModelInfo = model != null ? ctx.chatluna.platform.findModel(model) : void 0;
|
|
3497
|
+
const isInstalledImageService = ctx.chatluna.getPlugin("image-service") != null;
|
|
3497
3498
|
if (parsedModelInfo?.value != null && !parsedModelInfo.value.capabilities.includes(
|
|
3498
3499
|
import_types5.ModelCapabilities.ImageInput
|
|
3499
3500
|
)) {
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3501
|
+
if (!isInstalledImageService) {
|
|
3502
|
+
logger7.warn(
|
|
3503
|
+
// eslint-disable-next-line max-len
|
|
3504
|
+
`Model "${model}" does not support image input. Please use a model that supports vision capabilities, or install chatluna-image-service plugin to enable image description.`
|
|
3505
|
+
);
|
|
3506
|
+
}
|
|
3504
3507
|
return false;
|
|
3505
3508
|
}
|
|
3506
3509
|
const url = element.attrs.url ?? element.attrs.src;
|
|
3507
3510
|
const displayUrl = url.length > 100 ? url.substring(0, 100) + "..." : url;
|
|
3508
3511
|
logger7.debug(`Processing image: ${displayUrl}`);
|
|
3509
3512
|
if (!ctx.chatluna_storage) {
|
|
3510
|
-
return await oldImageRead(
|
|
3513
|
+
return await oldImageRead(
|
|
3514
|
+
ctx,
|
|
3515
|
+
url,
|
|
3516
|
+
message,
|
|
3517
|
+
element,
|
|
3518
|
+
isInstalledImageService
|
|
3519
|
+
);
|
|
3511
3520
|
}
|
|
3512
3521
|
const { buffer, ext } = await readImage(ctx, url);
|
|
3513
3522
|
if (ext == null) {
|
|
3514
3523
|
return false;
|
|
3515
3524
|
}
|
|
3516
3525
|
if (ext === "image/gif") {
|
|
3517
|
-
if (
|
|
3526
|
+
if (!isInstalledImageService) {
|
|
3518
3527
|
logger7.warn(
|
|
3519
3528
|
`Detected GIF image, which is not supported by most models. Please install chatluna-image-service plugin to parse GIF animations.`
|
|
3520
3529
|
);
|
|
@@ -3538,7 +3547,7 @@ function apply26(ctx, config, chain) {
|
|
|
3538
3547
|
},
|
|
3539
3548
|
-100
|
|
3540
3549
|
);
|
|
3541
|
-
async function oldImageRead(ctx2, url, message, element) {
|
|
3550
|
+
async function oldImageRead(ctx2, url, message, element, isInstalledImageService) {
|
|
3542
3551
|
const imageHash = await (0, import_string4.hashString)(url, 8);
|
|
3543
3552
|
element.attrs["imageHash"] = imageHash;
|
|
3544
3553
|
try {
|
|
@@ -3547,7 +3556,7 @@ function apply26(ctx, config, chain) {
|
|
|
3547
3556
|
return false;
|
|
3548
3557
|
}
|
|
3549
3558
|
if (ext === "image/gif") {
|
|
3550
|
-
if (
|
|
3559
|
+
if (!isInstalledImageService) {
|
|
3551
3560
|
logger7.warn(
|
|
3552
3561
|
`Detected GIF image, which is not supported by most models. Please install chatluna-image-service plugin to parse GIF animations.`
|
|
3553
3562
|
);
|
package/lib/index.mjs
CHANGED
|
@@ -3493,27 +3493,36 @@ function apply26(ctx, config, chain) {
|
|
|
3493
3493
|
"img",
|
|
3494
3494
|
async (session, element, message, model) => {
|
|
3495
3495
|
const parsedModelInfo = model != null ? ctx.chatluna.platform.findModel(model) : void 0;
|
|
3496
|
+
const isInstalledImageService = ctx.chatluna.getPlugin("image-service") != null;
|
|
3496
3497
|
if (parsedModelInfo?.value != null && !parsedModelInfo.value.capabilities.includes(
|
|
3497
3498
|
ModelCapabilities.ImageInput
|
|
3498
3499
|
)) {
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3500
|
+
if (!isInstalledImageService) {
|
|
3501
|
+
logger7.warn(
|
|
3502
|
+
// eslint-disable-next-line max-len
|
|
3503
|
+
`Model "${model}" does not support image input. Please use a model that supports vision capabilities, or install chatluna-image-service plugin to enable image description.`
|
|
3504
|
+
);
|
|
3505
|
+
}
|
|
3503
3506
|
return false;
|
|
3504
3507
|
}
|
|
3505
3508
|
const url = element.attrs.url ?? element.attrs.src;
|
|
3506
3509
|
const displayUrl = url.length > 100 ? url.substring(0, 100) + "..." : url;
|
|
3507
3510
|
logger7.debug(`Processing image: ${displayUrl}`);
|
|
3508
3511
|
if (!ctx.chatluna_storage) {
|
|
3509
|
-
return await oldImageRead(
|
|
3512
|
+
return await oldImageRead(
|
|
3513
|
+
ctx,
|
|
3514
|
+
url,
|
|
3515
|
+
message,
|
|
3516
|
+
element,
|
|
3517
|
+
isInstalledImageService
|
|
3518
|
+
);
|
|
3510
3519
|
}
|
|
3511
3520
|
const { buffer, ext } = await readImage(ctx, url);
|
|
3512
3521
|
if (ext == null) {
|
|
3513
3522
|
return false;
|
|
3514
3523
|
}
|
|
3515
3524
|
if (ext === "image/gif") {
|
|
3516
|
-
if (
|
|
3525
|
+
if (!isInstalledImageService) {
|
|
3517
3526
|
logger7.warn(
|
|
3518
3527
|
`Detected GIF image, which is not supported by most models. Please install chatluna-image-service plugin to parse GIF animations.`
|
|
3519
3528
|
);
|
|
@@ -3537,7 +3546,7 @@ function apply26(ctx, config, chain) {
|
|
|
3537
3546
|
},
|
|
3538
3547
|
-100
|
|
3539
3548
|
);
|
|
3540
|
-
async function oldImageRead(ctx2, url, message, element) {
|
|
3549
|
+
async function oldImageRead(ctx2, url, message, element, isInstalledImageService) {
|
|
3541
3550
|
const imageHash = await hashString(url, 8);
|
|
3542
3551
|
element.attrs["imageHash"] = imageHash;
|
|
3543
3552
|
try {
|
|
@@ -3546,7 +3555,7 @@ function apply26(ctx, config, chain) {
|
|
|
3546
3555
|
return false;
|
|
3547
3556
|
}
|
|
3548
3557
|
if (ext === "image/gif") {
|
|
3549
|
-
if (
|
|
3558
|
+
if (!isInstalledImageService) {
|
|
3550
3559
|
logger7.warn(
|
|
3551
3560
|
`Detected GIF image, which is not supported by most models. Please install chatluna-image-service plugin to parse GIF animations.`
|
|
3552
3561
|
);
|