koishi-plugin-chatluna-google-gemini-adapter 1.2.2 → 1.2.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 +10 -10
- package/lib/index.d.ts +1 -1
- package/lib/index.mjs +10 -10
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -33,14 +33,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
33
33
|
// src/locales/zh-CN.schema.yml
|
|
34
34
|
var require_zh_CN_schema = __commonJS({
|
|
35
35
|
"src/locales/zh-CN.schema.yml"(exports2, module2) {
|
|
36
|
-
module2.exports = { $inner: [{}, { $desc: "请求选项", platform: "适配器的平台名。(不懂请不要修改)", apiKeys: { $inner: ["Gemini 的 API Key", "Gemini API 的请求地址"], $desc: "Gemini 的 API Key 和请求地址列表。" } }, { $desc: "模型配置", maxTokens: "输入的最大上下文 Token(16~2097000,必须是 16 的倍数)。注意:仅当您使用的模型最大 Token 为 8000 及以上时,才建议设置超过 2000 token。", temperature: "回复的随机性程度,数值越高,回复越随机(范围:0~2)。", googleSearch: "为模型启用谷歌搜索。", thinkingBudget: "思考预算,范围:
|
|
36
|
+
module2.exports = { $inner: [{}, { $desc: "请求选项", platform: "适配器的平台名。(不懂请不要修改)", apiKeys: { $inner: ["Gemini 的 API Key", "Gemini API 的请求地址"], $desc: "Gemini 的 API Key 和请求地址列表。" } }, { $desc: "模型配置", maxTokens: "输入的最大上下文 Token(16~2097000,必须是 16 的倍数)。注意:仅当您使用的模型最大 Token 为 8000 及以上时,才建议设置超过 2000 token。", temperature: "回复的随机性程度,数值越高,回复越随机(范围:0~2)。", googleSearch: "为模型启用谷歌搜索。", thinkingBudget: "思考预算,范围:(-1~24576),设置的数值越大,思考时花费的 Token 越多,-1 为动态思考,0 为不思考。目前仅支持 gemini 2.5 系列模型。", groundingContentDisplay: "是否显示谷歌搜索结果。", imageGeneration: "为模型启用图像生成。目前仅支持 `gemini-2.0-flash-exp` 模型。", searchThreshold: "搜索的[置信度阈值](https://ai.google.dev/gemini-api/docs/grounding?lang=rest#dynamic-retrieval),范围:0~1,设置的数值越低,则越倾向于使用谷歌搜索。(仅支持 `gemini-1.5` 系列模型。gemini 2.0 模型起使用动态的工具调用)", includeThoughts: "是否获取模型的思考内容。", codeExecution: "为模型启用代码执行工具。", urlContext: "为模型启用 URL 内容获取工具。" }] };
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// src/locales/en-US.schema.yml
|
|
41
41
|
var require_en_US_schema = __commonJS({
|
|
42
42
|
"src/locales/en-US.schema.yml"(exports2, module2) {
|
|
43
|
-
module2.exports = { $inner: [{}, { $desc: "API Configuration", platform: "Adapter platform name. (Do not modify if you do not understand)", apiKeys: { $inner: ["Gemini API Key", "Gemini API Endpoint (optional)"], $desc: "Gemini API access credentials" } }, { $desc: "Model Parameters", maxTokens: "Max output tokens (16-2097000, multiple of 16). >2000 for 8k+ models", temperature: "Sampling temperature (0-2). Higher: more random, Lower: more deterministic", googleSearch: "Enable Google search", thinkingBudget: "Thinking budget (
|
|
43
|
+
module2.exports = { $inner: [{}, { $desc: "API Configuration", platform: "Adapter platform name. (Do not modify if you do not understand)", apiKeys: { $inner: ["Gemini API Key", "Gemini API Endpoint (optional)"], $desc: "Gemini API access credentials" } }, { $desc: "Model Parameters", maxTokens: "Max output tokens (16-2097000, multiple of 16). >2000 for 8k+ models", temperature: "Sampling temperature (0-2). Higher: more random, Lower: more deterministic", googleSearch: "Enable Google search", thinkingBudget: "Thinking budget (-1-24576). (-1: dynamic thinking, 0: no thinking) Higher: more tokens spent on thinking. Currently only supports `gemini-2.5` series models.", groundingContentDisplay: "Enable display of search results", imageGeneration: "Enable image generation (only for `gemini-2.0-flash-exp` model)", searchThreshold: "Search confidence [threshold](https://ai.google.dev/gemini-api/docs/grounding?lang=rest#dynamic-retrieval) (0-1). Lower: more likely to use Google search", includeThoughts: "Enable retrieval of model thoughts", codeExecution: "Enable code execution tool", urlContext: "Enable URL context retrieval tool" }] };
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -236,8 +236,8 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
236
236
|
];
|
|
237
237
|
let googleSearch = config.googleSearch;
|
|
238
238
|
let codeExecution = config.codeExecution;
|
|
239
|
-
let
|
|
240
|
-
const useCustomTools = config.googleSearch || config.codeExecution || config.
|
|
239
|
+
let urlContext = config.urlContext;
|
|
240
|
+
const useCustomTools = config.googleSearch || config.codeExecution || config.urlContext;
|
|
241
241
|
if (functions.length > 0 && !useCustomTools) {
|
|
242
242
|
result.push({
|
|
243
243
|
functionDeclarations: functions
|
|
@@ -254,7 +254,7 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
254
254
|
);
|
|
255
255
|
googleSearch = false;
|
|
256
256
|
codeExecution = false;
|
|
257
|
-
|
|
257
|
+
urlContext = false;
|
|
258
258
|
}
|
|
259
259
|
if (googleSearch) {
|
|
260
260
|
if (model.includes("gemini-2")) {
|
|
@@ -277,9 +277,9 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
277
277
|
code_execution: {}
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
|
-
if (
|
|
280
|
+
if (urlContext) {
|
|
281
281
|
result.push({
|
|
282
|
-
|
|
282
|
+
urlContext: {}
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
285
|
return result;
|
|
@@ -401,7 +401,7 @@ var GeminiRequester = class extends import_api.ModelRequester {
|
|
|
401
401
|
includeThoughts: this._pluginConfig.includeThoughts
|
|
402
402
|
} : void 0
|
|
403
403
|
},
|
|
404
|
-
tools: params.tools != null || this._pluginConfig.googleSearch || this._pluginConfig.codeExecution || this._pluginConfig.
|
|
404
|
+
tools: params.tools != null || this._pluginConfig.googleSearch || this._pluginConfig.codeExecution || this._pluginConfig.urlContext ? formatToolsToGeminiAITools(
|
|
405
405
|
params.tools ?? [],
|
|
406
406
|
this._pluginConfig,
|
|
407
407
|
params.model
|
|
@@ -476,7 +476,7 @@ var GeminiRequester = class extends import_api.ModelRequester {
|
|
|
476
476
|
}
|
|
477
477
|
const deltaFunctionCall = chatFunctionCallingPart?.functionCall;
|
|
478
478
|
if (deltaFunctionCall) {
|
|
479
|
-
let args = deltaFunctionCall.args
|
|
479
|
+
let args = deltaFunctionCall.args;
|
|
480
480
|
try {
|
|
481
481
|
let parsedArgs = JSON.parse(args);
|
|
482
482
|
if (typeof parsedArgs !== "string") {
|
|
@@ -810,7 +810,7 @@ var Config3 = import_koishi.Schema.intersect([
|
|
|
810
810
|
temperature: import_koishi.Schema.percent().min(0).max(2).step(0.1).default(0.8),
|
|
811
811
|
googleSearch: import_koishi.Schema.boolean().default(false),
|
|
812
812
|
codeExecution: import_koishi.Schema.boolean().default(false),
|
|
813
|
-
|
|
813
|
+
urlContext: import_koishi.Schema.boolean().default(false),
|
|
814
814
|
thinkingBudget: import_koishi.Schema.number().min(-1).max(24576).step(16).default(-1),
|
|
815
815
|
includeThoughts: import_koishi.Schema.boolean().default(false),
|
|
816
816
|
imageGeneration: import_koishi.Schema.boolean().default(false),
|
package/lib/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface Config extends ChatLunaPlugin.Config {
|
|
|
10
10
|
temperature: number;
|
|
11
11
|
googleSearch: boolean;
|
|
12
12
|
codeExecution: boolean;
|
|
13
|
-
|
|
13
|
+
urlContext: boolean;
|
|
14
14
|
searchThreshold: number;
|
|
15
15
|
groundingContentDisplay: boolean;
|
|
16
16
|
imageGeneration: boolean;
|
package/lib/index.mjs
CHANGED
|
@@ -8,14 +8,14 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
8
8
|
// src/locales/zh-CN.schema.yml
|
|
9
9
|
var require_zh_CN_schema = __commonJS({
|
|
10
10
|
"src/locales/zh-CN.schema.yml"(exports, module) {
|
|
11
|
-
module.exports = { $inner: [{}, { $desc: "请求选项", platform: "适配器的平台名。(不懂请不要修改)", apiKeys: { $inner: ["Gemini 的 API Key", "Gemini API 的请求地址"], $desc: "Gemini 的 API Key 和请求地址列表。" } }, { $desc: "模型配置", maxTokens: "输入的最大上下文 Token(16~2097000,必须是 16 的倍数)。注意:仅当您使用的模型最大 Token 为 8000 及以上时,才建议设置超过 2000 token。", temperature: "回复的随机性程度,数值越高,回复越随机(范围:0~2)。", googleSearch: "为模型启用谷歌搜索。", thinkingBudget: "思考预算,范围:
|
|
11
|
+
module.exports = { $inner: [{}, { $desc: "请求选项", platform: "适配器的平台名。(不懂请不要修改)", apiKeys: { $inner: ["Gemini 的 API Key", "Gemini API 的请求地址"], $desc: "Gemini 的 API Key 和请求地址列表。" } }, { $desc: "模型配置", maxTokens: "输入的最大上下文 Token(16~2097000,必须是 16 的倍数)。注意:仅当您使用的模型最大 Token 为 8000 及以上时,才建议设置超过 2000 token。", temperature: "回复的随机性程度,数值越高,回复越随机(范围:0~2)。", googleSearch: "为模型启用谷歌搜索。", thinkingBudget: "思考预算,范围:(-1~24576),设置的数值越大,思考时花费的 Token 越多,-1 为动态思考,0 为不思考。目前仅支持 gemini 2.5 系列模型。", groundingContentDisplay: "是否显示谷歌搜索结果。", imageGeneration: "为模型启用图像生成。目前仅支持 `gemini-2.0-flash-exp` 模型。", searchThreshold: "搜索的[置信度阈值](https://ai.google.dev/gemini-api/docs/grounding?lang=rest#dynamic-retrieval),范围:0~1,设置的数值越低,则越倾向于使用谷歌搜索。(仅支持 `gemini-1.5` 系列模型。gemini 2.0 模型起使用动态的工具调用)", includeThoughts: "是否获取模型的思考内容。", codeExecution: "为模型启用代码执行工具。", urlContext: "为模型启用 URL 内容获取工具。" }] };
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
// src/locales/en-US.schema.yml
|
|
16
16
|
var require_en_US_schema = __commonJS({
|
|
17
17
|
"src/locales/en-US.schema.yml"(exports, module) {
|
|
18
|
-
module.exports = { $inner: [{}, { $desc: "API Configuration", platform: "Adapter platform name. (Do not modify if you do not understand)", apiKeys: { $inner: ["Gemini API Key", "Gemini API Endpoint (optional)"], $desc: "Gemini API access credentials" } }, { $desc: "Model Parameters", maxTokens: "Max output tokens (16-2097000, multiple of 16). >2000 for 8k+ models", temperature: "Sampling temperature (0-2). Higher: more random, Lower: more deterministic", googleSearch: "Enable Google search", thinkingBudget: "Thinking budget (
|
|
18
|
+
module.exports = { $inner: [{}, { $desc: "API Configuration", platform: "Adapter platform name. (Do not modify if you do not understand)", apiKeys: { $inner: ["Gemini API Key", "Gemini API Endpoint (optional)"], $desc: "Gemini API access credentials" } }, { $desc: "Model Parameters", maxTokens: "Max output tokens (16-2097000, multiple of 16). >2000 for 8k+ models", temperature: "Sampling temperature (0-2). Higher: more random, Lower: more deterministic", googleSearch: "Enable Google search", thinkingBudget: "Thinking budget (-1-24576). (-1: dynamic thinking, 0: no thinking) Higher: more tokens spent on thinking. Currently only supports `gemini-2.5` series models.", groundingContentDisplay: "Enable display of search results", imageGeneration: "Enable image generation (only for `gemini-2.0-flash-exp` model)", searchThreshold: "Search confidence [threshold](https://ai.google.dev/gemini-api/docs/grounding?lang=rest#dynamic-retrieval) (0-1). Lower: more likely to use Google search", includeThoughts: "Enable retrieval of model thoughts", codeExecution: "Enable code execution tool", urlContext: "Enable URL context retrieval tool" }] };
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
|
|
@@ -219,8 +219,8 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
219
219
|
];
|
|
220
220
|
let googleSearch = config.googleSearch;
|
|
221
221
|
let codeExecution = config.codeExecution;
|
|
222
|
-
let
|
|
223
|
-
const useCustomTools = config.googleSearch || config.codeExecution || config.
|
|
222
|
+
let urlContext = config.urlContext;
|
|
223
|
+
const useCustomTools = config.googleSearch || config.codeExecution || config.urlContext;
|
|
224
224
|
if (functions.length > 0 && !useCustomTools) {
|
|
225
225
|
result.push({
|
|
226
226
|
functionDeclarations: functions
|
|
@@ -237,7 +237,7 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
237
237
|
);
|
|
238
238
|
googleSearch = false;
|
|
239
239
|
codeExecution = false;
|
|
240
|
-
|
|
240
|
+
urlContext = false;
|
|
241
241
|
}
|
|
242
242
|
if (googleSearch) {
|
|
243
243
|
if (model.includes("gemini-2")) {
|
|
@@ -260,9 +260,9 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
260
260
|
code_execution: {}
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
|
-
if (
|
|
263
|
+
if (urlContext) {
|
|
264
264
|
result.push({
|
|
265
|
-
|
|
265
|
+
urlContext: {}
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
268
|
return result;
|
|
@@ -384,7 +384,7 @@ var GeminiRequester = class extends ModelRequester {
|
|
|
384
384
|
includeThoughts: this._pluginConfig.includeThoughts
|
|
385
385
|
} : void 0
|
|
386
386
|
},
|
|
387
|
-
tools: params.tools != null || this._pluginConfig.googleSearch || this._pluginConfig.codeExecution || this._pluginConfig.
|
|
387
|
+
tools: params.tools != null || this._pluginConfig.googleSearch || this._pluginConfig.codeExecution || this._pluginConfig.urlContext ? formatToolsToGeminiAITools(
|
|
388
388
|
params.tools ?? [],
|
|
389
389
|
this._pluginConfig,
|
|
390
390
|
params.model
|
|
@@ -459,7 +459,7 @@ var GeminiRequester = class extends ModelRequester {
|
|
|
459
459
|
}
|
|
460
460
|
const deltaFunctionCall = chatFunctionCallingPart?.functionCall;
|
|
461
461
|
if (deltaFunctionCall) {
|
|
462
|
-
let args = deltaFunctionCall.args
|
|
462
|
+
let args = deltaFunctionCall.args;
|
|
463
463
|
try {
|
|
464
464
|
let parsedArgs = JSON.parse(args);
|
|
465
465
|
if (typeof parsedArgs !== "string") {
|
|
@@ -793,7 +793,7 @@ var Config3 = Schema.intersect([
|
|
|
793
793
|
temperature: Schema.percent().min(0).max(2).step(0.1).default(0.8),
|
|
794
794
|
googleSearch: Schema.boolean().default(false),
|
|
795
795
|
codeExecution: Schema.boolean().default(false),
|
|
796
|
-
|
|
796
|
+
urlContext: Schema.boolean().default(false),
|
|
797
797
|
thinkingBudget: Schema.number().min(-1).max(24576).step(16).default(-1),
|
|
798
798
|
includeThoughts: Schema.boolean().default(false),
|
|
799
799
|
imageGeneration: Schema.boolean().default(false),
|
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.4",
|
|
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.3"
|
|
76
76
|
},
|
|
77
77
|
"koishi": {
|
|
78
78
|
"description": {
|