ak-gemini 1.0.9 → 1.0.10

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/index.cjs CHANGED
@@ -134,6 +134,7 @@ var AITransformer = class {
134
134
  this.transformWithValidation = prepareAndValidateMessage.bind(this);
135
135
  this.estimate = estimateTokenUsage.bind(this);
136
136
  this.estimateTokenUsage = estimateTokenUsage.bind(this);
137
+ this.updateSystemInstructions = updateSystemInstructions.bind(this);
137
138
  }
138
139
  };
139
140
  var index_default = AITransformer;
@@ -500,6 +501,15 @@ function getChatHistory() {
500
501
  }
501
502
  return this.chat.getHistory();
502
503
  }
504
+ async function updateSystemInstructions(newInstructions) {
505
+ if (!newInstructions || typeof newInstructions !== "string") {
506
+ throw new Error("System instructions must be a non-empty string");
507
+ }
508
+ this.systemInstructions = newInstructions.trim();
509
+ this.chatConfig.systemInstruction = this.systemInstructions;
510
+ logger_default.debug("Updating system instructions and reinitializing chat...");
511
+ await this.init(true);
512
+ }
503
513
  function attemptJSONRecovery(text, maxAttempts = 100) {
504
514
  if (!text || typeof text !== "string") return null;
505
515
  try {
package/index.js CHANGED
@@ -134,6 +134,7 @@ class AITransformer {
134
134
  this.transformWithValidation = prepareAndValidateMessage.bind(this);
135
135
  this.estimate = estimateTokenUsage.bind(this);
136
136
  this.estimateTokenUsage = estimateTokenUsage.bind(this);
137
+ this.updateSystemInstructions = updateSystemInstructions.bind(this);
137
138
  }
138
139
  }
139
140
 
@@ -714,6 +715,24 @@ function getChatHistory() {
714
715
  return this.chat.getHistory();
715
716
  }
716
717
 
718
+ /**
719
+ * Updates system instructions and reinitializes the chat session
720
+ * @this {ExportedAPI}
721
+ * @param {string} newInstructions - The new system instructions
722
+ * @returns {Promise<void>}
723
+ */
724
+ async function updateSystemInstructions(newInstructions) {
725
+ if (!newInstructions || typeof newInstructions !== 'string') {
726
+ throw new Error('System instructions must be a non-empty string');
727
+ }
728
+
729
+ this.systemInstructions = newInstructions.trim();
730
+ this.chatConfig.systemInstruction = this.systemInstructions;
731
+
732
+ log.debug('Updating system instructions and reinitializing chat...');
733
+ await this.init(true); // Force reinitialize with new instructions
734
+ }
735
+
717
736
 
718
737
  /*
719
738
  ----
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... transforms",
5
- "version": "1.0.9",
5
+ "version": "1.0.10",
6
6
  "main": "index.js",
7
7
  "files": [
8
8
  "index.js",
package/types.d.ts CHANGED
@@ -139,8 +139,8 @@ export declare class AITransformer {
139
139
  getHistory(): Array<any>;
140
140
  estimateTokenUsage(nextPayload: Record<string, unknown> | string): Promise<{ totalTokens: number; breakdown?: any }>;
141
141
  estimate(nextPayload: Record<string, unknown> | string): Promise<{ totalTokens: number; breakdown?: any }>;
142
+ updateSystemInstructions(newInstructions: string): Promise<void>;
142
143
  }
143
144
 
144
145
  // Default export
145
- declare const _default: typeof AITransformer;
146
- export default _default;
146
+ export default AITransformer;