@paean-ai/adk 0.2.25 → 0.2.26
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 +1 -0
- package/dist/cjs/agents/llm_agent.js +1 -0
- package/dist/cjs/events/event.js +1 -2
- package/dist/cjs/index.js +12 -12
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/models/google_llm.js +23 -5
- package/dist/cjs/models/llm_response.js +7 -0
- package/dist/esm/agents/functions.js +1 -0
- package/dist/esm/agents/llm_agent.js +1 -0
- package/dist/esm/events/event.js +1 -2
- package/dist/esm/index.js +12 -12
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/models/google_llm.js +23 -5
- package/dist/esm/models/llm_response.js +7 -0
- package/dist/types/models/google_llm.d.ts +4 -0
- package/dist/web/agents/functions.js +1 -0
- package/dist/web/agents/llm_agent.js +1 -0
- package/dist/web/events/event.js +1 -2
- package/dist/web/index.js +1 -1
- package/dist/web/index.js.map +3 -3
- package/dist/web/models/google_llm.js +23 -5
- package/dist/web/models/llm_response.js +7 -0
- package/package.json +1 -1
|
@@ -73,11 +73,13 @@ class Gemini extends BaseLlm {
|
|
|
73
73
|
this.headers = headers;
|
|
74
74
|
this.isGemini3Preview = isGemini3PreviewModel(model);
|
|
75
75
|
const canReadEnv = typeof process === "object";
|
|
76
|
+
const aiStudioApiKey = canReadEnv ? process.env["AI_STUDIO_API_KEY"] : void 0;
|
|
77
|
+
const useAiStudioMode = !!aiStudioApiKey;
|
|
76
78
|
this.apiEndpoint = apiEndpoint;
|
|
77
79
|
if (!this.apiEndpoint && canReadEnv) {
|
|
78
80
|
this.apiEndpoint = process.env["GEMINI_API_ENDPOINT"];
|
|
79
81
|
}
|
|
80
|
-
if (!this.apiEndpoint && this.isGemini3Preview) {
|
|
82
|
+
if (!this.apiEndpoint && this.isGemini3Preview && !useAiStudioMode) {
|
|
81
83
|
this.apiEndpoint = GEMINI3_PREVIEW_API_ENDPOINT;
|
|
82
84
|
logger.info("Using Gemini 3 preview endpoint: ".concat(this.apiEndpoint));
|
|
83
85
|
}
|
|
@@ -88,6 +90,15 @@ class Gemini extends BaseLlm {
|
|
|
88
90
|
useVertexAI = vertexAIfromEnv.toLowerCase() === "true" || vertexAIfromEnv === "1";
|
|
89
91
|
}
|
|
90
92
|
}
|
|
93
|
+
if (useAiStudioMode) {
|
|
94
|
+
if (useVertexAI) {
|
|
95
|
+
logger.info(
|
|
96
|
+
"AI_STUDIO_API_KEY set \u2014 overriding Vertex AI mode to use AI Studio (generativelanguage.googleapis.com)"
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
useVertexAI = false;
|
|
100
|
+
this.apiKey = aiStudioApiKey;
|
|
101
|
+
}
|
|
91
102
|
if (this.isGemini3Preview && useVertexAI) {
|
|
92
103
|
const availableApiKey = apiKey || (canReadEnv ? process.env["GOOGLE_GENAI_API_KEY"] || process.env["GEMINI_API_KEY"] : void 0);
|
|
93
104
|
if (availableApiKey) {
|
|
@@ -266,10 +277,10 @@ class Gemini extends BaseLlm {
|
|
|
266
277
|
}
|
|
267
278
|
if (hasFunctionCalls) {
|
|
268
279
|
if (pendingFCResponse && ((_i = pendingFCResponse.content) == null ? void 0 : _i.parts)) {
|
|
269
|
-
const
|
|
270
|
-
(p) => p.functionCall
|
|
280
|
+
const newParts = (((_j = llmResponse.content) == null ? void 0 : _j.parts) || []).filter(
|
|
281
|
+
(p) => p.functionCall || p.thoughtSignature
|
|
271
282
|
);
|
|
272
|
-
pendingFCResponse.content.parts.push(...
|
|
283
|
+
pendingFCResponse.content.parts.push(...newParts);
|
|
273
284
|
pendingFCResponse.usageMetadata = llmResponse.usageMetadata;
|
|
274
285
|
} else {
|
|
275
286
|
pendingFCResponse = llmResponse;
|
|
@@ -300,7 +311,14 @@ class Gemini extends BaseLlm {
|
|
|
300
311
|
const partsWithSig = pendingFCResponse.content.parts.filter(
|
|
301
312
|
(p) => p.thoughtSignature
|
|
302
313
|
).length;
|
|
303
|
-
if (partsWithSig === 0) {
|
|
314
|
+
if (partsWithSig === 0 && thoughtSignature) {
|
|
315
|
+
for (const part of pendingFCResponse.content.parts) {
|
|
316
|
+
if (part.functionCall) {
|
|
317
|
+
part.thoughtSignature = thoughtSignature;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} else if (partsWithSig === 0) {
|
|
304
322
|
logger.warn(
|
|
305
323
|
"[Gemini3] No thoughtSignature on merged function call parts \u2014 may cause 400 on next request"
|
|
306
324
|
);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { FinishReason } from "@google/genai";
|
|
6
7
|
function createLlmResponse(response) {
|
|
7
8
|
var _a;
|
|
8
9
|
const usageMetadata = response.usageMetadata;
|
|
@@ -16,6 +17,12 @@ function createLlmResponse(response) {
|
|
|
16
17
|
finishReason: candidate.finishReason
|
|
17
18
|
};
|
|
18
19
|
}
|
|
20
|
+
if (candidate.finishReason === FinishReason.STOP) {
|
|
21
|
+
return {
|
|
22
|
+
usageMetadata,
|
|
23
|
+
finishReason: candidate.finishReason
|
|
24
|
+
};
|
|
25
|
+
}
|
|
19
26
|
return {
|
|
20
27
|
errorCode: candidate.finishReason,
|
|
21
28
|
errorMessage: candidate.finishMessage,
|