koishi-plugin-chatluna 1.3.2 → 1.3.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/lib/index.cjs +18 -9
- package/lib/index.d.ts +1 -1
- package/lib/index.mjs +18 -9
- package/lib/llm-core/agent/openai/index.d.ts +1 -1
- package/lib/llm-core/platform/model.cjs +2 -0
- package/lib/llm-core/platform/model.d.ts +4 -0
- package/lib/llm-core/platform/model.mjs +2 -0
- 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
|
);
|
|
@@ -7320,7 +7329,7 @@ var inject2 = {
|
|
|
7320
7329
|
};
|
|
7321
7330
|
var logger7;
|
|
7322
7331
|
var usage = `
|
|
7323
|
-
## chatluna v1.3
|
|
7332
|
+
## chatluna v1.3
|
|
7324
7333
|
|
|
7325
7334
|
ChatLuna 插件交流 QQ 群:282381753 (有问题或出现 Bug 先加群问)
|
|
7326
7335
|
|
package/lib/index.d.ts
CHANGED
|
@@ -24,5 +24,5 @@ export declare const inject2: {
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
export declare let logger: Logger;
|
|
27
|
-
export declare const usage = "\n## chatluna v1.3
|
|
27
|
+
export declare const usage = "\n## chatluna v1.3\n\nChatLuna \u63D2\u4EF6\u4EA4\u6D41 QQ \u7FA4\uFF1A282381753 \uFF08\u6709\u95EE\u9898\u6216\u51FA\u73B0 Bug \u5148\u52A0\u7FA4\u95EE\uFF09\n\n\u7FA4\u91CC\u76EE\u524D\u6CA1\u6709\u642D\u8F7D\u8BE5\u63D2\u4EF6\u7684 bot\uFF0C\u52A0\u7FA4\u7684\u8BDD\u6700\u597D\u662F\u6765\u8BE2\u95EE\u95EE\u9898\u6216\u8005\u63D0\u51FA\u610F\u89C1\u7684\u3002\n\n\u8BBF\u95EE [https://chatluna.chat](https://chatluna.chat) \u6765\u4E86\u89E3\u5982\u4F55\u4F7F\u7528 Chatluna\u3002\n\u4E5F\u53EF\u4EE5\u8BBF\u95EE [https://preset.chatluna.chat](https://preset.chatluna.chat) \u8FDB\u5165\u5728\u7EBF\u9884\u8BBE\u7F16\u8F91\u5668\u3002\u66F4\u6709\u9884\u8BBE\u5E7F\u573A\u6765\u6D4F\u89C8\u548C\u4E0B\u8F7D\u4F60\u5FC3\u4EEA\u7684\u9884\u8BBE\u3002\n";
|
|
28
28
|
export declare function apply(ctx: Context, config: Config): void;
|
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
|
);
|
|
@@ -7333,7 +7342,7 @@ var inject2 = {
|
|
|
7333
7342
|
};
|
|
7334
7343
|
var logger7;
|
|
7335
7344
|
var usage = `
|
|
7336
|
-
## chatluna v1.3
|
|
7345
|
+
## chatluna v1.3
|
|
7337
7346
|
|
|
7338
7347
|
ChatLuna 插件交流 QQ 群:282381753 (有问题或出现 Bug 先加群问)
|
|
7339
7348
|
|
|
@@ -22,4 +22,4 @@ export type CreateOpenAIAgentParams = {
|
|
|
22
22
|
};
|
|
23
23
|
export declare function createOpenAIAgent({ llm, tools, prompt }: CreateOpenAIAgentParams): RunnableSequence<{
|
|
24
24
|
steps: AgentStep[];
|
|
25
|
-
}, AgentAction |
|
|
25
|
+
}, AgentAction | AgentAction[] | AgentFinish>;
|
|
@@ -217,6 +217,7 @@ var ChatLunaChatModel = class extends import_chat_models.BaseChatModel {
|
|
|
217
217
|
"logitBias",
|
|
218
218
|
"id",
|
|
219
219
|
"variables_hide",
|
|
220
|
+
"overrideRequestParams",
|
|
220
221
|
"stream",
|
|
221
222
|
"tools"
|
|
222
223
|
];
|
|
@@ -244,6 +245,7 @@ var ChatLunaChatModel = class extends import_chat_models.BaseChatModel {
|
|
|
244
245
|
maxTokens: options?.maxTokens ?? this._options.maxTokens,
|
|
245
246
|
maxTokenLimit,
|
|
246
247
|
variables: options?.["variables_hide"] ?? {},
|
|
248
|
+
overrideRequestParams: options?.overrideRequestParams ?? this._options.overrideRequestParams ?? {},
|
|
247
249
|
stop: options?.stop ?? this._options.stop,
|
|
248
250
|
stream: options?.stream ?? this._options.stream,
|
|
249
251
|
tools: options?.tools ?? this._options.tools,
|
|
@@ -37,6 +37,10 @@ export interface ChatLunaModelCallOptions extends BaseChatModelCallOptions {
|
|
|
37
37
|
tool_choice?: string;
|
|
38
38
|
variables?: Record<string, any>;
|
|
39
39
|
variables_hide?: Record<string, any>;
|
|
40
|
+
/**
|
|
41
|
+
* Override request params for this request only.
|
|
42
|
+
*/
|
|
43
|
+
overrideRequestParams?: Record<string, any>;
|
|
40
44
|
}
|
|
41
45
|
export interface ChatLunaModelInput extends ChatLunaModelCallOptions {
|
|
42
46
|
llmType?: string;
|
|
@@ -199,6 +199,7 @@ var ChatLunaChatModel = class extends BaseChatModel {
|
|
|
199
199
|
"logitBias",
|
|
200
200
|
"id",
|
|
201
201
|
"variables_hide",
|
|
202
|
+
"overrideRequestParams",
|
|
202
203
|
"stream",
|
|
203
204
|
"tools"
|
|
204
205
|
];
|
|
@@ -226,6 +227,7 @@ var ChatLunaChatModel = class extends BaseChatModel {
|
|
|
226
227
|
maxTokens: options?.maxTokens ?? this._options.maxTokens,
|
|
227
228
|
maxTokenLimit,
|
|
228
229
|
variables: options?.["variables_hide"] ?? {},
|
|
230
|
+
overrideRequestParams: options?.overrideRequestParams ?? this._options.overrideRequestParams ?? {},
|
|
229
231
|
stop: options?.stop ?? this._options.stop,
|
|
230
232
|
stream: options?.stream ?? this._options.stream,
|
|
231
233
|
tools: options?.tools ?? this._options.tools,
|