Skip to content

Commit 24b1127

Browse files
holtskinnercopybara-github
authored andcommitted
feat: Add support for Grounding with Google Maps
PiperOrigin-RevId: 755055455
1 parent 6cb7d7a commit 24b1127

14 files changed

+1159
-0
lines changed

src/main/java/com/google/genai/LiveConverters.java

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,155 @@ ObjectNode enterpriseWebSearchToVertex(
339339
return toObject;
340340
}
341341

342+
@ExcludeFromGeneratedCoverageReport
343+
ObjectNode apiKeyConfigToMldev(
344+
ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
345+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
346+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"apiKeyString"}))) {
347+
throw new IllegalArgumentException("apiKeyString parameter is not supported in Gemini API.");
348+
}
349+
350+
return toObject;
351+
}
352+
353+
@ExcludeFromGeneratedCoverageReport
354+
ObjectNode apiKeyConfigToVertex(
355+
ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
356+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
357+
if (Common.getValueByPath(fromObject, new String[] {"apiKeyString"}) != null) {
358+
Common.setValueByPath(
359+
toObject,
360+
new String[] {"apiKeyString"},
361+
Common.getValueByPath(fromObject, new String[] {"apiKeyString"}));
362+
}
363+
364+
return toObject;
365+
}
366+
367+
@ExcludeFromGeneratedCoverageReport
368+
ObjectNode authConfigToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
369+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
370+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"}))) {
371+
throw new IllegalArgumentException("apiKeyConfig parameter is not supported in Gemini API.");
372+
}
373+
374+
if (Common.getValueByPath(fromObject, new String[] {"authType"}) != null) {
375+
Common.setValueByPath(
376+
toObject,
377+
new String[] {"authType"},
378+
Common.getValueByPath(fromObject, new String[] {"authType"}));
379+
}
380+
381+
if (Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}) != null) {
382+
Common.setValueByPath(
383+
toObject,
384+
new String[] {"googleServiceAccountConfig"},
385+
Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}));
386+
}
387+
388+
if (Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}) != null) {
389+
Common.setValueByPath(
390+
toObject,
391+
new String[] {"httpBasicAuthConfig"},
392+
Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}));
393+
}
394+
395+
if (Common.getValueByPath(fromObject, new String[] {"oauthConfig"}) != null) {
396+
Common.setValueByPath(
397+
toObject,
398+
new String[] {"oauthConfig"},
399+
Common.getValueByPath(fromObject, new String[] {"oauthConfig"}));
400+
}
401+
402+
if (Common.getValueByPath(fromObject, new String[] {"oidcConfig"}) != null) {
403+
Common.setValueByPath(
404+
toObject,
405+
new String[] {"oidcConfig"},
406+
Common.getValueByPath(fromObject, new String[] {"oidcConfig"}));
407+
}
408+
409+
return toObject;
410+
}
411+
412+
@ExcludeFromGeneratedCoverageReport
413+
ObjectNode authConfigToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
414+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
415+
if (Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"}) != null) {
416+
Common.setValueByPath(
417+
toObject,
418+
new String[] {"apiKeyConfig"},
419+
apiKeyConfigToVertex(
420+
apiClient,
421+
JsonSerializable.toJsonNode(
422+
Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"})),
423+
toObject));
424+
}
425+
426+
if (Common.getValueByPath(fromObject, new String[] {"authType"}) != null) {
427+
Common.setValueByPath(
428+
toObject,
429+
new String[] {"authType"},
430+
Common.getValueByPath(fromObject, new String[] {"authType"}));
431+
}
432+
433+
if (Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}) != null) {
434+
Common.setValueByPath(
435+
toObject,
436+
new String[] {"googleServiceAccountConfig"},
437+
Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}));
438+
}
439+
440+
if (Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}) != null) {
441+
Common.setValueByPath(
442+
toObject,
443+
new String[] {"httpBasicAuthConfig"},
444+
Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}));
445+
}
446+
447+
if (Common.getValueByPath(fromObject, new String[] {"oauthConfig"}) != null) {
448+
Common.setValueByPath(
449+
toObject,
450+
new String[] {"oauthConfig"},
451+
Common.getValueByPath(fromObject, new String[] {"oauthConfig"}));
452+
}
453+
454+
if (Common.getValueByPath(fromObject, new String[] {"oidcConfig"}) != null) {
455+
Common.setValueByPath(
456+
toObject,
457+
new String[] {"oidcConfig"},
458+
Common.getValueByPath(fromObject, new String[] {"oidcConfig"}));
459+
}
460+
461+
return toObject;
462+
}
463+
464+
@ExcludeFromGeneratedCoverageReport
465+
ObjectNode googleMapsToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
466+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
467+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"authConfig"}))) {
468+
throw new IllegalArgumentException("authConfig parameter is not supported in Gemini API.");
469+
}
470+
471+
return toObject;
472+
}
473+
474+
@ExcludeFromGeneratedCoverageReport
475+
ObjectNode googleMapsToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
476+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
477+
if (Common.getValueByPath(fromObject, new String[] {"authConfig"}) != null) {
478+
Common.setValueByPath(
479+
toObject,
480+
new String[] {"authConfig"},
481+
authConfigToVertex(
482+
apiClient,
483+
JsonSerializable.toJsonNode(
484+
Common.getValueByPath(fromObject, new String[] {"authConfig"})),
485+
toObject));
486+
}
487+
488+
return toObject;
489+
}
490+
342491
@ExcludeFromGeneratedCoverageReport
343492
ObjectNode toolToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
344493
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -373,6 +522,10 @@ ObjectNode toolToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode pare
373522
"enterpriseWebSearch parameter is not supported in Gemini API.");
374523
}
375524

525+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"googleMaps"}))) {
526+
throw new IllegalArgumentException("googleMaps parameter is not supported in Gemini API.");
527+
}
528+
376529
if (Common.getValueByPath(fromObject, new String[] {"codeExecution"}) != null) {
377530
Common.setValueByPath(
378531
toObject,
@@ -433,6 +586,17 @@ ObjectNode toolToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode par
433586
toObject));
434587
}
435588

589+
if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
590+
Common.setValueByPath(
591+
toObject,
592+
new String[] {"googleMaps"},
593+
googleMapsToVertex(
594+
apiClient,
595+
JsonSerializable.toJsonNode(
596+
Common.getValueByPath(fromObject, new String[] {"googleMaps"})),
597+
toObject));
598+
}
599+
436600
if (Common.getValueByPath(fromObject, new String[] {"codeExecution"}) != null) {
437601
Common.setValueByPath(
438602
toObject,

0 commit comments

Comments
 (0)