1- /**
2- * Copyright 2025 Google LLC
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
161import 'dotenv/config' ;
17- import { FunctionTool , LlmAgent } from '@google/adk' ;
18- import { z } from 'zod' ;
2+ import { FunctionTool , LlmAgent } from '@google/adk' ;
3+ import { z } from 'zod' ;
194
205const getWeather = new FunctionTool ( {
216 name : 'get_weather' ,
227 description : 'Retrieves the current weather report for a specified city.' ,
238 parameters : z . object ( {
249 city : z . string ( ) . describe ( 'The name of the city for which to retrieve the weather report.' ) ,
2510 } ) ,
26- execute : ( { city} ) => {
11+ execute : ( { city } ) => {
2712 if ( city . toLowerCase ( ) === 'new york' ) {
2813 return {
2914 status : 'success' ,
3015 report :
31- 'The weather in New York is sunny with a temperature of 25 degrees Celsius (77 degrees Fahrenheit).' ,
16+ 'The weather in New York is sunny with a temperature of 25 degrees Celsius (77 degrees Fahrenheit).' ,
3217 } ;
3318 } else {
3419 return {
@@ -45,7 +30,7 @@ const getCurrentTime = new FunctionTool({
4530 parameters : z . object ( {
4631 city : z . string ( ) . describe ( "The name of the city for which to retrieve the current time." ) ,
4732 } ) ,
48- execute : ( { city} ) => {
33+ execute : ( { city } ) => {
4934 let tz_identifier : string ;
5035 if ( city . toLowerCase ( ) === 'new york' ) {
5136 tz_identifier = 'America/New_York' ;
@@ -57,9 +42,9 @@ const getCurrentTime = new FunctionTool({
5742 }
5843
5944 const now = new Date ( ) ;
60- const report = `The current time in ${ city } is ${ now . toLocaleString ( 'en-US' , { timeZone : tz_identifier } ) } ` ;
45+ const report = `The current time in ${ city } is ${ now . toLocaleString ( 'en-US' , { timeZone : tz_identifier } ) } ` ;
6146
62- return { status : 'success' , report : report } ;
47+ return { status : 'success' , report : report } ;
6348 } ,
6449} ) ;
6550
0 commit comments