koishi-plugin-chatluna-google-gemini-adapter 1.3.0-alpha.12 → 1.3.0-alpha.13

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
- ## chatluna-google-gemini-adapter
2
-
3
- ## [![npm](https://img.shields.io/npm/v/koishi-plugin-chatluna-google-gemini-adapter)](https://www.npmjs.com/package/koishi-plugin-chatluna-google-gemini) [![npm](https://img.shields.io/npm/dm/koishi-plugin-chatluna-google-gemini-adapter)](https://www.npmjs.com/package//koishi-plugin-chatluna-google-gemini-adapter)
4
-
5
- > 为 ChatLuna 提供 Google Gemini 支持的适配器
6
-
7
- [Gemini 适配器文档](https://chatluna.chat/guide/configure-model-platform/google-gemini.html)
1
+ ## chatluna-google-gemini-adapter
2
+
3
+ ## [![npm](https://img.shields.io/npm/v/koishi-plugin-chatluna-google-gemini-adapter)](https://www.npmjs.com/package/koishi-plugin-chatluna-google-gemini) [![npm](https://img.shields.io/npm/dm/koishi-plugin-chatluna-google-gemini-adapter)](https://www.npmjs.com/package//koishi-plugin-chatluna-google-gemini-adapter)
4
+
5
+ > 为 ChatLuna 提供 Google Gemini 支持的适配器
6
+
7
+ [Gemini 适配器文档](https://chatluna.chat/guide/configure-model-platform/google-gemini.html)
package/lib/index.cjs CHANGED
@@ -405,6 +405,7 @@ __name(isChatResponse, "isChatResponse");
405
405
 
406
406
  // src/requester.ts
407
407
  var import_string2 = require("koishi-plugin-chatluna/utils/string");
408
+ var import_logger = require("koishi-plugin-chatluna/utils/logger");
408
409
  var GeminiRequester = class extends import_api.ModelRequester {
409
410
  constructor(ctx, _configPool, _pluginConfig, _plugin) {
410
411
  super(ctx, _configPool, _pluginConfig, _plugin);
@@ -448,6 +449,13 @@ var GeminiRequester = class extends import_api.ModelRequester {
448
449
  await (0, import_sse.checkResponse)(response);
449
450
  yield* this._processResponseStream(response);
450
451
  } catch (e) {
452
+ if (this.ctx.chatluna.config.isLog) {
453
+ await (0, import_logger.trackLogToLocal)(
454
+ "Request",
455
+ JSON.stringify(chatGenerationParams),
456
+ logger
457
+ );
458
+ }
451
459
  if (e instanceof import_error.ChatLunaError) {
452
460
  throw e;
453
461
  } else {
@@ -457,15 +465,16 @@ var GeminiRequester = class extends import_api.ModelRequester {
457
465
  }
458
466
  async completionInternal(params) {
459
467
  const modelConfig = prepareModelConfig(params, this._pluginConfig);
468
+ const chatGenerationParams = await createChatGenerationParams(
469
+ params,
470
+ this._plugin,
471
+ modelConfig,
472
+ this._pluginConfig
473
+ );
460
474
  try {
461
475
  const response = await this._post(
462
476
  `models/${modelConfig.model}:generateContent`,
463
- await createChatGenerationParams(
464
- params,
465
- this._plugin,
466
- modelConfig,
467
- this._pluginConfig
468
- ),
477
+ chatGenerationParams,
469
478
  {
470
479
  signal: params.signal
471
480
  }
@@ -473,6 +482,13 @@ var GeminiRequester = class extends import_api.ModelRequester {
473
482
  await (0, import_sse.checkResponse)(response);
474
483
  return await this._processResponse(response);
475
484
  } catch (e) {
485
+ if (this.ctx.chatluna.config.isLog) {
486
+ await (0, import_logger.trackLogToLocal)(
487
+ "Request",
488
+ JSON.stringify(chatGenerationParams),
489
+ logger
490
+ );
491
+ }
476
492
  if (e instanceof import_error.ChatLunaError) {
477
493
  throw e;
478
494
  } else {
@@ -978,12 +994,12 @@ var GeminiClient = class extends import_client.PlatformModelAndEmbeddingsClient
978
994
  };
979
995
 
980
996
  // src/index.ts
981
- var import_logger = require("koishi-plugin-chatluna/utils/logger");
997
+ var import_logger2 = require("koishi-plugin-chatluna/utils/logger");
982
998
  var logger;
983
999
  var reusable = true;
984
1000
  function apply(ctx, config) {
985
1001
  const plugin = new import_chat.ChatLunaPlugin(ctx, config, config.platform);
986
- logger = (0, import_logger.createLogger)(ctx, "chatluna-gemini-adapter");
1002
+ logger = (0, import_logger2.createLogger)(ctx, "chatluna-gemini-adapter");
987
1003
  ctx.on("ready", async () => {
988
1004
  plugin.parseConfig((config2) => {
989
1005
  return config2.apiKeys.map(([apiKey, apiEndpoint]) => {
package/lib/index.mjs CHANGED
@@ -402,6 +402,7 @@ __name(isChatResponse, "isChatResponse");
402
402
 
403
403
  // src/requester.ts
404
404
  import { getMessageContent } from "koishi-plugin-chatluna/utils/string";
405
+ import { trackLogToLocal } from "koishi-plugin-chatluna/utils/logger";
405
406
  var GeminiRequester = class extends ModelRequester {
406
407
  constructor(ctx, _configPool, _pluginConfig, _plugin) {
407
408
  super(ctx, _configPool, _pluginConfig, _plugin);
@@ -445,6 +446,13 @@ var GeminiRequester = class extends ModelRequester {
445
446
  await checkResponse(response);
446
447
  yield* this._processResponseStream(response);
447
448
  } catch (e) {
449
+ if (this.ctx.chatluna.config.isLog) {
450
+ await trackLogToLocal(
451
+ "Request",
452
+ JSON.stringify(chatGenerationParams),
453
+ logger
454
+ );
455
+ }
448
456
  if (e instanceof ChatLunaError) {
449
457
  throw e;
450
458
  } else {
@@ -454,15 +462,16 @@ var GeminiRequester = class extends ModelRequester {
454
462
  }
455
463
  async completionInternal(params) {
456
464
  const modelConfig = prepareModelConfig(params, this._pluginConfig);
465
+ const chatGenerationParams = await createChatGenerationParams(
466
+ params,
467
+ this._plugin,
468
+ modelConfig,
469
+ this._pluginConfig
470
+ );
457
471
  try {
458
472
  const response = await this._post(
459
473
  `models/${modelConfig.model}:generateContent`,
460
- await createChatGenerationParams(
461
- params,
462
- this._plugin,
463
- modelConfig,
464
- this._pluginConfig
465
- ),
474
+ chatGenerationParams,
466
475
  {
467
476
  signal: params.signal
468
477
  }
@@ -470,6 +479,13 @@ var GeminiRequester = class extends ModelRequester {
470
479
  await checkResponse(response);
471
480
  return await this._processResponse(response);
472
481
  } catch (e) {
482
+ if (this.ctx.chatluna.config.isLog) {
483
+ await trackLogToLocal(
484
+ "Request",
485
+ JSON.stringify(chatGenerationParams),
486
+ logger
487
+ );
488
+ }
473
489
  if (e instanceof ChatLunaError) {
474
490
  throw e;
475
491
  } else {
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.12",
4
+ "version": "1.3.0-alpha.13",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -22,13 +22,13 @@
22
22
  "repository": {
23
23
  "type": "git",
24
24
  "url": "https://github.com/ChatLunaLab/chatluna.git",
25
- "directory": "packages/google-gemini-adapter"
25
+ "directory": "packages/adapter-gemini"
26
26
  },
27
27
  "license": "AGPL-3.0",
28
28
  "bugs": {
29
29
  "url": "https://github.com/ChatLunaLab/chatluna/issues"
30
30
  },
31
- "homepage": "https://github.com/ChatLunaLab/chatluna/tree/v1-dev/packages/google-gemini-adapter#readme",
31
+ "homepage": "https://github.com/ChatLunaLab/chatluna/tree/v1-dev/packages/adapter-gemini#readme",
32
32
  "scripts": {
33
33
  "build": "atsc -b"
34
34
  },
@@ -65,15 +65,15 @@
65
65
  "@chatluna/v1-shared-adapter": "^1.0.11",
66
66
  "@langchain/core": "0.3.62",
67
67
  "zod": "3.25.76",
68
- "zod-to-json-schema": "^3.24.5"
68
+ "zod-to-json-schema": "^3.24.6"
69
69
  },
70
70
  "devDependencies": {
71
71
  "atsc": "^2.1.0",
72
- "koishi": "^4.18.7"
72
+ "koishi": "^4.18.9"
73
73
  },
74
74
  "peerDependencies": {
75
- "koishi": "^4.18.7",
76
- "koishi-plugin-chatluna": "^1.3.0-alpha.45",
75
+ "koishi": "^4.18.9",
76
+ "koishi-plugin-chatluna": "^1.3.0-alpha.49",
77
77
  "koishi-plugin-chatluna-storage-service": "^0.0.9"
78
78
  },
79
79
  "peerDependenciesMeta": {