@paean-ai/adk 0.2.23 → 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.
- package/dist/cjs/agents/functions.js +12 -1
- package/dist/cjs/agents/llm_agent.js +32 -5
- package/dist/cjs/events/event.js +2 -1
- package/dist/cjs/index.js +11 -11
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/models/google_llm.js +36 -8
- package/dist/esm/agents/functions.js +12 -1
- package/dist/esm/agents/llm_agent.js +32 -5
- package/dist/esm/events/event.js +2 -1
- package/dist/esm/index.js +11 -11
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/models/google_llm.js +36 -8
- package/dist/web/agents/functions.js +12 -1
- package/dist/web/agents/llm_agent.js +32 -5
- package/dist/web/events/event.js +2 -1
- package/dist/web/index.js +1 -1
- package/dist/web/index.js.map +3 -3
- package/dist/web/models/google_llm.js +39 -11
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
).
|
|
266
|
-
|
|
267
|
-
|
|
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 (
|
|
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: (
|
|
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 && ((
|
|
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) {
|