Skip to content

Commit 8839148

Browse files
committed
chore: improve prompts for better accuracy
1 parent b973af8 commit 8839148

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

src/tools/mongodb/read/aggregate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const VectorSearchStage = z.object({
3535
queryVector: z
3636
.union([z.string(), z.array(z.number())])
3737
.describe(
38-
"The content to search for. The embeddingParameters field is mandatory if the queryVector is a string."
38+
"The content to search for. The embeddingParameters field is mandatory if the queryVector is a string, in that case, the tool generates the embedding automatically using the provided configuration."
3939
),
4040
numCandidates: z
4141
.number()

tests/accuracy/aggregate.test.ts

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,69 @@ describeAccuracyTests([
2727
},
2828
{
2929
prompt: "Run a vectorSearch query on musicfy.songs on path 'title_embeddings' using the index 'titles' with the model voyage-3-large to find all 'hammer of justice' songs.",
30+
expectedToolCalls: [
31+
{
32+
toolName: "collection-indexes",
33+
parameters: {
34+
database: "musicfy",
35+
collection: "songs",
36+
},
37+
optional: true,
38+
},
39+
{
40+
toolName: "aggregate",
41+
parameters: {
42+
database: "musicfy",
43+
collection: "songs",
44+
pipeline: [
45+
{
46+
$vectorSearch: {
47+
exact: Matcher.anyOf(Matcher.undefined, Matcher.boolean(false)),
48+
index: "titles",
49+
path: "title_embeddings",
50+
queryVector: "hammer of justice",
51+
embeddingParameters: {
52+
model: "voyage-3-large",
53+
outputDimension: Matcher.anyOf(
54+
Matcher.undefined,
55+
Matcher.number((n) => n === 1024)
56+
),
57+
},
58+
filter: Matcher.emptyObjectOrUndefined,
59+
},
60+
},
61+
],
62+
responseBytesLimit: Matcher.anyOf(Matcher.number(), Matcher.undefined),
63+
},
64+
},
65+
],
66+
mockedTools: {
67+
"collection-indexes": (): CallToolResult => {
68+
return {
69+
content: [
70+
{
71+
type: "text",
72+
text: JSON.stringify({
73+
name: "titles",
74+
type: "vectorSearch",
75+
status: "READY",
76+
queryable: true,
77+
latestDefinition: {
78+
type: "vector",
79+
path: "title_embeddings",
80+
numDimensions: 1024,
81+
quantization: "none",
82+
similarity: "euclidean",
83+
},
84+
}),
85+
},
86+
],
87+
};
88+
},
89+
},
90+
},
91+
{
92+
prompt: "Run an exact vectorSearch query on musicfy.songs on path 'title_embeddings' using the index 'titles' with the model voyage-3-large to find 10 'hammer of justice' songs in any order.",
3093
expectedToolCalls: [
3194
{
3295
toolName: "collection-indexes",
@@ -48,9 +111,15 @@ describeAccuracyTests([
48111
index: "titles",
49112
path: "title_embeddings",
50113
queryVector: "hammer of justice",
114+
limit: 10,
51115
embeddingParameters: {
52116
model: "voyage-3-large",
117+
outputDimension: Matcher.anyOf(
118+
Matcher.undefined,
119+
Matcher.number((n) => n === 1024)
120+
),
53121
},
122+
filter: Matcher.emptyObjectOrUndefined,
54123
},
55124
},
56125
],
@@ -84,7 +153,7 @@ describeAccuracyTests([
84153
},
85154
},
86155
{
87-
prompt: "Run a vectorSearch query on mflix.movies on path 'plot_embeddings' with the model voyage-3-large to find all 'sci-fy' movies.",
156+
prompt: "Run an approximate vectorSearch query on mflix.movies on path 'plot_embeddings' with the model voyage-3-large to find all 'sci-fy' movies.",
88157
expectedToolCalls: [
89158
{
90159
toolName: "collection-indexes",
@@ -101,13 +170,18 @@ describeAccuracyTests([
101170
pipeline: [
102171
{
103172
$vectorSearch: {
104-
exact: Matcher.anyOf(Matcher.undefined, Matcher.boolean(true)),
173+
exact: Matcher.anyOf(Matcher.undefined, Matcher.boolean(false)),
105174
index: "my-index",
106175
path: "plot_embeddings",
107176
queryVector: "sci-fy",
108177
embeddingParameters: {
109178
model: "voyage-3-large",
179+
outputDimension: Matcher.anyOf(
180+
Matcher.undefined,
181+
Matcher.number((n) => n === 1024)
182+
),
110183
},
184+
filter: Matcher.emptyObjectOrUndefined,
111185
},
112186
},
113187
],

0 commit comments

Comments
 (0)