browser-use 0.7.1 → 0.7.2
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/llm/google/chat.js +33 -22
- package/package.json +4 -4
package/dist/llm/google/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GoogleGenAI } from '@google/genai';
|
|
1
|
+
import { GoogleGenAI, ThinkingLevel } from '@google/genai';
|
|
2
2
|
import { ModelProviderError } from '../exceptions.js';
|
|
3
3
|
import { ChatInvokeCompletion } from '../views.js';
|
|
4
4
|
import { SchemaOptimizer, zodSchemaToJsonSchema } from '../schema.js';
|
|
@@ -19,6 +19,12 @@ const buildGoogleHttpOptions = (httpOptions) => {
|
|
|
19
19
|
resolvedHttpOptions.headers = headers;
|
|
20
20
|
return resolvedHttpOptions;
|
|
21
21
|
};
|
|
22
|
+
const googleThinkingLevelByName = {
|
|
23
|
+
minimal: ThinkingLevel.MINIMAL,
|
|
24
|
+
low: ThinkingLevel.LOW,
|
|
25
|
+
medium: ThinkingLevel.MEDIUM,
|
|
26
|
+
high: ThinkingLevel.HIGH,
|
|
27
|
+
};
|
|
22
28
|
export class ChatGoogle {
|
|
23
29
|
model;
|
|
24
30
|
provider = 'google';
|
|
@@ -212,15 +218,17 @@ export class ChatGoogle {
|
|
|
212
218
|
async ainvoke(messages, output_format, options = {}) {
|
|
213
219
|
const serializer = new GoogleMessageSerializer();
|
|
214
220
|
const { contents, systemInstruction } = serializer.serializeWithSystem(messages, this.includeSystemInUser);
|
|
215
|
-
const
|
|
221
|
+
const requestConfig = this.config
|
|
222
|
+
? { ...this.config }
|
|
223
|
+
: {};
|
|
216
224
|
if (this.temperature !== null) {
|
|
217
|
-
|
|
225
|
+
requestConfig.temperature = this.temperature;
|
|
218
226
|
}
|
|
219
227
|
if (this.topP !== null) {
|
|
220
|
-
|
|
228
|
+
requestConfig.topP = this.topP;
|
|
221
229
|
}
|
|
222
230
|
if (this.seed !== null) {
|
|
223
|
-
|
|
231
|
+
requestConfig.seed = this.seed;
|
|
224
232
|
}
|
|
225
233
|
const isGemini3Pro = this.model.includes('gemini-3-pro');
|
|
226
234
|
const isGemini3Flash = this.model.includes('gemini-3-flash');
|
|
@@ -229,18 +237,18 @@ export class ChatGoogle {
|
|
|
229
237
|
if (level === 'minimal' || level === 'medium') {
|
|
230
238
|
level = 'low';
|
|
231
239
|
}
|
|
232
|
-
|
|
233
|
-
thinkingLevel: level
|
|
240
|
+
requestConfig.thinkingConfig = {
|
|
241
|
+
thinkingLevel: googleThinkingLevelByName[level],
|
|
234
242
|
};
|
|
235
243
|
}
|
|
236
244
|
else if (isGemini3Flash) {
|
|
237
245
|
if (this.thinkingLevel !== null) {
|
|
238
|
-
|
|
239
|
-
thinkingLevel: this.thinkingLevel
|
|
246
|
+
requestConfig.thinkingConfig = {
|
|
247
|
+
thinkingLevel: googleThinkingLevelByName[this.thinkingLevel],
|
|
240
248
|
};
|
|
241
249
|
}
|
|
242
250
|
else {
|
|
243
|
-
|
|
251
|
+
requestConfig.thinkingConfig = {
|
|
244
252
|
thinkingBudget: this.thinkingBudget === null ? -1 : this.thinkingBudget,
|
|
245
253
|
};
|
|
246
254
|
}
|
|
@@ -253,11 +261,11 @@ export class ChatGoogle {
|
|
|
253
261
|
budget = -1;
|
|
254
262
|
}
|
|
255
263
|
if (budget !== null) {
|
|
256
|
-
|
|
264
|
+
requestConfig.thinkingConfig = { thinkingBudget: budget };
|
|
257
265
|
}
|
|
258
266
|
}
|
|
259
267
|
if (this.maxOutputTokens !== null) {
|
|
260
|
-
|
|
268
|
+
requestConfig.maxOutputTokens = this.maxOutputTokens;
|
|
261
269
|
}
|
|
262
270
|
// Try to get schema from output_format
|
|
263
271
|
const schemaForJson = (() => {
|
|
@@ -289,8 +297,8 @@ export class ChatGoogle {
|
|
|
289
297
|
}
|
|
290
298
|
}
|
|
291
299
|
if (cleanSchemaForJson && this.supportsStructuredOutput) {
|
|
292
|
-
|
|
293
|
-
|
|
300
|
+
requestConfig.responseMimeType = 'application/json';
|
|
301
|
+
requestConfig.responseSchema = cleanSchemaForJson;
|
|
294
302
|
}
|
|
295
303
|
const requestContents = contents.map((entry) => ({
|
|
296
304
|
...entry,
|
|
@@ -309,22 +317,25 @@ export class ChatGoogle {
|
|
|
309
317
|
}
|
|
310
318
|
}
|
|
311
319
|
}
|
|
312
|
-
const request = {
|
|
313
|
-
model: this.model,
|
|
314
|
-
contents: requestContents,
|
|
315
|
-
};
|
|
316
320
|
if (systemInstruction && !this.includeSystemInUser) {
|
|
317
|
-
|
|
321
|
+
requestConfig.systemInstruction = {
|
|
318
322
|
role: 'system',
|
|
319
323
|
parts: [{ text: systemInstruction }],
|
|
320
324
|
};
|
|
321
325
|
}
|
|
322
|
-
if (
|
|
323
|
-
|
|
326
|
+
if (options.signal) {
|
|
327
|
+
requestConfig.abortSignal = options.signal;
|
|
328
|
+
}
|
|
329
|
+
const request = {
|
|
330
|
+
model: this.model,
|
|
331
|
+
contents: requestContents,
|
|
332
|
+
};
|
|
333
|
+
if (Object.keys(requestConfig).length > 0) {
|
|
334
|
+
request.config = requestConfig;
|
|
324
335
|
}
|
|
325
336
|
for (let attempt = 0; attempt < this.maxRetries; attempt += 1) {
|
|
326
337
|
try {
|
|
327
|
-
const result = await this.client.models.generateContent(request
|
|
338
|
+
const result = await this.client.models.generateContent(request);
|
|
328
339
|
const candidate = result.candidates?.[0];
|
|
329
340
|
const textParts = candidate?.content?.parts?.filter((p) => p.text) || [];
|
|
330
341
|
const text = textParts.map((p) => p.text).join('');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-use",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "A TypeScript-first library for programmatic browser control, designed for building AI-powered web agents.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
"@types/turndown": "^5.0.6",
|
|
355
355
|
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
356
356
|
"@typescript-eslint/parser": "^8.54.0",
|
|
357
|
-
"@vitest/coverage-v8": "^4.
|
|
357
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
358
358
|
"commitizen": "^4.3.1",
|
|
359
359
|
"cz-conventional-changelog": "^3.3.0",
|
|
360
360
|
"eslint": "^9.39.2",
|
|
@@ -366,7 +366,7 @@
|
|
|
366
366
|
"tsx": "^4.21.0",
|
|
367
367
|
"typescript": "^5.9.3",
|
|
368
368
|
"vite": "^7.3.2",
|
|
369
|
-
"vitest": "^4.
|
|
369
|
+
"vitest": "^4.1.8"
|
|
370
370
|
},
|
|
371
371
|
"pnpm": {
|
|
372
372
|
"onlyBuiltDependencies": [
|
|
@@ -384,7 +384,7 @@
|
|
|
384
384
|
"fast-xml-builder": "1.2.0",
|
|
385
385
|
"fast-xml-parser": "5.7.3",
|
|
386
386
|
"flatted": "3.4.2",
|
|
387
|
-
"hono": "4.12.
|
|
387
|
+
"hono": "4.12.23",
|
|
388
388
|
"ip-address": "10.2.0",
|
|
389
389
|
"lodash": "4.18.1",
|
|
390
390
|
"minimatch": "10.2.4",
|