koishi-plugin-chatluna-google-gemini-adapter 1.2.12 → 1.2.15
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 +9 -22
- package/lib/index.mjs +9 -12
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
6
|
var __commonJS = (cb, mod) => function __require() {
|
|
@@ -20,14 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
18
|
}
|
|
21
19
|
return to;
|
|
22
20
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
22
|
|
|
33
23
|
// src/locales/zh-CN.schema.yml
|
|
@@ -181,21 +171,20 @@ function extractSystemMessages(messages) {
|
|
|
181
171
|
}
|
|
182
172
|
const systemMessages = messages.slice(
|
|
183
173
|
0,
|
|
184
|
-
messages.indexOf(lastSystemMessage)
|
|
174
|
+
messages.indexOf(lastSystemMessage) + 1
|
|
175
|
+
);
|
|
176
|
+
const modelMessages = messages.slice(
|
|
177
|
+
messages.indexOf(lastSystemMessage) + 1
|
|
185
178
|
);
|
|
186
179
|
return [
|
|
187
180
|
{
|
|
188
181
|
role: "user",
|
|
189
|
-
parts:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return acc;
|
|
194
|
-
}, []).map((part) => partAsType(part).text).join("\n\n\n")
|
|
195
|
-
}
|
|
196
|
-
]
|
|
182
|
+
parts: systemMessages.reduce((acc, cur) => {
|
|
183
|
+
acc.push(...cur.parts);
|
|
184
|
+
return acc;
|
|
185
|
+
}, [])
|
|
197
186
|
},
|
|
198
|
-
|
|
187
|
+
modelMessages
|
|
199
188
|
];
|
|
200
189
|
}
|
|
201
190
|
__name(extractSystemMessages, "extractSystemMessages");
|
|
@@ -328,7 +317,6 @@ function messageTypeToGeminiRole(type) {
|
|
|
328
317
|
__name(messageTypeToGeminiRole, "messageTypeToGeminiRole");
|
|
329
318
|
|
|
330
319
|
// src/requester.ts
|
|
331
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
332
320
|
var GeminiRequester = class extends import_api.ModelRequester {
|
|
333
321
|
constructor(_config, _plugin, _pluginConfig) {
|
|
334
322
|
super();
|
|
@@ -631,7 +619,6 @@ ${groundingContent}`
|
|
|
631
619
|
}
|
|
632
620
|
}
|
|
633
621
|
const body = JSON.stringify(data);
|
|
634
|
-
import_promises.default.writeFile("./request.json", body);
|
|
635
622
|
return this._plugin.fetch(requestUrl, {
|
|
636
623
|
body,
|
|
637
624
|
headers: this._buildHeaders(),
|
package/lib/index.mjs
CHANGED
|
@@ -164,21 +164,20 @@ function extractSystemMessages(messages) {
|
|
|
164
164
|
}
|
|
165
165
|
const systemMessages = messages.slice(
|
|
166
166
|
0,
|
|
167
|
-
messages.indexOf(lastSystemMessage)
|
|
167
|
+
messages.indexOf(lastSystemMessage) + 1
|
|
168
|
+
);
|
|
169
|
+
const modelMessages = messages.slice(
|
|
170
|
+
messages.indexOf(lastSystemMessage) + 1
|
|
168
171
|
);
|
|
169
172
|
return [
|
|
170
173
|
{
|
|
171
174
|
role: "user",
|
|
172
|
-
parts:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return acc;
|
|
177
|
-
}, []).map((part) => partAsType(part).text).join("\n\n\n")
|
|
178
|
-
}
|
|
179
|
-
]
|
|
175
|
+
parts: systemMessages.reduce((acc, cur) => {
|
|
176
|
+
acc.push(...cur.parts);
|
|
177
|
+
return acc;
|
|
178
|
+
}, [])
|
|
180
179
|
},
|
|
181
|
-
|
|
180
|
+
modelMessages
|
|
182
181
|
];
|
|
183
182
|
}
|
|
184
183
|
__name(extractSystemMessages, "extractSystemMessages");
|
|
@@ -311,7 +310,6 @@ function messageTypeToGeminiRole(type) {
|
|
|
311
310
|
__name(messageTypeToGeminiRole, "messageTypeToGeminiRole");
|
|
312
311
|
|
|
313
312
|
// src/requester.ts
|
|
314
|
-
import fs from "fs/promises";
|
|
315
313
|
var GeminiRequester = class extends ModelRequester {
|
|
316
314
|
constructor(_config, _plugin, _pluginConfig) {
|
|
317
315
|
super();
|
|
@@ -614,7 +612,6 @@ ${groundingContent}`
|
|
|
614
612
|
}
|
|
615
613
|
}
|
|
616
614
|
const body = JSON.stringify(data);
|
|
617
|
-
fs.writeFile("./request.json", body);
|
|
618
615
|
return this._plugin.fetch(requestUrl, {
|
|
619
616
|
body,
|
|
620
617
|
headers: this._buildHeaders(),
|
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.2.
|
|
4
|
+
"version": "1.2.15",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"koishi": "^4.18.7",
|
|
75
|
-
"koishi-plugin-chatluna": "^1.3.0-alpha.
|
|
75
|
+
"koishi-plugin-chatluna": "^1.3.0-alpha.9"
|
|
76
76
|
},
|
|
77
77
|
"koishi": {
|
|
78
78
|
"description": {
|