@aigne/gemini 0.14.2 → 0.14.3-beta

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,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.14.3-beta](https://github.com/AIGNE-io/aigne-framework/compare/gemini-v0.14.2...gemini-v0.14.3-beta) (2025-10-21)
4
+
5
+
6
+ ### Features
7
+
8
+ * add thinking support to Gemini chat models ([#650](https://github.com/AIGNE-io/aigne-framework/issues/650)) ([09b828b](https://github.com/AIGNE-io/aigne-framework/commit/09b828ba668d90cc6aac68a5e8190adb146b5e45))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **gemini:** handle empty responses when files are present ([#648](https://github.com/AIGNE-io/aigne-framework/issues/648)) ([f4e259c](https://github.com/AIGNE-io/aigne-framework/commit/f4e259c5e5c687c347bb5cf29cbb0b5bf4d0d4a1))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @aigne/core bumped to 1.64.0-beta
21
+ * devDependencies
22
+ * @aigne/test-utils bumped to 0.5.56-beta
23
+
3
24
  ## [0.14.2](https://github.com/AIGNE-io/aigne-framework/compare/gemini-v0.14.2-beta.12...gemini-v0.14.2) (2025-10-19)
4
25
 
5
26
 
@@ -37,6 +37,7 @@ export declare class GeminiChatModel extends ChatModel {
37
37
  get modelOptions(): Omit<import("@aigne/core").ChatModelInputOptions, "model"> | undefined;
38
38
  process(input: ChatModelInput): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
39
39
  private processInput;
40
+ protected supportThinkingModels: string[];
40
41
  private buildConfig;
41
42
  private buildTools;
42
43
  private buildContents;
@@ -68,6 +68,9 @@ class GeminiChatModel extends core_1.ChatModel {
68
68
  model,
69
69
  contents,
70
70
  config: {
71
+ thinkingConfig: this.supportThinkingModels.includes(model)
72
+ ? { includeThoughts: true }
73
+ : undefined,
71
74
  responseModalities: input.modelOptions?.modalities,
72
75
  temperature: input.modelOptions?.temperature || this.modelOptions?.temperature,
73
76
  topP: input.modelOptions?.topP || this.modelOptions?.topP,
@@ -96,9 +99,14 @@ class GeminiChatModel extends core_1.ChatModel {
96
99
  if (content?.parts) {
97
100
  for (const part of content.parts) {
98
101
  if (part.text) {
99
- text += part.text;
100
- if (input.responseFormat?.type !== "json_schema") {
101
- yield { delta: { text: { text: part.text } } };
102
+ if (part.thought) {
103
+ yield { delta: { text: { thoughts: part.text } } };
104
+ }
105
+ else {
106
+ text += part.text;
107
+ if (input.responseFormat?.type !== "json_schema") {
108
+ yield { delta: { text: { text: part.text } } };
109
+ }
102
110
  }
103
111
  }
104
112
  if (part.inlineData?.data) {
@@ -149,7 +157,7 @@ class GeminiChatModel extends core_1.ChatModel {
149
157
  else if (!toolCalls.length) {
150
158
  // NOTE: gemini-2.5-pro sometimes returns an empty response,
151
159
  // so we check here and retry with structured output mode (empty responses occur less frequently with tool calls)
152
- if (!text) {
160
+ if (!text && !files.length) {
153
161
  logger_js_1.logger.warn("Empty response from Gemini, retrying with structured output mode");
154
162
  try {
155
163
  const outputSchema = zod_1.z.object({
@@ -193,6 +201,7 @@ class GeminiChatModel extends core_1.ChatModel {
193
201
  }
194
202
  yield { delta: { json: { usage, files: files.length ? files : undefined } } };
195
203
  }
204
+ supportThinkingModels = ["gemini-2.5-pro", "gemini-2.5-flash"];
196
205
  async buildConfig(input) {
197
206
  const config = {};
198
207
  const { tools, toolConfig } = await this.buildTools(input);
@@ -37,6 +37,7 @@ export declare class GeminiChatModel extends ChatModel {
37
37
  get modelOptions(): Omit<import("@aigne/core").ChatModelInputOptions, "model"> | undefined;
38
38
  process(input: ChatModelInput): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
39
39
  private processInput;
40
+ protected supportThinkingModels: string[];
40
41
  private buildConfig;
41
42
  private buildTools;
42
43
  private buildContents;
@@ -37,6 +37,7 @@ export declare class GeminiChatModel extends ChatModel {
37
37
  get modelOptions(): Omit<import("@aigne/core").ChatModelInputOptions, "model"> | undefined;
38
38
  process(input: ChatModelInput): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
39
39
  private processInput;
40
+ protected supportThinkingModels: string[];
40
41
  private buildConfig;
41
42
  private buildTools;
42
43
  private buildContents;
@@ -65,6 +65,9 @@ export class GeminiChatModel extends ChatModel {
65
65
  model,
66
66
  contents,
67
67
  config: {
68
+ thinkingConfig: this.supportThinkingModels.includes(model)
69
+ ? { includeThoughts: true }
70
+ : undefined,
68
71
  responseModalities: input.modelOptions?.modalities,
69
72
  temperature: input.modelOptions?.temperature || this.modelOptions?.temperature,
70
73
  topP: input.modelOptions?.topP || this.modelOptions?.topP,
@@ -93,9 +96,14 @@ export class GeminiChatModel extends ChatModel {
93
96
  if (content?.parts) {
94
97
  for (const part of content.parts) {
95
98
  if (part.text) {
96
- text += part.text;
97
- if (input.responseFormat?.type !== "json_schema") {
98
- yield { delta: { text: { text: part.text } } };
99
+ if (part.thought) {
100
+ yield { delta: { text: { thoughts: part.text } } };
101
+ }
102
+ else {
103
+ text += part.text;
104
+ if (input.responseFormat?.type !== "json_schema") {
105
+ yield { delta: { text: { text: part.text } } };
106
+ }
99
107
  }
100
108
  }
101
109
  if (part.inlineData?.data) {
@@ -146,7 +154,7 @@ export class GeminiChatModel extends ChatModel {
146
154
  else if (!toolCalls.length) {
147
155
  // NOTE: gemini-2.5-pro sometimes returns an empty response,
148
156
  // so we check here and retry with structured output mode (empty responses occur less frequently with tool calls)
149
- if (!text) {
157
+ if (!text && !files.length) {
150
158
  logger.warn("Empty response from Gemini, retrying with structured output mode");
151
159
  try {
152
160
  const outputSchema = z.object({
@@ -190,6 +198,7 @@ export class GeminiChatModel extends ChatModel {
190
198
  }
191
199
  yield { delta: { json: { usage, files: files.length ? files : undefined } } };
192
200
  }
201
+ supportThinkingModels = ["gemini-2.5-pro", "gemini-2.5-flash"];
193
202
  async buildConfig(input) {
194
203
  const config = {};
195
204
  const { tools, toolConfig } = await this.buildTools(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/gemini",
3
- "version": "0.14.2",
3
+ "version": "0.14.3-beta",
4
4
  "description": "AIGNE Gemini SDK for integrating with Google's Gemini AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -39,7 +39,7 @@
39
39
  "@google/genai": "^1.24.0",
40
40
  "zod": "^3.25.67",
41
41
  "zod-to-json-schema": "^3.24.6",
42
- "@aigne/core": "^1.63.0",
42
+ "@aigne/core": "^1.64.0-beta",
43
43
  "@aigne/platform-helpers": "^0.6.3"
44
44
  },
45
45
  "devDependencies": {
@@ -48,7 +48,7 @@
48
48
  "npm-run-all": "^4.1.5",
49
49
  "rimraf": "^6.0.1",
50
50
  "typescript": "^5.9.2",
51
- "@aigne/test-utils": "^0.5.55"
51
+ "@aigne/test-utils": "^0.5.56-beta"
52
52
  },
53
53
  "scripts": {
54
54
  "lint": "tsc --noEmit",