koishi-plugin-chatluna-google-gemini-adapter 1.3.0-alpha.5 → 1.3.0-alpha.7
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 +8 -7
- package/lib/index.mjs +8 -10
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -55,7 +55,7 @@ var import_types = require("koishi-plugin-chatluna/llm-core/platform/types");
|
|
|
55
55
|
var import_error2 = require("koishi-plugin-chatluna/utils/error");
|
|
56
56
|
|
|
57
57
|
// src/requester.ts
|
|
58
|
-
var
|
|
58
|
+
var import_messages = require("@langchain/core/messages");
|
|
59
59
|
var import_outputs = require("@langchain/core/outputs");
|
|
60
60
|
var import_api = require("koishi-plugin-chatluna/llm-core/platform/api");
|
|
61
61
|
var import_error = require("koishi-plugin-chatluna/utils/error");
|
|
@@ -63,7 +63,6 @@ var import_sse = require("koishi-plugin-chatluna/utils/sse");
|
|
|
63
63
|
var import_stream = require("koishi-plugin-chatluna/utils/stream");
|
|
64
64
|
|
|
65
65
|
// src/utils.ts
|
|
66
|
-
var import_messages = require("@langchain/core/messages");
|
|
67
66
|
var import_zod_to_json_schema = require("zod-to-json-schema");
|
|
68
67
|
var import_v1_shared_adapter = require("@chatluna/v1-shared-adapter");
|
|
69
68
|
var import_string = require("koishi-plugin-chatluna/utils/string");
|
|
@@ -130,7 +129,8 @@ function parseJsonArgs(args) {
|
|
|
130
129
|
}
|
|
131
130
|
__name(parseJsonArgs, "parseJsonArgs");
|
|
132
131
|
function processFunctionMessage(message) {
|
|
133
|
-
if (message
|
|
132
|
+
if (message["tool_calls"]) {
|
|
133
|
+
message = message;
|
|
134
134
|
const toolCalls = message.tool_calls;
|
|
135
135
|
return {
|
|
136
136
|
role: "model",
|
|
@@ -145,13 +145,14 @@ function processFunctionMessage(message) {
|
|
|
145
145
|
})
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
+
const finalMessage = message;
|
|
148
149
|
return {
|
|
149
150
|
role: "user",
|
|
150
151
|
parts: [
|
|
151
152
|
{
|
|
152
153
|
functionResponse: {
|
|
153
154
|
name: message.name,
|
|
154
|
-
id:
|
|
155
|
+
id: finalMessage.tool_call_id,
|
|
155
156
|
response: parseJsonArgs(message.content)
|
|
156
157
|
}
|
|
157
158
|
}
|
|
@@ -808,7 +809,7 @@ var GeminiRequester = class extends import_api.ModelRequester {
|
|
|
808
809
|
if (groundingContent.length > 0) {
|
|
809
810
|
logger.debug(`grounding content: ${groundingContent}`);
|
|
810
811
|
if (this._pluginConfig.groundingContentDisplay) {
|
|
811
|
-
const groundingMessage = new
|
|
812
|
+
const groundingMessage = new import_messages.AIMessageChunk(
|
|
812
813
|
`
|
|
813
814
|
${groundingContent}`
|
|
814
815
|
);
|
|
@@ -821,7 +822,7 @@ ${groundingContent}`
|
|
|
821
822
|
}
|
|
822
823
|
}
|
|
823
824
|
_createMessageChunk(content, functionCall, imagePart) {
|
|
824
|
-
const messageChunk = new
|
|
825
|
+
const messageChunk = new import_messages.AIMessageChunk({
|
|
825
826
|
content: content ?? "",
|
|
826
827
|
tool_call_chunks: [functionCall].filter(Boolean)
|
|
827
828
|
});
|
|
@@ -923,7 +924,7 @@ var GeminiClient = class extends import_client.PlatformModelAndEmbeddingsClient
|
|
|
923
924
|
if (model.name.includes("gemini-2.5") && !model.name.includes("pro") && !model.name.includes("image")) {
|
|
924
925
|
if (!model.name.includes("-thinking")) {
|
|
925
926
|
models.push(
|
|
926
|
-
{ ...info, name: model.name + "-
|
|
927
|
+
{ ...info, name: model.name + "-non-thinking" },
|
|
927
928
|
{ ...info, name: model.name + "-thinking" },
|
|
928
929
|
info
|
|
929
930
|
);
|
package/lib/index.mjs
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
|
|
41
41
|
// src/requester.ts
|
|
42
42
|
import {
|
|
43
|
-
AIMessageChunk
|
|
43
|
+
AIMessageChunk
|
|
44
44
|
} from "@langchain/core/messages";
|
|
45
45
|
import { ChatGenerationChunk } from "@langchain/core/outputs";
|
|
46
46
|
import {
|
|
@@ -54,10 +54,6 @@ import { checkResponse, sseIterable } from "koishi-plugin-chatluna/utils/sse";
|
|
|
54
54
|
import { readableStreamToAsyncIterable } from "koishi-plugin-chatluna/utils/stream";
|
|
55
55
|
|
|
56
56
|
// src/utils.ts
|
|
57
|
-
import {
|
|
58
|
-
AIMessage,
|
|
59
|
-
AIMessageChunk
|
|
60
|
-
} from "@langchain/core/messages";
|
|
61
57
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
62
58
|
import {
|
|
63
59
|
fetchImageUrl,
|
|
@@ -130,7 +126,8 @@ function parseJsonArgs(args) {
|
|
|
130
126
|
}
|
|
131
127
|
__name(parseJsonArgs, "parseJsonArgs");
|
|
132
128
|
function processFunctionMessage(message) {
|
|
133
|
-
if (message
|
|
129
|
+
if (message["tool_calls"]) {
|
|
130
|
+
message = message;
|
|
134
131
|
const toolCalls = message.tool_calls;
|
|
135
132
|
return {
|
|
136
133
|
role: "model",
|
|
@@ -145,13 +142,14 @@ function processFunctionMessage(message) {
|
|
|
145
142
|
})
|
|
146
143
|
};
|
|
147
144
|
}
|
|
145
|
+
const finalMessage = message;
|
|
148
146
|
return {
|
|
149
147
|
role: "user",
|
|
150
148
|
parts: [
|
|
151
149
|
{
|
|
152
150
|
functionResponse: {
|
|
153
151
|
name: message.name,
|
|
154
|
-
id:
|
|
152
|
+
id: finalMessage.tool_call_id,
|
|
155
153
|
response: parseJsonArgs(message.content)
|
|
156
154
|
}
|
|
157
155
|
}
|
|
@@ -808,7 +806,7 @@ var GeminiRequester = class extends ModelRequester {
|
|
|
808
806
|
if (groundingContent.length > 0) {
|
|
809
807
|
logger.debug(`grounding content: ${groundingContent}`);
|
|
810
808
|
if (this._pluginConfig.groundingContentDisplay) {
|
|
811
|
-
const groundingMessage = new
|
|
809
|
+
const groundingMessage = new AIMessageChunk(
|
|
812
810
|
`
|
|
813
811
|
${groundingContent}`
|
|
814
812
|
);
|
|
@@ -821,7 +819,7 @@ ${groundingContent}`
|
|
|
821
819
|
}
|
|
822
820
|
}
|
|
823
821
|
_createMessageChunk(content, functionCall, imagePart) {
|
|
824
|
-
const messageChunk = new
|
|
822
|
+
const messageChunk = new AIMessageChunk({
|
|
825
823
|
content: content ?? "",
|
|
826
824
|
tool_call_chunks: [functionCall].filter(Boolean)
|
|
827
825
|
});
|
|
@@ -923,7 +921,7 @@ var GeminiClient = class extends PlatformModelAndEmbeddingsClient {
|
|
|
923
921
|
if (model.name.includes("gemini-2.5") && !model.name.includes("pro") && !model.name.includes("image")) {
|
|
924
922
|
if (!model.name.includes("-thinking")) {
|
|
925
923
|
models.push(
|
|
926
|
-
{ ...info, name: model.name + "-
|
|
924
|
+
{ ...info, name: model.name + "-non-thinking" },
|
|
927
925
|
{ ...info, name: model.name + "-thinking" },
|
|
928
926
|
info
|
|
929
927
|
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna-google-gemini-adapter",
|
|
3
3
|
"description": "google-gemini adapter for chatluna",
|
|
4
|
-
"version": "1.3.0-alpha.
|
|
4
|
+
"version": "1.3.0-alpha.7",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"koishi": "^4.18.7",
|
|
76
|
-
"koishi-plugin-chatluna": "^1.3.0-alpha.
|
|
76
|
+
"koishi-plugin-chatluna": "^1.3.0-alpha.32",
|
|
77
77
|
"koishi-plugin-chatluna-storage-service": "^0.0.8"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|