@aigne/gemini 0.12.0 → 0.12.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.12.2](https://github.com/AIGNE-io/aigne-framework/compare/gemini-v0.12.1...gemini-v0.12.2) (2025-09-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **model:** transform local file to base64 before request llm ([#462](https://github.com/AIGNE-io/aigne-framework/issues/462)) ([58ef5d7](https://github.com/AIGNE-io/aigne-framework/commit/58ef5d77046c49f3c4eed15b7f0cc283cbbcd74a))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/openai bumped to 0.14.2
16
+ * devDependencies
17
+ * @aigne/core bumped to 1.58.2
18
+ * @aigne/test-utils bumped to 0.5.46
19
+
20
+ ## [0.12.1](https://github.com/AIGNE-io/aigne-framework/compare/gemini-v0.12.0...gemini-v0.12.1) (2025-09-05)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * should not return local path from aigne hub service ([#460](https://github.com/AIGNE-io/aigne-framework/issues/460)) ([c959717](https://github.com/AIGNE-io/aigne-framework/commit/c95971774f7e84dbeb3313f60b3e6464e2bb22e4))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @aigne/openai bumped to 0.14.1
33
+ * devDependencies
34
+ * @aigne/core bumped to 1.58.1
35
+ * @aigne/test-utils bumped to 0.5.45
36
+
3
37
  ## [0.12.0](https://github.com/AIGNE-io/aigne-framework/compare/gemini-v0.11.6...gemini-v0.12.0) (2025-09-05)
4
38
 
5
39
 
@@ -4,7 +4,6 @@ exports.GeminiChatModel = void 0;
4
4
  const core_1 = require("@aigne/core");
5
5
  const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
6
6
  const openai_1 = require("@aigne/openai");
7
- const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
8
7
  const genai_1 = require("@google/genai");
9
8
  const uuid_1 = require("uuid");
10
9
  const GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai";
@@ -49,9 +48,9 @@ class GeminiChatModel extends openai_1.OpenAIChatModel {
49
48
  const model = input.modelOptions?.model || this.credential.model;
50
49
  if (!model.includes("image"))
51
50
  return super.process(input, options);
52
- return this.handleImageModelProcessing(input, options);
51
+ return this.handleImageModelProcessing(input);
53
52
  }
54
- async *handleImageModelProcessing(input, options) {
53
+ async *handleImageModelProcessing(input) {
55
54
  const model = input.modelOptions?.model || this.credential.model;
56
55
  const { contents, config } = await this.buildContents(input);
57
56
  const parameters = {
@@ -92,13 +91,12 @@ class GeminiChatModel extends openai_1.OpenAIChatModel {
92
91
  }
93
92
  }
94
93
  if (part.inlineData?.data) {
95
- files.push(await this.transformFileOutput(input, {
94
+ files.push({
96
95
  type: "file",
97
96
  data: part.inlineData.data,
98
97
  filename: part.inlineData.displayName,
99
98
  mimeType: part.inlineData.mimeType,
100
- }, options));
101
- yield { delta: { json: { files } } };
99
+ });
102
100
  }
103
101
  if (part.functionCall?.name) {
104
102
  toolCalls.push({
@@ -117,12 +115,12 @@ class GeminiChatModel extends openai_1.OpenAIChatModel {
117
115
  if (chunk.usageMetadata) {
118
116
  usage.inputTokens += chunk.usageMetadata.promptTokenCount || 0;
119
117
  usage.outputTokens += chunk.usageMetadata.candidatesTokenCount || 0;
120
- yield { delta: { json: { usage } } };
121
118
  }
122
119
  }
123
120
  if (input.responseFormat?.type === "json_schema") {
124
121
  yield { delta: { json: { json: (0, core_1.safeParseJSON)(text) } } };
125
122
  }
123
+ yield { delta: { json: { usage, files } } };
126
124
  }
127
125
  async buildConfig(input) {
128
126
  const config = {};
@@ -219,12 +217,7 @@ class GeminiChatModel extends openai_1.OpenAIChatModel {
219
217
  case "file":
220
218
  return { inlineData: { data: item.data, mimeType: item.mimeType } };
221
219
  case "local":
222
- return {
223
- inlineData: {
224
- data: await index_js_1.nodejs.fs.readFile(item.path, "base64"),
225
- mimeType: item.mimeType,
226
- },
227
- };
220
+ throw new Error(`Unsupported local file: ${item.path}, it should be converted to base64 at ChatModel`);
228
221
  }
229
222
  }));
230
223
  }
@@ -1,7 +1,6 @@
1
1
  import { safeParseJSON, } from "@aigne/core";
2
2
  import { isNonNullable } from "@aigne/core/utils/type-utils.js";
3
3
  import { OpenAIChatModel } from "@aigne/openai";
4
- import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
5
4
  import { FunctionCallingConfigMode, GoogleGenAI, } from "@google/genai";
6
5
  import { v7 } from "uuid";
7
6
  const GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai";
@@ -46,9 +45,9 @@ export class GeminiChatModel extends OpenAIChatModel {
46
45
  const model = input.modelOptions?.model || this.credential.model;
47
46
  if (!model.includes("image"))
48
47
  return super.process(input, options);
49
- return this.handleImageModelProcessing(input, options);
48
+ return this.handleImageModelProcessing(input);
50
49
  }
51
- async *handleImageModelProcessing(input, options) {
50
+ async *handleImageModelProcessing(input) {
52
51
  const model = input.modelOptions?.model || this.credential.model;
53
52
  const { contents, config } = await this.buildContents(input);
54
53
  const parameters = {
@@ -89,13 +88,12 @@ export class GeminiChatModel extends OpenAIChatModel {
89
88
  }
90
89
  }
91
90
  if (part.inlineData?.data) {
92
- files.push(await this.transformFileOutput(input, {
91
+ files.push({
93
92
  type: "file",
94
93
  data: part.inlineData.data,
95
94
  filename: part.inlineData.displayName,
96
95
  mimeType: part.inlineData.mimeType,
97
- }, options));
98
- yield { delta: { json: { files } } };
96
+ });
99
97
  }
100
98
  if (part.functionCall?.name) {
101
99
  toolCalls.push({
@@ -114,12 +112,12 @@ export class GeminiChatModel extends OpenAIChatModel {
114
112
  if (chunk.usageMetadata) {
115
113
  usage.inputTokens += chunk.usageMetadata.promptTokenCount || 0;
116
114
  usage.outputTokens += chunk.usageMetadata.candidatesTokenCount || 0;
117
- yield { delta: { json: { usage } } };
118
115
  }
119
116
  }
120
117
  if (input.responseFormat?.type === "json_schema") {
121
118
  yield { delta: { json: { json: safeParseJSON(text) } } };
122
119
  }
120
+ yield { delta: { json: { usage, files } } };
123
121
  }
124
122
  async buildConfig(input) {
125
123
  const config = {};
@@ -216,12 +214,7 @@ export class GeminiChatModel extends OpenAIChatModel {
216
214
  case "file":
217
215
  return { inlineData: { data: item.data, mimeType: item.mimeType } };
218
216
  case "local":
219
- return {
220
- inlineData: {
221
- data: await nodejs.fs.readFile(item.path, "base64"),
222
- mimeType: item.mimeType,
223
- },
224
- };
217
+ throw new Error(`Unsupported local file: ${item.path}, it should be converted to base64 at ChatModel`);
225
218
  }
226
219
  }));
227
220
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/gemini",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "AIGNE Gemini SDK for integrating with Google's Gemini AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -38,8 +38,8 @@
38
38
  "@google/genai": "^1.15.0",
39
39
  "uuid": "^11.1.0",
40
40
  "zod": "^3.25.67",
41
- "@aigne/platform-helpers": "^0.6.2",
42
- "@aigne/openai": "^0.14.0"
41
+ "@aigne/openai": "^0.14.2",
42
+ "@aigne/platform-helpers": "^0.6.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/bun": "^1.2.18",
@@ -47,8 +47,8 @@
47
47
  "npm-run-all": "^4.1.5",
48
48
  "rimraf": "^6.0.1",
49
49
  "typescript": "^5.8.3",
50
- "@aigne/core": "^1.58.0",
51
- "@aigne/test-utils": "^0.5.44"
50
+ "@aigne/core": "^1.58.2",
51
+ "@aigne/test-utils": "^0.5.46"
52
52
  },
53
53
  "scripts": {
54
54
  "lint": "tsc --noEmit",