ak-gemini 1.0.57 → 1.0.58
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/package.json +8 -5
- package/types.d.ts +10 -5
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.
|
|
5
|
+
"version": "1.0.58",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"index.js",
|
|
@@ -32,14 +32,16 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/ak--47/ak-gemini#readme",
|
|
34
34
|
"scripts": {
|
|
35
|
-
"prepublishOnly": "npm run build:cjs",
|
|
35
|
+
"prepublishOnly": "npm run typecheck && npm run build:cjs",
|
|
36
36
|
"post": "npm publish --access public",
|
|
37
37
|
"release": "npm version patch && npm publish --access public",
|
|
38
38
|
"update-deps": "npx npm-check-updates -u && npm install",
|
|
39
39
|
"prune": "rm -rf tmp/*",
|
|
40
40
|
"test": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
41
41
|
"test:unit": "npm test -- tests/module.test.js",
|
|
42
|
-
"build:cjs": "esbuild index.js --bundle --platform=node --format=cjs --outfile=index.cjs --external:@google/genai --external:ak-tools --external:dotenv --external:pino-pretty --external:pino"
|
|
42
|
+
"build:cjs": "esbuild index.js --bundle --platform=node --format=cjs --outfile=index.cjs --external:@google/genai --external:ak-tools --external:dotenv --external:pino-pretty --external:pino",
|
|
43
|
+
"coverage": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
|
|
44
|
+
"typecheck": "tsc --noEmit"
|
|
43
45
|
},
|
|
44
46
|
"type": "module",
|
|
45
47
|
"keywords": [
|
|
@@ -59,6 +61,7 @@
|
|
|
59
61
|
"@types/jest": "^29.5.14",
|
|
60
62
|
"esbuild": "^0.25.5",
|
|
61
63
|
"jest": "^29.7.0",
|
|
62
|
-
"nodemon": "^3.1.10"
|
|
64
|
+
"nodemon": "^3.1.10",
|
|
65
|
+
"typescript": "^5.9.2"
|
|
63
66
|
}
|
|
64
|
-
}
|
|
67
|
+
}
|
package/types.d.ts
CHANGED
|
@@ -31,20 +31,25 @@ export interface AITransformerContext {
|
|
|
31
31
|
systemInstructionsKey?: string;
|
|
32
32
|
maxRetries?: number;
|
|
33
33
|
retryDelay?: number;
|
|
34
|
-
init?: () => Promise<void>; // Initialization function
|
|
34
|
+
init?: (force?: boolean) => Promise<void>; // Initialization function
|
|
35
35
|
seed?: () => Promise<void>; // Function to seed the transformer with examples
|
|
36
36
|
message?: (payload: Record<string, unknown>) => Promise<Record<string, unknown>>; // Function to send messages to the model
|
|
37
|
-
rebuild?: () => Promise<Record<string, unknown
|
|
38
|
-
rawMessage?: (payload: Record<string, unknown>) => Promise<Record<string, unknown>>; // Function to send raw messages to the model
|
|
37
|
+
rebuild?: (lastPayload: Record<string, unknown>, serverError: string) => Promise<Record<string, unknown>>; // Function to rebuild the transformer
|
|
38
|
+
rawMessage?: (payload: Record<string, unknown> | string) => Promise<Record<string, unknown>>; // Function to send raw messages to the model
|
|
39
39
|
genAIClient?: GoogleGenAI; // Google GenAI client instance
|
|
40
40
|
onlyJSON?: boolean; // If true, only JSON responses are allowed
|
|
41
41
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface TransformationExample {
|
|
45
|
-
CONTEXT?: Record<string, unknown
|
|
45
|
+
CONTEXT?: Record<string, unknown> | string; // optional context for the transformation
|
|
46
46
|
PROMPT?: Record<string, unknown>; // what the user provides as input
|
|
47
47
|
ANSWER?: Record<string, unknown>; // what the model should return as output
|
|
48
|
+
INPUT?: Record<string, unknown>; // alias for PROMPT
|
|
49
|
+
OUTPUT?: Record<string, unknown>; // alias for ANSWER
|
|
50
|
+
SYSTEM?: string; // system instructions for this example
|
|
51
|
+
EXPLANATION?: string; // explanation for this example
|
|
52
|
+
[key: string]: any; // allow additional properties for flexible key mapping
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
export interface ExampleFileContent {
|
|
@@ -103,7 +108,7 @@ export declare class AITransformer {
|
|
|
103
108
|
init(force?: boolean): Promise<void>;
|
|
104
109
|
seed(examples?: TransformationExample[]): Promise<any>;
|
|
105
110
|
message(payload: Record<string, unknown>, opts?: object, validatorFn?: AsyncValidatorFunction | null): Promise<Record<string, unknown>>;
|
|
106
|
-
rawMessage(sourcePayload: Record<string, unknown> | string): Promise<Record<string, unknown
|
|
111
|
+
rawMessage(sourcePayload: Record<string, unknown> | string): Promise<Record<string, unknown> | any>;
|
|
107
112
|
transformWithValidation(sourcePayload: Record<string, unknown>, validatorFn: AsyncValidatorFunction, options?: object): Promise<Record<string, unknown>>;
|
|
108
113
|
messageAndValidate(sourcePayload: Record<string, unknown>, validatorFn: AsyncValidatorFunction, options?: object): Promise<Record<string, unknown>>;
|
|
109
114
|
rebuild(lastPayload: Record<string, unknown>, serverError: string): Promise<Record<string, unknown>>;
|