ak-gemini 2.0.5 → 2.0.7

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/base.js CHANGED
@@ -98,6 +98,9 @@ class BaseGemini {
98
98
  this.resourceExhaustedRetries = options.resourceExhaustedRetries ?? 5;
99
99
  this.resourceExhaustedDelay = options.resourceExhaustedDelay ?? 1000;
100
100
 
101
+ // ── Health Check ──
102
+ this.healthCheck = options.healthCheck ?? false;
103
+
101
104
  // ── Logging ──
102
105
  this._configureLogLevel(options.logLevel);
103
106
 
@@ -192,11 +195,13 @@ class BaseGemini {
192
195
  const chatOptions = this._getChatCreateOptions();
193
196
  this.chatSession = this.genAIClient.chats.create(chatOptions);
194
197
 
195
- try {
196
- await this.genAIClient.models.list();
197
- log.debug(`${this.constructor.name}: API connection successful.`);
198
- } catch (e) {
199
- throw new Error(`${this.constructor.name} initialization failed: ${e.message}`);
198
+ if (this.healthCheck) {
199
+ try {
200
+ await this._withRetry(() => this.genAIClient.models.list());
201
+ log.debug(`${this.constructor.name}: API connection successful.`);
202
+ } catch (e) {
203
+ throw new Error(`${this.constructor.name} initialization failed: ${e.message}`);
204
+ }
200
205
  }
201
206
 
202
207
  log.debug(`${this.constructor.name}: Chat session initialized.`);
package/index.cjs CHANGED
@@ -363,6 +363,7 @@ var BaseGemini = class {
363
363
  }
364
364
  this.resourceExhaustedRetries = options.resourceExhaustedRetries ?? 5;
365
365
  this.resourceExhaustedDelay = options.resourceExhaustedDelay ?? 1e3;
366
+ this.healthCheck = options.healthCheck ?? false;
366
367
  this._configureLogLevel(options.logLevel);
367
368
  this.labels = options.labels || {};
368
369
  this.enableGrounding = options.enableGrounding || false;
@@ -425,11 +426,13 @@ var BaseGemini = class {
425
426
  logger_default.debug(`Initializing ${this.constructor.name} chat session with model: ${this.modelName}...`);
426
427
  const chatOptions = this._getChatCreateOptions();
427
428
  this.chatSession = this.genAIClient.chats.create(chatOptions);
428
- try {
429
- await this.genAIClient.models.list();
430
- logger_default.debug(`${this.constructor.name}: API connection successful.`);
431
- } catch (e) {
432
- throw new Error(`${this.constructor.name} initialization failed: ${e.message}`);
429
+ if (this.healthCheck) {
430
+ try {
431
+ await this._withRetry(() => this.genAIClient.models.list());
432
+ logger_default.debug(`${this.constructor.name}: API connection successful.`);
433
+ } catch (e) {
434
+ throw new Error(`${this.constructor.name} initialization failed: ${e.message}`);
435
+ }
433
436
  }
434
437
  logger_default.debug(`${this.constructor.name}: Chat session initialized.`);
435
438
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ak-gemini",
3
3
  "author": "ak@mixpanel.com",
4
4
  "description": "AK's Generative AI Helper for doing... everything",
5
- "version": "2.0.5",
5
+ "version": "2.0.7",
6
6
  "main": "index.js",
7
7
  "files": [
8
8
  "index.js",
package/types.d.ts CHANGED
@@ -174,6 +174,9 @@ export interface BaseGeminiOptions {
174
174
  resourceExhaustedRetries?: number;
175
175
  /** Initial backoff delay in ms for 429 retries, doubles each attempt (default: 1000) */
176
176
  resourceExhaustedDelay?: number;
177
+
178
+ /** Run models.list() health check during init() (default: false) */
179
+ healthCheck?: boolean;
177
180
  }
178
181
 
179
182
  export interface TransformerOptions extends BaseGeminiOptions {