Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/agents/custom-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ Finally, you instantiate your `StoryFlowAgent` and use the `Runner` as usual.
=== "TypeScript"

```typescript
# Full runnable code for the StoryFlowAgent example
// Full runnable code for the StoryFlowAgent example

--8<-- "examples/typescript/snippets/agents/custom-agent/storyflow_agent.ts"
```

Expand Down
29 changes: 7 additions & 22 deletions examples/typescript/snippets/get-started/multi_tool_agent/agent.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'dotenv/config';
import {FunctionTool, LlmAgent} from '@google/adk';
import {z} from 'zod';
import { FunctionTool, LlmAgent } from '@google/adk';
import { z } from 'zod';

const getWeather = new FunctionTool({
name: 'get_weather',
description: 'Retrieves the current weather report for a specified city.',
parameters: z.object({
city: z.string().describe('The name of the city for which to retrieve the weather report.'),
}),
execute: ({city}) => {
execute: ({ city }) => {
if (city.toLowerCase() === 'new york') {
return {
status: 'success',
report:
'The weather in New York is sunny with a temperature of 25 degrees Celsius (77 degrees Fahrenheit).',
'The weather in New York is sunny with a temperature of 25 degrees Celsius (77 degrees Fahrenheit).',
};
} else {
return {
Expand All @@ -45,7 +30,7 @@ const getCurrentTime = new FunctionTool({
parameters: z.object({
city: z.string().describe("The name of the city for which to retrieve the current time."),
}),
execute: ({city}) => {
execute: ({ city }) => {
let tz_identifier: string;
if (city.toLowerCase() === 'new york') {
tz_identifier = 'America/New_York';
Expand All @@ -57,9 +42,9 @@ const getCurrentTime = new FunctionTool({
}

const now = new Date();
const report = `The current time in ${city} is ${now.toLocaleString('en-US', {timeZone: tz_identifier})}`;
const report = `The current time in ${city} is ${now.toLocaleString('en-US', { timeZone: tz_identifier })}`;

return {status: 'success', report: report};
return { status: 'success', report: report };
},
});

Expand Down
Loading