Skip to content

Commit a975c17

Browse files
committed
chore: add accuracy test
1 parent 4284c09 commit a975c17

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/tools/mongodb/read/aggregate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const VectorSearchStage = z.object({
2626
.describe(
2727
"When true, uses an ENN algorithm, otherwise uses ANN. Using ENN is not compatible with numCandidates, in that case, numCandidates must be left empty."
2828
),
29-
index: z.string().optional().default("default"),
29+
index: z.string().describe("Name of the index, as retrieved from the collection-indexes tool."),
3030
path: z
3131
.string()
3232
.describe(

tests/accuracy/aggregate.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
22
import { Matcher } from "./sdk/matcher.js";
3+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
34

45
describeAccuracyTests([
56
{
@@ -24,4 +25,59 @@ describeAccuracyTests([
2425
},
2526
],
2627
},
28+
{
29+
prompt: "Run a vectorSearch query on mflix.movies on path 'plot_embeddings' with the model voyage-3-large to find all 'sci-fy' movies.",
30+
expectedToolCalls: [
31+
{
32+
toolName: "collection-indexes",
33+
parameters: {
34+
database: "mflix",
35+
collection: "movies",
36+
},
37+
},
38+
{
39+
toolName: "aggregate",
40+
parameters: {
41+
database: "mflix",
42+
collection: "movies",
43+
pipeline: [
44+
{
45+
$vectorSearch: {
46+
exact: Matcher.anyOf(Matcher.undefined, Matcher.boolean(true)),
47+
index: "my-index",
48+
path: "plot_embeddings",
49+
queryVector: "sci-fy",
50+
embeddingModel: "voyage-3-large",
51+
},
52+
},
53+
],
54+
responseBytesLimit: Matcher.anyOf(Matcher.number(), Matcher.undefined),
55+
},
56+
},
57+
],
58+
mockedTools: {
59+
"collection-indexes": (): CallToolResult => {
60+
return {
61+
content: [
62+
{
63+
type: "text",
64+
text: JSON.stringify({
65+
name: "my-index",
66+
type: "vectorSearch",
67+
status: "READY",
68+
queryable: true,
69+
latestDefinition: {
70+
type: "vector",
71+
path: "plot_embeddings",
72+
numDimensions: 1024,
73+
quantization: "none",
74+
similarity: "euclidean",
75+
},
76+
}),
77+
},
78+
],
79+
};
80+
},
81+
},
82+
},
2783
]);

0 commit comments

Comments
 (0)