Skip to content

Commit 0fd7c20

Browse files
chore: adds missed out tests for tools
1 parent 662a72f commit 0fd7c20

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

tests/accuracy/aggregate.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { describeAccuracyTests, describeSuite } from "./sdk/describe-accuracy-tests.js";
2+
import { getAvailableModels } from "./sdk/models.js";
3+
import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js";
4+
5+
function callsAggregate(prompt: string, pipeline: Record<string, unknown>[]): AccuracyTestConfig {
6+
return {
7+
injectConnectedAssumption: true,
8+
prompt: prompt,
9+
mockedTools: {},
10+
expectedToolCalls: [
11+
{
12+
toolName: "aggregate",
13+
parameters: {
14+
pipeline: pipeline,
15+
},
16+
},
17+
],
18+
};
19+
}
20+
21+
describeAccuracyTests(getAvailableModels(), {
22+
...describeSuite("should call 'aggregate' tool", [
23+
callsAggregate(
24+
"Group all the movies in 'mflix.movies' namespace by 'release_year' and give me a count of them",
25+
[{ $group: { _id: "$release_year", count: { $sum: 1 } } }]
26+
),
27+
]),
28+
});

tests/accuracy/create-index.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { describeAccuracyTests, describeSuite } from "./sdk/describe-accuracy-tests.js";
2+
import { getAvailableModels } from "./sdk/models.js";
3+
import { AccuracyTestConfig } from "./sdk/describe-accuracy-tests.js";
4+
5+
function callsCreateIndex(prompt: string, indexKeys: Record<string, unknown>): AccuracyTestConfig {
6+
return {
7+
injectConnectedAssumption: true,
8+
prompt: prompt,
9+
mockedTools: {},
10+
expectedToolCalls: [
11+
{
12+
toolName: "create-index",
13+
parameters: {
14+
database: "mflix",
15+
collection: "movies",
16+
keys: indexKeys,
17+
},
18+
},
19+
],
20+
};
21+
}
22+
23+
describeAccuracyTests(getAvailableModels(), {
24+
...describeSuite("should call 'create-index' tool", [
25+
callsCreateIndex(
26+
"Create an index that covers the following query on 'mflix.movies' namespace - { \"release_year\": 1992 }",
27+
{
28+
release_year: 1,
29+
}
30+
),
31+
callsCreateIndex("Create a text index on title field in 'mflix.movies' namespace", {
32+
title: "text",
33+
}),
34+
]),
35+
});

0 commit comments

Comments
 (0)