You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Used by both streamQuery() and call() to keep behavior consistent
64
+
*/
65
+
privatebuildSetTimeFilterTool(){
66
+
returntool({
67
+
description:
68
+
"Set the time filter for the query page UI instead of adding triggered_at conditions to the query. ALWAYS use this tool when the user wants to filter by time (e.g., 'last 7 days', 'past hour', 'yesterday'). The UI will apply this filter automatically. Do NOT add triggered_at to the WHERE clause - use this tool instead.",
69
+
parameters: z.object({
70
+
period: z
71
+
.string()
72
+
.optional()
73
+
.describe(
74
+
"Relative time period like '1m', '5m', '30m', '1h', '6h', '12h', '1d', '3d', '7d', '14d', '30d', '90d'. Use this for 'last X days/hours/minutes' requests."
75
+
),
76
+
from: z
77
+
.string()
78
+
.optional()
79
+
.describe(
80
+
"ISO 8601 timestamp for the start of an absolute date range. Use with 'to' for specific date ranges."
81
+
),
82
+
to: z
83
+
.string()
84
+
.optional()
85
+
.describe(
86
+
"ISO 8601 timestamp for the end of an absolute date range. Use with 'from' for specific date ranges."
87
+
),
88
+
}),
89
+
execute: async({ period, from, to })=>{
90
+
// Store the time filter so we can include it in the result
91
+
this.pendingTimeFilter={ period, from, to };
92
+
return{
93
+
success: true,
94
+
message: period
95
+
? `Time filter set to: last ${period}`
96
+
: `Time filter set to: ${from??"start"} - ${to??"now"}`,
97
+
};
98
+
},
99
+
});
100
+
}
101
+
61
102
/**
62
103
* Generate a TSQL query from natural language, streaming the result
63
104
*/
@@ -104,40 +145,7 @@ export class AIQueryService {
104
145
returnthis.getSchemaInfo(tableName);
105
146
},
106
147
}),
107
-
setTimeFilter: tool({
108
-
description:
109
-
"Set the time filter for the query page UI instead of adding triggered_at conditions to the query. ALWAYS use this tool when the user wants to filter by time (e.g., 'last 7 days', 'past hour', 'yesterday'). The UI will apply this filter automatically. Do NOT add triggered_at to the WHERE clause - use this tool instead.",
110
-
parameters: z.object({
111
-
period: z
112
-
.string()
113
-
.optional()
114
-
.describe(
115
-
"Relative time period like '1m', '5m', '30m', '1h', '6h', '12h', '1d', '3d', '7d', '14d', '30d', '90d'. Use this for 'last X days/hours/minutes' requests."
116
-
),
117
-
from: z
118
-
.string()
119
-
.optional()
120
-
.describe(
121
-
"ISO 8601 timestamp for the start of an absolute date range. Use with 'to' for specific date ranges."
122
-
),
123
-
to: z
124
-
.string()
125
-
.optional()
126
-
.describe(
127
-
"ISO 8601 timestamp for the end of an absolute date range. Use with 'from' for specific date ranges."
128
-
),
129
-
}),
130
-
execute: async({ period, from, to })=>{
131
-
// Store the time filter so we can include it in the result
132
-
this.pendingTimeFilter={ period, from, to };
133
-
return{
134
-
success: true,
135
-
message: period
136
-
? `Time filter set to: last ${period}`
137
-
: `Time filter set to: ${from??"start"} - ${to??"now"}`,
138
-
};
139
-
},
140
-
}),
148
+
setTimeFilter: this.buildSetTimeFilterTool(),
141
149
},
142
150
maxSteps: 5,
143
151
experimental_telemetry: {
@@ -203,40 +211,7 @@ export class AIQueryService {
203
211
returnthis.getSchemaInfo(tableName);
204
212
},
205
213
}),
206
-
setTimeFilter: tool({
207
-
description:
208
-
"Set the time filter for the query page UI instead of adding triggered_at conditions to the query. ALWAYS use this tool when the user wants to filter by time (e.g., 'last 7 days', 'past hour', 'yesterday'). The UI will apply this filter automatically. Do NOT add triggered_at to the WHERE clause - use this tool instead.",
209
-
parameters: z.object({
210
-
period: z
211
-
.string()
212
-
.optional()
213
-
.describe(
214
-
"Relative time period like '1m', '5m', '30m', '1h', '6h', '12h', '1d', '3d', '7d', '14d', '30d', '90d'. Use this for 'last X days/hours/minutes' requests."
215
-
),
216
-
from: z
217
-
.string()
218
-
.optional()
219
-
.describe(
220
-
"ISO 8601 timestamp for the start of an absolute date range. Use with 'to' for specific date ranges."
221
-
),
222
-
to: z
223
-
.string()
224
-
.optional()
225
-
.describe(
226
-
"ISO 8601 timestamp for the end of an absolute date range. Use with 'from' for specific date ranges."
227
-
),
228
-
}),
229
-
execute: async({ period, from, to })=>{
230
-
// Store the time filter so we can include it in the result
231
-
this.pendingTimeFilter={ period, from, to };
232
-
return{
233
-
success: true,
234
-
message: period
235
-
? `Time filter set to: last ${period}`
236
-
: `Time filter set to: ${from??"start"} - ${to??"now"}`,
0 commit comments