Skip to content

Commit 509c37b

Browse files
chore: adds accuracy test for aggregation export
1 parent 5c2638f commit 509c37b

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

src/tools/mongodb/read/export.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,21 @@ export class ExportTool extends MongoDBToolBase {
1818
.array(
1919
z.discriminatedUnion("name", [
2020
z.object({
21-
name: z.literal("find"),
22-
arguments: z.object({
23-
...FindArgs,
24-
limit: FindArgs.limit.removeDefault(),
25-
}),
21+
name: z
22+
.literal("find")
23+
.describe("The literal name 'find' to represent a find cursor as target."),
24+
arguments: z
25+
.object({
26+
...FindArgs,
27+
limit: FindArgs.limit.removeDefault(),
28+
})
29+
.describe("The arguments for 'find' operation."),
2630
}),
2731
z.object({
28-
name: z.literal("aggregate"),
29-
arguments: z.object(AggregateArgs),
32+
name: z
33+
.literal("aggregate")
34+
.describe("The literal name 'aggregate' to represent an aggregation cursor as target."),
35+
arguments: z.object(AggregateArgs).describe("The arguments for 'aggregate' operation."),
3036
}),
3137
])
3238
)

tests/accuracy/export.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,34 @@ describeAccuracyTests([
9595
},
9696
],
9797
},
98+
{
99+
prompt: "Export an aggregation that groups all movie titles by the field release_year from mflix.movies",
100+
expectedToolCalls: [
101+
{
102+
toolName: "export",
103+
parameters: {
104+
database: "mflix",
105+
collection: "movies",
106+
exportTitle: Matcher.string(),
107+
exportTarget: [
108+
{
109+
name: "aggregate",
110+
arguments: {
111+
pipeline: [
112+
{
113+
$group: {
114+
_id: "$release_year",
115+
titles: {
116+
$push: "$title",
117+
},
118+
},
119+
},
120+
],
121+
},
122+
},
123+
],
124+
},
125+
},
126+
],
127+
},
98128
]);

0 commit comments

Comments
 (0)