koishi-plugin-chatluna 1.3.0-alpha.21 → 1.3.0-alpha.23
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/chains/chain.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare class ChainMiddleware {
|
|
|
46
46
|
constructor(name: string, execute: ChainMiddlewareFunction, graph: ChatChainDependencyGraph);
|
|
47
47
|
before<T extends keyof ChainMiddlewareName>(name: T): this;
|
|
48
48
|
after<T extends keyof ChainMiddlewareName>(name: T): this;
|
|
49
|
-
run(session: Session, options: ChainMiddlewareContext): Promise<string |
|
|
49
|
+
run(session: Session, options: ChainMiddlewareContext): Promise<string | h[] | ChainMiddlewareRunStatus | h[][]>;
|
|
50
50
|
}
|
|
51
51
|
export interface ChainMiddlewareContext {
|
|
52
52
|
config: Config;
|
package/lib/index.cjs
CHANGED
|
@@ -3398,7 +3398,6 @@ __name(mergeMessages, "mergeMessages");
|
|
|
3398
3398
|
var import_koishi8 = require("koishi");
|
|
3399
3399
|
var import_string2 = require("koishi-plugin-chatluna/utils/string");
|
|
3400
3400
|
var import_types5 = require("koishi-plugin-chatluna/llm-core/platform/types");
|
|
3401
|
-
var qface = __toESM(require("qface"), 1);
|
|
3402
3401
|
function apply24(ctx, config, chain) {
|
|
3403
3402
|
chain.middleware("read_chat_message", async (session, context) => {
|
|
3404
3403
|
let message = context.command != null ? context.message : session.elements;
|
|
@@ -3421,7 +3420,7 @@ function apply24(ctx, config, chain) {
|
|
|
3421
3420
|
ctx.chatluna.messageTransformer.intercept(
|
|
3422
3421
|
"text",
|
|
3423
3422
|
async (session, element, message) => {
|
|
3424
|
-
message
|
|
3423
|
+
addMessageContent(message, element.attrs["content"]);
|
|
3425
3424
|
}
|
|
3426
3425
|
);
|
|
3427
3426
|
ctx.chatluna.messageTransformer.intercept(
|
|
@@ -3430,47 +3429,18 @@ function apply24(ctx, config, chain) {
|
|
|
3430
3429
|
const name2 = element.attrs["name"];
|
|
3431
3430
|
const id = element.attrs["id"];
|
|
3432
3431
|
if (id !== session.bot.selfId) {
|
|
3433
|
-
|
|
3432
|
+
addMessageContent(
|
|
3433
|
+
message,
|
|
3434
|
+
`<at ${name2 != null ? `name="${name2}"` : ""} id="${id}"/>`
|
|
3435
|
+
);
|
|
3434
3436
|
}
|
|
3435
3437
|
}
|
|
3436
3438
|
);
|
|
3437
|
-
const ensureContentArray = /* @__PURE__ */ __name((message, fallbackText) => {
|
|
3438
|
-
if (typeof message.content === "string") {
|
|
3439
|
-
message.content = [
|
|
3440
|
-
{
|
|
3441
|
-
type: "text",
|
|
3442
|
-
text: message.content.trim().length < 1 ? fallbackText : message.content
|
|
3443
|
-
}
|
|
3444
|
-
];
|
|
3445
|
-
}
|
|
3446
|
-
}, "ensureContentArray");
|
|
3447
|
-
const addImageToContent = /* @__PURE__ */ __name((message, imageUrl, hash) => {
|
|
3448
|
-
;
|
|
3449
|
-
message.content.push({
|
|
3450
|
-
type: "image_url",
|
|
3451
|
-
image_url: {
|
|
3452
|
-
url: imageUrl,
|
|
3453
|
-
...hash && { hash }
|
|
3454
|
-
}
|
|
3455
|
-
});
|
|
3456
|
-
}, "addImageToContent");
|
|
3457
3439
|
ctx.chatluna.messageTransformer.intercept(
|
|
3458
3440
|
"face",
|
|
3459
3441
|
async (session, element, message) => {
|
|
3460
|
-
const
|
|
3461
|
-
|
|
3462
|
-
"https://koishi.js.org/QFace"
|
|
3463
|
-
) ?? false)) {
|
|
3464
|
-
return false;
|
|
3465
|
-
}
|
|
3466
|
-
const originContent = message.content;
|
|
3467
|
-
const face = qface.get(element.attrs["id"]);
|
|
3468
|
-
const faceXml = `[face:${face.QSid}:${face.QDes}]`;
|
|
3469
|
-
if (typeof originContent === "string") {
|
|
3470
|
-
message.content = originContent + ` ${faceXml}`;
|
|
3471
|
-
} else {
|
|
3472
|
-
ensureContentArray(message, faceXml);
|
|
3473
|
-
}
|
|
3442
|
+
const faceXml = `[face:${element.attrs.id}:${element.attrs.name}]`;
|
|
3443
|
+
addMessageContent(message, faceXml);
|
|
3474
3444
|
return true;
|
|
3475
3445
|
}
|
|
3476
3446
|
);
|
|
@@ -3571,6 +3541,39 @@ async function readImage(ctx, url) {
|
|
|
3571
3541
|
};
|
|
3572
3542
|
}
|
|
3573
3543
|
__name(readImage, "readImage");
|
|
3544
|
+
function addImageToContent(message, imageUrl, hash) {
|
|
3545
|
+
;
|
|
3546
|
+
message.content.push({
|
|
3547
|
+
type: "image_url",
|
|
3548
|
+
image_url: {
|
|
3549
|
+
url: imageUrl,
|
|
3550
|
+
...hash && { hash }
|
|
3551
|
+
}
|
|
3552
|
+
});
|
|
3553
|
+
}
|
|
3554
|
+
__name(addImageToContent, "addImageToContent");
|
|
3555
|
+
function ensureContentArray(message, fallbackText) {
|
|
3556
|
+
if (typeof message.content === "string") {
|
|
3557
|
+
message.content = [
|
|
3558
|
+
{
|
|
3559
|
+
type: "text",
|
|
3560
|
+
text: message.content.trim().length < 1 ? fallbackText : message.content
|
|
3561
|
+
}
|
|
3562
|
+
];
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
__name(ensureContentArray, "ensureContentArray");
|
|
3566
|
+
function addMessageContent(message, content) {
|
|
3567
|
+
if (typeof message.content === "string" && typeof content === "string") {
|
|
3568
|
+
message.content += content;
|
|
3569
|
+
return;
|
|
3570
|
+
}
|
|
3571
|
+
message.content = [
|
|
3572
|
+
...typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content,
|
|
3573
|
+
...typeof content === "string" ? [{ type: "text", text: content }] : content
|
|
3574
|
+
];
|
|
3575
|
+
}
|
|
3576
|
+
__name(addMessageContent, "addMessageContent");
|
|
3574
3577
|
|
|
3575
3578
|
// src/middlewares/chat/render_message.ts
|
|
3576
3579
|
function apply25(ctx, config, chain) {
|
package/lib/index.mjs
CHANGED
|
@@ -3395,7 +3395,6 @@ __name(mergeMessages, "mergeMessages");
|
|
|
3395
3395
|
import { h as h4 } from "koishi";
|
|
3396
3396
|
import { hashString } from "koishi-plugin-chatluna/utils/string";
|
|
3397
3397
|
import { ModelCapabilities } from "koishi-plugin-chatluna/llm-core/platform/types";
|
|
3398
|
-
import * as qface from "qface";
|
|
3399
3398
|
function apply24(ctx, config, chain) {
|
|
3400
3399
|
chain.middleware("read_chat_message", async (session, context) => {
|
|
3401
3400
|
let message = context.command != null ? context.message : session.elements;
|
|
@@ -3418,7 +3417,7 @@ function apply24(ctx, config, chain) {
|
|
|
3418
3417
|
ctx.chatluna.messageTransformer.intercept(
|
|
3419
3418
|
"text",
|
|
3420
3419
|
async (session, element, message) => {
|
|
3421
|
-
message
|
|
3420
|
+
addMessageContent(message, element.attrs["content"]);
|
|
3422
3421
|
}
|
|
3423
3422
|
);
|
|
3424
3423
|
ctx.chatluna.messageTransformer.intercept(
|
|
@@ -3427,47 +3426,18 @@ function apply24(ctx, config, chain) {
|
|
|
3427
3426
|
const name2 = element.attrs["name"];
|
|
3428
3427
|
const id = element.attrs["id"];
|
|
3429
3428
|
if (id !== session.bot.selfId) {
|
|
3430
|
-
|
|
3429
|
+
addMessageContent(
|
|
3430
|
+
message,
|
|
3431
|
+
`<at ${name2 != null ? `name="${name2}"` : ""} id="${id}"/>`
|
|
3432
|
+
);
|
|
3431
3433
|
}
|
|
3432
3434
|
}
|
|
3433
3435
|
);
|
|
3434
|
-
const ensureContentArray = /* @__PURE__ */ __name((message, fallbackText) => {
|
|
3435
|
-
if (typeof message.content === "string") {
|
|
3436
|
-
message.content = [
|
|
3437
|
-
{
|
|
3438
|
-
type: "text",
|
|
3439
|
-
text: message.content.trim().length < 1 ? fallbackText : message.content
|
|
3440
|
-
}
|
|
3441
|
-
];
|
|
3442
|
-
}
|
|
3443
|
-
}, "ensureContentArray");
|
|
3444
|
-
const addImageToContent = /* @__PURE__ */ __name((message, imageUrl, hash) => {
|
|
3445
|
-
;
|
|
3446
|
-
message.content.push({
|
|
3447
|
-
type: "image_url",
|
|
3448
|
-
image_url: {
|
|
3449
|
-
url: imageUrl,
|
|
3450
|
-
...hash && { hash }
|
|
3451
|
-
}
|
|
3452
|
-
});
|
|
3453
|
-
}, "addImageToContent");
|
|
3454
3436
|
ctx.chatluna.messageTransformer.intercept(
|
|
3455
3437
|
"face",
|
|
3456
3438
|
async (session, element, message) => {
|
|
3457
|
-
const
|
|
3458
|
-
|
|
3459
|
-
"https://koishi.js.org/QFace"
|
|
3460
|
-
) ?? false)) {
|
|
3461
|
-
return false;
|
|
3462
|
-
}
|
|
3463
|
-
const originContent = message.content;
|
|
3464
|
-
const face = qface.get(element.attrs["id"]);
|
|
3465
|
-
const faceXml = `[face:${face.QSid}:${face.QDes}]`;
|
|
3466
|
-
if (typeof originContent === "string") {
|
|
3467
|
-
message.content = originContent + ` ${faceXml}`;
|
|
3468
|
-
} else {
|
|
3469
|
-
ensureContentArray(message, faceXml);
|
|
3470
|
-
}
|
|
3439
|
+
const faceXml = `[face:${element.attrs.id}:${element.attrs.name}]`;
|
|
3440
|
+
addMessageContent(message, faceXml);
|
|
3471
3441
|
return true;
|
|
3472
3442
|
}
|
|
3473
3443
|
);
|
|
@@ -3568,6 +3538,39 @@ async function readImage(ctx, url) {
|
|
|
3568
3538
|
};
|
|
3569
3539
|
}
|
|
3570
3540
|
__name(readImage, "readImage");
|
|
3541
|
+
function addImageToContent(message, imageUrl, hash) {
|
|
3542
|
+
;
|
|
3543
|
+
message.content.push({
|
|
3544
|
+
type: "image_url",
|
|
3545
|
+
image_url: {
|
|
3546
|
+
url: imageUrl,
|
|
3547
|
+
...hash && { hash }
|
|
3548
|
+
}
|
|
3549
|
+
});
|
|
3550
|
+
}
|
|
3551
|
+
__name(addImageToContent, "addImageToContent");
|
|
3552
|
+
function ensureContentArray(message, fallbackText) {
|
|
3553
|
+
if (typeof message.content === "string") {
|
|
3554
|
+
message.content = [
|
|
3555
|
+
{
|
|
3556
|
+
type: "text",
|
|
3557
|
+
text: message.content.trim().length < 1 ? fallbackText : message.content
|
|
3558
|
+
}
|
|
3559
|
+
];
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
__name(ensureContentArray, "ensureContentArray");
|
|
3563
|
+
function addMessageContent(message, content) {
|
|
3564
|
+
if (typeof message.content === "string" && typeof content === "string") {
|
|
3565
|
+
message.content += content;
|
|
3566
|
+
return;
|
|
3567
|
+
}
|
|
3568
|
+
message.content = [
|
|
3569
|
+
...typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content,
|
|
3570
|
+
...typeof content === "string" ? [{ type: "text", text: content }] : content
|
|
3571
|
+
];
|
|
3572
|
+
}
|
|
3573
|
+
__name(addMessageContent, "addMessageContent");
|
|
3571
3574
|
|
|
3572
3575
|
// src/middlewares/chat/render_message.ts
|
|
3573
3576
|
function apply25(ctx, config, chain) {
|
|
@@ -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>;
|
|
@@ -72,7 +72,7 @@ export type CreateReactAgentParams = {
|
|
|
72
72
|
*/
|
|
73
73
|
export declare function createReactAgent({ llm, tools, prompt, streamRunnable, instructions }: CreateReactAgentParams): Promise<AgentRunnableSequence<{
|
|
74
74
|
steps: AgentStep[];
|
|
75
|
-
}, import("@langchain/core/agents").
|
|
75
|
+
}, import("@langchain/core/agents").AgentAction[] | import("@langchain/core/agents").AgentFinish>>;
|
|
76
76
|
/**
|
|
77
77
|
* Construct the scratchpad that lets the agent continue its thought process.
|
|
78
78
|
* @param intermediateSteps
|
|
@@ -11,7 +11,7 @@ export declare class ChatLunaSaveableVectorStore<T extends VectorStore = VectorS
|
|
|
11
11
|
constructor(_store: T, input: ChatLunaSaveableVectorStoreInput<T>);
|
|
12
12
|
addVectors(...args: Parameters<typeof this._store.addVectors>): Promise<void | string[]>;
|
|
13
13
|
addDocuments(...args: Parameters<T['addDocuments']>): Promise<void | string[]>;
|
|
14
|
-
similaritySearchVectorWithScore(...args: Parameters<T['similaritySearchVectorWithScore']>): Promise<[
|
|
14
|
+
similaritySearchVectorWithScore(...args: Parameters<T['similaritySearchVectorWithScore']>): Promise<[Document<Record<string, any>>, number][]>;
|
|
15
15
|
editDocument(oldDocumentId: string, newDocument: Document): Promise<void>;
|
|
16
16
|
save(): Promise<void>;
|
|
17
17
|
delete(input: ChatLunaSaveableVectorDelete): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna",
|
|
3
3
|
"description": "chatluna for koishi",
|
|
4
|
-
"version": "1.3.0-alpha.
|
|
4
|
+
"version": "1.3.0-alpha.23",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -226,7 +226,6 @@
|
|
|
226
226
|
"undici": "^6.21.2",
|
|
227
227
|
"uuid": "^9.0.1",
|
|
228
228
|
"ws": "^8.18.1",
|
|
229
|
-
"qface": "^1.4.1",
|
|
230
229
|
"zod": "^3.25.0-canary.20250211T214501",
|
|
231
230
|
"zod-to-json-schema": "^3.24.5"
|
|
232
231
|
},
|