@paean-ai/adk 0.2.25 → 0.2.27
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 +7 -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 +40 -5
- package/dist/cjs/models/llm_response.js +7 -0
- package/dist/cjs/utils/variant_utils.js +1 -1
- package/dist/esm/agents/functions.js +1 -0
- package/dist/esm/agents/llm_agent.js +7 -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 +40 -5
- package/dist/esm/models/llm_response.js +7 -0
- package/dist/esm/utils/variant_utils.js +1 -1
- 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 +7 -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 +40 -5
- package/dist/web/models/llm_response.js +7 -0
- package/dist/web/utils/variant_utils.js +1 -1
- 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
|
);
|
|
@@ -477,6 +495,7 @@ class Gemini extends BaseLlm {
|
|
|
477
495
|
return new GeminiLlmConnection(liveSession);
|
|
478
496
|
}
|
|
479
497
|
preprocessRequest(llmRequest) {
|
|
498
|
+
var _a;
|
|
480
499
|
if (this.apiBackend === GoogleLLMVariant.GEMINI_API) {
|
|
481
500
|
if (llmRequest.config) {
|
|
482
501
|
llmRequest.config.labels = void 0;
|
|
@@ -490,6 +509,22 @@ class Gemini extends BaseLlm {
|
|
|
490
509
|
}
|
|
491
510
|
}
|
|
492
511
|
}
|
|
512
|
+
if (((_a = llmRequest.config) == null ? void 0 : _a.tools) && llmRequest.config.tools.length > 1) {
|
|
513
|
+
const hasBuiltInSearch = llmRequest.config.tools.some(
|
|
514
|
+
(t) => "googleSearch" in t || "googleSearchRetrieval" in t
|
|
515
|
+
);
|
|
516
|
+
const hasFunctionDeclarations = llmRequest.config.tools.some(
|
|
517
|
+
(t) => "functionDeclarations" in t
|
|
518
|
+
);
|
|
519
|
+
if (hasBuiltInSearch && hasFunctionDeclarations) {
|
|
520
|
+
logger.warn(
|
|
521
|
+
"Gemini API (AI Studio) does not support combining built-in search tools with custom function declarations. Removing built-in search tool from this request."
|
|
522
|
+
);
|
|
523
|
+
llmRequest.config.tools = llmRequest.config.tools.filter(
|
|
524
|
+
(t) => !("googleSearch" in t) && !("googleSearchRetrieval" in t)
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
493
528
|
}
|
|
494
529
|
}
|
|
495
530
|
}
|
|
@@ -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,
|
|
@@ -16,7 +16,7 @@ function getBooleanEnvVar(envVar) {
|
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
18
|
const envVarValue = (process.env[envVar] || "").toLowerCase();
|
|
19
|
-
return ["true", "1"].includes(
|
|
19
|
+
return ["true", "1"].includes(envVarValue);
|
|
20
20
|
}
|
|
21
21
|
export {
|
|
22
22
|
GoogleLLMVariant,
|