@paean-ai/adk 0.2.6 → 0.2.8
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/index.js +11 -11
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/models/google_llm.js +57 -10
- package/dist/esm/index.js +11 -11
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/models/google_llm.js +62 -11
- package/dist/web/index.js +1 -1
- package/dist/web/index.js.map +3 -3
- package/dist/web/models/google_llm.js +62 -11
- package/package.json +1 -1
|
@@ -83,11 +83,15 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
83
83
|
if (this.isGemini3Preview && useVertexAI) {
|
|
84
84
|
const availableApiKey = apiKey || (canReadEnv ? process.env["GOOGLE_GENAI_API_KEY"] || process.env["GEMINI_API_KEY"] : void 0);
|
|
85
85
|
if (availableApiKey) {
|
|
86
|
-
import_logger.logger.info(
|
|
86
|
+
import_logger.logger.info(
|
|
87
|
+
"Gemini 3 preview detected with Vertex AI mode. Switching to API key mode for correct endpoint handling."
|
|
88
|
+
);
|
|
87
89
|
useVertexAI = false;
|
|
88
90
|
this.apiKey = availableApiKey;
|
|
89
91
|
} else {
|
|
90
|
-
import_logger.logger.warn(
|
|
92
|
+
import_logger.logger.warn(
|
|
93
|
+
"Gemini 3 preview requires API key authentication for correct endpoint handling. Set GEMINI_API_KEY or GOOGLE_GENAI_API_KEY environment variable for best compatibility."
|
|
94
|
+
);
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
this.vertexai = useVertexAI;
|
|
@@ -127,7 +131,7 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
127
131
|
* @yields LlmResponse: The model response.
|
|
128
132
|
*/
|
|
129
133
|
async *generateContentAsync(llmRequest, stream = false) {
|
|
130
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
134
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
131
135
|
this.preprocessRequest(llmRequest);
|
|
132
136
|
this.maybeAppendUserContent(llmRequest);
|
|
133
137
|
import_logger.logger.info(
|
|
@@ -146,6 +150,7 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
146
150
|
config: llmRequest.config
|
|
147
151
|
});
|
|
148
152
|
let thoughtText = "";
|
|
153
|
+
let thoughtSignature;
|
|
149
154
|
let text = "";
|
|
150
155
|
let usageMetadata;
|
|
151
156
|
let lastResponse;
|
|
@@ -157,6 +162,9 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
157
162
|
if (firstPart == null ? void 0 : firstPart.text) {
|
|
158
163
|
if ("thought" in firstPart && firstPart.thought) {
|
|
159
164
|
thoughtText += firstPart.text;
|
|
165
|
+
if ("thoughtSignature" in firstPart && firstPart.thoughtSignature) {
|
|
166
|
+
thoughtSignature = firstPart.thoughtSignature;
|
|
167
|
+
}
|
|
160
168
|
} else {
|
|
161
169
|
text += firstPart.text;
|
|
162
170
|
}
|
|
@@ -164,7 +172,11 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
164
172
|
} else if ((thoughtText || text) && (!firstPart || !firstPart.inlineData)) {
|
|
165
173
|
const parts = [];
|
|
166
174
|
if (thoughtText) {
|
|
167
|
-
|
|
175
|
+
const thoughtPart = { text: thoughtText, thought: true };
|
|
176
|
+
if (thoughtSignature) {
|
|
177
|
+
thoughtPart.thoughtSignature = thoughtSignature;
|
|
178
|
+
}
|
|
179
|
+
parts.push(thoughtPart);
|
|
168
180
|
}
|
|
169
181
|
if (text) {
|
|
170
182
|
parts.push((0, import_genai.createPartFromText)(text));
|
|
@@ -179,12 +191,26 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
179
191
|
thoughtText = "";
|
|
180
192
|
text = "";
|
|
181
193
|
}
|
|
194
|
+
if (this.isGemini3Preview && thoughtSignature && ((_e = llmResponse.content) == null ? void 0 : _e.parts)) {
|
|
195
|
+
for (const part of llmResponse.content.parts) {
|
|
196
|
+
if (part.functionCall && !part.thoughtSignature) {
|
|
197
|
+
part.thoughtSignature = thoughtSignature;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
182
201
|
yield llmResponse;
|
|
202
|
+
if ((_g = (_f = llmResponse.content) == null ? void 0 : _f.parts) == null ? void 0 : _g.some((part) => part.functionCall)) {
|
|
203
|
+
thoughtSignature = void 0;
|
|
204
|
+
}
|
|
183
205
|
}
|
|
184
|
-
if ((text || thoughtText) && ((
|
|
206
|
+
if ((text || thoughtText) && ((_i = (_h = lastResponse == null ? void 0 : lastResponse.candidates) == null ? void 0 : _h[0]) == null ? void 0 : _i.finishReason) === import_genai.FinishReason.STOP) {
|
|
185
207
|
const parts = [];
|
|
186
208
|
if (thoughtText) {
|
|
187
|
-
|
|
209
|
+
const thoughtPart = { text: thoughtText, thought: true };
|
|
210
|
+
if (thoughtSignature) {
|
|
211
|
+
thoughtPart.thoughtSignature = thoughtSignature;
|
|
212
|
+
}
|
|
213
|
+
parts.push(thoughtPart);
|
|
188
214
|
}
|
|
189
215
|
if (text) {
|
|
190
216
|
parts.push({ text });
|
|
@@ -199,11 +225,28 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
199
225
|
}
|
|
200
226
|
} else {
|
|
201
227
|
const response = await this.apiClient.models.generateContent({
|
|
202
|
-
model: (
|
|
228
|
+
model: (_j = llmRequest.model) != null ? _j : this.model,
|
|
203
229
|
contents: llmRequest.contents,
|
|
204
230
|
config: llmRequest.config
|
|
205
231
|
});
|
|
206
|
-
|
|
232
|
+
const llmResponse = (0, import_llm_response.createLlmResponse)(response);
|
|
233
|
+
if (this.isGemini3Preview && ((_k = llmResponse.content) == null ? void 0 : _k.parts)) {
|
|
234
|
+
let thoughtSig;
|
|
235
|
+
for (const part of llmResponse.content.parts) {
|
|
236
|
+
if (part.thought && part.thoughtSignature) {
|
|
237
|
+
thoughtSig = part.thoughtSignature;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (thoughtSig) {
|
|
242
|
+
for (const part of llmResponse.content.parts) {
|
|
243
|
+
if (part.functionCall && !part.thoughtSignature) {
|
|
244
|
+
part.thoughtSignature = thoughtSig;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
yield llmResponse;
|
|
207
250
|
}
|
|
208
251
|
}
|
|
209
252
|
get apiClient() {
|
|
@@ -228,7 +271,9 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
228
271
|
import_logger.logger.debug(`Using custom API endpoint: ${this.apiEndpoint}`);
|
|
229
272
|
if (this.isGemini3Preview) {
|
|
230
273
|
httpOptions.apiVersion = "";
|
|
231
|
-
import_logger.logger.info(
|
|
274
|
+
import_logger.logger.info(
|
|
275
|
+
`Gemini 3 preview mode: using direct API path without version prefix`
|
|
276
|
+
);
|
|
232
277
|
}
|
|
233
278
|
}
|
|
234
279
|
this._apiClient = new import_genai.GoogleGenAI({
|
|
@@ -292,7 +337,9 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
292
337
|
llmRequest.liveConnectConfig.systemInstruction = {
|
|
293
338
|
role: "system",
|
|
294
339
|
// TODO - b/425992518: validate type casting works well.
|
|
295
|
-
parts: [
|
|
340
|
+
parts: [
|
|
341
|
+
(0, import_genai.createPartFromText)(llmRequest.config.systemInstruction)
|
|
342
|
+
]
|
|
296
343
|
};
|
|
297
344
|
}
|
|
298
345
|
llmRequest.liveConnectConfig.tools = (_c = llmRequest.config) == null ? void 0 : _c.tools;
|