koishi-plugin-chatluna-google-gemini-adapter 1.2.17 → 1.2.19

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 CHANGED
@@ -210,7 +210,8 @@ function formatToolsToGeminiAITools(tools, config, model) {
210
210
  ];
211
211
  const imageGenerationModels = [
212
212
  "gemini-2.0-flash-exp",
213
- "gemini-2.0-flash-exp-image-generation"
213
+ "gemini-2.0-flash-exp-image-generation",
214
+ "gemini-2.5-flash-image-preview"
214
215
  ];
215
216
  let googleSearch = config.googleSearch;
216
217
  let codeExecution = config.codeExecution;
@@ -344,6 +345,10 @@ var GeminiRequester = class extends import_api.ModelRequester {
344
345
  } else if (thinkingBudget >= 0 && thinkingBudget < 128) {
345
346
  thinkingBudget = 128;
346
347
  }
348
+ let imageGeneration = this._pluginConfig.imageGeneration ?? false;
349
+ if (imageGeneration) {
350
+ imageGeneration = params.model.includes("gemini-2.0-flash-exp") || params.model.includes("gemini-2.5-flash-image");
351
+ }
347
352
  const response = await this._post(
348
353
  `models/${model}:streamGenerateContent?alt=sse`,
349
354
  {
@@ -375,10 +380,7 @@ var GeminiRequester = class extends import_api.ModelRequester {
375
380
  temperature: params.temperature,
376
381
  maxOutputTokens: params.model.includes("vision") ? void 0 : params.maxTokens,
377
382
  topP: params.topP,
378
- responseModalities: params.model.includes(
379
- // TODO: Wait for google release to all models
380
- "gemini-2.0-flash-exp"
381
- ) && this._pluginConfig.imageGeneration ? ["TEXT", "IMAGE"] : void 0,
383
+ responseModalities: imageGeneration ? ["TEXT", "IMAGE"] : void 0,
382
384
  thinkingConfig: enabledThinking != null || this._pluginConfig.includeThoughts ? {
383
385
  thinkingBudget,
384
386
  includeThoughts: this._pluginConfig.includeThoughts
@@ -419,11 +421,14 @@ var GeminiRequester = class extends import_api.ModelRequester {
419
421
  }
420
422
  for (const candidate of transformValue.candidates) {
421
423
  const parts = candidate.content?.parts;
422
- if ((parts == null || parts.length < 1) && candidate.finishReason !== "STOP") {
424
+ if ((parts == null || parts.length < 1) && candidate.finishReason !== "STOP" && candidate.content === null) {
423
425
  throw new Error(chunk);
424
426
  } else if (candidate.finishReason === "STOP" && parts == null) {
425
427
  continue;
426
428
  }
429
+ if (parts == null) {
430
+ continue;
431
+ }
427
432
  for (const part of parts) {
428
433
  controller.enqueue(part);
429
434
  }
@@ -694,7 +699,7 @@ var GeminiClient = class extends import_client.PlatformModelAndEmbeddingsClient
694
699
  functionCall: !model.name.includes("vision"),
695
700
  supportMode: ["all"]
696
701
  };
697
- if (model.name.includes("gemini-2.5") && !model.name.includes("pro")) {
702
+ if (model.name.includes("gemini-2.5") && !model.name.includes("pro") && !model.name.includes("image")) {
698
703
  if (!model.name.includes("-thinking")) {
699
704
  models.push(
700
705
  { ...info, name: model.name + "-nonthinking" },
@@ -781,7 +786,7 @@ var Config4 = import_koishi.Schema.intersect([
781
786
  }),
782
787
  import_koishi.Schema.object({
783
788
  maxTokens: import_koishi.Schema.number().min(16).max(2097e3).step(16).default(8064),
784
- temperature: import_koishi.Schema.percent().min(0).max(2).step(0.1).default(0.8),
789
+ temperature: import_koishi.Schema.percent().min(0).max(2).step(0.1).default(1),
785
790
  googleSearch: import_koishi.Schema.boolean().default(false),
786
791
  codeExecution: import_koishi.Schema.boolean().default(false),
787
792
  urlContext: import_koishi.Schema.boolean().default(false),
package/lib/index.mjs CHANGED
@@ -203,7 +203,8 @@ function formatToolsToGeminiAITools(tools, config, model) {
203
203
  ];
204
204
  const imageGenerationModels = [
205
205
  "gemini-2.0-flash-exp",
206
- "gemini-2.0-flash-exp-image-generation"
206
+ "gemini-2.0-flash-exp-image-generation",
207
+ "gemini-2.5-flash-image-preview"
207
208
  ];
208
209
  let googleSearch = config.googleSearch;
209
210
  let codeExecution = config.codeExecution;
@@ -337,6 +338,10 @@ var GeminiRequester = class extends ModelRequester {
337
338
  } else if (thinkingBudget >= 0 && thinkingBudget < 128) {
338
339
  thinkingBudget = 128;
339
340
  }
341
+ let imageGeneration = this._pluginConfig.imageGeneration ?? false;
342
+ if (imageGeneration) {
343
+ imageGeneration = params.model.includes("gemini-2.0-flash-exp") || params.model.includes("gemini-2.5-flash-image");
344
+ }
340
345
  const response = await this._post(
341
346
  `models/${model}:streamGenerateContent?alt=sse`,
342
347
  {
@@ -368,10 +373,7 @@ var GeminiRequester = class extends ModelRequester {
368
373
  temperature: params.temperature,
369
374
  maxOutputTokens: params.model.includes("vision") ? void 0 : params.maxTokens,
370
375
  topP: params.topP,
371
- responseModalities: params.model.includes(
372
- // TODO: Wait for google release to all models
373
- "gemini-2.0-flash-exp"
374
- ) && this._pluginConfig.imageGeneration ? ["TEXT", "IMAGE"] : void 0,
376
+ responseModalities: imageGeneration ? ["TEXT", "IMAGE"] : void 0,
375
377
  thinkingConfig: enabledThinking != null || this._pluginConfig.includeThoughts ? {
376
378
  thinkingBudget,
377
379
  includeThoughts: this._pluginConfig.includeThoughts
@@ -412,11 +414,14 @@ var GeminiRequester = class extends ModelRequester {
412
414
  }
413
415
  for (const candidate of transformValue.candidates) {
414
416
  const parts = candidate.content?.parts;
415
- if ((parts == null || parts.length < 1) && candidate.finishReason !== "STOP") {
417
+ if ((parts == null || parts.length < 1) && candidate.finishReason !== "STOP" && candidate.content === null) {
416
418
  throw new Error(chunk);
417
419
  } else if (candidate.finishReason === "STOP" && parts == null) {
418
420
  continue;
419
421
  }
422
+ if (parts == null) {
423
+ continue;
424
+ }
420
425
  for (const part of parts) {
421
426
  controller.enqueue(part);
422
427
  }
@@ -687,7 +692,7 @@ var GeminiClient = class extends PlatformModelAndEmbeddingsClient {
687
692
  functionCall: !model.name.includes("vision"),
688
693
  supportMode: ["all"]
689
694
  };
690
- if (model.name.includes("gemini-2.5") && !model.name.includes("pro")) {
695
+ if (model.name.includes("gemini-2.5") && !model.name.includes("pro") && !model.name.includes("image")) {
691
696
  if (!model.name.includes("-thinking")) {
692
697
  models.push(
693
698
  { ...info, name: model.name + "-nonthinking" },
@@ -774,7 +779,7 @@ var Config4 = Schema.intersect([
774
779
  }),
775
780
  Schema.object({
776
781
  maxTokens: Schema.number().min(16).max(2097e3).step(16).default(8064),
777
- temperature: Schema.percent().min(0).max(2).step(0.1).default(0.8),
782
+ temperature: Schema.percent().min(0).max(2).step(0.1).default(1),
778
783
  googleSearch: Schema.boolean().default(false),
779
784
  codeExecution: Schema.boolean().default(false),
780
785
  urlContext: 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.17",
4
+ "version": "1.2.19",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -62,10 +62,10 @@
62
62
  "adapter"
63
63
  ],
64
64
  "dependencies": {
65
+ "@chatluna/v1-shared-adapter": "^1.0.2",
65
66
  "@langchain/core": "^0.3.43",
66
67
  "zod": "^3.25.0-canary.20250211T214501",
67
- "zod-to-json-schema": "^3.24.5",
68
- "@chatluna/v1-shared-adapter": "^1.0.2"
68
+ "zod-to-json-schema": "^3.24.5"
69
69
  },
70
70
  "devDependencies": {
71
71
  "atsc": "^2.1.0",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  "peerDependencies": {
75
75
  "koishi": "^4.18.7",
76
- "koishi-plugin-chatluna": "^1.3.0-alpha.11"
76
+ "koishi-plugin-chatluna": "^1.3.0-alpha.13"
77
77
  },
78
78
  "koishi": {
79
79
  "description": {