Skip to content

Commit c23a453

Browse files
authored
Fix TS example code snippets (#1071)
* Update example TS code snippets * Update
1 parent 824be91 commit c23a453

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

docs/agents/custom-agents.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ Finally, you instantiate your `StoryFlowAgent` and use the `Runner` as usual.
414414
=== "TypeScript"
415415

416416
```typescript
417-
# Full runnable code for the StoryFlowAgent example
417+
// Full runnable code for the StoryFlowAgent example
418+
418419
--8<-- "examples/typescript/snippets/agents/custom-agent/storyflow_agent.ts"
419420
```
420421

examples/typescript/snippets/get-started/multi_tool_agent/agent.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
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-
*/
161
import '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

205
const 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

Comments
 (0)