@paean-ai/adk 0.2.24 → 0.2.25

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.
@@ -140,7 +140,7 @@ class Gemini extends BaseLlm {
140
140
  */
141
141
  generateContentAsync(llmRequest, stream = false) {
142
142
  return __asyncGenerator(this, null, function* () {
143
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
143
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
144
144
  this.preprocessRequest(llmRequest);
145
145
  this.maybeAppendUserContent(llmRequest);
146
146
  logger.info(
@@ -160,6 +160,7 @@ class Gemini extends BaseLlm {
160
160
  let text = "";
161
161
  let usageMetadata;
162
162
  let lastResponse;
163
+ let pendingFCResponse = null;
163
164
  try {
164
165
  for (var iter = __forAwait(streamResult), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
165
166
  const response = temp.value;
@@ -190,7 +191,9 @@ class Gemini extends BaseLlm {
190
191
  } else {
191
192
  text += firstPart.text;
192
193
  }
193
- llmResponse.partial = true;
194
+ if (!hasFunctionCalls) {
195
+ llmResponse.partial = true;
196
+ }
194
197
  if (this.isGemini3Preview && hasFunctionCalls) {
195
198
  thoughtText = "";
196
199
  thoughtSignature = void 0;
@@ -260,14 +263,25 @@ class Gemini extends BaseLlm {
260
263
  }
261
264
  }
262
265
  }
263
- const partsWithSig = llmResponse.content.parts.filter(
264
- (p) => p.thoughtSignature
265
- ).length;
266
- if (partsWithSig === 0) {
267
- logger.warn(
268
- "[Gemini3] No thoughtSignature on function call parts \u2014 may cause 400 on next request"
266
+ }
267
+ if (hasFunctionCalls) {
268
+ if (pendingFCResponse && ((_i = pendingFCResponse.content) == null ? void 0 : _i.parts)) {
269
+ const newFCParts = (((_j = llmResponse.content) == null ? void 0 : _j.parts) || []).filter(
270
+ (p) => p.functionCall
269
271
  );
272
+ pendingFCResponse.content.parts.push(...newFCParts);
273
+ pendingFCResponse.usageMetadata = llmResponse.usageMetadata;
274
+ } else {
275
+ pendingFCResponse = llmResponse;
270
276
  }
277
+ continue;
278
+ }
279
+ if (pendingFCResponse) {
280
+ if (!((_l = (_k = llmResponse.content) == null ? void 0 : _k.parts) == null ? void 0 : _l.length)) {
281
+ continue;
282
+ }
283
+ yield pendingFCResponse;
284
+ pendingFCResponse = null;
271
285
  }
272
286
  yield llmResponse;
273
287
  }
@@ -281,7 +295,21 @@ class Gemini extends BaseLlm {
281
295
  throw error[0];
282
296
  }
283
297
  }
284
- if ((text || thoughtText) && ((_j = (_i = lastResponse == null ? void 0 : lastResponse.candidates) == null ? void 0 : _i[0]) == null ? void 0 : _j.finishReason) === FinishReason.STOP) {
298
+ if (pendingFCResponse) {
299
+ if (this.isGemini3Preview && ((_m = pendingFCResponse.content) == null ? void 0 : _m.parts)) {
300
+ const partsWithSig = pendingFCResponse.content.parts.filter(
301
+ (p) => p.thoughtSignature
302
+ ).length;
303
+ if (partsWithSig === 0) {
304
+ logger.warn(
305
+ "[Gemini3] No thoughtSignature on merged function call parts \u2014 may cause 400 on next request"
306
+ );
307
+ }
308
+ }
309
+ yield pendingFCResponse;
310
+ pendingFCResponse = null;
311
+ }
312
+ if ((text || thoughtText) && ((_o = (_n = lastResponse == null ? void 0 : lastResponse.candidates) == null ? void 0 : _n[0]) == null ? void 0 : _o.finishReason) === FinishReason.STOP) {
285
313
  const parts = [];
286
314
  if (thoughtText) {
287
315
  const thoughtPart = { text: thoughtText, thought: true };
@@ -303,12 +331,12 @@ class Gemini extends BaseLlm {
303
331
  }
304
332
  } else {
305
333
  const response = yield new __await(this.apiClient.models.generateContent({
306
- model: (_k = llmRequest.model) != null ? _k : this.model,
334
+ model: (_p = llmRequest.model) != null ? _p : this.model,
307
335
  contents: llmRequest.contents,
308
336
  config: llmRequest.config
309
337
  }));
310
338
  const llmResponse = createLlmResponse(response);
311
- if (this.isGemini3Preview && ((_l = llmResponse.content) == null ? void 0 : _l.parts)) {
339
+ if (this.isGemini3Preview && ((_q = llmResponse.content) == null ? void 0 : _q.parts)) {
312
340
  let thoughtSig;
313
341
  let hasThoughtPartWithSignature = false;
314
342
  for (const part of llmResponse.content.parts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paean-ai/adk",
3
- "version": "0.2.24",
3
+ "version": "0.2.25",
4
4
  "description": "Google ADK JS (paean-ai fork with streaming fixes)",
5
5
  "author": "paean-ai",
6
6
  "license": "Apache-2.0",