-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathagent-tools.ts
More file actions
44 lines (41 loc) · 1.27 KB
/
agent-tools.ts
File metadata and controls
44 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type { FunctionTool } from "@databricks/appkit";
export const weatherTool: FunctionTool = {
type: "function",
name: "get_weather",
description: "Get the current weather for a location",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "City name, e.g. 'San Francisco'",
},
},
required: ["location"],
},
execute: async ({ location }) => {
const conditions = ["sunny", "partly cloudy", "rainy", "windy"];
const condition = conditions[Math.floor(Math.random() * conditions.length)];
const temp = Math.floor(Math.random() * 30) + 50;
return `Weather in ${location}: ${condition}, ${temp}°F`;
},
};
export const timeTool: FunctionTool = {
type: "function",
name: "get_current_time",
description: "Get the current date and time in a timezone",
parameters: {
type: "object",
properties: {
timezone: {
type: "string",
description: "IANA timezone, e.g. 'America/New_York'. Defaults to UTC",
},
},
},
execute: async ({ timezone }) => {
const tz = (timezone as string) ?? "UTC";
return `Current time in ${tz}: ${new Date().toLocaleString("en-US", { timeZone: tz })}`;
},
};
export const demoTools = { weatherTool, timeTool };