@adminforth/completion-adapter-google-gemini 2.0.3 → 2.0.5

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.
Files changed (3) hide show
  1. package/dist/index.js +13 -0
  2. package/index.ts +14 -0
  3. package/package.json +3 -4
package/dist/index.js CHANGED
@@ -49,4 +49,17 @@ export default class CompletionAdapterGoogleGemini {
49
49
  throw new Error("geminiApiKey is required");
50
50
  }
51
51
  }
52
+ measureTokensCount(content) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ // Implement token counting logic here
55
+ const ai = new GoogleGenAI({
56
+ apiKey: this.options.geminiApiKey,
57
+ });
58
+ const countTokensResponse = yield ai.models.countTokens({
59
+ model: "gemini-2.0-flash",
60
+ contents: content,
61
+ });
62
+ return countTokensResponse.totalTokens;
63
+ });
64
+ }
52
65
  }
package/index.ts CHANGED
@@ -19,6 +19,20 @@ export default class CompletionAdapterGoogleGemini
19
19
  }
20
20
  }
21
21
 
22
+ async measureTokensCount(content: string): Promise<number> {
23
+ // Implement token counting logic here
24
+ const ai = new GoogleGenAI({
25
+ apiKey: this.options.geminiApiKey,
26
+ });
27
+ const countTokensResponse = await ai.models.countTokens({
28
+ model: "gemini-2.0-flash",
29
+ contents: content,
30
+ });
31
+
32
+ return countTokensResponse.totalTokens;
33
+ }
34
+
35
+
22
36
  complete = async (content: string, stop = ["."], maxTokens = 50, outputSchema?: any): Promise<{
23
37
  content?: string;
24
38
  finishReason?: string;
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@adminforth/completion-adapter-google-gemini",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "tsc && npm version patch",
9
- "rollout": "npm run build && npm publish --access public",
10
- "prepare": "npm link adminforth"
9
+ "rollout": "npm run build && npm publish --access public"
11
10
  },
12
11
  "keywords": [],
13
12
  "author": "",
@@ -18,7 +17,7 @@
18
17
  "p-retry": "^7.1.1"
19
18
  },
20
19
  "peerDependencies": {
21
- "adminforth": "next"
20
+ "adminforth": "^2.24.0"
22
21
  },
23
22
  "devDependencies": {
24
23
  "typescript": "^5.9.3"