Skip to content

Commit 4a1a032

Browse files
committed
Support directives in nested functions/closure tracking
1 parent c2fa9df commit 4a1a032

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { tool } from 'ai';
2+
import { z } from 'zod';
3+
4+
export const weatherTool = tool({
5+
description: 'Get the weather in a location',
6+
parameters: z.object({
7+
location: z.string().describe('The location to get the weather for'),
8+
}),
9+
execute: async ({ location }) => {
10+
'use step';
11+
const response = await fetch(
12+
`https://api.weather.com/v1/current?location=${location}`
13+
);
14+
return response.json();
15+
},
16+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { tool } from 'ai';
2+
import { z } from 'zod';
3+
export const weatherTool = tool({
4+
description: 'Get the weather in a location',
5+
parameters: z.object({
6+
location: z.string().describe('The location to get the weather for')
7+
}),
8+
execute: async ({ location })=>{
9+
'use step';
10+
const response = await fetch(`https://api.weather.com/v1/current?location=${location}`);
11+
return response.json();
12+
}
13+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { tool } from 'ai';
2+
import { z } from 'zod';
3+
export const weatherTool = tool({
4+
description: 'Get the weather in a location',
5+
parameters: z.object({
6+
location: z.string().describe('The location to get the weather for')
7+
}),
8+
execute: async ({ location })=>{
9+
'use step';
10+
const response = await fetch(`https://api.weather.com/v1/current?location=${location}`);
11+
return response.json();
12+
}
13+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { tool } from 'ai';
2+
import { z } from 'zod';
3+
export const weatherTool = tool({
4+
description: 'Get the weather in a location',
5+
parameters: z.object({
6+
location: z.string().describe('The location to get the weather for')
7+
}),
8+
execute: async ({ location })=>{
9+
'use step';
10+
const response = await fetch(`https://api.weather.com/v1/current?location=${location}`);
11+
return response.json();
12+
}
13+
});

0 commit comments

Comments
 (0)