koishi-plugin-chatluna-google-gemini-adapter 1.2.0-alpha.4 → 1.2.0-alpha.6
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 +44 -18
- package/lib/index.d.ts +1 -0
- package/lib/index.mjs +44 -18
- package/package.json +1 -1
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: "为模型启用谷歌搜索。", groundingContentDisplay: "是否显示谷歌搜索结果。", imageGeneration: "为模型启用图像生成。目前仅支持 `gemini-2.0-flash-exp` 模型。", searchThreshold: "搜索的置信度阈值,范围:0~1,设置的数值越低,则越倾向于使用谷歌搜索。" }] };
|
|
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: "思考预算,范围:0~24576,设置的数值越大,思考时花费的 Token 越多。目前仅支持 gemini 2.5 系列模型。", groundingContentDisplay: "是否显示谷歌搜索结果。", imageGeneration: "为模型启用图像生成。目前仅支持 `gemini-2.0-flash-exp` 模型。", searchThreshold: "搜索的置信度阈值,范围:0~1,设置的数值越低,则越倾向于使用谷歌搜索。" }] };
|
|
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", 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" }] };
|
|
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 (0-24576). 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" }] };
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -142,7 +142,7 @@ async function langchainMessageToGeminiMessage(messages, model) {
|
|
|
142
142
|
}
|
|
143
143
|
]
|
|
144
144
|
};
|
|
145
|
-
if ((model.includes("vision") || model.includes("gemini")) && images != null && !model.includes("gemini-1.0")) {
|
|
145
|
+
if ((model.includes("vision") || model.includes("gemini") || model.includes("gemma")) && images != null && !model.includes("gemini-1.0")) {
|
|
146
146
|
for (const image of images) {
|
|
147
147
|
const mineType = image.split(";")?.[0]?.split(":")?.[1];
|
|
148
148
|
const data = image.replace(/^data:image\/\w+;base64,/, "");
|
|
@@ -230,7 +230,7 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
230
230
|
"gemini-1.5-flash",
|
|
231
231
|
"gemini-2.0-flash-exp"
|
|
232
232
|
];
|
|
233
|
-
const
|
|
233
|
+
const imageGenerationModels = [
|
|
234
234
|
"gemini-2.0-flash-exp",
|
|
235
235
|
"gemini-2.0-flash-exp-image-generation"
|
|
236
236
|
];
|
|
@@ -243,7 +243,7 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
243
243
|
logger.warn("Google search is enabled, tool calling will be disable.");
|
|
244
244
|
} else if ((unsupportedModels.some(
|
|
245
245
|
(unsupportedModel) => model.includes(unsupportedModel)
|
|
246
|
-
) ||
|
|
246
|
+
) || imageGenerationModels.some(
|
|
247
247
|
(unsupportedModels2) => model.includes(unsupportedModels2)
|
|
248
248
|
) && config.imageGeneration) && googleSearch) {
|
|
249
249
|
logger.warn(
|
|
@@ -337,29 +337,35 @@ var GeminiRequester = class extends import_api.ModelRequester {
|
|
|
337
337
|
}
|
|
338
338
|
async *completionStream(params) {
|
|
339
339
|
try {
|
|
340
|
+
let model = params.model;
|
|
341
|
+
let enabledThinking = null;
|
|
342
|
+
if (model.includes("-thinking") && model.includes("gemini-2.5")) {
|
|
343
|
+
enabledThinking = !model.includes("-no-thinking");
|
|
344
|
+
model = model.replace("-no-thinking", "").replace("-thinking", "");
|
|
345
|
+
}
|
|
340
346
|
const response = await this._post(
|
|
341
|
-
`models/${
|
|
347
|
+
`models/${model}:streamGenerateContent?alt=sse`,
|
|
342
348
|
{
|
|
343
349
|
contents: await langchainMessageToGeminiMessage(
|
|
344
350
|
params.input,
|
|
345
|
-
|
|
351
|
+
model
|
|
346
352
|
),
|
|
347
353
|
safetySettings: [
|
|
348
354
|
{
|
|
349
355
|
category: "HARM_CATEGORY_HARASSMENT",
|
|
350
|
-
threshold: params.model.includes("gemini-2
|
|
356
|
+
threshold: params.model.includes("gemini-2") ? "OFF" : "BLOCK_NONE"
|
|
351
357
|
},
|
|
352
358
|
{
|
|
353
359
|
category: "HARM_CATEGORY_HATE_SPEECH",
|
|
354
|
-
threshold: params.model.includes("gemini-2
|
|
360
|
+
threshold: params.model.includes("gemini-2") ? "OFF" : "BLOCK_NONE"
|
|
355
361
|
},
|
|
356
362
|
{
|
|
357
363
|
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
358
|
-
threshold: params.model.includes("gemini-2
|
|
364
|
+
threshold: params.model.includes("gemini-2") ? "OFF" : "BLOCK_NONE"
|
|
359
365
|
},
|
|
360
366
|
{
|
|
361
367
|
category: "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
362
|
-
threshold: params.model.includes("gemini-2
|
|
368
|
+
threshold: params.model.includes("gemini-2") ? "OFF" : "BLOCK_NONE"
|
|
363
369
|
},
|
|
364
370
|
{
|
|
365
371
|
category: "HARM_CATEGORY_CIVIC_INTEGRITY",
|
|
@@ -374,8 +380,11 @@ var GeminiRequester = class extends import_api.ModelRequester {
|
|
|
374
380
|
responseModalities: params.model.includes(
|
|
375
381
|
// TODO: Wait for google release to all models
|
|
376
382
|
"gemini-2.0-flash-exp"
|
|
377
|
-
) && this._pluginConfig.imageGeneration ? ["TEXT", "IMAGE"] : void 0
|
|
378
|
-
|
|
383
|
+
) && this._pluginConfig.imageGeneration ? ["TEXT", "IMAGE"] : void 0,
|
|
384
|
+
thinkingConfig: enabledThinking != null ? {
|
|
385
|
+
thinkingBudget: enabledThinking ? this._pluginConfig.thinkingBudget ?? 4096 : 0
|
|
386
|
+
// includeThoughts: true
|
|
387
|
+
} : void 0
|
|
379
388
|
},
|
|
380
389
|
tools: params.tools != null || this._pluginConfig.googleSearch ? formatToolsToGeminiAITools(
|
|
381
390
|
params.tools ?? [],
|
|
@@ -581,7 +590,7 @@ ${groundingContent}`
|
|
|
581
590
|
);
|
|
582
591
|
}
|
|
583
592
|
return data.models.map((model) => model.name).filter(
|
|
584
|
-
(model) => model.includes("gemini") || model.includes("embedding")
|
|
593
|
+
(model) => model.includes("gemini") || model.includes("gemma") || model.includes("embedding")
|
|
585
594
|
);
|
|
586
595
|
} catch (e) {
|
|
587
596
|
const error = new Error(
|
|
@@ -663,15 +672,17 @@ var GeminiClient = class extends import_client.PlatformModelAndEmbeddingsClient
|
|
|
663
672
|
}
|
|
664
673
|
async refreshModels() {
|
|
665
674
|
try {
|
|
666
|
-
|
|
675
|
+
let rawModels = await this._requester.getModels();
|
|
667
676
|
if (!rawModels.length) {
|
|
668
677
|
throw new import_error2.ChatLunaError(
|
|
669
678
|
import_error2.ChatLunaErrorCode.MODEL_INIT_ERROR,
|
|
670
679
|
new Error("No model found")
|
|
671
680
|
);
|
|
672
681
|
}
|
|
673
|
-
|
|
674
|
-
|
|
682
|
+
rawModels = rawModels.map((model) => model.replace("models/", ""));
|
|
683
|
+
const models = [];
|
|
684
|
+
for (const model of rawModels) {
|
|
685
|
+
const info = {
|
|
675
686
|
name: model,
|
|
676
687
|
maxTokens: ((model2) => {
|
|
677
688
|
if (model2.includes("gemini-1.5-pro")) {
|
|
@@ -689,7 +700,21 @@ var GeminiClient = class extends import_client.PlatformModelAndEmbeddingsClient
|
|
|
689
700
|
functionCall: !model.includes("vision"),
|
|
690
701
|
supportMode: ["all"]
|
|
691
702
|
};
|
|
692
|
-
|
|
703
|
+
if (model.includes("gemini-2.5")) {
|
|
704
|
+
if (!model.includes("-thinking")) {
|
|
705
|
+
models.push(
|
|
706
|
+
{ ...info, name: model + "-no-thinking" },
|
|
707
|
+
{ ...info, name: model + "-thinking" },
|
|
708
|
+
info
|
|
709
|
+
);
|
|
710
|
+
} else {
|
|
711
|
+
models.push(info);
|
|
712
|
+
}
|
|
713
|
+
} else {
|
|
714
|
+
models.push(info);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
return models;
|
|
693
718
|
} catch (e) {
|
|
694
719
|
throw new import_error2.ChatLunaError(import_error2.ChatLunaErrorCode.MODEL_INIT_ERROR, e);
|
|
695
720
|
}
|
|
@@ -776,6 +801,7 @@ var Config3 = import_koishi.Schema.intersect([
|
|
|
776
801
|
maxTokens: import_koishi.Schema.number().min(16).max(2097e3).step(16).default(8064),
|
|
777
802
|
temperature: import_koishi.Schema.percent().min(0).max(2).step(0.1).default(0.8),
|
|
778
803
|
googleSearch: import_koishi.Schema.boolean().default(false),
|
|
804
|
+
thinkingBudget: import_koishi.Schema.number().min(0).max(24576).step(16).default(4096),
|
|
779
805
|
imageGeneration: import_koishi.Schema.boolean().default(false),
|
|
780
806
|
groundingContentDisplay: import_koishi.Schema.boolean().default(false),
|
|
781
807
|
searchThreshold: import_koishi.Schema.number().min(0).max(1).step(0.1).default(0.5)
|
package/lib/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface Config extends ChatLunaPlugin.Config {
|
|
|
12
12
|
searchThreshold: number;
|
|
13
13
|
groundingContentDisplay: boolean;
|
|
14
14
|
imageGeneration: boolean;
|
|
15
|
+
thinkingBudget: number;
|
|
15
16
|
}
|
|
16
17
|
export declare const Config: Schema<Config>;
|
|
17
18
|
export declare const inject: string[];
|
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: "为模型启用谷歌搜索。", groundingContentDisplay: "是否显示谷歌搜索结果。", imageGeneration: "为模型启用图像生成。目前仅支持 `gemini-2.0-flash-exp` 模型。", searchThreshold: "搜索的置信度阈值,范围:0~1,设置的数值越低,则越倾向于使用谷歌搜索。" }] };
|
|
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: "思考预算,范围:0~24576,设置的数值越大,思考时花费的 Token 越多。目前仅支持 gemini 2.5 系列模型。", groundingContentDisplay: "是否显示谷歌搜索结果。", imageGeneration: "为模型启用图像生成。目前仅支持 `gemini-2.0-flash-exp` 模型。", searchThreshold: "搜索的置信度阈值,范围:0~1,设置的数值越低,则越倾向于使用谷歌搜索。" }] };
|
|
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", 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" }] };
|
|
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 (0-24576). 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" }] };
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
|
|
@@ -125,7 +125,7 @@ async function langchainMessageToGeminiMessage(messages, model) {
|
|
|
125
125
|
}
|
|
126
126
|
]
|
|
127
127
|
};
|
|
128
|
-
if ((model.includes("vision") || model.includes("gemini")) && images != null && !model.includes("gemini-1.0")) {
|
|
128
|
+
if ((model.includes("vision") || model.includes("gemini") || model.includes("gemma")) && images != null && !model.includes("gemini-1.0")) {
|
|
129
129
|
for (const image of images) {
|
|
130
130
|
const mineType = image.split(";")?.[0]?.split(":")?.[1];
|
|
131
131
|
const data = image.replace(/^data:image\/\w+;base64,/, "");
|
|
@@ -213,7 +213,7 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
213
213
|
"gemini-1.5-flash",
|
|
214
214
|
"gemini-2.0-flash-exp"
|
|
215
215
|
];
|
|
216
|
-
const
|
|
216
|
+
const imageGenerationModels = [
|
|
217
217
|
"gemini-2.0-flash-exp",
|
|
218
218
|
"gemini-2.0-flash-exp-image-generation"
|
|
219
219
|
];
|
|
@@ -226,7 +226,7 @@ function formatToolsToGeminiAITools(tools, config, model) {
|
|
|
226
226
|
logger.warn("Google search is enabled, tool calling will be disable.");
|
|
227
227
|
} else if ((unsupportedModels.some(
|
|
228
228
|
(unsupportedModel) => model.includes(unsupportedModel)
|
|
229
|
-
) ||
|
|
229
|
+
) || imageGenerationModels.some(
|
|
230
230
|
(unsupportedModels2) => model.includes(unsupportedModels2)
|
|
231
231
|
) && config.imageGeneration) && googleSearch) {
|
|
232
232
|
logger.warn(
|
|
@@ -320,29 +320,35 @@ var GeminiRequester = class extends ModelRequester {
|
|
|
320
320
|
}
|
|
321
321
|
async *completionStream(params) {
|
|
322
322
|
try {
|
|
323
|
+
let model = params.model;
|
|
324
|
+
let enabledThinking = null;
|
|
325
|
+
if (model.includes("-thinking") && model.includes("gemini-2.5")) {
|
|
326
|
+
enabledThinking = !model.includes("-no-thinking");
|
|
327
|
+
model = model.replace("-no-thinking", "").replace("-thinking", "");
|
|
328
|
+
}
|
|
323
329
|
const response = await this._post(
|
|
324
|
-
`models/${
|
|
330
|
+
`models/${model}:streamGenerateContent?alt=sse`,
|
|
325
331
|
{
|
|
326
332
|
contents: await langchainMessageToGeminiMessage(
|
|
327
333
|
params.input,
|
|
328
|
-
|
|
334
|
+
model
|
|
329
335
|
),
|
|
330
336
|
safetySettings: [
|
|
331
337
|
{
|
|
332
338
|
category: "HARM_CATEGORY_HARASSMENT",
|
|
333
|
-
threshold: params.model.includes("gemini-2
|
|
339
|
+
threshold: params.model.includes("gemini-2") ? "OFF" : "BLOCK_NONE"
|
|
334
340
|
},
|
|
335
341
|
{
|
|
336
342
|
category: "HARM_CATEGORY_HATE_SPEECH",
|
|
337
|
-
threshold: params.model.includes("gemini-2
|
|
343
|
+
threshold: params.model.includes("gemini-2") ? "OFF" : "BLOCK_NONE"
|
|
338
344
|
},
|
|
339
345
|
{
|
|
340
346
|
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
341
|
-
threshold: params.model.includes("gemini-2
|
|
347
|
+
threshold: params.model.includes("gemini-2") ? "OFF" : "BLOCK_NONE"
|
|
342
348
|
},
|
|
343
349
|
{
|
|
344
350
|
category: "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
345
|
-
threshold: params.model.includes("gemini-2
|
|
351
|
+
threshold: params.model.includes("gemini-2") ? "OFF" : "BLOCK_NONE"
|
|
346
352
|
},
|
|
347
353
|
{
|
|
348
354
|
category: "HARM_CATEGORY_CIVIC_INTEGRITY",
|
|
@@ -357,8 +363,11 @@ var GeminiRequester = class extends ModelRequester {
|
|
|
357
363
|
responseModalities: params.model.includes(
|
|
358
364
|
// TODO: Wait for google release to all models
|
|
359
365
|
"gemini-2.0-flash-exp"
|
|
360
|
-
) && this._pluginConfig.imageGeneration ? ["TEXT", "IMAGE"] : void 0
|
|
361
|
-
|
|
366
|
+
) && this._pluginConfig.imageGeneration ? ["TEXT", "IMAGE"] : void 0,
|
|
367
|
+
thinkingConfig: enabledThinking != null ? {
|
|
368
|
+
thinkingBudget: enabledThinking ? this._pluginConfig.thinkingBudget ?? 4096 : 0
|
|
369
|
+
// includeThoughts: true
|
|
370
|
+
} : void 0
|
|
362
371
|
},
|
|
363
372
|
tools: params.tools != null || this._pluginConfig.googleSearch ? formatToolsToGeminiAITools(
|
|
364
373
|
params.tools ?? [],
|
|
@@ -564,7 +573,7 @@ ${groundingContent}`
|
|
|
564
573
|
);
|
|
565
574
|
}
|
|
566
575
|
return data.models.map((model) => model.name).filter(
|
|
567
|
-
(model) => model.includes("gemini") || model.includes("embedding")
|
|
576
|
+
(model) => model.includes("gemini") || model.includes("gemma") || model.includes("embedding")
|
|
568
577
|
);
|
|
569
578
|
} catch (e) {
|
|
570
579
|
const error = new Error(
|
|
@@ -646,15 +655,17 @@ var GeminiClient = class extends PlatformModelAndEmbeddingsClient {
|
|
|
646
655
|
}
|
|
647
656
|
async refreshModels() {
|
|
648
657
|
try {
|
|
649
|
-
|
|
658
|
+
let rawModels = await this._requester.getModels();
|
|
650
659
|
if (!rawModels.length) {
|
|
651
660
|
throw new ChatLunaError2(
|
|
652
661
|
ChatLunaErrorCode2.MODEL_INIT_ERROR,
|
|
653
662
|
new Error("No model found")
|
|
654
663
|
);
|
|
655
664
|
}
|
|
656
|
-
|
|
657
|
-
|
|
665
|
+
rawModels = rawModels.map((model) => model.replace("models/", ""));
|
|
666
|
+
const models = [];
|
|
667
|
+
for (const model of rawModels) {
|
|
668
|
+
const info = {
|
|
658
669
|
name: model,
|
|
659
670
|
maxTokens: ((model2) => {
|
|
660
671
|
if (model2.includes("gemini-1.5-pro")) {
|
|
@@ -672,7 +683,21 @@ var GeminiClient = class extends PlatformModelAndEmbeddingsClient {
|
|
|
672
683
|
functionCall: !model.includes("vision"),
|
|
673
684
|
supportMode: ["all"]
|
|
674
685
|
};
|
|
675
|
-
|
|
686
|
+
if (model.includes("gemini-2.5")) {
|
|
687
|
+
if (!model.includes("-thinking")) {
|
|
688
|
+
models.push(
|
|
689
|
+
{ ...info, name: model + "-no-thinking" },
|
|
690
|
+
{ ...info, name: model + "-thinking" },
|
|
691
|
+
info
|
|
692
|
+
);
|
|
693
|
+
} else {
|
|
694
|
+
models.push(info);
|
|
695
|
+
}
|
|
696
|
+
} else {
|
|
697
|
+
models.push(info);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return models;
|
|
676
701
|
} catch (e) {
|
|
677
702
|
throw new ChatLunaError2(ChatLunaErrorCode2.MODEL_INIT_ERROR, e);
|
|
678
703
|
}
|
|
@@ -759,6 +784,7 @@ var Config3 = Schema.intersect([
|
|
|
759
784
|
maxTokens: Schema.number().min(16).max(2097e3).step(16).default(8064),
|
|
760
785
|
temperature: Schema.percent().min(0).max(2).step(0.1).default(0.8),
|
|
761
786
|
googleSearch: Schema.boolean().default(false),
|
|
787
|
+
thinkingBudget: Schema.number().min(0).max(24576).step(16).default(4096),
|
|
762
788
|
imageGeneration: Schema.boolean().default(false),
|
|
763
789
|
groundingContentDisplay: Schema.boolean().default(false),
|
|
764
790
|
searchThreshold: Schema.number().min(0).max(1).step(0.1).default(0.5)
|
package/package.json
CHANGED